Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
17
Task/Rep-string/EchoLisp/rep-string-1.echolisp
Normal file
17
Task/Rep-string/EchoLisp/rep-string-1.echolisp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
(lib 'list) ;; list-rotate
|
||||
|
||||
;; a list is a rep-list if equal? to itself after a rotation of lam units
|
||||
;; lam <= list length / 2
|
||||
;; truncate to a multiple of lam before rotating
|
||||
;; try cycles in decreasing lam order (longest wins)
|
||||
|
||||
(define (cyclic? cyclic)
|
||||
(define len (length cyclic))
|
||||
(define trunc null)
|
||||
|
||||
(if (> len 1)
|
||||
(for ((lam (in-range (quotient len 2) 0 -1)))
|
||||
(set! trunc (take cyclic (- len (modulo len lam))))
|
||||
#:break (equal? trunc (list-rotate trunc lam)) => (list->string (take cyclic lam))
|
||||
'no-rep )
|
||||
'too-short-no-rep))
|
||||
Loading…
Add table
Add a link
Reference in a new issue