ABC problem: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Automated syntax highlighting fixup (second round - minor fixes)) |
|||
Line 9,674: | Line 9,674: | ||
Can we spell 'SQUAD'? true |
Can we spell 'SQUAD'? true |
||
Can we spell 'CONFUSE'? true |
Can we spell 'CONFUSE'? true |
||
</pre> |
|||
=={{header|Transd}}== |
|||
The code properly handles the backtracking issue (see the note in the Fortran solution). |
|||
<syntaxhighlight lang="Scheme">#lang transd |
|||
MainModule: { |
|||
blocks: ["BO", "XK", "DQ", "CP", "NA", "GT", "RE", "TG", "QD", "FS", |
|||
"JW", "HU", "VI", "AN", "OB", "ER", "FS", "LY", "PC", "ZM"], |
|||
words: ["A","BARK","BOOK","TREAT","COMMON","SQUAD","CONFUSE"], |
|||
testMake: Lambda<String Vector<String> Bool>(λ |
|||
w String() v Vector<String>() |
|||
locals: c (toupper (subn w 0)) |
|||
(for bl in v do |
|||
(if (contains bl c) |
|||
(if (== (size w) 1) (ret true)) |
|||
(if (exec testMake (sub w 1) (erase (cp v) @idx)) |
|||
(ret true))) |
|||
) |
|||
(ret false) |
|||
), |
|||
_start: (lambda |
|||
(for word in words do |
|||
(lout :boolalpha word " : " |
|||
(exec testMake word blocks)) |
|||
) |
|||
) |
|||
}</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
A : true |
|||
BARK : true |
|||
BOOK : false |
|||
TREAT : true |
|||
COMMON : false |
|||
SQUAD : true |
|||
CONFUSE : true |
|||
</pre> |
</pre> |
||