How to Make this Code Be coorect in All Test Cases | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to Make this Code Be coorect in All Test Cases

I was on hackerEarth trying to solve a coding challenge but the code is only correct for the first Test Case Code: https://code.sololearn.com/cDvx4eYiXddG/?ref=app Link To Challenge: https://www.hackerearth.com/practice/codemonk/

31st Aug 2022, 1:18 PM
MATOVU CALEB
MATOVU CALEB - avatar
3 Answers
+ 3
MATOVU CALEB I'm not exactly sure after running 5 9 7 2 4 6 8 1 3 5 7 9 result # 6 8 1 3 7 9 2 4 SoloProg i got the same answer but your code threw an error out of range on N, K = map(int,input().split())
31st Aug 2022, 5:33 PM
BroFar
BroFar - avatar
+ 3
BroFar 5# is the number of test cases to be used by the hackerEarth ide 9#number of elements that will make up the array 7# refers to how many items the last element will be rotated to the right direct
31st Aug 2022, 5:36 PM
MATOVU CALEB
MATOVU CALEB - avatar
+ 2
# (⌐■_■) Keep learning & happy coding :D T = int(input()) for t in range(T): N, K = map(int,input().split()) Idx = N-(K%N) arr = list( map(int, input().strip().split()) )[:N] A = [] for i in range(Idx, N): A.append(str(arr[i])) for i in range(Idx): A.append(str(arr[i])) arr = A print(" ".join(arr))
31st Aug 2022, 4:15 PM
SoloProg
SoloProg - avatar