← Back to Forum

CCC 2021 J3 - Secret Instructions

#Morgan Su, BayviewSS
array=[]
inpt="0"
i=0
prior=""

#Loop until user input 99999 is entered
while int(inpt) != 99999:
    inpt=input()
    array+=[inpt]
    i+=1
    
#Loop through all inputs except for 99999, sum first two digits of code
for j in range(i-1):
    code=array[j]
    intT=int(code[0])+int(code[1])

#Determine direction given sum of first two digits
#If sum is odd
    if intT%2 !=0:
        print("left", end=" ")
        prior="left"

#If sum is even and positive
    elif intT>0:
        print("right", end=" ")
        prior="right"

#If sum is 0, repeat previous direction
    else:
        print(prior, end=" ")

    print(code[2:5])


By msu7 on 8/31/2025
0

Comments