Solving Imaginary Problems

by Daniel Fone on at Christchurch Ruby

The interview question:

def f(n)
  # define f so that f(f(n)) == -n
end

Approach to solving:

  1. Define problem…
  2. … with tests
  3. Write the code we wish we had
  4. Implement that code, quick and dirty
  5. Tests passing? Refactor!

See the finished result on GitHub and the commit log that got us there.