Hacker News new | ask | show | jobs
by pickdenis 2214 days ago
That's awesome! I really wish I had teachers like that. In high school, I had a fancy TI Nspire which had an incredibly hobbled language that vaguely resembled the classic TI-BASIC. It was missing a TON of important programming features but it had symbolic manipulation which I loved to abuse.

I wrote a program to balance arbitrary chemical equations using a series of ridiculous hacks. First, I parsed chemical compounds (like CO2 and H2(CO2)3, notice the nesting) by running through them char-by-char and translating them into expressions and then "eval"ing them: "CO2" -> e.C + 2 e.O (where e.C and e.O are free symbols). Then, I used the feature where you can type "X + Y | X=3, Y=5" to get 8 to extract the coefficients from the expression which I then shoved into a matrix and solved the system of equations. If you look at the code, you'd vomit, but it was a night of furiously typing on the abcdef keyboard that I will never forget.

I never actually used it in class because during this process I became so quick at balancing the simple equations they would give us that it took longer to type them in than simply doing it in my head.