(How to put 2 programs in 1 program slot)
|The target audience of this blog post are Hong Kong secondary school students who uses programs in their calculators during exams,| though it may be useful to others as well. This technique should work for the type of calculators commonly used by students.
Let's get straight to the point. I'll leave all the backgrounds and explanations to later. |There is also a Chinese translation available below.|
Now every time you use this program, |you will need to first input a number to select which sub-program to run.| Type `0` to run the 2nd sub-program. Type anything else to run the 1st sub-program.
每次你想使用此 program 時,第一個輸入的數字將會用作內部選擇 program。
如選擇 |第二個 program| ,輸入 `0`,否則輸入 |任何數字選擇第一個 program。|
I am a Hongkonger, and I certainly had once been a Hong Kong secondary school student. |I studied Mathematics Module 2 (M2 for short), aka Calculus and Algebra.| To make life easier, we had 2 calculators, one for CORE and one for M2. However, both subject requires its own programs, and while both calculators have 4 slots for programs, the M2 one has significantly less storage space. It was impossible to put all the relevant programs into the corresponding calculator.
Therefore, my friend "Jarmy" and I went on a quest to optimize the heck out of these programs. One of the things we did was |inputting 2 programs into the same program slot| as we want to put some M2 programs into the CORE calculator to fully utilize its storage. Our solution was a few bytes larger than the one I presented here. Pretty good I'd say.
|At one point I had an absolutely insane setup where both of my calculators had 0 bytes left.| Unfortunately my CORE calculator's battery inflated and it lost all its programs.
This is how the double-program template looks like:
`?→X:If X:Then <prog1>◢Else <prog2>`
Hopefully this is a bit easier to read and understand for the programmers reading this blog post.
Quoting Mumbo Jumbo, "This is really quite simple."
If you are a good programmer, you should add `◢IfEnd` at the end to properly close the if-else statements. However, since the program is most likely |interpreted| (vs compiled), it will stop running when it reaches the end anyway. As we are optimizing for storage, any amount of bytes saved is good for us.