Paul Clapham wrote:It can't just be a function of M and N, because (up to isomorphism) there are two different 4-element lists with 2 distinct elements, namely [0, 0, 1, 1] and [0, 1, 1, 1].
And they have different maximum derangements: the first's MD is 4 and the second's is 2.
In general for a list with K zeroes and L ones, where K <= L, the maximum derangement is 2K, unless I'm missing something. But extending that to 3 or more distinct elements isn't nearly as obvious, although I haven't spent any time poking at it.
Campbell Ritchie wrote:
The remove() method should remove.
David Newton wrote:I'm pretty sure I can handle specs.
(No sense in declaring "expected", though, and it makes the test harder to read. Plus you don't always use it anyway.)
TDD and BDD are the same: write the most minimal test case that fails, write the code to make it pass. The output of a program is a large-scale behavior, and tests written for it will not pass until the sub-behaviors pass. That you were writing the large-scale behavior test first suggests you either (a) didn't test during development, or (b) expected it to fail for a long time while the actual code was developed.