This file contains hidden or 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 "set" | |
#include "vector" | |
#include "deque" | |
#include "algorithm" | |
struct PointRef { | |
int vecIdx; | |
int ptIdx; | |
}; |
This file contains hidden or 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 "set" | |
#include "vector" | |
#include "deque" | |
#include "algorithm" | |
struct PointRef { | |
int vecIdx; | |
int ptIdx; | |
}; |
This file contains hidden or 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 qualified Data.Map as M | |
import qualified Data.Set as S | |
import Data.Semigroup | |
import Control.Applicative | |
import Data.List | |
import Data.Maybe | |
import Criterion.Main | |
import System.Random | |
import Data.Char |
This file contains hidden or 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 Criterion.Main | |
import System.Random | |
import Data.List | |
import qualified Data.Vector.Unboxed as U | |
rainfall1 :: [Int] -> Int | |
rainfall1 xs = sum (zipWith (-) mins xs) | |
where | |
mins = zipWith min maxl maxr | |
maxl = scanl1 max xs |
This file contains hidden or 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 "emmintrin.h" | |
#include "stdlib.h" | |
int tower(int length, int *towers) | |
{ | |
unsigned char *maxt, *towers8; | |
int i, length8; | |
__m128i vec1, vec2, vec3; | |
length8 = (length+15)/16; |
This file contains hidden or 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
benchmarking rainfall/list | |
time 2.697 s (2.532 s .. 3.065 s) | |
0.998 R² (NaN R² .. 1.000 R²) | |
mean 2.771 s (2.712 s .. 2.800 s) | |
std dev 51.39 ms (0.0 s .. 51.77 ms) | |
variance introduced by outliers: 19% (moderately inflated) | |
benchmarking rainfall/unboxed vector | |
time 51.66 ms (51.59 ms .. 51.83 ms) | |
1.000 R² (1.000 R² .. 1.000 R²) |
This file contains hidden or 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> | |
inline long f(long x, long y) { | |
return x + (y*2); | |
} | |
long g(long n) { | |
long s = 0; | |
for (long i = 0; i < n; i++) { |
This file contains hidden or 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 Data.List | |
import Data.Function | |
import Text.Read | |
import Data.Maybe | |
import Data.Char | |
all_numbers :: String -> [Int] | |
all_numbers = | |
mapMaybe (readMaybe :: String -> Maybe Int) . |
This file contains hidden or 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 Data.List | |
import Data.Function | |
rank :: [Int] -> [Int] | |
rank = order . order | |
where | |
order = | |
map fst . | |
sortBy (compare `on` snd) . | |
zip [1..] |
This file contains hidden or 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
triangle = map (\i -> [(i * (i-1) `quot` 2) + 1 .. | |
(i * (i+1) `quot` 2)]) | |
[1..] |
OlderNewer