Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (0..9).to_a.repeated_combination(4).each do |fourDigits|
- ten = false
- first = false
- fourDigits.permutation.each do |a, b, c, d|
- ['+', '-', '*', '/'].repeated_permutation(3).each do |op1, op2, op3|
- term = "((#{a}.0#{op1}#{b}.0)#{op2}#{c}.0)#{op3}#{d}.0"
- if (eval(term) == 10.0 rescue false)
- ten = true
- break
- end
- term = "(#{a}.0#{op1}#{b}.0)#{op2}(#{c}.0#{op3}#{d}.0)"
- if (eval(term) == 10.0 rescue false)
- ten = true
- break
- end
- end
- end
- p fourDigits unless ten
- end
Add Comment
Please, Sign In to add comment