YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 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