# CoderNight

• Apr 11, 2013 · 6:00 PM

This month's problem set: http://rubyquiz.com/quiz61.html

Since rubyquiz is down: http://web.archive.org/web/20130215052933/http://rubyquiz.com/quiz61.html

Also, from @JEG2https://gist.github.com/JEG2/5197937

Try not to read the submitted answers to this rubyquiz problem set or the writeup under "Quiz Summary" -- try to solve the quiz on your own before reviewing the solutions.

Code will be due on: *March 21* to give us a week to review before the meetup on *March 28*

• ##### Chong K.

Love CoderNight. Always learning something new.

April 12, 2013

• ##### Paul W.

Won't be able to make it. See everyone next month!

March 25, 2013

• ##### Chong K.

I think I found a bug in pry. If you're using pry to look at the rand() sequence after setting srand, you'll get a different sequence than what you'd expect. It works fine in irb and in regular ruby.

For instance, in irb, you get the sequence 4,5 (with srand 1)
irb(main):001:0> srand 1
irb(main):002:0> rand(1..5)
=> 4
irb(main):003:0> rand(1..5)
=> 5

which is what you expect and what your code will use

but if you do this in pry, you get the sequence 4,1 (with srand 1):
[1] pry(main)> srand 1
[2] pry(main)> rand(1..5)
=> 4
[3] pry(main)> rand(1..5)
=> 1

If you put it inside of a block, then you get the expected values (4,5):
[1] pry(main)> srand 1
[2] pry(main)> 2.times { puts rand(1..5) }
4 5
=> 2

I was wondering why my cucumber tests were not passing, which took me into this little detour.

March 22, 2013

• ##### Gavin S.

I wonder if pry is "consuming" another value from rand? That is, is it somehow calling it twice? Perhaps once to get the value and once to print it? (or once to store it in the _ variable?)

March 22, 2013

• ##### Jason P.

Hey guys.

I just took a read of the problem for this month's Coder Night. I reazlied there's probably others in the group who, like me, may not have played AD&D in their youth and/or may fail at reading comprehension.

Although it's explained clear as day (once you grok it) in the BNF notation, here's what the example "(5d5-4)d(16/d4)+3" means:

"5d5" represents the sum of a roll of 5 five-sided dice. The dice are numbered 1-5, so the "-4" makes sense in that it allows you to roll a "1" in that expression. The range you can roll with "5d5-4" would be 1-21. "16/d4" then is "sixteen divided by the single roll of a four sided die". The rest of the expression should just look like regular alegbra now if the "d" operator make sense to you.

March 10, 2013

• ##### Jason P.

Also, it should be clear now that d100 is a 100 sided die. Apparently a real d100 is a pain in the ass. Table top gamers often use 2d10, numbered 0-9, and multiply the result or one of the pair is labeled 00 - 90 and the rolls are summed. A roll of 0 and 0 can mean 100 depending on the game rules. I guess that doesn't have anything to do with solving the puzzle, but, THE MOAR YOU KNOW, right?

March 10, 2013

• ##### Barry E.

Meant to thank you last week for this Jason. I was feeling dumb and scratching my head at Ruby Quiz's terse explanation until I read your comment.

March 21, 2013

• ##### Robin H.

will be out of state

March 11, 2013

### Seminole, FL

Founded Feb 27, 2013

Contact

#### People in this Meetup are also in:

• ##### Tampa Startup Technology Founders, Freelancers, and Friends

1,275 Techies, Geeks, and Freelancers

879 Members

• ##### Tampa Bay Microsoft Platform Developers

645 App Developers

• ##### Tampa Bay Agile

1,101 Members