forked from usamajay/hacktoberfest2021-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
q1.py
56 lines (44 loc) 路 901 Bytes
/
q1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import random
n=int(input())
def findmax(l):
count=0
maximum=-1
prev=l[0]
for i in range(1,50):
if(prev==l[i]):
count+=1
else:
prev=l[i]
if(maximum<count):
maximum=count
count=0
return maximum
def generate():
l=[]
for i in range(50):
nbr = random.randint(0, 1)
l=l+[nbr]
counto=0
counte=0
for i in range(50):
if(l[i]==0):
counto+=1
else:
counte+=1
if(counto/50>=0.7):
l=generate()
return l
new=[]
dicto={}
for i in range(50):
dicto[i]=0
for i in range(n):
l=generate()
maximum = findmax(l)
new=new+[maximum]
dicto[maximum]+=1
print(new)
print(dicto)
# new=generate()
# lo=findmax(new)
# print(lo)