------art_8118_7473268.1200248517958
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Well I feel save enough to answer ;).
The attached solution does not seem to work on Windows
(Timeout::timeout does not timeout) and as I have no Mac I cannot
tell.
On Linux it seems to work fine though, sorry for the revolutionary
user interface but I tried to separate the dealing mechanism from the
UI quite ok so if someone wants to write a plugin ;).
Ok here we go
file: human-interface.rb
require 'timeout'

class << HumanInterface  bject.new
  attr_reader :errors
  def read_int_within_delay delay
    Timeout::timeout( delay ){ $stdin.readline.chomp }
  rescue Timeout::Error
    nil
  end

  def show_cards cards, delay, count
    @errors || 
    puts cards.join(",")
    print "> "
    $stdout.flush
    read_value  ead_int_within_delay delay
    case read_value
    when nil
      @errors + 
      puts "Sorry timeout, current count is #{count}"
    else
      if read_value.to_i count
        puts "ok"
      else
        @errors + 
        puts "Sorry this is incorrect, current count is #{count}"
      end
    end
  end
end

file:robert-dober-152.rb
require 'human-interface'

class Array
  def random_element
    self[ rand( size ) ]
  end
  def shift_some n    (1..[n,size].min).map{ shift }
  end
  def zip_with zip_value
    zip [ zip_value ] * size
  end

end

class Shoe
  ShoeParameters  w{ decks delay cards }

  HonorCards  w{ 10 J Q K A }
  MediumCards  w{ 8 9 }
  SmallCards  w{ 2 3 4 5 6 7 }

  CardValues  ash[ *(
                      HonorCards.zip_with( -1 ) +
                      MediumCards.zip_with( 0 ) +
                      SmallCards.zip_with( 1 )
                      ).flatten ]

  FaceValues  mallCards + MediumCards + HonorCards

  private
  def draw_cards
    cards  deck.shift_some @cards.random_element
    @count + ards.inject(0){|s, c| s + CardValues[c[1..-1]]}
    cards
  end

  def initialize params  }
    set_ivars_default

    params.each do  | name, value |
      instance_variable_set "@#{name}", value
      raise RuntimeError, "No such parameter #{name}" unless
        ShoeParameters.include? name.to_s
    end

    set_computed_ivars
  end

  def set_computed_ivars
    @count   * ( 1 - @decks )
    @deck  w{S H D C}.inject([]){ |deck, suit|
      deck + FaceValues.map{ |c| suit + c }
    } * @decks
    @deck  deck.sort_by{ rand }
  end

  def set_ivars_default
    @decks  
    @delay  
    @cards  
  end

  public
  def training human_interface
    loop do
      return if @deck.empty?
      cards  raw_cards
      human_interface.show_cards cards, @delay, @count
    end
  end
end

def usage
  puts <<-EOS
  usage:
    #{$0} <number of decks> <delay in seconds> <cards drawn> [<cards max drawn>]

  Trains you in counting cards. The trainer uses the number of decks
you indicate
  as first parameter, shows you the drawn cards for a delay in seconds indicated
  as the second parameter.
  The number of cards drawn at each draw is either constant, as indicated by the
  third parameter or random in a range bound by the third and fourth parameter.
  EOS
  exit -1
end

usage if ARGV.size < 3 || /^-h|^--help/  ARGV.first
training_shoe  hoe.new :decks ARGV[0].to_i,
         :delay ARGV[1].to_i,
         :cards [*ARGV[2].to_i .. (ARGV[3]||ARGV[2]).to_i]

puts "Starting training with #{ARGV.first} decks of cards:"
sleep 1
training_shoe.training HumanInterface

puts "Total errors made: #{HumanInterface.errors}"

------art_8118_7473268.1200248517958
Content-Type: application/x-ruby; name=robert-dober-152.rb
Content-Transfer-Encoding: base64
X-Attachment-Id: f_fbdwttp90
Content-Disposition: attachment; filename=robert-dober-152.rb

IyB2aW06IHN3PTIgdHM9MiBmdD1ydWJ5IGV4cGFuZHRhYiB0dz0wIG51OgpyZXF1aXJlICdodW1h
bi1pbnRlcmZhY2UnCgpjbGFzcyBBcnJheQogIGRlZiByYW5kb21fZWxlbWVudAogICAgc2VsZlsg
cmFuZCggc2l6ZSApIF0KICBlbmQKICBkZWYgc2hpZnRfc29tZSBuPTEKICAgICgxLi5bbixzaXpl
XS5taW4pLm1hcHsgc2hpZnQgfQogIGVuZAogIGRlZiB6aXBfd2l0aCB6aXBfdmFsdWUKICAgIHpp
cCBbIHppcF92YWx1ZSBdICogc2l6ZQogIGVuZAoKZW5kCgpjbGFzcyBTaG9lCiAgU2hvZVBhcmFt
ZXRlcnMgPSAld3sgZGVja3MgZGVsYXkgY2FyZHMgfQoKICBIb25vckNhcmRzID0gJXd7IDE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RoZQogIHRoaXJkIHBhcmFtZXRlciBvciByYW5kb20gaW4gYSByYW5nZSBi
b3VuZCBieSB0aGUgdGhpcmQgYW5kIGZvdXJ0aCBwYXJhbWV0ZXIuCiAgRU9TCiAgZXhpdCAtMQpl
bmQKCnVzYWdlIGlmIEFSR1Yuc2l6ZSA8IDMgfHwgL14taHxeLS1oZWxwLyA9PT0gQVJHVi5maXJz
dCAKdHJhaW5pbmdfc2hvZSA9IFNob2UubmV3IDpkZWNrcyA9PiBBUkdWWzBdLnRvX2ksCiAgICAg
ICAgIDpkZWxheSA9PiBBUkdWWzFdLnRvX2ksCiAgICAgICAgIDpjYXJkcyA9PiBbKkFSR1ZbMl0u
dG9faSAuLiAoQVJHVlszXXx8QVJHVlsyXSkudG9faV0KCnB1dHMgIlN0YXJ0aW5nIHRyYWluaW5n
IHdpdGggI3tBUkdWLmZpcnN0fSBkZWNrcyBvZiBjYXJkczoiCnNsZWVwIDEKdHJhaW5pbmdfc2hv
ZS50cmFpbmluZyBIdW1hbkludGVyZmFjZQoKcHV0cyAiVG90YWwgZXJyb3JzIG1hZGU6ICN7SHVt
YW5JbnRlcmZhY2UuZXJyb3JzfSIK
------art_8118_7473268.1200248517958
Content-Type: application/x-ruby; name=human-interface.rb
Content-Transfer-Encoding: base64
X-Attachment-Id: f_fbdwu8aj1
Content-Disposition: attachment; filename=human-interface.rb

DQpyZXF1aXJlICd0aW1lb3V0Jw0KDQpjbGFzcyA8PCBIdW1hbkludGVyZmFjZSA9IE9iamVjdC5u
ZXcNCiAgYXR0cl9yZWFkZXIgOmVycm9ycw0KICBkZWYgcmVhZF9pbnRfd2l0aGluX2RlbGF5IGRl
bGF5DQogICAgVGltZW91dDo6dGltZW91dCggZGVsYXkgKXsgJHN0ZGluLnJlYWRsaW5lLmNob21w
IH0NCiAgcmVzY3VlIFRpbWVvdXQ6OkVycm9yDQogICAgbmlsDQogIGVuZA0KDQogIGRlZiBzaG93
X2NhcmRzIGNhcmRzLCBkZWxheSwgY291bnQNCiAgICBAZXJyb3JzIHx8PSAwDQogICAgcHV0cyBj
YXJkcy5qb2luKCIsIikNCiAgICBwcmludCAiPiAiDQogICAgJHN0ZG91dC5mbHVzaA0KICAgIHJl
YWRfdmFsdWUgPSByZWFkX2ludF93aXRoaW5fZGVsYXkgZGVsYXkNCiAgICBjYXNlIHJlYWRfdmFs
dWUNCiAgICB3aGVuIG5pbA0KICAgICAgQGVycm9ycyArPSAxDQogICAgICBwdXRzICJTb3JyeSB0
aW1lb3V0LCBjdXJyZW50IGNvdW50IGlzICN7Y291bnR9Ig0KICAgIGVsc2UNCiAgICAgIGlmIHJl
YWRfdmFsdWUudG9faSA9PSBjb3VudA0KICAgICAgICBwdXRzICJvayINCiAgICAgIGVsc2UNCiAg
ICAgICAgQGVycm9ycyArPSAxDQogICAgICAgIHB1dHMgIlNvcnJ5IHRoaXMgaXMgaW5jb3JyZWN0
LCBjdXJyZW50IGNvdW50IGlzICN7Y291bnR9Ig0KICAgICAgZW5kDQogICAgZW5kDQogIGVuZCAN
CmVuZA0K
------art_8118_7473268.1200248517958--