The ugliest implementation of Arnoldc, in Ruby.