Level/Planet Names

From Turing Complete
Revision as of 21:34, 13 November 2023 by Gelthor (talk | contribs) (Added infobox)
Section Assembly Challenges
Type Leg  Architechture
Prerequisite Stack
Scored No
API {{{api-enum-id}}} ({{{api-enum-number}}})

We had the intern type out planet names in human script. Unfortunately, he forgot to capitalize each name.

The inputs in this level represent the characters in a list of planet names, encoded as ASCII (see the manual). Each name is separated by a space which has the numeric value 32. Replace the first letter in each word with it's uppercase counterpart. (The possible input characters are a to z lowercase, space, apostrophe and dash)

All one has to do is read each character in and, if it follows a space, subtract 32 from its value in order to capitalize it, then output the result.

One approach to solving the level is:

  1. Load 32 into Register 0.
  2. Label the beginning of the loop.
  3. Read the input into Register 1
  4. If Register 0 = 32, subtract 32 from Register 1
  5. Output Register 1
  6. Copy Register 1 to Register 0
  7. Loop back to step 2.

As we pre-loaded a 32 in Register 0, in which we keep track of the last character we processed, it will capitalize the first character as if it had followed a space.