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
29
Task/ABC-Problem/SequenceL/abc-problem-1.sequencel
Normal file
29
Task/ABC-Problem/SequenceL/abc-problem-1.sequencel
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import <Utilities/Conversion.sl>;
|
||||
import <Utilities/Sequence.sl>;
|
||||
|
||||
main(args(2)) :=
|
||||
let
|
||||
result[i] := args[i] ++ ": " ++ boolToString(can_make_word(args[i], InitBlocks));
|
||||
in
|
||||
delimit(result, '\n');
|
||||
|
||||
InitBlocks := ["BO", "XK", "DQ", "CP", "NA", "GT", "RE", "TG", "QD", "FS", "JW", "HU", "VI", "AN", "OB", "ER", "FS", "LY", "PC", "ZM"];
|
||||
|
||||
can_make_word(word(1), blocks(2)) :=
|
||||
let
|
||||
choices[i] := i when some(blocks[i] = toUpper(head(word)));
|
||||
blocksAfterChoice[i] := blocks[(1 ... (choices[i] - 1)) ++ ((choices[i] + 1) ... size(blocks))];
|
||||
in
|
||||
true when size(word) = 0
|
||||
else
|
||||
false when size(choices) = 0
|
||||
else
|
||||
some(can_make_word(tail(word), blocksAfterChoice));
|
||||
|
||||
toUpper(letter(0)) :=
|
||||
let
|
||||
ascii := asciiToInt(letter);
|
||||
in
|
||||
letter when ascii >= 65 and ascii <= 90
|
||||
else
|
||||
intToAscii(ascii - 32);
|
||||
31
Task/ABC-Problem/SequenceL/abc-problem-2.sequencel
Normal file
31
Task/ABC-Problem/SequenceL/abc-problem-2.sequencel
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import <Utilities/Conversion.sl>;
|
||||
import <Utilities/Sequence.sl>;
|
||||
import <RegEx/RegEx.sl>;
|
||||
|
||||
main(args(2)) :=
|
||||
let
|
||||
result[i] := args[i] ++ ": " ++ boolToString(can_make_word(args[i], InitBlocks));
|
||||
in
|
||||
delimit(result, '\n');
|
||||
|
||||
InitBlocks := "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM";
|
||||
|
||||
can_make_word(word(1), blocks(1)) :=
|
||||
let
|
||||
regEx := "(\\a" ++ [toUpper(head(word))] ++ "|" ++ [toUpper(head(word))] ++ "\\a)";
|
||||
|
||||
newBlocks := replaceFirst(blocks, regEx, "");
|
||||
in
|
||||
true when size(word) = 0
|
||||
else
|
||||
false when size(newBlocks) = size(blocks)
|
||||
else
|
||||
can_make_word(tail(word), newBlocks);
|
||||
|
||||
toUpper(letter(0)) :=
|
||||
let
|
||||
ascii := asciiToInt(letter);
|
||||
in
|
||||
letter when ascii >= 65 and ascii <= 90
|
||||
else
|
||||
intToAscii(ascii - 32);
|
||||
Loading…
Add table
Add a link
Reference in a new issue