I solved the Chanukah problem from kattis in my IDE and it works perfectly, but when I'm submitting it on kattis, I get a runtime error.
This is the code I'm trying to submit, which works perfectly fine in my local IDE and also on replit.
def chanukah():
sets = int(input())
dict = {}
for k in range(sets):
days = int(input())
total = (days * (days + 1) // 2) + days
dict[k + 1] = total
for key, value in dict.items():
print(key, value)
chanukah()
I encountered a similar issue on a previous problem, and what I did to fix it was adding extra variables assigning the inputs as int
after getting the input from the user, instead of converting the input into int
right in the input line, like you can see below, but this time it doesn't make the trick and kattis doesn't like my solution.
def chanukah():
sets = input()
dict = {}
sts = int(sets)
for k in range(sts):
days = input()
dys = int(days)
total = (dys * (dys + 1) // 2) + dys
dict[k + 1] = total
for key, value in dict.items():
print(key, value)
chanukah()
Why is kattis throwing a run-time error and how I can fix it?
source https://stackoverflow.com/questions/75567599/run-time-error-for-chanukah-problem-on-kattis
Comments
Post a Comment