Created
September 10, 2015 17:40
-
-
Save anonymous/bf7055a0f9f75ea93b3c 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
class Equation | |
def read | |
File.open("./input", "r") do |file| | |
file.each_line do |line| | |
sum(line.split) | |
end | |
end | |
end | |
private | |
def sum(args) | |
res = [] | |
for i in -100..100 do | |
result = 0 | |
args.each_with_index do |value, index| | |
value = value.to_i | |
result += value * i ** ((args.size - 1) - index) | |
end | |
res << i if result == 0 | |
end | |
show(res) | |
end | |
def show(res) | |
puts "SUM #{res}" | |
end | |
end | |
check = Equation.new | |
check.read |
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
1 -3 0 0 | |
3 -15 18 0 | |
1 -7 -33 135 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment