Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
45
Task/ABC-problem/Elena/abc-problem.elena
Normal file
45
Task/ABC-problem/Elena/abc-problem.elena
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import system'routines;
|
||||
import system'collections;
|
||||
import extensions;
|
||||
import extensions'routines;
|
||||
|
||||
extension op
|
||||
{
|
||||
canMakeWordFrom(blocks)
|
||||
{
|
||||
var list := ArrayList.load(blocks);
|
||||
|
||||
^ nil == (cast string(self)).upperCase().seekEach:(ch)
|
||||
{
|
||||
var index := list.indexOfElement
|
||||
((word => word.indexOf(0, ch) != -1).asComparator());
|
||||
|
||||
if (index>=0)
|
||||
{
|
||||
list.removeAt(index); ^ false
|
||||
}
|
||||
else
|
||||
{
|
||||
^ true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public program()
|
||||
{
|
||||
var blocks := new string[]{"BO", "XK", "DQ", "CP", "NA",
|
||||
"GT", "RE", "TG", "QD", "FS",
|
||||
"JW", "HU", "VI", "AN", "OB",
|
||||
"ER", "FS", "LY", "PC", "ZM"};
|
||||
|
||||
var words := new string[]{"", "A", "BARK", "BOOK", "TREAT", "COMMON", "SQUAD", "Confuse"};
|
||||
|
||||
Enumerator e := words.enumerator();
|
||||
e.next();
|
||||
|
||||
words.forEach:(word)
|
||||
{
|
||||
console.printLine("can make '",word,"' : ",word.canMakeWordFrom(blocks));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue