Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = [[0, 11.049562682215745], [1, 2.055393586005831], [2, 12.463556851311955], [3, 11.705539358600586], [4, 13.571428571428573], [5, 14.314868804664723], [6, 8.39650145772595], [7, 5.88921282798834], [8, 7.1865889212828], [9, 13.367346938775512]]
- target = rand; puts a.find { |x, weight| target -= weight; target < 0 }.first
Advertisement
Add Comment
Please, Sign In to add comment