Fun with Sudoku pt 1


I did a sudoku puzzle for the first time in a long time this weekend, and it got me thinking about a few questions around the number of possible puzzles, etc.

The rules of Sudoku are pretty simple. For a 9 x 9 grid, fill it in so each row includes the digits 1 – 9 and each column includes the digits 1 – 9. Additionally, the grid is broken up into nine 3 x 3 sub-grids. Each character can only appear once in each grid.

Lazy Sudoku

Lazy Sudoku is a super fun game I invented. You start with Sudoku, except rows don’t need to be unique. Nor columns… Nor sub-grids.

How many variations are possible if the only rules are to fill in the N x N grid with the digits 0 – N?

This one’s pretty easy, it’s just an N^2 digit number. For a 1 x 1 grid, you can put 1. For a 2 x 2 grid, you can put 1111, 1112, 1113, …4443, 4444. For a standard 9 x 9 grid, you can fill it from 1{81 times} – 9{81 times}. Generally, to figure out how many values can be represented by a number in a positional number system (what we use, not Roman Numerals), you take the number of possible characters and raise it to the number of spaces you can fill in. So for a three digit, base-10 number, it’s 10 ^ 3 or 1000.

So for our N ^ 2 digit number, with N possible characters, it’s N ^ (N ^ 2). That would mean our Lazy Sudoku puzzle has 9 ^ 9 ^ 2 possibilities, also known as 196627050475552913618075908526912116283103450944214766927315415537966391196809

How can you build a Lazy Sudoku puzzle?

I mean.. you can just do [random() for i in range(N)]. If you want to get a tiny bit fancier (but more verbose and generally worse), you could do:

def createLazySudoku(puzzleSize=81, charSet=range(1, 10)):
     char = random.choice(charSet)
     if puzzleSize == 1:
             return f'{char}'
     return f'{char}{createLazySudoku(puzzleSize - 1, charSet)}'

Quick Notes on Wolfram’s “Mathematic Notation: Past and Future”

You can find the text here.

The main question is “how did contemporary notation develop.” Wolfram’s sprints through the history, making a few important distinctions.

Numerals begin being represented around 25,000 years ago in unary — notches on a bone. Eventually, around the 1800s BC (think: Hammurabi), the Babylonians develop a base-60 positional notation. This is lost until the Greek develop a base-10 positional notation. In the interim, we’re stuck with additive-type systems, where distinct symbols represent values. For instance, the Egyptians represented 1000 with a lotus flower.

Finally, around 1000AD (think: Lief Ericson finds North America; Lions finally go extinct in Europe), Hindu-Arabic notation is in full swing. It gets introduced to Europe in 1202 (Francis of Asisi; Genghis Khan), when Fibonacci publishes Liber Abaci.

So that’s numerals, but we can’t develop much without more, and this is Wolfram’s main other distinction. Numerals, Operators, and Variables.

Variables aren’t really introduced until the 1600s (King James Bible), which in general is when notation really gets going. Leibniz invents the elongated S for integrals and the d for derivatives; an early inventor of a type of slide rule, Oughtred, introduces the ‘X’ for multiplication and argues that algebra should be done by notation, not natural language.

Operators by the way – They didn’t really exist. The plus sign arises in the 1400s.

Things die down again, until the mid-1800s, with the explosion of mathematical logic. The one that sticks around is Peano’s, which is popularized in Russell and Whitehead’s Principia.

Random Notes

  • Traditional notation represents objects, not processes.
  • Math notation is 2 dimensional (a^2 = 1/10), while natural language is 1
  • Pythagorean Triples are right triangles whose sides are whole numbers, like 3, 4, 5 right triangle.
  • Sapir-Whorf hypothesis is that the structure of language affects the way we think. A strong formulation is conscious thought is only possible due to language.

Addition with Roman Numerals

For a little bit I’ve been interested in how people do equivalent things with largely different systems. For instance, when we add in roman numerals and arabic numerals, we’re representing the same thing: 1 thing and another thing is two things. The algorithm we use, and presumably the way we think of it, are hugely different, though.

I coded up a quick script that can take two roman numerals and add them. It only supports the most naive form — you can’t use subtractives like IX, only VIIII, and you can’t pass in V-with-a-bar-on-top, only MMMMM.

The rules are:

  • Concatenate the two numbers:
    • VII and XVI become VIIXVI
  • Sort them from M -> I
    • VIIXVI becomes XVVIII
  • Combine any like values into larger numerals
    • XVVIII becomes XXIII

You can see the code here.

The post that told me how it all worked is here.

How do I want to spend my time?

I’ve been thinking about what type of jobs I want to have in the future. With a few days of the 80,000 Hours podcast pumped into my ears, I’ve had a surge in focus around both being more purposeful with my field. It’s easy to keep my ambition limited to “the next rung” or “some person who’s a bit above me”. The danger is that keeps me on the default path: Developer -> slightly-more-senior-Developer -> etc, until I die. While there’s nothing wrong with that, it seems a richer professional life could be had by bobbing and weaving a bit between industries.

An Attempt at Writing Consistently

It’s been a goal since college to make writing a greater part of my routine. There’s been periods of journaling, publication-plotting, and another failed blog. So for this iteration, the goal is a bit simpler — all I have to do is post every day. That’s it. The post can be empty!

So how am I going to make this achievable?

  • Get the WP mobile app, so worst case I can post without my computer
  • Allow empty posts

The final task is to nest it within a current habit. That’s something I need to work on. I could probably write more, but I’m getting bored, and let’s not make this a chore.