Created
September 9, 2014 11:21
-
-
Save sas1ni69/3ac26a5f55ea0e4e1a7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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