Skip to content

Instantly share code, notes, and snippets.

@karmiclychee
Created July 10, 2013 04:59
Show Gist options
  • Save karmiclychee/5963586 to your computer and use it in GitHub Desktop.
Save karmiclychee/5963586 to your computer and use it in GitHub Desktop.
class NumberCruncher
def initialize(input)
@initial_string = input
end
def crunch(working=@initial_string)
p working = working.to_s
sum = working.split('').map(&:to_i).inject(:+)
sum <= 9 ? p(sum.to_s) : crunch(sum)
end
end
NumberCruncher.new(ARGV.first).crunch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment