This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
# Returns a list of compare-swap tuples that merges two lists | |
def gen_merge(a, b): | |
return [(x, y) for x in a for y in b] | |
# Returns a list of compare-swap tuples that performs a merge sort | |
# Generates n^2/2 - n/2 = O(n^2) compare-swaps | |
def gen_sort(l): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int as_int(float f) { | |
union { float f; int i; } u; | |
u.f = f; | |
return u.i; | |
} | |
float as_float(int i) { | |
union { float f; int i; } u; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Install vim-plug and create vim config | |
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
echo "syntax enable | |
"\"" Avoid problems when pressing Q by error (Dvorak layout) | |
map Q <Nop> | |
"\"" Allow executing local .vimrc files | |
set exrc | |
set secure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <time.h> | |
#define PAGE_SIZE 4096 | |
typedef struct asmbuf_s asmbuf_t; | |
struct asmbuf_s { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <assert.h> | |
#include <string.h> | |
typedef struct symb_s symb_t; | |
typedef struct queue_s queue_t; | |
typedef struct dict_s dict_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <limits> | |
#include <algorithm> | |
#include <cstdint> | |
int clz(uint32_t u) { | |
uint32_t a = 0; | |
uint32_t b = 32; | |
uint32_t all = 0xFFFFFFFF; | |
#pragma unroll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <memory> | |
#include <string> | |
#include <algorithm> | |
#include <cmath> | |
#include <png.h> | |
struct Image { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def insert(p, i, m, n): | |
q = [] | |
for j in range(0, n): | |
if j == i: | |
s = set(p[j]) | |
s.add(m) | |
q.append(s) | |
else: | |
q.append(p[j]) | |
return q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <stddef.h> | |
#include <stdbool.h> | |
#include <string.h> | |
#include <inttypes.h> | |
#include <assert.h> | |
static inline uint8_t first_bit_set(uint32_t bits) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Math.Polynomial | |
import Math.Polynomial.Chebyshev | |
coeff f n j = (2 / nf) * (sum [f(xk) * yk | (xk, yk) <- zip x y]) | |
where | |
x = map ((\x -> cos (pi * (x + 0.5) / nf)) . fromIntegral) [0..n-1] | |
y = map ((\x -> cos (jf * pi * (x + 0.5) / nf)) . fromIntegral) [0..n-1] | |
nf = fromIntegral n | |
jf = fromIntegral j |
OlderNewer