For excessively paranoid client authentication.
Organization & Common Name: Some human identifier for this server CA.
openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
trans2NegForm :: Integer -> [Int] | |
trans2NegForm x = loop x "init" [] | |
where | |
trans 0 "init" = (0, "init") | |
trans 1 "init" = (-1, "trans") | |
trans 1 "trans" = (0, "trans") | |
trans 0 "trans" = (1, "init") | |
loop 0 "trans" ans = 1:ans | |
loop 0 "init" ans = ans | |
loop i status ans = loop (i `shiftR` 1) newStatus (newBit:ans) |
/* | |
* linux 2.6.37-3.x.x x86_64, ~100 LOC | |
* gcc-4.6 -O2 semtex.c && ./a.out | |
* 2010 [email protected], salut! | |
* | |
* update may 2013: | |
* seems like centos 2.6.32 backported the perf bug, lol. | |
* jewgold to 115T6jzGrVMgQ2Nt1Wnua7Ch1EuL9WXT2g if you insist. | |
*/ |
sieve [] = [] | |
sieve (x:xs) = x: sieve notMutipleOfX | |
where notMutipleOfX = filter (\n -> n `mod` x /= 0 ) xs | |
primes = sieve [2..] | |
main = print $ take 5000 primes |
For excessively paranoid client authentication.
Organization & Common Name: Some human identifier for this server CA.
openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
import itertools | |
from itertools import islice | |
from itertools import ifilter | |
def sieve(numbers): | |
head = next(numbers) | |
yield head | |
for x in sieve(ifilter(lambda x: x % head, numbers)): | |
yield x |
import Data.List | |
import qualified Data.Map as Map | |
sieve xs = sieve' xs Map.empty | |
sieve' [] table = [] | |
sieve' (x:xs) table = | |
case Map.lookup x table of | |
Nothing -> x: sieve' xs (Map.insert (x+x) [x] table) | |
Just facts -> sieve' xs (foldl' reinsert (Map.delete x table) facts) |
from itertools import ifilter | |
from itertools import islice | |
def sieve_worker(numbers, table): | |
head = next(numbers) | |
if head not in table: | |
yield head | |
table[head+head] = [head] | |
else: |
(defn exchange [table coin] | |
(let [table-size (count table)] | |
(reduce #(assoc %1 %2 (+ (nth %1 %2) (nth %1 (- %2 coin)))) | |
table | |
(range coin table-size)))) | |
(defn total-exchange [money coins] | |
(let [table (->> (take money (repeat 0N)) | |
(#(conj % 1N)) | |
vec)] |
(def atom? | |
(fn [a] | |
(not (seq? a)))) | |
(def null? | |
(fn [a] | |
(or | |
(nil? a) | |
(= () a)))) |
(def b '[3 - - - - 5 - 1 - | |
- 7 - - - 6 - 3 - | |
1 - - - 9 - - - - | |
7 - 8 - - - - 9 - | |
9 - - 4 - 8 - - 2 | |
- 6 - - - - 5 - 1 | |
- - - - 4 - - - 6 | |
- 4 - 7 - - - 2 - | |
- 2 - 6 - - - - 3]) |