Last active
February 17, 2017 05:24
-
-
Save admiralakber/20616d76f76a17240e43b87a7fe03eb5 to your computer and use it in GitHub Desktop.
Canberra Multicultural Festival Bingo Generator!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" Canberra Multicultural Festival Bingo Card Generator | |
USAGE: | |
Edit vars if you want: ncols, nrows, ctc | |
$ python3 multi-culti.py | |
Make up the rules amongst your own friends! | |
Don't judge my code, I wrote this in a rush! | |
Have fun and drink responsibly. | |
Author: Aqeel Akber, 2017 | |
Twitter: @AdmiralAkber | |
""" | |
import random | |
ncols = 4 | |
nrows = 4 | |
# ratio of continents to countries (still random, just weight by probability) | |
ctc = 1 | |
continents = ['Asia', 'Africa', 'North America', 'South America', 'Europe', 'Oceania'] | |
countries = ['China', 'Australia', 'Turkey', \ | |
'Lebanon', 'Germany', 'Indonesia', 'Italy', \ | |
'Greece', 'Mexico', 'India', 'Nepal', 'Ethiopia', \ | |
'Japan', 'Austria', 'Ukraine', 'Scotland', 'England', \ | |
'Ireland', 'Singapore', 'Tibet', 'Malaysia', 'Bangladesh', \ | |
'Belgium', 'Serbia', 'Croatia', 'Macedonia', 'Sweden', 'Estonia', \ | |
'Lithuania', 'France', 'Portugal', 'Sri Lanka', 'Poland', 'Denmark', \ | |
'Vietnam', 'Myanmar', 'Thailand', 'Cambodia', 'New Zealand', \ | |
'Phillippines', 'Spain', 'Egypt', 'Romania', 'Slovakia', 'Hungary', \ | |
'Latvia', 'Afghanistan', 'Iran', 'Syria', 'Iraq', 'Pakistan', \ | |
'Papa New Guinea', 'Argentina', 'Brazil', 'Chile', 'Peru', 'Ecuador', \ | |
'Canada', 'USA', 'Mongolia', 'Korea', 'New Zealand', 'Belarus', \ | |
'Czech Republic'] | |
###################### | |
# HERE BE DRAGONS :) # | |
###################### | |
# random from list | |
random_from_list = lambda L: L[random.randint(0, len(L)-1)] | |
# many random from list into new list | |
def random_list_from_list(L, n): | |
outlist = [] | |
for i in range(n): | |
outlist.append(random_from_list(L)) | |
return outlist | |
mult = round(ctc*len(countries)/len(continents)) | |
# recreate list | |
pickfrom = list(countries) | |
for i in range(mult): | |
pickfrom += continents | |
print("") | |
print("CANBERRA MULTI CULTI FEST BINGO! :D (Twitter: @AdmiralAkber)".center(18*ncols)) | |
linerule = '*'*18*ncols | |
linepad = '* *'*ncols | |
linecell = lambda L: ['*'+s.center(16)+'*' for s in random_list_from_list(L, ncols)] | |
print(linerule) | |
for row in range(nrows): | |
print(linepad) | |
print(linepad) | |
print("".join(linecell(pickfrom))) | |
print(linepad) | |
print(linepad) | |
print(linerule) | |
print("Drink responsibly, to promote joy, never violence! - Ken Helm".center(18*ncols)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment