RosettaCodeData/Task/ABC-problem/MAXScript/abc-problem-3.max

31 lines
713 B
Plaintext

fn isWordPossible2 word =
(
Blocks = #("BO","XK","DQ","CP","NA", \
"GT","RE","TG","QD","FS", \
"JW","HU","VI","AN","OB", \
"ER","FS","LY","PC","ZM")
word = toupper word
local pos = 1
local solvedLetters = #()
while pos <= word.count do
(
for i = 1 to blocks.count do
(
if (matchpattern blocks[i] pattern:("*"+word[pos]+"*")) then
(
deleteitem blocks i
appendifunique solvedLetters pos
pos +=1
exit
)
else if i == blocks.count do return false
)
)
if solvedLetters.count == word.count then
(
local check = ""
for bit in solvedLetters do append check word[bit]
if check == word then return true else return false
) else return false
)