Best of Ruby Quiz Pragmatic programmers phần 1 ppsx

Best of Ruby Quiz Pragmatic programmers phần 6 ppsx

Best of Ruby Quiz Pragmatic programmers phần 6 ppsx

... :high) and faces =~ /^(\w) \1\ 1 \1/ end def full_house? order(:face_count, :high) and faces =~ /^(\w) \1\ 1(\w)\2/ end def flush? order(:suit_count, :high) and suits =~ /^(\w) \1\ 1 \1\ 1/ end def straight? # ... |word| Report erratum ANSWER 13 . 1- 800-THE -QUIZ 15 3 Answer 13 From page 31 1-800-THE -QUIZ Some problems are just easier to express with recursion. For me, this is one...

Ngày tải lên: 12/08/2014, 09:21

29 326 0
Best of Ruby Quiz Pragmatic programmers phần 2 pps

Best of Ruby Quiz Pragmatic programmers phần 2 pps

... 9 14 18 21 2 25 12 9 22 5 12 15 14 7 5 18 15 The of cial site for Solitaire is at http://www.schneier.com/solitaire.html. Report erratum QUIZ 16 . ENGLISH NUMERALS 41 Quiz 16 Answer on page 17 6 English ... Figure 1. 1, on the following page, shows the name of every square on the board. Report erratum QUIZ 10 . KNIGHT’S TRAVAILS 26 Figure 1. 1: Chess Squares by Name...

Ngày tải lên: 12/08/2014, 09:20

29 245 0
Best of Ruby Quiz Pragmatic programmers phần 3 doc

Best of Ruby Quiz Pragmatic programmers phần 3 doc

... line. # # =6 # 5 4 # =3 # 2 1 # =0 Digits = [0b 111 011 1, 0b 010 010 0, 0b1 011 1 01, 0b 110 110 1, 0b 010 111 0, 0b 110 1 011 , 0b 111 1 011 , 0b 010 010 1, 0b 111 111 1, 0b 110 111 1, 0b00 010 00, 0b 111 1000] # Minus, Dot Top, ... 1, 1 ], "4" => [ 0, 3, 1, 1, 0 ], "5" => [ 1, 2, 1, 1, 1 ], "6" => [ 1, 2, 1, 3, 1 ], "7" =>...

Ngày tải lên: 12/08/2014, 09:20

29 269 0
Best of Ruby Quiz Pragmatic programmers phần 5 pot

Best of Ruby Quiz Pragmatic programmers phần 5 pot

... @level.index(/@|\+/) return pos % 19 , pos / 19 end def [](x, y) @level[x + y * 19 ] end def []=(x, y, v) @level[x + y * 19 ] = v end def to_s (0 16 ).map {|i| @level[i * 19 , 19 ]}.join("\n") end end levels ... :rock][rand(3)] end end 30 Ruby Quiz is hosted on the Ruby Talk mailing list, and you will often se e discussion there about the problems. You can find more inf...

Ngày tải lên: 12/08/2014, 09:21

29 262 0
Best of Ruby Quiz Pragmatic programmers phần 7 potx

Best of Ruby Quiz Pragmatic programmers phần 7 potx

... am: code_cleaning/p2p_clean.rb #!/usr/local/bin /ruby # # p2p.rb # # Server: ruby p2p.rb password server public-uri private-uri merge-servers # Sample: ruby p2p.rb foobar server druby:/ /12 3 .12 3 .12 3 .12 3 :13 37 # druby:// :13 37 druby://foo.bar :13 37 # ... cluster of place-values. # The lowest overall string must be composed of elements from this list. components = [ minimum_e...

Ngày tải lên: 12/08/2014, 09:21

29 447 0
Best of Ruby Quiz Pragmatic programmers phần 9 docx

Best of Ruby Quiz Pragmatic programmers phần 9 docx

... the moves available in one row [ 0b1000, 0b 010 0, 0b0 010 , 0b00 01, 0b 110 0, 0b 011 0, 0b0 011 , 0b 111 0, 0b 011 1, 0b 111 1 ].each do |move| # spread it to each row of the board move = move << 4 ... choices.find { |m| m.moves.size % 2 == 0 } best or choices.first end end def over? @position == 0b 111 1 _11 11_ 111 1 _11 11 end end The real magic here is the combination of...

Ngày tải lên: 12/08/2014, 09:21

29 305 0
Best of Ruby Quiz Pragmatic programmers phần 10 docx

Best of Ruby Quiz Pragmatic programmers phần 10 docx

... 256 assert_equal(Tactics::WIN, Tactics.new(0b 111 1_0 011 _11 11_ 111 1).play) assert_equal(Tactics::WIN, Tactics.new(0b 111 1 _10 01_ 111 1 _11 11) .play) assert_equal(Tactics::WIN, Tactics.new(0b 111 1 _11 00 _11 11_ 111 1).play) assert_equal(Tactics::WIN, ... Tactics.new(0b 111 1 _11 00 _11 11_ 111 1).play) assert_equal(Tactics::WIN, Tactics.new(0b 111 1 _11 11_ 0 011 _11 11) .play) assert...

Ngày tải lên: 12/08/2014, 09:21

24 272 0
Best of Ruby Quiz potx

Best of Ruby Quiz potx

... sake of example, let’s just say we get this: DWJXH YRFDG TMSHP UURXJ 3. Convert the message from step 1 into numbers, A = 1, B = 2, and so on: 3 15 4 5 9 14 18 21 2 25 12 9 22 5 12 15 14 7 5 18 15 The ... (Consider the deck Report erratum QUIZ 4. ANIMAL QUIZ 11 Quiz 4 Answer on page 81 Animal Quiz Posed by Jim Weirich Here’s an animal quiz progr am to try as a Rub...

Ngày tải lên: 06/03/2014, 10:20

285 700 0
Best of Ruby Quiz doc

Best of Ruby Quiz doc

... decoded to numbers: 7 12 14 3 17 13 10 1 6 6 6 22 15 13 2 10 9 25 3 2 3. Convert the keystream lett ers from step 1 to numbers: 4 23 10 24 8 25 18 6 4 7 20 13 19 8 16 21 21 18 24 10 4. S ubtract the ... For example, 22 - 1 = 21 as expected, but 1 - 22 = 5 (27 - 22): 3 15 4 5 9 14 18 21 2 25 12 9 22 5 12 15 14 7 5 18 5. Convert the numbers from step 4 back t...

Ngày tải lên: 27/06/2014, 09:20

285 282 0
w