# Whats the issue with this pseudo-code and how would you fix it?

Page 1 of 1

## 1 Replies - 350 Views - Last Post: 14 August 2018 - 08:07 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=412208&amp;s=76d4a2f4b0b42821a30e1ca3d2cf81bc&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 nymphic

Reputation: 0
• Posts: 1
• Joined: 14-August 18

# Whats the issue with this pseudo-code and how would you fix it?

Posted 14 August 2018 - 07:54 PM

indentation does not matter in this code, ":=" denotes the substitution, and "=" is the equal comparator.

========
Initial state of an array "a":

```[[2, NULL, 2, NULL],
[2, NULL, 2, NULL],
[NULL, NULL, NULL, NULL],
[NULL, NULL, NULL, 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
```

This post has been edited by modi123_1: 16 August 2018 - 06:36 AM
Reason for edit:: In the future, please highlight the text that is code and click the [code] button in the editor.

Is This A Good Question/Topic? 0

## Replies To: Whats the issue with this pseudo-code and how would you fix it?

### #2 jon.kiparsky

• Beginner

Reputation: 11426
• Posts: 19,482
• Joined: 19-March 11

## Re: Whats the issue with this pseudo-code and how would you fix it?

Posted 14 August 2018 - 08:07 PM

Well, what gives you the idea that anything's wrong with it?
What's it meant to do, for a start?

Tell you what, it's your homework, why don't you start working it out and we'll throw in a suggestion here and there, a little "hot" and "cold" to guide you along. Fair?