The question that everyone has been asking me since I compiled Python to run on tmux is: “can you actually do anything useful with this?”. I’m h

Solving Sudoku with tmux

submited by
Style Pass
2024-12-27 09:00:03

The question that everyone has been asking me since I compiled Python to run on tmux is: “can you actually do anything useful with this?”. I’m happy to report back that the answer is still no, but I can now use tmux to solve sudoku, and I can do it using a different and trickier approach than the one I used with the compiler.

If you want to just check out the code for yourself, you can see the code on GitHub but the real joy is understanding in great detail how this works.

I got the idea for this project after seeing konsti write a sudoku solver using Python dependency resolution. This seemed like an interesting area to apply my (very weird) expertise. It’s also much more useful than the is_prime function that I ran on tmux before.

My Python-tmux (and Brainfuck-tmux) compiler worked using tmux hooks. You can activate a hook when a client navigates to a particular window, and that hook can then run any tmux action, like create a new window or split the window into separate panes. You can run multiple actions on one hook, and by having the last action navigate to the next window, you can treat tmux windows and their hooks as instructions in a program. Control flow is implemented by jumping forwards or backwards over multiple windows, depending on the value of a variable.

Since I’d made the compiler, I knew it was possible to solve a sudoku, but my compiler doesn’t support arrays, strings, or scoped/non-global variables, so it would either be incredibly painful, require changes to the compiler, or both.

Leave a Comment