Last active
August 25, 2017 03:14
-
-
Save track8/34ecd29debad8195957c082084ab3982 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mathn' | |
car, *cdr = (1..9).map{|i| ['', '+', '-', '*', '/'].map { |o| o + i.to_s }} | |
exps = car.product(*cdr).map {|exp| exp.join}.delete_if{|e| e =~ /^[\+|\*|\/]/} | |
komachies = exps.select{|e| eval(e) == 100} | |
komachies.each {|k| puts k} | |
puts "#{komachies.count} / #{exps.count}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment