No banner uploaded

Sudoku Generator

6 devlogs
8h 40m 39s

use math and algorithms (and C++) to make sudoku, my fav game :D

Rei

Now there is HARD 6x6 sudoku generation too! (alongside MEDIUM and EASY).

i doubt it’s hard, but it’s 6x6 sudoku so what can i expect lol?

i had tooo many errors, especially with loops. Next im going to make this generator faster, next im going to visualize it yaya :D

here is a hard 6x6 sudoku puzzle :0

Attachment
0
Rei

I replaced naive backtracking with constraint-based solving >w<

Before, the generator would place a number into a cell (like at (r, c)), check if it’s valid, and if not, backtrack and brute-try every number from 1 to 6.

Now it first figures out which numbers actually make sense for that cell and only tries those. No more pointless checks. It’s faster, cleaner, and way smarter :3

Here’s a 6x6 sudoku, try it, it’s fun :D

Attachment
0
Rei

Fixed the bug (turns out I was using the same rng every time), so I kept getting identical puzzles. Now that’s sorted, and I’ve upgraded the whole thing. I’m using bitmasks now, which makes the generator faster than before (wayyy faster), plus I tossed in a few extra improvements :D

Testing it was actually pretty fun — the puzzles I’m getting all have unique solutions. This is a 6×6 Sudoku generator (grid is either 2×3 or 3×2), so naturally I had to try giving it some cursed dimensions like 3×3, 4×8, etc… just to see what happens hehehe

This is the answer I got: (this was funniest part lol)
It crashes and outputs nth js in one case: 3x3 ⬇️

Attachment
Attachment
0
Rei

I think I broke smth when I tided the code a lil, idk Im rlly sleepy so Good Night People UwU

Gotta fix the code (tmr)

Here’s a 6x6 (3, 2) sudoku enjoy solving it Ov<*

Attachment
2

Comments

Laney
Laney 7 days ago

3 4 | 6 5 | 1 2
5 1 | 3 2 | 6 4
2 6 | 4 1 | 3 5

6 3 | 2 4 | 5 1
1 2 | 5 6 | 4 3
4 5 | 1 3 | 2 6

Fun puzzle! I did enjoy solving it

Rei
Rei 6 days ago

Ohh I’m glad to hear that :D

Rei

I think the 6x6 sudoku generator is ready, all I have to do is to:

  1. make sure the outputted sudoku is always correct.
  2. clean the code (cuz I got many errors and commented a lot of stuff).

Then I can commit it OwO

Here (down ⬇️) is an easy 6x6 sudoku (3, 2) with solution

Attachment
Attachment
0
Rei

So, uhem uhem, I’ve wasted an hour trying to figure out why I get these red lines in my code even tho everything is right, no syntax errors, but VS Code keeps showing up these red lines. The code compiles and works perfectly, whyyyy the red linessss. And because I have OCD, I couldn’t work. It seems like the problem is from VS Code, so I installed Dev cpp, but tbh it sucks, like all cpp editors. Now I gave up (temporarily), gonna js work on my proj till I figure it out.

I coded the 4x4 sudoku generator like 2 months ago, now I’m working on the 6x6 sudoku generator :D

Attachment
0