# What is wrong in my code

#it works well in my python ide.

def divisor_of_three(k,d0,d1):
sum=0
temp=(d0+d1)%10
sum=d0+d1
if k==2:
return not ((sum) % 3)

``````sum+=temp
no_of_groups=(k-3)//4
rem_digits=(k-3)%4
sum=(20* no_of_groups)
for i in range(rem_digits):
temp=(2*temp)%10
sum+=temp
return not ((sum) % 3)
``````

def main():
for test in range(int(input().strip())):
k, d0, d1 = tuple(map(int, input().strip().split()))
print("{0}".format(“YES” if divisor_of_three(k, d0, d1) else “NO”))

if name == “main”:
main()

Please post the link to the problem you are referring to and format the code .
How to format code in CodeChef
This works, though I can’t comment on the logic

``````def divisor_of_three(k,d0,d1):
sum=0
temp=(d0+d1)%10
sum=d0+d1
if k==2:
return not ((sum) % 3)
sum+=temp
no_of_groups=(k-3)//4
rem_digits=(k-3)%4
sum=(20* no_of_groups)
for i in range(rem_digits):
temp=(2*temp)%10
sum+=temp
return not ((sum) % 3)

for test in range(int(input().strip())):
k, d0, d1 = tuple(map(int, input().strip().split()))
print("{0}".format("YES" if divisor_of_three(k, d0, d1) else "NO"))

``````
1 Like