Last letter-first letter: Difference between revisions

Content added Content deleted
(Improved second D version)
(Fixed bug in second D version)
Line 132: Line 132:


foreach (ushort i, item; items)
foreach (ushort i, item; items)
refs ~= Ref(i, item[0], item[$-1]);
refs ~= Ref(i, item[$-1], item[0]);


// try each item as possible start
// try each item as possible start
Line 169: Line 169:
writeln("Paths of that length: ", sol_nsol[1]);
writeln("Paths of that length: ", sol_nsol[1]);
writeln("Example path of that length:");
writeln("Example path of that length:");
foreach (i; iota(0, sol_nsol[0].length, 7))
for (int i = 0; i < sol_nsol[0].length; i += 7)
writeln(" ", sol_nsol[0][i .. min(i+7, $)].join(" "));
writeln(" ", sol_nsol[0][i .. min(i+7, $)].join(" "));
}</lang>
}</lang>
Runtime: about 0.67 seconds, dmd compiler.
Runtime: about 0.79 seconds, dmd compiler.


=={{header|Go}}==
=={{header|Go}}==