Submission details
Task:Lukujono
Sender:Wiita
Submission time:2025-10-29 21:35:41 +0200
Language:text
Status:READY
Result:29
Feedback
groupverdictscore
#1ACCEPTED29
Test results
testverdicttimescore
#1ACCEPTED0.00 s29details

Code

# J = 4
INCREASE J
INCREASE J
INCREASE J
INCREASE J

# I = 174 (maximum needed is 178)
REPEAT J TIMES ( 
    INCREASE J
    REPEAT J TIMES ( 
        REPEAT J TIMES ( 
            INCREASE I 
        ) 
    ) 
)

# add the remaining 4
INCREASE I
INCREASE I
INCREASE I
INCREASE I

# V = 2 for the times function (3*X)
INCREASE V
INCREASE V


REPEAT I TIMES ( 

    # Set Q to 1 to enable calculating
    CLEAR Q
    INCREASE Q


    REPEAT P TIMES ( CLEAR Q )

    # Stop calculating if Q = 0
    REPEAT Q TIMES ( 

        PRINT X 

        # Clear variables for calculation
        CLEAR A
        CLEAR T
        CLEAR C


        # Parity check loop determines if X is even or odd
        # After X iterations:
        #   A = 1 if X is odd, 0 if even
        #   T = A (Helper variable)
        #   C = X // 2
        REPEAT X TIMES ( 
        
            INCREASE T

            # Increase C if A = 1 and set T to 0
            REPEAT A TIMES ( 
                CLEAR T
                CLEAR A
                INCREASE C
            )

            # Increase A if T = 1
            REPEAT T TIMES ( 
                INCREASE A 
            )
        )

        # B = 1 if X is even
        CLEAR B
        INCREASE B
        REPEAT A TIMES ( CLEAR B )


        # Check if X = 1, E = 1 
        CLEAR E
        INCREASE E
        REPEAT C TIMES ( CLEAR E ) # For X = 1, C = 0 so E = 1 | for X > 1, C > 0 so E = 0

        REPEAT E TIMES ( INCREASE P ) # If X = 1, set P = 1 to stop future calculation


        # Decide whether to update X: Q = 1 unless X = 1
        CLEAR Q
        INCREASE Q

        REPEAT E TIMES ( CLEAR Q ) # Decide whether to update X: Q = 1 unless X = 1

        # if Q = 1 update X to next Collatz number
        REPEAT Q TIMES ( 

            # even X: C = X // 2
            REPEAT B TIMES ( 
                CLEAR X
                REPEAT C TIMES ( INCREASE X )  
            )

            # odd X: 3 * X + 1
            REPEAT A TIMES ( 
                REPEAT X TIMES (                 
                    REPEAT V TIMES ( INCREASE X ) # add two times X to X to make it 3X
                )
                INCREASE X  # Add 1 to make 3 * X + 1
            )

        )
    )
)

Test details

Test 1 (public)

Verdict: ACCEPTED

input
(empty)

correct output
(empty)

user output
# J = 4
INCREASE J
INCREASE J
INCREASE J
INCREASE J
...

Feedback: 291 tests processed (command limit exceeded)