Jumping on the Clouds

Hacker Rank Link

test

Test Inputs

In [89]:
inputs = ['0 0 1 0 0 1 0','0 0 0 1 0 0']
In [90]:
def jumpingOnClouds(clouds):
    jumps = 0
    for i,cloud in enumerate(clouds):
        if i%2 and (clouds[i] !=1):
            jumps +=1
        if(clouds[i] == 1):
            jumps +=1
    print(jumps)
In [92]:
for cloud_input in inputs:
    c = list(map(int, cloud_input.rstrip().split()))
    jumpingOnClouds(c)
4
3
In [ ]: