You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
504 B
22 lines
504 B
# typed: false
|
|
require_relative "computer"
|
|
|
|
program = ARGF.read.split(?,).map(&:to_i)
|
|
|
|
# modified = program.dup
|
|
# modified[1] = 12
|
|
# modified[2] = 2
|
|
# c = Computer.new(modified)
|
|
# puts c.each.inject(nil) {|_,i| i }.fetch(0)
|
|
|
|
noun, verb = (0..99).flat_map {|noun| (0..99).map {|verb| [noun, verb] } }
|
|
.find {|(noun, verb)|
|
|
modified = program.dup
|
|
modified[1] = noun
|
|
modified[2] = verb
|
|
c = Computer.new(modified)
|
|
final = c.run
|
|
final.fetch(0) == 19690720
|
|
}
|
|
puts 100 * noun + verb
|