#!/usr/bin/env ruby require 'calc24' begin # validate user input digits = ARGV.to_i raise "need 4 digits, such as: 5 9 5 9" unless digits.size == 4 t0 = Time.now player = Calc24::TwentyFourGamePlayer.new(digits) if player.solutions.empty? puts "no solutions" else puts "found #{player.solutions.size} solutions:" #STDIN.gets puts player.solutions.values.join("\n").to_p puts "#{Time.now - t0}s" end rescue Exception => e print "#{e.class}: " unless e.class == RuntimeError puts "#{e.message}" exit 1 end