File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ #birthday paradox
2
+ import random
3
+ import datetime
4
+ birthday=[]
5
+ i=0
6
+ while(i<50):
7
+ year=random.randint(2000,2010)
8
+ if(year%4==0 and year%100!=0 or year%400==0):
9
+ leap=1
10
+ else:
11
+ leap=0
12
+ month=random.randint(1,12)
13
+ if(month==2 and leap==1):
14
+ day=random.randint(1,29)
15
+ elif(month==2 and leap==0):
16
+ day=random.randint(1,28)
17
+ elif(month==7 or month==8):
18
+ day=random.randint(1,31)
19
+ elif(month%2!=0 and month<7):
20
+ day=random.randint(1,31)
21
+ elif(month%2!=0 and month>7 and month<12):
22
+ day=random.randint(1,31)
23
+ else:
24
+ day=random.randint(1,30)
25
+ dd=datetime.date(year,month,day)
26
+ day_of_year=dd.timetuple().tm_yday
27
+ i=i+1
28
+ birthday.append(day_of_year)
29
+ birthday.sort()
30
+ i=0
31
+ while(i<50):
32
+ print(birthday[i])
33
+ i=i+1
You can’t perform that action at this time.
0 commit comments