Set puzzle: Difference between revisions
Content added Content deleted
(Updated D entry) |
|||
Line 551: | Line 551: | ||
} |
} |
||
immutable Card[81] deck; |
static immutable Card[81] deck; |
||
} |
} |
||
pure nothrow @safe static this() { |
|||
immutable colors = [EnumMembers!Color]; |
immutable colors = [EnumMembers!Color]; |
||
immutable numbers = [EnumMembers!Number]; |
immutable numbers = [EnumMembers!Number]; |
||
Line 577: | Line 577: | ||
// of 3. |
// of 3. |
||
bool validSet(in ref Card c1, in ref Card c2, in ref Card c3) |
bool validSet(in ref Card c1, in ref Card c2, in ref Card c3) |
||
const pure nothrow { |
const pure nothrow @safe @nogc { |
||
return !((c1.c + c2.c + c3.c) % 3 || |
return !((c1.c + c2.c + c3.c) % 3 || |
||
(c1.n + c2.n + c3.n) % 3 || |
(c1.n + c2.n + c3.n) % 3 || |
||
Line 585: | Line 585: | ||
immutable(Card)[3][] findSets(in Card[] cards, in uint target = 0) |
immutable(Card)[3][] findSets(in Card[] cards, in uint target = 0) |
||
const pure nothrow { |
const pure nothrow @safe { |
||
immutable len = cards.length; |
immutable len = cards.length; |
||
if (len < 3) |
if (len < 3) |