Skip to content

Instantly share code, notes, and snippets.

@bradherman
Created April 12, 2011 14:21
Show Gist options
  • Save bradherman/915574 to your computer and use it in GitHub Desktop.
Save bradherman/915574 to your computer and use it in GitHub Desktop.
wrote this real quick to solve a tough math problem for a girl at work... she got it right
a = c = (-50..50).to_a
b = d = (-50..-1).to_a + (1..50).to_a
for i in 0..100
for j in 0..99
for k in 0..100
for l in 0..99
e = Float(a[i])
f = Float(b[j])
g = Float(c[k])
h = Float(d[l])
eee = Float(e*e*e)
fff = Float(f*f*f)
ggg = Float(g*g*g)
hhh = Float(h*h*h)
eq = Float((eee/fff)+(ggg/hhh))
if (eq == Float(6)) and (e != f and f != g and g != h and e != g and f != h and e != h)
puts "Answer: #{eq}"
puts "a: #{e}, b: #{f}, c: #{g}, d: #{h}"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment