Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
22
Task/ABC-Problem/D/abc-problem-1.d
Normal file
22
Task/ABC-Problem/D/abc-problem-1.d
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import std.stdio, std.algorithm, std.string;
|
||||
|
||||
bool canMakeWord(in string word, in string[] blocks) pure /*nothrow*/ @safe {
|
||||
auto bs = blocks.dup;
|
||||
outer: foreach (immutable ch; word.toUpper) {
|
||||
foreach (immutable block; bs)
|
||||
if (block.canFind(ch)) {
|
||||
bs = bs.remove(bs.countUntil(block));
|
||||
continue outer;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void main() @safe {
|
||||
immutable blocks = "BO XK DQ CP NA GT RE TG QD FS JW HU VI
|
||||
AN OB ER FS LY PC ZM".split;
|
||||
|
||||
foreach (word; "" ~ "A BARK BoOK TrEAT COmMoN SQUAD conFUsE".split)
|
||||
writefln(`"%s" %s`, word, canMakeWord(word, blocks));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue