Here’s a puzzle for you. How do you represent counting numbers — integers starting with 1 and going on indefinitely — using letters, the way a spreadsheet’s columns are labeled? You’d use the letters A through Z, then AA, AB, AC thorough ZZ, AAA, AAB and so on.
Lots of folks think think is trivial when they first hear of it. I did. “That shouldn’t be too hard” is what I said to @kaleidic, when he brought it up. Ha!
I’ll leave it to you to figure out whether it’s trivial for you to solve. But for us, it was challenging. We wanted a functional solution. (Functional-ish, I guess, in the J programming language.) And we weren’t able to create it just by thinking hard.
Not knowing how to do this got me excited. I love the way we humans create new knowledge, and I wanted to try it.
Could we solve it by breaking it down into small pieces. Could we do that and produce something like a functional (denotative) solution? Could we see an algorithm evolve before our eyes through TDD?
[an aside: when I say TDD, I mean finding the smallest bit of success you can specify, and automating that — a unit test or micro test. Then writing the least bit of code to pass that test. Then refactoring the code toward the four rules of simple design. (No duplication, minimal pieces, expressing intent, and passing the tests.) And to watch design emerge from that process.]
So, we’re trying it.
First, Tracy (@kaleidic, that is) wanted to figure it out in his head, and write it down in one chunk, working. But that was taking a while, so we started looking for smaller pieces. We started writing unit tests.
At first, they were too big. We’d move forward a little bit, and then get stuck, and stop and look for a smaller chunk to approach.
We’re not done yet, but we’ve gotten far enough that it’s feeling like we might make it. If you’d like to see our progress, check it out on github. (Idiomatic J sometimes makes strong geeks cry. But this is unusually readable. Still not for the faint of heart.)
So what do you think? Can TDD result in the emergence of an algorithm to solve something like this? Or do we have to wrap our minds around a problem before we can solve it?