Level/Planet Names: Difference between revisions

From Turing Complete
(Added infobox)
(Added highscores)
 
Line 5: Line 5:
| architechture      = Leg
| architechture      = Leg
| prerequisite1      = Stack
| prerequisite1      = Stack
| scored              = No
| highscore          = 37
| highscore-gate      = 2
| highscore-delay    = 2
| highscore-tick      = 33
| api-enum-id        = capitalize
| api-enum-number    = 68
}}
}}



Latest revision as of 21:11, 17 November 2023

Section Assembly Challenges
Type Leg  Architechture
Prerequisite Stack
Scored No
High score 37
API capitalize (68)

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.