![]() ![]() Instead of using the first counter to keep track of where the new letter should go, we'll simply use box 12 as a container while we test, and then copy it to a new box before taking it to the OUTBOX if we decide it's unique. However, it's possible to tweak just a little more speed out of it, and stay below the size requirements by altering the logic a bit. ![]() The above code already exceeds both the speed and size requirements set for you. Otherwise, we're not done testing, so we'll check the next letter. If that turns out to be negative it means we checked all the existing letters and didn't find a match, so we can copy the letter to the OUTBOX. If the answer is zero, we found a duplicate, and we'll start over with the next letter. We'll subtract that value from the box indicated by box 13. Then we'll pick up a letter from the INBOX and place it in the box indicated by box 14. We'll copy the value of box 14 to box 13 and bump it down one. The real work will begin with the second letter. Since it's the first letter, it will obviously be unique, and there's nothing else to test it against. To start this all off, we will initially take the first letter, drop it in box 0, and carry it straight to the OUTBOX. This is because the particular tools you have available, namely JUMP IF ZERO and JUMP IF NEGATIVE, make it easier to tell when you're done counting down than when you're done counting up. It is important to note that we will work our way down the boxes, instead of up. In other words, if we're placing the next letter in box 4, we want to start by comparing it against box 3. ![]() Every time we fetch a new letter, we will reset the value of the second number to the value of the first, minus one. The other will indicate which of the previous letters we are testing against. One will indicate how many unique letters we've found so far, and therefore which box to place new letters from the INBOX for testing. ![]() Rather than having the values you need to skip made available for you, you'll need to generate them on your own as you encounter new letters.įor this stage, we will rely on not just one, but two different indirect counters. This exercise is a lot like the previous one, except that now you start with an empty floor. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |