Skip to content

Instantly share code, notes, and snippets.

@sas1ni69
Created September 9, 2014 11:21
Show Gist options
  • Save sas1ni69/3ac26a5f55ea0e4e1a7c to your computer and use it in GitHub Desktop.
Save sas1ni69/3ac26a5f55ea0e4e1a7c to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
puts "If the world is round..."
STDOUT.flush
str = gets.chomp.split('+')
first = str.first.strip
second = str.last.strip
def get_result(num)
ans = 0
num.split("").each do |c|
c = c.to_i
if c == 0 || c == 6 || c == 9
ans += 1
elsif c == 8
ans += 2
end
end
ans
end
puts get_result(first) + get_result(second)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment