100 Days of Code Day 76
Today’s exercise was Roman numerals. Surprisingly difficult for me to get right. I saw the community solutions and mine is overly complicated. I just went down the line of each possible numeral largest to smallest. Other people had special cases like 900 in a key value pair they iterated over. Well at least you know I didn’t cheat. Mine is still readable at least (probably more extensible too).
For the interpreter, I added objects for statements, line, and lines. If a line begins with a line number, it gets added to the program part of the runtime. I hacked in some functions for list and run.
List doesn’t look right at all.
Run well, runs but needs more work. Nothing for a program counter or branching yet.
If you don’t have a line number it just interprets the current line. I also added comments of both the single quote and REM variety.
Now I need to go back and fill in some of the important statements like FOR, IF, PRINT and branching. I still need to figure out how I want arrays to look. Then maybe I can add in LOAD, and SAVE. Shouldn’t forget to add more built-ins too, I need RND
