RosettaCodeData/Task/ABC-problem/EchoLisp/abc-problem.l

16 lines
485 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(lib 'list) ;; list-delete
(define BLOCKS '("BO" "XK" "DQ" "CP" "NA" "GT" "RE" "TG" "QD" "FS"
2026-02-01 16:33:20 -08:00
"JW" "HU" "VI" "AN" "OB" "ER" "FS" "LY" "PC" "ZM" ))
2023-07-01 11:58:00 -04:00
(define WORDS '("A" "BARK" "BOOK" "TREAT" "COMMON" "SQUAD" "CONFUSE"))
2026-02-01 16:33:20 -08:00
2023-07-01 11:58:00 -04:00
(define (spell word blocks)
(cond
2026-02-01 16:33:20 -08:00
((string-empty? word) #t)
((empty? blocks) #f)
(else
(for/or [(block blocks)]
#:continue (not (string-match block (string-first word)))
(spell (string-rest word) (list-delete blocks block))))))