Anonymous user
Dinesman's multiple-dwelling problem: Difference between revisions
Dinesman's multiple-dwelling problem (view source)
Revision as of 08:47, 19 July 2011
, 12 years agoImproved D version
m ({{omit from|GUISS}}) |
(Improved D version) |
||
Line 98:
=={{header|D}}==
<lang d>import std.stdio, std.range, std.math, std.traits;▼
▲<lang d>import std.stdio, std.range, std.math;
// From http://rosettacode.org/wiki/Permutations#D
void perms(
if (s.length)
foreach (i, c; s)
perms(s[0 .. i] ~ s[i
}
perms(
return
}
foreach
if (!pred(perm))
▲ foreach (p; perms) {
▲ }
▲ return null;
}
void main() {
▲ enum {Baker, Cooper, Fletcher, Miller, Smith};
▲ auto c6 = (int[] s){ return abs(s[Cooper] - s[Fletcher]) != 1; };
// c1, c2, ... can't be an array
if (solution.length)
}</lang>
Output:
<pre>[
=={{header|Haskell}}==
|