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.
Test case 2, 3 and 15 fails with this code. Can anyone maybe check where I went wrong?
def solve(n, k):
# Write your code here
# math. ceil()
first_k = k
end = False
count = 1
summation = 0
while(not end):
x = 0
incr = 0
if (kn):
x = int(math.ceil(((k/2)+0.5)))
if (x>n):
end = True
else:
incr = n - x + 1
summation = summation + incr
if (incr==1):
end = True
elif (k==n):
end = True
count = count + 1
k = k + first_k
return summation
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Help Mike
You are viewing a single comment's thread. Return to all comments →
Test case 2, 3 and 15 fails with this code. Can anyone maybe check where I went wrong?
def solve(n, k): # Write your code here # math. ceil() first_k = k end = False count = 1 summation = 0 while(not end): x = 0 incr = 0 if (kn):