w:c:strategywiki>Krenath (Create page. Fight with formatting and give up.) |
w:c:strategywiki>Prod m (cleanup) |
||
Line 1: | Line 1: | ||
{{Header Nav|game=Turing Complete}} | |||
''The inputs in this level represent the characters in a list of planet names, encoded as ASCII (see the manual). | ''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)'' | ''(The possible input characters are a to z lowercase, space, apostrophe and dash)'' | ||
Line 16: | Line 18: | ||
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. | 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. | ||
{{Footer Nav|game=Turing Complete|prevpage=Tower of Alloy|nextpage=Water World}} |
Revision as of 03:21, 2 June 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:
- Load 32 into Register 0.
- Label the beginning of the loop.
- Read the input into Register 1
- If Register 0 = 32, subtract 32 from Register 1
- Output Register 1
- Copy Register 1 to Register 0
- 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.