Sha256: 86439d9c96ef28fb16525a4bb68397b362170b2b2ddaca8ac624abbb640dfb92

Contents?: true

Size: 866 Bytes

Versions: 1

Compression:

Stored size: 866 Bytes

Contents

#!/usr/bin/env ruby

lib_path = File.expand_path('../../lib', __FILE__)
$:.unshift(lib_path)
require 'calc24'
require 'calc24/version'

begin
  digits = []
  
  raise Calc24::VERSION if ['--version', '-v'].include? ARGV[0]
  
  if ARGV.count == 1 and ARGV[0].size == 4
    ARGV[0].each_char do |c|
      digits << c
    end
  elsif ARGV.count == 4
    digits = ARGV.to_i
  else
    raise "    inputs 4 numbers such as: 5959 or 5 9 5 9"
  end
  
  t0 = Time.now 
  player = Calc24::TwentyFourGamePlayer.new(digits)

  if player.solutions.empty?
    puts "no solutions"
  else
    puts "found #{player.solutions.size} solutions:\n\n"
    puts player.solutions.values.join("\n").to_p
    puts "\n#{Time.now - t0}s"
  end
rescue Exception => e
  print "#{e.class}: " unless e.class == RuntimeError
  puts "#{e.message}"
  exit 1
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
24games-0.2.3 bin/24games