always be careful of boundary conditions.
FOR y := 0 to 3
FOR x := 0 to 3
IF a[x+1][y] != NULL
a[x+1][y] is undefined for x = 3.
Just restrict the loop, FOR x := 0 to 2
it'll start giving correct/incorrect but some results.
Regards, Atif


On Tue, Dec 17, 2019 at 11:53 PM Chiranjib Parida <
[email protected]> wrote:

> Please note that the syntax may be completely different from any of
> programming languages you know. More specifically, indentation does not
> matter in this code, ":=" denotes the substitution, "=" is the equal
> comparator, and the condition in FOR statement is boundary-inclusive.
>
> ========
> Initial state of an array "a":
>
> [[4, 2, 4, 2],
> [4, NULL, 4, 2],
> [2, NULL, 8, 2],
> [16, NULL, 4, NULL]]
>
> ========
> Main function:
>
> FUNCTION foo()
> FOR y := 0 to 3
> FOR x := 0 to 3
> IF a[x+1][y] != NULL
> IF a[x+1][y] = a[x][y]
> a[x][y] := a[x][y]*2
> a[x+1][y] := NULL
> END IF
> IF a[x][y] = NULL
> a[x][y] := a[x+1][y]
> a[x+1][y] := NULL
> END IF
> END IF
> END FOR
> END FOR
> END FUNCTION
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/ee6ad0c4-429f-4589-844f-ecaca8d21897%40googlegroups.com
> <https://groups.google.com/d/msgid/google-code/ee6ad0c4-429f-4589-844f-ecaca8d21897%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
-
Regards
Atif hussain

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAHri%2BDwhnXdk2_rV3j%2B8V5a5DmzsiyuK82jtznXh5rZ5crD16Q%40mail.gmail.com.

Reply via email to