REM ***********************************************

REM ***************** John Elias ******************

REM ********** Conrad Weiser High School **********

REM ********** Contest #4 Intermediate 5 **********

REM ************ Written in TRUEBasic *************

REM ***********************************************

 

DIM grid(10)

FOR input = 1 to 5

    INPUT prompt "How many birds? ": numofbirds

 

    FOR clear = 1 to 10

        LET grid(clear) = 0

    NEXT clear

 

    FOR assign = 1 to numofbirds

        INPUT prompt "Where? ": place

        LET grid(place) = 1

    NEXT assign

 

    INPUT prompt "How many stages? ": stages

 

    FOR times = 2 to stages

        IF grid(1) = 0 and grid(10) = 1 then

           LET grid(1) = 1

           LET grid(10) = 0

           LET start = 2

        ELSE

           LET start = 1

        END IF

 

        FOR spot = start to 9

            IF grid(spot) = 1 and grid(spot+1) = 0 then

               LET grid(spot) = 0

               LET grid(spot+1) = 1

               LET spot = spot + 1

            END IF

        NEXT spot

    NEXT times

 

    LET count = 0

    LET max = 0

 

    FOR checker = 1 to 10

        IF grid(checker) = 1 then

           LET count = count + 1

           IF count > max then

              LET max = count

           END IF

        ELSE

           LET count = 0

        END IF

    NEXT checker

 

    PRINT max

NEXT input

END