Submission details
Task:Lukujono
Sender:Wiita
Submission time:2025-10-29 14:03:57 +0200
Language:text
Status:READY
Result:19
Feedback
groupverdictscore
#1ACCEPTED19
Test results
testverdicttimescore
#1ACCEPTED0.00 s19details

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 = 3 for the times function (3*X)
INCREASE V
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 B
        CLEAR C
        CLEAR D

        # B = 1 for parity check
        INCREASE B

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

            REPEAT B TIMES ( INCREASE A ) # A = B
            CLEAR B

            REPEAT T TIMES ( INCREASE B ) # B = T

            # Increment C if A was zero (D = 1)
            REPEAT B TIMES ( INCREASE C )
        )

    
        # Check if X = 1: E = 1 only if X = 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

        # F = 1 if X is even, 0 if X is odd
        CLEAR F
        INCREASE F
        REPEAT A TIMES ( CLEAR F ) # Clear F if A > 0 (X odd)

        REPEAT F TIMES ( CLEAR E ) # If X even, ensure 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 ( 
            CLEAR Z
            # even X: Z = C = X // 2
            REPEAT C TIMES ( INCREASE Z )

            # odd X: Z = 3 * X + 1
            # (V = 3)
            REPEAT A TIMES ( 
                CLEAR Z
                # Z = 3 * X
                REPEAT X TIMES ( 
                    REPEAT V TIMES ( INCREASE Z )
                )
                INCREASE Z  # Add 1 to make 3 * X + 1
            )

            # Set X to Z for next iteration
            CLEAR X
            REPEAT Z TIMES ( INCREASE X )
        )
    )
)

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: 192 tests processed (command limit exceeded)