Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
24
Task/Balanced-brackets/ArkScript/balanced-brackets.ark
Normal file
24
Task/Balanced-brackets/ArkScript/balanced-brackets.ark
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
(import std.List)
|
||||
|
||||
(let gen_string (fun (length) {
|
||||
(mut output "")
|
||||
(while (< (len output) length) {
|
||||
(set output (+ output (@ "[]" (random 0 1)))) })
|
||||
output }))
|
||||
|
||||
(let balanced? (fun (str) {
|
||||
(mut i 0)
|
||||
(=
|
||||
(len str)
|
||||
(len
|
||||
(list:takeWhile str (fun (char) {
|
||||
(if (= "[" char)
|
||||
(set i (+ i 1))
|
||||
(set i (- i 1)))
|
||||
(>= i 0) }))))}))
|
||||
|
||||
(list:forEach
|
||||
(list:iota 0 5)
|
||||
(fun (_) {
|
||||
(let str (gen_string (random 2 8)))
|
||||
(print (string:format "{:<8}: {:^6}" str (if (balanced? str) "OK" "NOT OK"))) }))
|
||||
Loading…
Add table
Add a link
Reference in a new issue