aboutsummaryrefslogtreecommitdiffhomepage
path: root/samples/rosetta/de_bruijn_sequence.bruijn
blob: 967fa72d2c2190c94213ee981d37024355de5eb0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# TODO: Too slow to be published. Probably needs Maps/Sets/Vectors/sth.

:import std/Combinator .
:import std/Char C
:import std/List .
:import std/Math .

# very slow but elegant
de-bruijn y [[[C.?infix? (take 0 1) ~1 case-end case-rec]]]
	case-rec max-by (compare ⋔ length) ([3 (0 : 2) 1] <$> (C.?nub 1))
	case-end drop 0 1

:test (de-bruijn "abcd" (+2)) ("dccaadbbacbdabcd")

main [[0]]