Data update
This commit is contained in:
parent
796d366b97
commit
35bcdeebf8
504 changed files with 7045 additions and 610 deletions
23
Task/ABC-problem/EasyLang/abc-problem.easy
Normal file
23
Task/ABC-problem/EasyLang/abc-problem.easy
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
b$[][] = [ [ "B" "O" ] [ "X" "K" ] [ "D" "Q" ] [ "C" "P" ] [ "N" "A" ] [ "G" "T" ] [ "R" "E" ] [ "T" "G" ] [ "Q" "D" ] [ "F" "S" ] [ "J" "W" ] [ "H" "U" ] [ "V" "I" ] [ "A" "N" ] [ "O" "B" ] [ "E" "R" ] [ "F" "S" ] [ "L" "Y" ] [ "P" "C" ] [ "Z" "M" ] ]
|
||||
len b[] len b$[][]
|
||||
global w$[] cnt .
|
||||
#
|
||||
proc backtr wi . .
|
||||
if wi > len w$[]
|
||||
cnt += 1
|
||||
return
|
||||
.
|
||||
for i = 1 to len b$[][]
|
||||
if b[i] = 0 and (b$[i][1] = w$[wi] or b$[i][2] = w$[wi])
|
||||
b[i] = 1
|
||||
backtr wi + 1
|
||||
b[i] = 0
|
||||
.
|
||||
.
|
||||
.
|
||||
for s$ in [ "A" "BARK" "BOOK" "TREAT" "COMMON" "SQUAD" "CONFUSE" ]
|
||||
w$[] = strchars s$
|
||||
cnt = 0
|
||||
backtr 1
|
||||
print s$ & " can be spelled in " & cnt & " ways"
|
||||
.
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
(var find-idx #(when (let found (find % %1)) (idx %1 found)))
|
||||
(function in-block? c (when (let block-idx (find-idx (substr? (upper-case c)) rem-blocks)) (var! rem-blocks drop block-idx)))
|
||||
(function in-block? c
|
||||
(when (let block-idx (find-idx (substr? (upper-case c)) rem-blocks))
|
||||
(var! rem-blocks drop block-idx)))
|
||||
|
||||
(function can-make-word word
|
||||
(var rem-blocks ["BO" "XK" "DQ" "CP" "NA" "GT" "RE" "TG" "QD" "FS" "JW" "HU" "VI" "AN" "OB" "ER" "FS" "LY" "PC" "ZM"])
|
||||
(.. and (map in-block? word)))
|
||||
|
||||
(join ", " (map #(str % " => " (can-make-word %)) ["A" "bark" "Book" "TREAT" "Common" "squaD" "CoNFuSe"])) ; Notice case insensitivity
|
||||
(-> ["A" "bark" "Book" "TREAT" "Common" "squaD" "CoNFuSe"] ; Notice case insensitivity
|
||||
(map #(str % " => " (can-make-word %)))
|
||||
(join ", "))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue