We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Implementation
  4. Jumping on the Clouds: Revisited
  5. Discussions

Jumping on the Clouds: Revisited

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 894 Discussions, By:

votes

Please Login in order to post a comment

  • mitchmcdee
    6 years ago+ 19 comments

    Simple python solution:

    energy = 100 #initial energy
    i = k % n #initial jump from 0
    energy -= c[i] * 2 + 1 #initial energy loss
    while i != 0:
        i = (i + k) % n
        energy -= c[i] * 2 + 1
        
    print energy
    
    106|
    Permalink
    View more Comments..
  • nh314
    4 years ago+ 1 comment

    Can we downvote this problem :P

    104|
    Permalink
  • andamus
    4 years ago+ 2 comments

    The testcases are not up to the constraints. Please update the question.

    66|
    Permalink
  • polmki99
    6 years ago+ 11 comments

    3 tight little lines.

    n, k  = map(int, input().strip().split())
    clouds = list(map(int, input().strip().split()))
    print(100 - sum(1 + 2 * clouds[i] for i in range(0, n, k)))
    

    And an unreadable one-liner.

    print((lambda x,y: 100-sum(1+2*y[i] for i in range(0,x[0],x[1])))(list(map(int,input().strip().split())), list(map(int,input().strip().split()))))
    
    19|
    Permalink
    View more Comments..
  • neymar_nr7
    4 years ago+ 1 comment
    def jumpingOnClouds(c, k):
        energy=100
        pos=0
        n=len(c)
        while True:
            pos=(pos+k)%n
            if c[pos]==1:
                energy-=3
            else:
                energy-=1
            
            if pos==0:
                break
        return energy
    
    18|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature