Skip to content

Instantly share code, notes, and snippets.

@prakashmurthy
Created August 15, 2012 04:26
Show Gist options
  • Save prakashmurthy/3355880 to your computer and use it in GitHub Desktop.
Save prakashmurthy/3355880 to your computer and use it in GitHub Desktop.
runtime_error?
## Why would the following code give run time error?
## Inputs to the program:
## up to 100 entries from STDIN, values range : 1 ≤ n ≤ 10**18
##
inputs = []
while true
input = $stdin.gets.chomp
break if input.empty?
inputs << input.to_i
end
inputs.each { |input| puts (input/9)*81 + (input%9)**2 }
@danrabinowitz
Copy link

I don't see any way it could give a runtime error. Can you provide a failing test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment