-
Notifications
You must be signed in to change notification settings - Fork 433
Expand file tree
/
Copy path011. Jumping on the Clouds.py
More file actions
51 lines (38 loc) · 939 Bytes
/
011. Jumping on the Clouds.py
File metadata and controls
51 lines (38 loc) · 939 Bytes
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
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the jumpingOnClouds function below.
def jumpingOnClouds(c): #0 0 1 0 0 1 0
n = len(c)
jmp = 0
while n > 1:
if n != 2:
if c[1] == 0 and c[2] == 0:
jmp += 1
c[:2] = ''
n -= 2
elif c[1] == 1 and c[2] == 0:
jmp += 1
c[:2] = ''
n -= 2
else:
c[:1] = ''
jmp += 1
n -= 1
else:
if c[1] == 0:
c[:1] = ''
jmp += 1
n -= 1
n -= 1
return jmp
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input())
c = list(map(int, input().rstrip().split()))
result = jumpingOnClouds(c)
fptr.write(str(result) + '\n')
fptr.close()