#LuaLang

Reed Midekereedmideke
2025-12-23

@futzle silliness

(getmetatable'').__call=function(s,f)
	print(f:format(({
		'first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth','eleventh','twelfth'
	})[s+0],
	table.concat({
		'twelve drummers drumming',
		'eleven pipers piping',
		'ten lords a-leaping',
		'nine ladies dancing',
		'eight maids a-milking',
		'seven swans a-swimming',
		'six geese a-laying',
		'five gold rings',
		'four calling birds',
		'three French hens',
		'two turtle doves',
		(s=='1' and 'a' or 'and a')..' partridge in a pear tree'
	},',\n',13-s)))
end
for i=1,12 do
	(i..'')('On the %s day of Christmas, my true love sent to me\n%s\n')
end
2025-12-12

#adventOfCode day 12 in #LuaLang

gitlab.cs.washington.edu/fidel

  • PC - 2ms
  • Raspberry Pi 2: 76ms
  • #ti92 Plus: Crashed

I wasn't expecting that to work!

And as usual, AoC is a good source of stressing cases to expose crashes/bugs in the #ticalc Lua port :p

Merry Christmas!
This is the first Advent of Code I've ever completed!

2025-12-11

#adventOfCode day 10 in #LuaLang and #Mathematica

gitlab.cs.washington.edu/fidel

  • PC - 487 ms
  • Raspberry Pi 4: a few seconds
  • #ti92 Plus: N/A

Ok, finally all caught up and looking forward to some sleep and Day 12!

After a night and day in math land confusing myself with row echelon matrices and intersecting N-spaces, I remembered that I have a Raspberry Pi that for some reason has free preinstalled Mathematica.

So my Lua program code-gens a Mathematica program, which then runs on the Pi to solve Part B!

This generated code is checked in if you want to look at it - it's several thousand lines of simultaneous equations being solved with constraints applied: gitlab.cs.washington.edu/fidel

Given all that, it's pleasantly fast. Mathematica over VNC on wifi is pretty laggy but the actual execution couldn't have taken more than a second or two!

(Yes, I did attempt to solve the equations on the TI-92+ #ticalc, as it has a very capable computer algebra system, but I couldn't figure out how to apply all the necessary constraints -- maybe later.)

A Mathematica notebook running on Linux on a Raspberry Pi.  Several lines of simultaneous equation solutions, denoting numbers of button presses, can be seen.  A running total is also interspersed with these lines, the last line being the Part B solution.
2025-12-11

#adventOfCode day 11 in #LuaLang

gitlab.cs.washington.edu/fidel

  • PC - 1m 10s
  • Raspberry Pi 2: N/A
  • #ti92 Plus: N/A

EDIT: wow I added 3 lines and now this is one of my fastest programs

  • PC - 2.1 ms
  • Raspberry Pi 2 - 65 ms
  • #ti92 Plus: N/A

Yeah, I don't have day 10 part B results to share yet. However, I took a break from that to do day 11!

It's brute force with a small twist to make it finish before the heat death of the universe. And it's based on intimate knowledge of my input file, so I don't know if it generalizes to others. At least the program itself is short....

Bonus: puzzle input visualized in graphviz!

A very large directed-acyclic-graph.  It has some obvious choke points, and a few nodes are colored red.
2025-12-09

#adventOfCode day 9 in #LuaLang

gitlab.cs.washington.edu/fidel

  • PC - 148 ms
  • Raspberry Pi 2: 6.133 sec
  • #ti92 Plus: out of memory

I'm very pleased with the speed here, although I'm sure looking at other peoples' solutions will deflate some of that pride.

The feasibility of the whole solution relied on a big insight I got while staring at the grid far too long. To avoid spoilers, I won't elaborate here.

My original version took about 4 seconds on PC: I owe some of the later ~20x optimizations to studying a friend's Rust solution after we both got ours working.

2025-12-08

#adventOfCode day 8 in #LuaLang

gitlab.cs.washington.edu/fidel

  • PC - 1.79 sec
  • Raspberry Pi 2: 57 sec
  • #ti92 Plus: hahaha, no - judging by the scale factor from previous problems, it'd take about two months, if it fit in ram, which it decidedly does not.

Eric is sadistic putting the first big problem on a work night, huh?

I'm lucky that breaking Part A into steps, then stringing together well-intentioned but non-optimal solutions to each step, was good enough to return an answer before the heat death of the universe.

I'm not sure how to make my Part A more efficient - it is O(N2 ) and takes a good 500ms by itself on my PC. It'll be really interesting to learn faster ways from other peoples' solutions.

My Part B is doing obvious repeated work. I left some performance on the table to solve the problem sooner using building blocks I already had from Part A.

Getting this working on a TI-92+ or other retro platform seems like a daunting task!

2025-12-07

#adventOfCode day 7 in #LuaLang

gitlab.cs.washington.edu/fidel

  • PC - 1.5 ms
  • Raspberry Pi 2: 41 ms
  • #ti92 Plus: >18 min

After a couple of days where the TI-92+ has been disagreeable, it was refreshing to get a puzzle where the Lua solution Just Works without memory exhaustion. Though, speedy it ain't. And when I got my camera out to photograph the real calc, I found it had crashed, so you get a boring emulator screenshot of it working instead.... ;)

I'm a little confused why it's this slow on the #ticalc: something about it seems difficult compared to the other working examples. I think it's because my approach generates lots of garbage so Lua's gc is working hard.

TI-92+ emulator displaying Part A, B: 1633 34339203133559
2025-12-07

I just completed "Laboratories" - Day 7 - Advent of Code 2025 #AdventOfCode adventofcode.com/2025/day/7 in #lua #lualang

2025-12-06

I just completed "Trash Compactor" - Day 6 - Advent of Code 2025 #AdventOfCode adventofcode.com/2025/day/6 in #lua #lualang

Another fun example on how requirements can change from one instant to the next 😀

2025-12-06

For anyone interested in the port of #LuaLang I'm using for #AdventOfCode on the #Ti92 Plus graphing calculator, I've uploaded the patched Lua sources and prebuilt binaries for TI-89 and TI-92+ to gitlab.cs.washington.edu/fidel
Please let me know if you try it out!

#ticalc #retrocomputing

TI-92+ emulator running the Lua program:
while true do if math.random() > 0.5 then io.write("/") else io.write("\\") end end
which is the Lua equivalent of the famous "10 PRINT CHR..." C64 maze generator oneliner.
2025-12-06

#adventOfCode day 6 in #LuaLang

gitlab.cs.washington.edu/fidel

  • PC - 5.1 ms
  • Raspberry Pi 2: 147 ms
  • #ti92 Plus: out of memory

I'm steadily accumulating a backlog that I need to rewrite into C for the #ticalc. I'm really jonesing to switch back to the DOS-based HP 200LX palmtop... 640K RAM feels mighty spacious in comparison to the calculator. Maybe in my copious spare time I need to track down the memory corruption problem that's stopping the 16-bit MS-DOS Lua from working.

2025-12-05

#adventOfCode day 5 in #LuaLang

gitlab.cs.washington.edu/fidel

  • PC - 1.7 ms
  • Raspberry Pi 2: 49 ms
  • #ti92 Plus: out of memory

The #ticalc doesn't make it through input parsing before exhausting memory. It will be necessary to rewrite in C again.

2025-12-05

I just completed "Cafeteria" - Day 5 - Advent of Code 2025 #AdventOfCode adventofcode.com/2025/day/5 #lua #lualang

Again, a nice one today.
Forces you to think about your approach and find a performant solution, as usual.

codeberg.org/slang75/AdventOfC

2025-12-05

My port of #LuaLang to TI-92+ had a bug where math.huge was accidentally NaN instead of +∞. This is now fixed, so we can infinitely loop the fun way.

I like that the screen's slow update speed is clearly visible in the photo....

#ti92 #ticalc #retrocomputing

A TI-92+ looping to display the numbers between 1 and math.huge.  So far, the numbers 1-111 are visible.  The numbers 109, 110 and 111 are more and more obscure, with 111 barely legible, because this is a slow LED where it takes a moment for pixels to fade in after being set.
2025-12-04

Doing Advent of Code for the first time. Didn't expect to have that much fun! Just finished Day 4 and cant wait for the new puzzle to come up. Using Lua is fun and easy. Maybe later I will port my solutions to C.

#AdventOfCode #lua #lualang #C

2025-12-04

I just completed "Printing Department" - Day 4 - Advent of Code 2025 #AdventOfCode adventofcode.com/2025/day/4 #lua #lualang

2025-12-04

#adventOfCode day 4 in #LuaLang

gitlab.cs.washington.edu/fidel

  • PC - 28 ms
  • Raspberry Pi 2: 884 ms

Unfortunately, it will not fit in the TI-92's RAM due to how I'm representing the grid. Unless it can be optimized more....

2025-12-03

#adventOfCode day 3 in #LuaLang, update: Execution time on my real #ti92 was 17m12s.

The TI-92+ appears to run Lua programs at 1/10,000 the speed of my Raspberry Pi 2B: that is, take the RPi execution time, shift to the next SI size category (like milliseconds to seconds) then multiply by ten, and you'll be in the ballpark.

Meanwhile, the Raspberry Pi is about 1/50 the speed of my desktop.

#ticalc #retrocomputing

Real TI-92+ displaying the same puzzle answers as the previous pic in the thread.
2025-12-03

#adventOfCode day 3 in #LuaLang

gitlab.cs.washington.edu/fidel

  • PC - 5.4 ms
  • Raspberry Pi 2: 156 ms
  • #ti92 Plus: ??? minutes (still running)

The program runs successfully in TiEmu with the emulation speed multiplier unlocked. It has yet to be seen how long it'll take on the real calc...

#ticalc #retrocomputing

TI-92 emulator displaying
Part A, B: 17193 171297349921310

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst