Skip to content

Instantly share code, notes, and snippets.

@prusswan
Last active December 14, 2015 00:19
Show Gist options
  • Save prusswan/4998193 to your computer and use it in GitHub Desktop.
Save prusswan/4998193 to your computer and use it in GitHub Desktop.
X+Y
h = Hash.new(0)
product = Hash.new([])
sum = Hash.new([])
(2..99).to_a.each do |x|
next if x == 99
((x+1)..99).to_a.each do |y|
# puts "#{x} #{y} #{x+y} #{x*y}"
puts product[x*y]
product[x*y] = product[x*y].push([x,y])
puts "after: #{product[x*y]}"
# sum[x+y] = sum
end
end
product.keys.each do |k|
# puts k, product[k]
# puts product[k].length
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment