Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
44
Task/ABC-Problem/Phix/abc-problem.phix
Normal file
44
Task/ABC-Problem/Phix/abc-problem.phix
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
-- Here is my recursive solution which also solves the extra problems on the discussion page:
|
||||
|
||||
sequence blocks = {"BO","XK","DQ","CP","NA","GT","RE","TG","QD","FS",
|
||||
"JW","HU","VI","AN","OB","ER","FS","LY","PC","ZM"}
|
||||
|
||||
sequence words = {"","A","BarK","BOOK","TrEaT","COMMON","SQUAD","CONFUSE"}
|
||||
|
||||
--sequence blocks = {"US","TZ","AO","QA"}
|
||||
--sequence words = {"AuTO"}
|
||||
|
||||
--sequence blocks = {"AB","AB","AC","AC"}
|
||||
--sequence words = {"abba"}
|
||||
|
||||
sequence used = repeat(0,length(blocks))
|
||||
|
||||
function ABC_Solve(sequence word, integer idx)
|
||||
integer ch
|
||||
integer res = 0
|
||||
if idx>length(word) then
|
||||
res = 1
|
||||
else
|
||||
ch = word[idx]
|
||||
for k=1 to length(blocks) do
|
||||
if used[k]=0
|
||||
and find(ch,blocks[k]) then
|
||||
used[k] = 1
|
||||
res = ABC_Solve(word,idx+1)
|
||||
used[k] = 0
|
||||
if res then exit end if
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
return res
|
||||
end function
|
||||
|
||||
constant TF = {"False","True"}
|
||||
procedure ABC_Problem()
|
||||
for i=1 to length(words) do
|
||||
printf(1,"%s: %s\n",{words[i],TF[ABC_Solve(upper(words[i]),1)+1]})
|
||||
end for
|
||||
if getc(0) then end if
|
||||
end procedure
|
||||
|
||||
ABC_Problem()
|
||||
Loading…
Add table
Add a link
Reference in a new issue