#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2014
    Posts
    2
    Rep Power
    0

    bingo card generator


    Can anyone help me out with the bingo game code as i am new user to python? i am using pydev with eclipse and i am having problems using pydev with eclipse. It would be greatful if anyone can help me out with the code. i want to 1st generate the bingo game board and then the random unrepeated numbers from 1-75. Thank you.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480

    Remember to have the caller add 1


    Code:
    >>> import random; L=list(range(75)); random.shuffle(L)
    >>> L
    [12, 44, 49, 42, 39, 62, 10, 27, 4, 13, 54, 38, 23, 28, 3, 21, 35, 65, 64, 41, 58, 66, 46, 60, 11, 5, 50, 29, 68, 55, 8, 9, 1, 71, 7, 45, 73, 24, 26, 19, 0, 20, 36, 43, 57, 2, 34, 74, 25, 51, 61, 63, 15, 30, 14, 69, 37, 52, 70, 40, 47, 32, 22, 17, 59, 53, 6, 48, 56, 18, 33, 67, 16, 31, 72]
    >>>
    And otherwise you want someone to write a beautiful gui for you but you need not learn anything?
    Last edited by b49P23TIvg; March 15th, 2014 at 08:53 PM.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2014
    Posts
    2
    Rep Power
    0
    import random

    gridSize = 5
    minNum = 1
    maxNum = 50
    cards = 40

    for h in range(cards):
    card = []
    randRange = range(minNum, maxNum)
    card = random.sample(randRange, gridSize * gridSize)
    for i in range(gridSize):
    string = ""
    for j in range(gridSize):
    string += str(card[i + j * gridSize]) + "t"
    print string

    can you suggest me how should i modify this in order to get values pull out random unrepeated values from 1 to 15 for B, 16-30 for I, 31-45 for N, 46-50 for N and 51-75 for O. this code is able to generate random values in a 5*5 matrix but not able to generate in the bingo board fashion.
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    Code:
    import random
    
    # make a list of the data you need shuffled
    cards = []
    for (i, c,) in enumerate('BINGO'):
        I = i * 15
        for j in range(1, 16):
            cards.append((c, I + j,))
    
    # rearrange
    random.shuffle(cards)
    
    # use the data
    print(cards)
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo