4 Comments

I probably should have raised this last time, but why did you key off length (lines 3 and 5) rather than contents? Are you intentionally avoiding domain knowledge?

Expand full comment

Wow that's a really great question Bill!

No, there was definitely no deliberate intention to avoid domain knowledge -- and I don't even recall thinking about that. I suspect that I think of the length check as being the simplest way to ascertain whether the lists are different, without having to worry about their contents.

I'm probably also motivated by the sequence of the tests: the first basket is empty, the next contains one item, the next adds another item, etc. I'm highly susceptible to symmetries and sequences, so the pattern of the array lengths would have been uppermost in my mind as I read through the test cases. If the second test case supplied by Dave Thomas had been [30, ['B']] I wouldn't have been steered so much by the 0-1-2 sequence of lengths (and it wouldn't have worked anyway).

So I blame Dave Thomas for triggering my in-built sensitivity to symmetry 😊

Expand full comment

There may be another reason, which is that I didn't "need" to check the array contents. Maybe my old C/assembler programmer brain thinks that an emptiness check is more efficient than a contents check, and somehow (forty years on) still also considers that to be important.

Expand full comment

That guy's pretty sneaky sometimes:)

Expand full comment