Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/ABC-problem/XPL0/abc-problem.xpl0
Normal file
29
Task/ABC-problem/XPL0/abc-problem.xpl0
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
string 0;
|
||||
|
||||
char Side1, Side2;
|
||||
def Size = 20;
|
||||
char Avail(Size);
|
||||
|
||||
func CanMakeWord(Word); \returns 'true' if blocks can make Word
|
||||
char Word;
|
||||
int I, Let;
|
||||
[Let:= Word(0) & $5F; \get letter and make sure it's uppercase
|
||||
if Let = 0 then return true; \if 0 then end of word; return successful
|
||||
for I:= 0 to Size-1 do \scan for block that contains letter
|
||||
if Avail(I) and (Side1(I) = Let or Side2(I) = Let) then
|
||||
[Avail(I):= false;
|
||||
if CanMakeWord(Word+1) then return true;
|
||||
];
|
||||
return false;
|
||||
];
|
||||
|
||||
int I, J, Words;
|
||||
[Side1:= "BXDCNGRTQFJHVAOEFLPZ";
|
||||
Side2:= "OKQPATEGDSWUINBRSYCM";
|
||||
Words:= ["A", "bark", "Book", "Treat", "Common", "Squad", "conFuse"];
|
||||
for J:= 0 to 6 do
|
||||
[Text(0, "Can make ^""); Text(0, Words(J)); Text(0, "^": ");
|
||||
for I:= 0 to Size-1 do Avail(I):= true;
|
||||
Text(0, if CanMakeWord(Words(J)) then "True" else "False"); CrLf(0);
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue