From: rretzbach@... Date: 2007-02-21T19:50:09+09:00 Subject: Re: Housie (#114) On 16 Feb., 17:47, Ruby Quiz wrote: > The three rules of RubyQuiz: > > 1. Please do not post any solutions or spoiler discussion for thisquizuntil > 48 hours have passed from the time on this message. > > 2. Support RubyQuizby submitting ideas as often as you can: > > http://www.rubyquiz.com/ > > 3. Enjoy! > > Suggestion: A [QUIZ] in the subject of emails about the problem helps everyone > on Ruby Talk follow the discussion. Please reply to the originalquizmessage, > if you can. > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-�=-=-= > > by Brian Candler > > A version of Bingo played in the UK and some other countries is called "Housie". > Players buy "books" of 6 tickets. Each ticket shows exactly 15 numbers, and in > each book every number from 1 to 90 is used exactly once. > > A ticket is a grid of 3 rows by 9 columns. The first column contains numbers > from 1 to 9; the second column numbers from 10 to 19; the third 20 to 29 and so > on up until the last column, which contains numbers from 80 to 90. > > Each column contains one, two or three numbers, in increasing order downwards. > Each row contains exactly 5 numbers (and hence 4 blanks). > > An example ticket looks like this: > > +----+----+----+----+----+----+----+----+----+ > | 5 | | | | 49 | | 63 | 75 | 80 | > +----+----+----+----+----+----+----+----+----+ > | | | 28 | 34 | | 52 | 66 | 77 | | > +----+----+----+----+----+----+----+----+----+ > | 6 | 11 | | | | 59 | 69 | | 82 | > +----+----+----+----+----+----+----+----+----+ > > There are two levels ofquizdifficulty to choose from. Given the above rules > for the validity of tickets and books, then: > > 1. Write a Ruby program which generates random individual tickets > or > 2. Write a Ruby program which generates random complete books of tickets I wanted to participate to a ruby quiz again - took a 40 quizzes break. But I can't get a perfect algo for creating a Book. This is probably a spoiler, maybe not One Idea was to create each ticket, by building 2 rows and complete the last row: if both elements of the column were nil, mark the third element as "to be filled" and so on. But by doing this, I would actually change the probabilities, because the last row depends on the first two rows. So far the only perfect "algo" that came to my mind was to create all possible books and chose one randomly. By this method the chances are perfectly balanged. I mean we're talking about BINGO! It's about money... and you should be able to proof that your algo generates all possible books at equal probability. Am I right with that, or is this totally nonsense? Either way, please feedback to me :>