C:\> Rostislav Persion's Projects

.:: Birthday Paradox ::.
Python Birthday Paradox Simulator


This is a Python program that simulates the "Birthday Paradox". If you have 23 people in a group, then the chance of two people having a birthday ont he same day is 50%. This program simulates the problems and gives statistical results.

RESULTS:

TRIAL #11 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #21 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #31 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #4NO BIRTHDAY MATCHES FOUND!TRIAL #5NO BIRTHDAY MATCHES FOUND!TRIAL #61 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #7NO BIRTHDAY MATCHES FOUND!TRIAL #83 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #9NO BIRTHDAY MATCHES FOUND!TRIAL #102 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #11NO BIRTHDAY MATCHES FOUND!TRIAL #12NO BIRTHDAY MATCHES FOUND!TRIAL #131 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #141 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #15NO BIRTHDAY MATCHES FOUND!TRIAL #16NO BIRTHDAY MATCHES FOUND!TRIAL #171 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #181 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #192 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #20NO BIRTHDAY MATCHES FOUND!TRIAL #21NO BIRTHDAY MATCHES FOUND!TRIAL #221 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #23NO BIRTHDAY MATCHES FOUND!TRIAL #24NO BIRTHDAY MATCHES FOUND!TRIAL #251 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #261 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #272 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #281 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #29NO BIRTHDAY MATCHES FOUND!TRIAL #30NO BIRTHDAY MATCHES FOUND!TRIAL #311 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #321 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #33NO BIRTHDAY MATCHES FOUND!TRIAL #341 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #352 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #36NO BIRTHDAY MATCHES FOUND!TRIAL #371 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #38NO BIRTHDAY MATCHES FOUND!TRIAL #391 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #401 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #411 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #422 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #431 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #443 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #452 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #461 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #471 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #48NO BIRTHDAY MATCHES FOUND!TRIAL #491 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #501 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #51NO BIRTHDAY MATCHES FOUND!TRIAL #52NO BIRTHDAY MATCHES FOUND!TRIAL #532 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #54NO BIRTHDAY MATCHES FOUND!TRIAL #55NO BIRTHDAY MATCHES FOUND!TRIAL #561 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #571 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #581 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #59NO BIRTHDAY MATCHES FOUND!TRIAL #60NO BIRTHDAY MATCHES FOUND!TRIAL #611 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #621 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #63NO BIRTHDAY MATCHES FOUND!TRIAL #642 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #65NO BIRTHDAY MATCHES FOUND!TRIAL #66NO BIRTHDAY MATCHES FOUND!TRIAL #67NO BIRTHDAY MATCHES FOUND!TRIAL #68NO BIRTHDAY MATCHES FOUND!TRIAL #69NO BIRTHDAY MATCHES FOUND!TRIAL #70NO BIRTHDAY MATCHES FOUND!TRIAL #71NO BIRTHDAY MATCHES FOUND!TRIAL #721 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #731 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #74NO BIRTHDAY MATCHES FOUND!TRIAL #75NO BIRTHDAY MATCHES FOUND!TRIAL #76NO BIRTHDAY MATCHES FOUND!TRIAL #773 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #781 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #791 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #802 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #811 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #82NO BIRTHDAY MATCHES FOUND!TRIAL #83NO BIRTHDAY MATCHES FOUND!TRIAL #84NO BIRTHDAY MATCHES FOUND!TRIAL #851 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #861 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #87NO BIRTHDAY MATCHES FOUND!TRIAL #88NO BIRTHDAY MATCHES FOUND!TRIAL #89NO BIRTHDAY MATCHES FOUND!TRIAL #901 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #91NO BIRTHDAY MATCHES FOUND!TRIAL #921 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #933 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #94NO BIRTHDAY MATCHES FOUND!TRIAL #95NO BIRTHDAY MATCHES FOUND!TRIAL #961 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #971 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #98NO BIRTHDAY MATCHES FOUND!TRIAL #99NO BIRTHDAY MATCHES FOUND!TRIAL #100NO BIRTHDAY MATCHES FOUND!TRIAL #101NO BIRTHDAY MATCHES FOUND!TRIAL #102NO BIRTHDAY MATCHES FOUND!TRIAL #1032 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #104NO BIRTHDAY MATCHES FOUND!TRIAL #1051 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #106NO BIRTHDAY MATCHES FOUND!TRIAL #107NO BIRTHDAY MATCHES FOUND!TRIAL #108NO BIRTHDAY MATCHES FOUND!TRIAL #1091 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #110NO BIRTHDAY MATCHES FOUND!TRIAL #1111 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #112NO BIRTHDAY MATCHES FOUND!TRIAL #113NO BIRTHDAY MATCHES FOUND!TRIAL #114NO BIRTHDAY MATCHES FOUND!TRIAL #115NO BIRTHDAY MATCHES FOUND!TRIAL #116NO BIRTHDAY MATCHES FOUND!TRIAL #117NO BIRTHDAY MATCHES FOUND!TRIAL #1181 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #119NO BIRTHDAY MATCHES FOUND!TRIAL #120NO BIRTHDAY MATCHES FOUND!TRIAL #121NO BIRTHDAY MATCHES FOUND!TRIAL #1221 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1231 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #124NO BIRTHDAY MATCHES FOUND!TRIAL #1253 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #126NO BIRTHDAY MATCHES FOUND!TRIAL #127NO BIRTHDAY MATCHES FOUND!TRIAL #128NO BIRTHDAY MATCHES FOUND!TRIAL #1294 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #130NO BIRTHDAY MATCHES FOUND!TRIAL #131NO BIRTHDAY MATCHES FOUND!TRIAL #1321 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #133NO BIRTHDAY MATCHES FOUND!TRIAL #1341 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #135NO BIRTHDAY MATCHES FOUND!TRIAL #1361 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1372 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1381 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1391 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #140NO BIRTHDAY MATCHES FOUND!TRIAL #141NO BIRTHDAY MATCHES FOUND!TRIAL #1421 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1431 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1441 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #145NO BIRTHDAY MATCHES FOUND!TRIAL #146NO BIRTHDAY MATCHES FOUND!TRIAL #147NO BIRTHDAY MATCHES FOUND!TRIAL #1481 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #149NO BIRTHDAY MATCHES FOUND!TRIAL #150NO BIRTHDAY MATCHES FOUND!TRIAL #1512 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #152NO BIRTHDAY MATCHES FOUND!TRIAL #153NO BIRTHDAY MATCHES FOUND!TRIAL #154NO BIRTHDAY MATCHES FOUND!TRIAL #155NO BIRTHDAY MATCHES FOUND!TRIAL #1561 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #157NO BIRTHDAY MATCHES FOUND!TRIAL #158NO BIRTHDAY MATCHES FOUND!TRIAL #1592 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1602 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #161NO BIRTHDAY MATCHES FOUND!TRIAL #1622 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #163NO BIRTHDAY MATCHES FOUND!TRIAL #164NO BIRTHDAY MATCHES FOUND!TRIAL #1652 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1662 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #167NO BIRTHDAY MATCHES FOUND!TRIAL #1684 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1693 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #170NO BIRTHDAY MATCHES FOUND!TRIAL #171NO BIRTHDAY MATCHES FOUND!TRIAL #1721 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1731 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1741 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #175NO BIRTHDAY MATCHES FOUND!TRIAL #176NO BIRTHDAY MATCHES FOUND!TRIAL #177NO BIRTHDAY MATCHES FOUND!TRIAL #178NO BIRTHDAY MATCHES FOUND!TRIAL #1791 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1802 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1811 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #182NO BIRTHDAY MATCHES FOUND!TRIAL #1832 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #184NO BIRTHDAY MATCHES FOUND!TRIAL #1851 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1861 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1871 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #188NO BIRTHDAY MATCHES FOUND!TRIAL #1891 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #190NO BIRTHDAY MATCHES FOUND!TRIAL #1911 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #192NO BIRTHDAY MATCHES FOUND!TRIAL #193NO BIRTHDAY MATCHES FOUND!TRIAL #1941 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1951 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #1962 BIRTHDAY MATCHES FOUND IN A GROUP OF 23!TRIAL #197NO BIRTHDAY MATCHES FOUND!TRIAL #198NO BIRTHDAY MATCHES FOUND!TRIAL #199NO BIRTHDAY MATCHES FOUND!96 WINS AND 103 LOSSES.


SOFTWARE WRITTEN IN PYTHON
import datetimeimport random#keep track of wins and losseswins = 0losses = 0for mainloop in range(1,200):    datelist = []    for x in range(0,23):        month = random.randint(1, 12)        if month == 1:            day = random.randint(1, 31)        if month == 2:            day = random.randint(1, 28)        if month == 3:            day = random.randint(1, 31)        if month == 4:            day = random.randint(1, 30)        if month == 5:            day = random.randint(1, 31)        if month == 6:            day = random.randint(1, 30)        if month == 7:            day = random.randint(1, 31)        if month == 8:            day = random.randint(1, 31)        if month == 9:            day = random.randint(1, 30)        if month == 10:            day = random.randint(1, 31)        if month == 11:            day = random.randint(1, 30)        if month == 12:            day = random.randint(1, 31)        datelist.append(datetime.datetime(2020, month, day))    Count = 0    for a in range(0,23):        for b in range(0,23):            if (datelist[a] == datelist[b]) and (a != b):                Count += 1    Count = Count / 2    print("TRIAL #" + str(mainloop))    if Count >  0:        wins += 1        print(str(int(Count)) + " BIRTHDAY MATCHES FOUND IN A GROUP OF 23!")    else:        losses += 1        print("NO BIRTHDAY MATCHES FOUND!")    print("")print("")print(str(wins) + " WINS AND " + str(losses) + " LOSSES.")