Skip to content

Instantly share code, notes, and snippets.

@Sanjogsharma
Last active September 9, 2015 23:11
Show Gist options
  • Select an option

  • Save Sanjogsharma/78c10951db0bb473f57a to your computer and use it in GitHub Desktop.

Select an option

Save Sanjogsharma/78c10951db0bb473f57a to your computer and use it in GitHub Desktop.
Check if two people share the same birthday (python)
import random
random.seed()
def paradox_tester(num_people): #this fucntion tests if num_people share birthday
same_birthdays = 0
birthdays = []
for people in range(num_people):
birthdays.append(random.randint(0, 365))
birthdays.sort()
seen_birthdays = []
for bday in birthdays:
if bday in seen_birthdays:
same_birthdays += 1
seen_birthdays.append(bday)
break
else:
seen_birthdays.append(bday)
return same_birthdays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment