chiranjibparida123
BAN USER
- 2of 2 votes
AnswerPlease have a look at the following pseudo-code. 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.
- chiranjibparida123 in United States
========
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
What is the issue with the above code?
How would you fix it?| Report Duplicate | Flag | PURGE
RepChariserMachado, Android test engineer at ABC TECH SUPPORT
Hey, I am Charisar. And I'm working in Stratpro as a meeting director and it's been 3 years ...
RepGeraldRuder, Kindergarten teacher at Nelson Brothers
I am a kindergarten teacher who teaches basic written and reading skills to children. I make learning fun with numerous ...
Repkatierlaursen123, Analyst at ABC TECH SUPPORT
Hello I am working in Maxprofit as a Data coder operator.I have been working here for 5 years.When ...
RepEddieCody, abc at A9
I am a creative freelance graphic designer with over 3 years of experience in developing engaging and innovative digital and ...
RepEzraDavis, abc at A9
I am a hardworking and disciplined newly-certified architect with internship experience in designing commercial buildings and creating accurate 2D and ...
RepZoeKim, AT&T Customer service email at A9
Holds a job in the social work sector and directly deals primarily with women and children who are fleeing domestic ...