Skip to content

Instantly share code, notes, and snippets.

@okutane
okutane / taylor.c
Created March 12, 2020 04:01
Taylor series for cos
#include <stdio.h>
#include <math.h>
double my_cos(double x) {
int n = 2;
double result = 1;
double x2 = x * x;
double a = -x * x / 2;
while (fabs(a) > 0.0001) {
docker run -d -p 8888:8080 sanitytool/bitreader-service
echo "int i = 5;" > test.c
clang test.c -c -emit-llvm -femit-all-decls -g -o result.bc
curl --header "Content-Type:application/octet-stream" --trace-ascii debugdump.txt --data-binary @result.bc http://localhost:8888/parse
@okutane
okutane / BitsInK3.java
Created March 30, 2017 12:49
Given K = 2^a[0] + 2^a[1] + ... + 2^a[n-1] calculate number of set bits in K*3
public class BitsInK3 {
static int solution(int A[]) {
State state = new State();
for (int i : A) {
state.putBit(i);
state.putBit(i + 1);
}