Skip to content

Instantly share code, notes, and snippets.

View zlotnleo's full-sized avatar

Leo Zlotnikov zlotnleo

View GitHub Profile
@zlotnleo
zlotnleo / primes.py
Created May 23, 2019 01:08
Lazy Genuine Sieve of Eratosthenes in Python
import heapq
import itertools
from dataclasses import dataclass, field
def primes():
@dataclass(init=True, order=True)
class Element:
key: int = field(compare=True)
nums: any = field(compare=False)

Keybase proof

I hereby claim:

  • I am zlotnleo on github.
  • I am zlotnleo (https://keybase.io/zlotnleo) on keybase.
  • I have a public key whose fingerprint is E68E 9386 5196 13D9 608C EE73 F3EE 9DBA C529 5C97

To claim this, I am signing this object:

@zlotnleo
zlotnleo / Automata.sml
Created July 4, 2017 20:16
SML modules implementing sets, NFA and DFA
val _ = use "Set.sml";
functor Automata(eqtype alpha) :>
sig
type nfa
type dfa
type regex
val Union : regex * regex -> regex
val Concat : regex * regex -> regex
@zlotnleo
zlotnleo / 234Tree.sml
Created June 2, 2017 18:03
2-3-4 Tree
datatype 'a tree =
Lf
| Db of 'a tree * 'a * 'a tree
| Tr of 'a tree * 'a * 'a tree * 'a * 'a tree
| Qd of 'a tree * 'a * 'a tree * 'a * 'a tree * 'a * 'a tree
fun get Lf _ = raise Subscript
| get (Db(t1, (k1, v1), t2)) k =
if k < k1 then get t1 k
else if k = k1 then v1
@zlotnleo
zlotnleo / ttt.sml
Last active May 19, 2017 13:42
SML TTT Tree
datatype player = X | O;
datatype cell = Nil | Cell of player;
datatype state = Win of player | Draw;
exception IllegalState;
val newboard = List.tabulate (9, fn _ => Nil);
fun getNext [] _ = []
| getNext (Nil::cs) p = ((Cell p)::cs) :: map (fn l => Nil::l) (getNext cs p)
| getNext (c::cs) p = map (fn l => c::l) (getNext cs p)