Twelve statements: Difference between revisions
Content deleted Content added
Simpler D entry |
Simpler D entry |
||
Line 180:
=={{header|D}}==
{{trans|Python}}
<lang d>import std.stdio, std.typecons, std.algorithm, std.range,std.functional;
immutable texts = [
Line 212 ⟶ 211:
s => sumi(s[6 .. 9]) == 1,
s => sumi(s[0 .. 11]) == 4];
immutable pos = matches.countUntil(false);▼
writefln(`Missed by statement %d: "%s"`, pos + 1, texts[pos]);▼
} else▼
writeln("Solution:");▼
write(" ");▼
foreach (i, t; st)▼
writef("%d:%s ", i + 1, t ? "T" : "F");▼
writeln();▼
void main() {
Line 245 ⟶ 232:
foreach (sols, isPartial; zip([full, partial], [false, true]))
foreach (stm; sols) {
pos + 1, texts[pos]);
▲ } else
▲ writeln("Solution:");
▲ write(" ");
▲ writef("%d:%s ", i + 1, t ? "T" : "F");
▲ writeln();
}
}</lang>
{{out}}
|