Skip to content

Commit 887c705

Browse files
committed
solved Pandemia question
1 parent 66c0370 commit 887c705

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Pandemia/Sol.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def infected(s):
2+
total = 0
3+
infected = 0
4+
check = False
5+
temp = 0
6+
for i in s:
7+
if i == "0" or i =="1":
8+
total += 1
9+
temp += 1
10+
if i == "1" :
11+
check = True
12+
else:
13+
if check:
14+
infected += temp
15+
check = False
16+
temp = 0
17+
if check: infected += temp
18+
if total == 0 : return total
19+
return (100*infected)/total

0 commit comments

Comments
 (0)