Level/Planet Names: Difference between revisions

From Turing Complete
w:c:strategywiki>Prod
m (cleanup)
m (2 revisions imported: Imported from https://strategywiki.org/)
(No difference)

Revision as of 20:39, 28 October 2023

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.