Nonoblock: Difference between revisions

Fixed D entry
(→‎{{header|D}}: Marked incomplete as is missing count of the number of different possibilities that are found.)
(Fixed D entry)
Line 61:
=={{header|D}}==
{{trans|python}}
{{incomplete|D|Missing count of the number of different possibilities that are found.}}
<lang d>import std.stdio, std.array, std.algorithm, std.exception, std.conv;
 
Line 149 ⟶ 148:
show([], prob.nCells).writeln;
"Possibilities:".writeln;
auto nConfigs = 0;
foreach (const sol; NonoBlocks(prob.tupleof)) {
show(sol, prob.nCells).writeln;
nConfigs++;
}
writefln("A total of %d possible configurations.", nConfigs);
writeln;
}
Line 161 ⟶ 164:
[AA__B]
[_AA_B]
A total of 3 possible configurations.
 
Configuration (5 cells and [] blocks):
Line 166 ⟶ 170:
Possibilities:
[_____]
A total of 1 possible configurations.
 
Configuration (10 cells and [8] blocks):
Line 173 ⟶ 178:
[_AAAAAAAA_]
[__AAAAAAAA]
A total of 3 possible configurations.
 
Configuration (15 cells and [2, 3, 2, 3] blocks):
Line 192 ⟶ 198:
[_AA__BBB_CC_DDD]
[__AA_BBB_CC_DDD]
A total of 15 possible configurations.
 
Configuration (10 cells and [4, 3] blocks):
Line 202 ⟶ 209:
[_AAAA__BBB]
[__AAAA_BBB]
A total of 6 possible configurations.
 
Configuration (5 cells and [2, 1] blocks):
Line 209 ⟶ 217:
[AA__B]
[_AA_B]
A total of 3 possible configurations.
 
Configuration (10 cells and [3, 1] blocks):
Line 234 ⟶ 243:
[____AAA__B]
[_____AAA_B]
A total of 21 possible configurations.
 
Configuration (5 cells and [2, 3] blocks):
[_____]
Possibilities:
Possibilities:
object.Exception @nonoblock.d(17): Those blocks cannot fit in those cells.