Tell me more ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

A Bingo card is five columns of five squares each, with the middle square designated "FREE". Numbers cannot duplicate.

The five columns are populated with the following range of numbers:

  • B:1-15
  • I:16-30
  • N:31-45
  • G:46-60
  • O:61-75

In as few characters as possible, output a string that can be interpreted as a randomized Bingo card. For example:

1,2,3,4,5,16,17,18,19,20,31,32,33,34,35,46,47,48,49,50,61,62,63,64,65

This example is not randomized so that I can show that column 1 is populated with 1,2,3,4,5. Also note that the free space has not been given any special treatment because the front-end that interprets this string will skip it.

Another example would be:

1,16,31,46,61,2,17,32,47,62...

In this example, the output is by row instead of by column.

A third example might be:

01020304051617181920313233343546474849506162636465

This is the same output as the 1st example except in fixed length.

share|improve this question
Am I the only one who has never heard of Bingo but instead only of Bullshit Bingo? – Joey May 20 '11 at 18:54
Yes! That's it! My idea is to come up with a list of 75 or more words and populate the card with SELECT * FROM List ORDER BY NEWID() – Phillip May 20 '11 at 23:29

4 Answers

Ruby 1.9, 48 characters

$><<(0..4).map{|i|[*1..75][15*i,15].sample 5}*?,
share|improve this answer

Windows PowerShell, 51 54

I'm not sure whether I understood your task correctly, though.

(0..4|%{($x=15*$_+1)..($x+14)|random -c 5})-join','

Sample outputs:

5,9,1,7,13,26,18,23,17,22,37,33,34,41,44,50,53,59,60,58,73,72,64,69,66
14,10,13,5,1,24,29,26,17,30,34,33,43,41,38,59,50,60,49,56,71,61,72,70,68
3,11,4,5,13,27,16,25,26,22,43,34,42,32,38,51,52,49,58,54,61,70,73,71,62
1,9,13,12,4,23,25,20,26,22,40,33,35,44,37,55,47,52,59,53,74,70,75,64,69
8,6,7,1,9,16,21,23,18,17,35,41,37,38,34,60,50,57,51,59,66,75,73,74,71
11,6,13,4,1,29,27,24,22,18,40,35,41,32,43,51,54,57,58,53,74,71,69,66,64
share|improve this answer

PHP 106

<?$z=1;for($i=0;$i<5;$i++){for($j=0;$j<rand(1,5);$j++){$o[]=rand($z,$z+15);}$z+=15;}echo implode(",", $o);

I'm not sure I understood correctly the problem... Can you provide a more detailed explanation?

share|improve this answer

Clojure - 52 chars

(map #(take 5(shuffle %))(partition 15(range 1 76)))

Example output (note that it provides the separate rows as sub-lists):

((4 1 12 10 2) (25 23 21 16 27) (39 33 45 44 43) (48 53 59 54 47) (73 71 61 64 63))
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.