Posted October 02, 2019
I seemed to be doing well enough until year 9. The goal is to send only zeroes to the outbox, so I did this:
1. INBOX
2. JUMP if ZERO (to step 4)
3. INBOX
4. OUTBOX
5. JUMP (to step 1)
The reasoning behind this is that as long as the block that's taken is not a zero, it will keep taking new blocks from the inbox. And then as soon as a zero block is taken it skips the second "inbox" command and goes to the outbox.
It worked correcty for all the number blocks, but it seems to treat the letter blocks as if they were zeroes too, so instead of sending only the zero blocks to the outbox, the first letter block goes there too and of course makes everything stop because that wasn't the assignment.
It did work when I changed the algorithm to:
1. INBOX
2. JUMP if ZERO (to step 4)
3. JUMP (to step 1)
4. OUTBOX
5. JUMP (to step 1)
Which is basically the same, except it looked less elegant to me with the three "jump" commands and their respective arrows.
I still don't get why the first algorithm didn't work for letters and the second one did. What am I missing??
1. INBOX
2. JUMP if ZERO (to step 4)
3. INBOX
4. OUTBOX
5. JUMP (to step 1)
The reasoning behind this is that as long as the block that's taken is not a zero, it will keep taking new blocks from the inbox. And then as soon as a zero block is taken it skips the second "inbox" command and goes to the outbox.
It worked correcty for all the number blocks, but it seems to treat the letter blocks as if they were zeroes too, so instead of sending only the zero blocks to the outbox, the first letter block goes there too and of course makes everything stop because that wasn't the assignment.
It did work when I changed the algorithm to:
1. INBOX
2. JUMP if ZERO (to step 4)
3. JUMP (to step 1)
4. OUTBOX
5. JUMP (to step 1)
Which is basically the same, except it looked less elegant to me with the three "jump" commands and their respective arrows.
I still don't get why the first algorithm didn't work for letters and the second one did. What am I missing??
No posts in this topic were marked as the solution yet. If you can help, add your reply