Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
15
Task/Rep-string/Factor/rep-string.factor
Normal file
15
Task/Rep-string/Factor/rep-string.factor
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
USING: formatting grouping kernel math math.ranges qw sequences ;
|
||||
IN: rosetta-code.rep-string
|
||||
|
||||
: (find-rep-string) ( str -- str )
|
||||
dup dup length 2/ [1,b]
|
||||
[ <groups> [ head? ] monotonic? ] with find nip dup
|
||||
[ head ] [ 2drop "N/A" ] if ;
|
||||
|
||||
: find-rep-string ( str -- str )
|
||||
dup length 1 <= [ drop "N/A" ] [ (find-rep-string) ] if ;
|
||||
|
||||
qw{ 1001110011 1110111011 0010010010 1010101010 1111111111
|
||||
0100101101 0100100 101 11 00 1 }
|
||||
"Shortest cycle:\n\n" printf
|
||||
[ dup find-rep-string "%-10s -> %s\n" printf ] each
|
||||
Loading…
Add table
Add a link
Reference in a new issue