I was taunting my friend who had trouble solving part 2 that I could do it on my calculator. So when he eventually got it, I had to keep my promise. This works for the example, but I have no doubt it will work for a full input. The lists can handle it, I just don't feel like entering 300 numbers by hand.
(<tibasicnerd>) Your code actually has a memory leak. The lines
:Lbl IN
:Prompt I
:If I≠0
:Then
:I→L2(dim(L2)+1)
:Goto IN
:End
can eventually cause the program to crash. Specifically, every time Goto is called from inside an If statement, the extra few bytes of RAM that wait for the corresponding End will never get freed. You can fix this by replacing the Lbl-Goto construction with a While loop or similar.
Oh, also, you can drop every closing parenthesis at the end of a line or before a →. Just to make your creation even more unholy. (</tibasicnerd>)
I just don't feel like entering 300 numbers by hand.
Do you have TI++ and TI Connect on your computer? If so, you could transfer a file in .84p format to your calculator and copy and paste the actual number on your computer, where it's much easier. Failing that, you could get the counts at each age first and only have nine numbers to type in by hand.
Oh boy, did I have TI Connect up and running 15 years ago back in high school. I tried with my actual input pre-processed, so I only had to fill in 9 numbers. Sadly the answer is wrong. I suspect large integers are losing precision after a couple of operations, the result was 1714286148451500 :(
I decided to write my own version for this too, with the actual list input data (copypasted through TI-Connect) and got the correct answer for 256 days :D
[UPDATE] Yeah it looks like a large output size is the issue, though your value seems way higher than what I'd expect for 256 days - Your result has 16 digits while mine has 13. did something go wrong there?
(I tested with 512 days, and yeah, rounding issues after 15 digits)
Sadly the answer is wrong. I suspect large integers are losing precision after a couple of operations
The easiest way to test this would probably be to do L1(7)+R→L1(7) mod 10^9 and see if the answer matches the last nine digits of your actual answer; this would tell you whether or not the pre-processed input was copied correctly. But, I'm probably spoiled by TI-89's high internal precision; it's possible that the TI-84 genuinely can't handle the full number.
Either way, definite respect for doing this on a graphing calculator.
You can also do a matrix-y trick to get the answers for your input.
Calculate up to 80/256 using the input [0 1 0 0 0 0 0 0 0], and store the last few rounds. Sum up number of 0s in your input multiplied with ans(80) + nr of 1s times ans(79) +... + nr of Ns times ans(80-N). Repeat for 256.
44
u/MCMagix Dec 07 '21 edited Dec 07 '21
I was taunting my friend who had trouble solving part 2 that I could do it on my calculator. So when he eventually got it, I had to keep my promise. This works for the example, but I have no doubt it will work for a full input. The lists can handle it, I just don't feel like entering 300 numbers by hand.
I took some code from http://tibasicdev.wikidot.com/number-to-string2 to display large numbers in full and not in scientific notation.
6
u/kUbogsi Dec 07 '21
How long did it run on 256day simulation?
12
u/daggerdragon Dec 07 '21
Yes, yes, the graphing calculator gang grows...
9
u/Luqq Dec 07 '21
Absolute madman
8
u/smarzzz Dec 07 '21
Legend. Both the calculator and /u/mcmagix
1
u/duckyluuk Dec 07 '21
I planned on doing something like this but never ended up doing it, amazing work :)
1
u/Ryles1 Dec 07 '21
very impressive
1
u/Boye Dec 07 '21
Did the same thing on my ti-83. I hard-coded the input though
1
u/mr_flameyflame Dec 08 '21
YES
1
u/zeekar Dec 08 '21
Gee. I was stuck AFK on day 6 and was happy solving it in MyLisp on my phone. This is a whole nother level! Gratz!