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
FROM alpine:latest | |
RUN ["apk", "add", "bash"] | |
COPY "sieve.sh" "$WORKDIR" | |
ENTRYPOINT ["./sieve.sh"] |
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
# Moved: https://github.com/nvanderw/voting/blob/main/proportional.py |
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
(i:=__import__,n:=255,p:=lambda a:print(a,end='',flush=True),t:=i('blessed').Terminal(),H:=0,w:=t.width,h:=t.height,p(t.clear+t.home),x:=1,y:=1,X:=1,Y:=1,u:=lambda v,p,m:v if 0<p<m-1else -v,p(t.hide_cursor),all((x:=x+X,y:=y+Y,X:=u(X,x,w),Y:=u(Y,y,h),R:=i('colorsys').hsv_to_rgb(H/n,1,1),p(t.move_xy(x,y)+t.bold+t.color_rgb(*map(lambda m:int(m*n),R))+"☻"),H:=H+7&n,i('time').sleep(.01))for _ in iter(int,1))) |
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 os | |
import signal | |
import sys | |
import time | |
import random | |
NUM_ITERATIONS = 10000000 | |
NUM_WORKERS = 20 | |
def unpack_bits(bs): |
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
from blessed import Terminal | |
from colorsys import hsv_to_rgb | |
from time import sleep | |
from random import randrange, choice | |
from sys import stdout | |
# Print with no trailing newline | |
def printn(*args, **kwargs): | |
kwargs['end'] = '' | |
print(*args, **kwargs) |
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
# For finding the best wordle starting word | |
import argparse | |
import itertools | |
import math | |
import random | |
from dataclasses import dataclass | |
from multiprocessing import Pool | |
from typing import Any |
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
module type Functor = sig | |
type 'a t | |
val map : ('a -> 'b) -> 'a t -> 'b t | |
end | |
module type Monad = sig | |
type 'a t | |
val map : ('a -> 'b) -> 'a t -> 'b t | |
val return : 'a -> 'a 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
module type FUNCTOR = sig | |
type 'v f | |
val map : ('a -> 'b) -> 'a f -> 'b f | |
end | |
module type MONAD = sig | |
type 'v f | |
val map : ('a -> 'b) -> 'a f -> 'b f | |
val pure : 'a -> 'a f | |
val join : ('a f) f -> 'a f |
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
from functional import fun | |
from itertools import imap, ifilter, takewhile, count | |
@fun(2) | |
def add(x,y): return x + y | |
# Here I define a function which takes a string and shows what it evaluates to. | |
@fun(1) | |
def evalPrint(s): | |
print "%s -> %s" % (s, eval(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
import itertools | |
# Monad instance on a Python iterator, very similar to Haskell's list monad. | |
# In general, Haskell typeclass instances can be regarded as dictionaries which | |
# map the implemented function to its implementation. For a good explanation of | |
# this, see Philip Wadler's "Faith, Evolution, and Programming Languages" | |
# lecture. What this means for us is that we can write a function whose type | |
# signature in Haskell would be: | |
# Monad m => f m | |
# |
NewerOlder