2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
22
Task/ABC-Problem/Maple/abc-problem.maple
Normal file
22
Task/ABC-Problem/Maple/abc-problem.maple
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
canSpell := proc(w)
|
||||
local blocks, i, j, word, letterFound;
|
||||
blocks := [["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"]];
|
||||
word := StringTools[UpperCase](convert(w, string));
|
||||
for i to length(word) do
|
||||
letterFound := false;
|
||||
for j to numelems(blocks) do
|
||||
if not letterFound and (substring(word, i) = blocks[j][1] or substring(word, i) = blocks[j][2]) then
|
||||
blocks[j][1] := undefined;
|
||||
blocks[j][2] := undefined;
|
||||
letterFound := true;
|
||||
end if;
|
||||
end do;
|
||||
if not letterFound then
|
||||
return false;
|
||||
end if;
|
||||
end do;
|
||||
return true;
|
||||
end proc:
|
||||
|
||||
seq(printf("%a: %a\n", i, canSpell(i)), i in [a, Bark, bOok, treat, COMMON, squad, confuse]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue