------art_29694_20600554.1176073898625
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Apr 6, 6:55 am, Ruby Quiz <j... / grayproductions.net> wrote:
> Extra Credit: Write your program to accept an arbitrary number and
> ordering of digits, an arbitrary set of operators (but allowing the
> same operator more than once), and an arbitrary target number that
> the equation is supposed to evaluate to.

I got a bit carried away with this one; it has the extra credit along
with three on/off switches.  I even wrote a little combinatorics
library (attached) to go with it, which has quite a few more functions
than I needed, including two string permutors, and an algorithm I
borrowed from the ASPN Python Cookbook.

As yet another demonstration of the benefits of convention over
configuration, the array and string permutors had almost no
difference; I only had to change 'each' to 'each_byte'.

Note that it doesn't print every equation it tests, as the extra
switches make it possible to produce millions of possibilities.  To
have it solve the original example, use either of the following
commands:

  ruby -- ./ruby119.rb -R 123456789--+0
  ./ruby119.rb -R 123456789--+0

Anyway, here it is.  Beware of cheap hacks.

#########################

#!/usr/bin/env ruby -w
# ruby119.rb -- solves combinatorial arithmetic puzzles
# Released 2007 with no license by Harrison Reiser

require 'combinatorics'
require 'getoptlong'

def dispense_advice
  puts "Usage: #{$0} [OPTIONS] digits ops  um"
  puts "  e.g. #{$0} 123456789 + - -  00"
  puts "equiv: #{$0} 123 - 45 - 67 + 89  00"
  puts
  puts "Will attempt to search for a combination of the digits and"
  puts "operators given that produce the sum. Each solution uses"
  puts "each digit once and includes all given operator types."
  puts
  puts "Operators recognized: +, -, *, /, . (decimal point)"
  puts "Standard operator precedence is used: (*, /) over (+, -)"
  puts
  puts "Options:"
  puts "  --help, -h"
  puts "    Shows this message."
  puts "  --permute-digits, -p"
  puts "    Allows the given digits to be combined arbitrarily."
  puts "  --no-permute-digits, -P"
  puts "    Maintains the given order of the digits. (default)"
  puts "  --repeat-ops, -r"
  puts "    Uses arbitrary (1..*) operator multiplicity. (default)"
  puts "  --no-repeat-ops, -R"
  puts "    Maintains each of the given operators' multiplicities."
  puts "  --unary-minus, -n"
  puts "    Allows the use of '-' as negation of the first number."
  puts "  --no-unary-minus, -N"
  puts "    Disallows the use of the negation operator. (default)"
  exit
end

opts  etoptLong.new(
  ['--help', '-h', GetoptLong::NO_ARGUMENT],
  ['--permute-digits', '-p', GetoptLong::NO_ARGUMENT],
  ['--no-permute-digits', '-P', GetoptLong::NO_ARGUMENT],
  ['--repeat-ops', '-r', GetoptLong::NO_ARGUMENT],
  ['--no-repeat-ops', '-R', GetoptLong::NO_ARGUMENT],
  ['--unary-minus', '-n', GetoptLong::NO_ARGUMENT],
  ['--no-unary-minus', '-N', GetoptLong::NO_ARGUMENT]
)

repeat_ops  rue
unary_minus  alse
permute_digits  alse

opts.each do |opt, arg|
  case opt
  when '--help'
    dispense_advice
  when '--permute-digits'
    permute_digits  rue
  when '--no-permute-digits'
    permute_digits  alse
  when '--repeat-ops'
    repeat_ops  rue
  when '--no-repeat-ops'
    repeat_ops  alse
  when '--unary-minus'
    unary_minus  rue
  when '--no-unary-minus'
    unary_minus  alse
  end
end

dispense_advice if ARGV.length 0

digits  ]
operators  ]

arg_str, sum  RGV.join.split(/
sum  um.to_i
dispense_advice if sum 0

arg_str.each_byte do |byte|
  case byte
  when ?0..?9
    digits << byte.chr
  when ?-, ?+, ?*, ?/
    operators << byte.chr
  else
    dispense_advice
  end
end

operators.uniq! if repeat_ops
count  
hits  

ops_send_args   epeat_ops ? [:each_tuple, 0] : [:each_unique_permutation]
digits_message  ermute_digits ? :each_partition : :each_ordered_partition

digits.send(digits_message) do |part|
  next unless repeat_ops or part.length operators.length + 1
  part  art.map { |x| x.join } if part.first.respond_to?(:join)

  ops_send_args[1]  art.length - 1 if repeat_ops
  operators.send(*ops_send_args) do |tuple|
    expr  art.zip(tuple).join(' ')
    if eval(expr.gsub(/ (\d*) /, ' \1.0 ').gsub(' . ', '.')) sum
      puts "#{expr} {sum}"
      hits + 
    end
    count + 

    if unary_minus and operators.include?('-')
      num  art[0].to_i
      part[0]  -num).to_i
      redo if num > 0
    end
  end

  if permute_digits
    part << part.shift
    redo unless part.first part.min
  end
end

print "#{count} equation#{count 1 ? '' : 's'} searched, ",
      "#{hits} solution#{hits 1 ? '' : 's'} found.\n"

------art_29694_20600554.1176073898625
Content-Type: application/octet-stream; name=quiz119.rb
Content-Transfer-Encoding: base64
X-Attachment-Id: f_f0a3d38w
Content-Disposition: attachment; filename="quiz119.rb"

IyEvdXNyL2Jpbi9lbnYgcnVieSAtdwojIHJ1YnkxMTkucmIgLS0gc29sdmVzIGNvbWJpbmF0b3Jp
YWwgYXJpdGhtZXRpYyBwdXp6bGVzCiMgUmVsZWFzZWQgMjAwNyB3aXRoIG5vIGxpY2Vuc2UgYnkg
SGFycmlzb24gUmVpc2VyCgpyZXF1aXJlICdjb21iaW5hdG9yaWNzJwpyZXF1aXJlICdnZXRvcHRs
b25nJwoKZGVmIGRpc3BlbnNlX2FkdmljZQogIHB1dHMgIlVzYWdlOiAjeyQwfSBbT1BUSU9OU10g
ZGlnaXRzIG9wcyA9IHN1bSIKICBwdXRzICIgIGUuZy4gI3skMH0gMTIzNDU2Nzg5ICsgLSAtID0g
MTAwIgogIHB1dHMgImVxdWl2OiAjeyQwfSAxMjMgLSA0NSAtIDY3ICsgODkgPSAxMDAiCiAgcHV0
cwogIHB1dHMgIldpbGwgYXR0ZW1wdCB0byBzZWFyY2ggZm9yIGEgY29tYmluYXRpb24gb2YgdGhl
IGRpZ2l0cyBhbmQiCiAgcHV0cyAib3BlcmF0b3JzIGdpdmVuIHRoYXQgcHJvZHVjZSB0aGUgc3Vt
LiBFYWNoIHNvbHV0aW9uIHVzZXMiCiAgcHV0cyAiZWFjaCBkaWdpdCBvbmNlIGFuZCBpbmNsdWRl
cyBhbGwgZ2l2ZW4gb3BlcmF0b3IgdHlwZXMuIgogIHB1dHMKICBwdXRzICJPcGVyYXRvcnMgcmVj
b2duaXplZDogKywgLSwgKiwgLywgLiAoZGVjaW1hbCBwb2ludCkiCiAgcHV0cyAiU3RhbmRhcmQg
b3BlcmF0b3IgcHJlY2VkZW5jZS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HByLmdzdWIoLyAoXGQqKSAvLCAnIFwxLjAgJykuZ3N1YignIC4gJywgJy4nKSkgPT0gc3VtCiAg
ICAgIHB1dHMgIiN7ZXhwcn09ICN7c3VtfSIKICAgICAgaGl0cyArPSAxCiAgICBlbmQKICAgIGNv
dW50ICs9IDEKICAgIAogICAgaWYgdW5hcnlfbWludXMgYW5kIG9wZXJhdG9ycy5pbmNsdWRlPygn
LScpCiAgICAgIG51bSA9IHBhcnRbMF0udG9faQogICAgICBwYXJ0WzBdID0gKC1udW0pLnRvX2kK
ICAgICAgcmVkbyBpZiBudW0gPiAwCiAgICBlbmQKICBlbmQKICAKICBpZiBwZXJtdXRlX2RpZ2l0
cwogICAgcGFydCA8PCBwYXJ0LnNoaWZ0CiAgICByZWRvIHVubGVzcyBwYXJ0LmZpcnN0ID09IHBh
cnQubWluCiAgZW5kCmVuZAoKcHJpbnQgIiN7Y291bnR9IGVxdWF0aW9uI3tjb3VudCA9PSAxID8g
JycgOiAncyd9IHNlYXJjaGVkLCAiLAogICAgICAiI3toaXRzfSBzb2x1dGlvbiN7aGl0cyA9PSAx
ID8gJycgOiAncyd9IGZvdW5kLlxuIgo------art_29694_20600554.1176073898625
Content-Type: application/octet-stream; name=combinatorics.rb
Content-Transfer-Encoding: base64
X-Attachment-Id: f_f0a42ebb
Content-Disposition: attachment; filename="combinatorics.rb"

IyBjb21iaW5hdG9yaWNzLnJiIC0tIGNvbWJpbmF0b3JpYWwgaXRlcmF0b3JzIGZvciBSdWJ5CiMg
Q29weXJpZ2h0IChjKSAyMDA3IEhhcnJpc29uIFJlaXNlciwgbGljZW5zZWQgdW5kZXIgR1BMIDIu
MAojIE5vdGU6IHRoZSBhbGdvcml0aG0gZm9yIGVhY2hfdW5pcXVlX3BhcnRpdGlvbiB3YXMgdGFr
ZW4gZnJvbQojIGh0dHA6Ly9hc3BuLmFjdGl2ZXN0YXRlLmNvbS9BU1BOL0Nvb2tib29rL1B5dGhv
bi9SZWNpcGUvNDk2ODY5C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FbnVtZXJhYmxlCiAgZGVmIGVhY2hfdHVw
bGUobikKICAgIHRvX2EuZWFjaF90dXBsZShuKQogIGVuZAogIAogIGRlZiBlYWNoX3Blcm11dGF0
aW9uCiAgICB0b19hLmVhY2hfcGVybXV0YXRpb24KICBlbmQKICAKICBkZWYgZWFjaF91bmlxdWVf
cGVybXV0YXRpb24KICAgIHRvX2EuZWFjaF9wZXJtdXRhdGlvbgogIGVuZAplbmQK
------art_29694_20600554.1176073898625--