September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
19
Task/ABC-Problem/Zkl/abc-problem.zkl
Normal file
19
Task/ABC-Problem/Zkl/abc-problem.zkl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
var blocks=T("BO", "XK", "DQ", "CP", "NA", "GT", "RE", "TG", "QD", "FS",
|
||||
"JW", "HU", "VI", "AN", "OB", "ER", "FS", "LY", "PC", "ZM", );
|
||||
|
||||
fcn can_make_word(word){
|
||||
fcn(blks,word){
|
||||
if (not word) return(True); // bottom of recursion
|
||||
foreach b in (blks){ n:=__bWalker.idx;
|
||||
if(not b.holds(word[0])) continue; // letter not on this block
|
||||
blks.del(n); // remove this block from pile
|
||||
if (self.fcn(blks,word[1,*])) return(True); // try remaining blocks
|
||||
blks.insert(n,b); // put block back in pile: backtracking
|
||||
}
|
||||
False; // out of blocks but not out of word
|
||||
}(blocks.copy(),word.toUpper())
|
||||
}
|
||||
|
||||
foreach word in (T("","A","BarK","BOOK","TREAT","COMMON","SQUAD","Confuse","abba")){
|
||||
can_make_word(word).println(": ",word);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue