Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Balanced-brackets/EchoLisp/balanced-brackets.l
Normal file
28
Task/Balanced-brackets/EchoLisp/balanced-brackets.l
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
(define (balance str)
|
||||
(for/fold (closed 0) ((par str))
|
||||
#:break (< closed 0 ) => closed
|
||||
(+ closed
|
||||
(cond
|
||||
((string=? par "[") 1)
|
||||
((string=? par "]") -1)
|
||||
(else 0)))))
|
||||
|
||||
(define (task N)
|
||||
(define str (list->string (append (make-list N "[") (make-list N "]"))))
|
||||
(for ((i 10))
|
||||
(set! str (list->string (shuffle (string->list str))))
|
||||
(writeln (if (zero? (balance str)) '👍 '❌ ) str)))
|
||||
|
||||
(task 4)
|
||||
|
||||
❌ "[]]][[]["
|
||||
❌ "]][][[[]"
|
||||
❌ "][[[]]]["
|
||||
👍 "[][[[]]]"
|
||||
❌ "]][[][]["
|
||||
❌ "][][[[]]"
|
||||
👍 "[][][[]]"
|
||||
❌ "]][[][[]"
|
||||
❌ "[[]]][[]"
|
||||
❌ "[[][]]]["
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue