[RUBY QUIZ #106], too late?

Discussion in 'Ruby' started by Alex Watt, Dec 30, 2006.

  1. Alex Watt

    Alex Watt Guest

    I've only just had time to finish it. If it's not too late, here's what I've
    done:

    Bishopt = [
    "BB------", # 0
    "B--B----", # 1
    "B----B--", # 2
    "B------B", # 3
    "-BB-----", # 4
    "--BB----", # 5
    "--B--B--", # 6
    "--B----B", # 7
    "-B--B---", # 8
    "---BB---", # 9
    "----BB--", # 10
    "----B--B", # 11
    "-B----B-", # 12
    "---B--B-", # 13
    "-----BB-", # 14
    "------BB" # 15
    ]
    Kingt = [
    "QNNRKR", # 0
    "NQNRKR", # 16
    "NNQRKR", # 32
    "NNRQKR", # 48
    "NNRQKR", # 64
    "NNRKRQ", # 80
    "QNRNKR", # 96
    "NQRNKR", # 112
    "NRQNKR", # 128
    "NRNQKR", # 144
    "NRNKQR", # 160
    "NRNKRQ", # 176
    "QNRKNR", # 192
    "NQRKNR", # 208
    "NRQKNR", # 224
    "NRKQNR", # 240
    "NRKNQR", # 256
    "NRKNRQ", # 272
    "QNRKRN", # 288
    "NQRKRN", # 304
    "NRQKRN", # 320
    "NRKQRN", # 336
    "NRKRQN", # 352
    "NRKRNQ", # 368
    "QRNNKR", # 384
    "RQNNKR", # 400
    "RNQNKR", # 416
    "RNNQKR", # 432
    "RNNKQR", # 448
    "RNNKRQ", # 464
    "QRNKNR", # 480
    "RQNKNR", # 496
    "RNQKNR", # 512
    "RNKQNR", # 528
    "RNKNQR", # 544
    "RNKNRQ", # 560
    "QRNKRN", # 576
    "RQNKRN", # 592
    "RNQKRN", # 608
    "RNKQRN", # 624
    "RNKRQN", # 640
    "RNKRNQ", # 656
    "QRKNNR", # 672
    "RQKNNR", # 688
    "RKQNNR", # 704
    "RKNQNR", # 720
    "RKNNQR", # 736
    "RKNNRQ", # 752
    "QRKNRN", # 768
    "RQKNRN", # 784
    "RKQNRN", # 800
    "RKNQRN", # 816
    "RKNRQN", # 832
    "RKNRNQ", # 848
    "QRKRNN", # 864
    "RQKRNN", # 880
    "RKQRNN", # 896
    "RKRQNN", # 912
    "RKRNQN", # 928
    "RKRNNQ", # 944
    "QNNRKR", # 960
    ]

    pieces = %w(K Q R R B B N N)
    row = [*("A".."H")]

    loop do
    pieces = pieces.sort_by { rand }
    break if pieces.to_s =~ /.*R.*K.*R.*/ and pieces.to_s =~ /.*B(..)*B.*/
    end

    bCombo = pieces.to_s.gsub(/[KQRN]/,'-')
    bishopComboNo = Bishopt.index(bCombo)

    kCombo = pieces.to_s.gsub(/B/,'')
    kingComboNo = (Kingt.index(kCombo) == 0) ? 0 : Kingt.index(kCombo) +
    (15*Kingt.index(kCombo))

    puts "Starting position: #{kingComboNo + bishopComboNo}"
    puts
    puts "Black Pieces"
    puts row.map { |square| square + "8" }.join(" ")
    puts pieces.join(" ")
    4.times { puts }
    puts pieces.join(" ")
    puts row.map { |square| square + "1" }.join(" ")
    puts "White Pieces"

    _________________________________________________________________
    MSN Hotmail is evolving – check out the new Windows Live Mail
    http://ideas.live.com
     
    Alex Watt, Dec 30, 2006
    #1
    1. Advertising

  2. On Dec 30, 2006, at 1:31 PM, Alex Watt wrote:

    > I've only just had time to finish it. If it's not too late, here's
    > what I've done:


    It's never too late. Thanks for sharing!

    James Edward Gray II
     
    James Edward Gray II, Dec 31, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mo
    Replies:
    5
    Views:
    359
    Knute Johnson
    Feb 16, 2007
  2. Replies:
    1
    Views:
    1,809
    Dennis Lee Bieber
    Jan 18, 2007
  3. Kroeger Simon (ext)

    [QUIZ] a very late SOLUTION

    Kroeger Simon (ext), Aug 1, 2005, in forum: Ruby
    Replies:
    0
    Views:
    101
    Kroeger Simon (ext)
    Aug 1, 2005
  4. Ruby Quiz

    [QUIZ] Chess960 (#106)

    Ruby Quiz, Dec 15, 2006, in forum: Ruby
    Replies:
    20
    Views:
    266
    James Edward Gray II
    Dec 21, 2006
  5. Kyle Schmitt

    Late huffman (quiz 123)

    Kyle Schmitt, May 16, 2007, in forum: Ruby
    Replies:
    0
    Views:
    92
    Kyle Schmitt
    May 16, 2007
Loading...

Share This Page