Created
August 15, 2012 04:26
-
-
Save prakashmurthy/3355880 to your computer and use it in GitHub Desktop.
runtime_error?
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
## 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 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't see any way it could give a runtime error. Can you provide a failing test?