Skip to content

Instantly share code, notes, and snippets.

@passy
Created June 9, 2010 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save passy/431305 to your computer and use it in GitHub Desktop.
Save passy/431305 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
welcal
~~~~~~
Erzeut eine Liste mit Wochen und zwei Namen als CSV auf STDOUT.
:copyright: 2010, Pascal Hartig <phartig@weluse.de>
:license: BSD
"""
import random
NAMES = (
'Oliver',
'Marten',
'Daniel',
'Markus',
'Marc',
'Passy'
)
def print_header():
print("Woche,Opfer 1,Opfer 2")
def main():
print_header()
last_name1, last_name2 = None, None
iterations = 0
for week in xrange(1, 53):
iterations += 1
name1 = random.choice(NAMES)
name2 = random.choice(NAMES)
lastset = set([last_name1, last_name2])
while name2 == name1 or \
name1 in lastset or \
name2 in lastset:
name1 = random.choice(NAMES)
name2 = random.choice(NAMES)
iterations += 1
print("{0},{1},{2}".format(week, name1, name2))
last_name1 = name1
last_name2 = name2
print("\nTotal Iterations: {0}".format(iterations))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment