Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def construct_tri(balls)
- #not aware of an easy way to turn linear coordinates into triangular
- #coordinates, so this is all hardcoded for now
- balls[5] = (balls[0]-balls[1]).abs
- balls[6] = (balls[1] - balls[2]).abs
- balls[7] = (balls[2] - balls[3]).abs
- balls[8] = (balls[3] - balls[4]).abs
- balls[9] = (balls[5] - balls[6]).abs
- balls[10] = (balls[6] - balls[7]).abs
- balls[11] = (balls[7] - balls[8]).abs
- balls[12] = (balls[9] - balls[10]).abs
- balls[13] = (balls[10] - balls[11]).abs
- balls[14] = (balls[12] - balls[13]).abs
- end
- def valid_tri?(balls)
- used = []
- balls.each do |ball|
- return false if used.include?(ball)
- used.push(ball)
- end
- true
- end
- balls = Array.new
- max = 15**5
- for i in 0...max
- val = i
- for k in 0...5
- balls[k] = val%15 + 1
- val /= 15
- end
- construct_tri(balls)
- print balls, "\n" if valid_tri?(balls)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement