Skip to content

Instantly share code, notes, and snippets.

@hexbinoct
Created January 30, 2025 05:21
Show Gist options
  • Save hexbinoct/342713e6d02f971e0379e71465322e7b to your computer and use it in GitHub Desktop.
Save hexbinoct/342713e6d02f971e0379e71465322e7b to your computer and use it in GitHub Desktop.
7b R1 distill solves sudoku
To solve this 4x4 puzzle, I'll start by analyzing the given numbers and applying the rules step by step.

First, I'll examine the first row. I notice that the corners already contain 2 and 3. Since each row must include the numbers 1, 2, 3, and 4 without repetition, the missing numbers in the first row must be 1 and 4.

Next, I'll look at the first column. The top-left cell is 2, and the bottom-left cell is 1. This means the remaining cells in the first column must be 3 and 4.

Moving on to the second row, the leftmost cell is 1, and there's already a 2 in the third column. To avoid repetition, the missing numbers in this row should be 3 and 4.

In the third row, the leftmost cell is empty, and there's a 1 in the second column and a 3 in the third column. This suggests that the missing numbers here are 2 and 4.

Finally, the fourth row has a 1 in the bottom-right corner. The missing numbers in this row should be 2, 3, and 4. However, considering the columns, the fourth row's first cell cannot be 4 because the first column already has a 4 in the second row. Therefore, the fourth row must contain 2, 3, and 4.

By systematically applying these constraints and ensuring that each row and column contains the numbers 1 through 4 without repetition, I can fill in the missing cells accordingly.

Certainly! Let's solve the puzzle step by step. The goal is to fill the empty cells with numbers 1, 2, 3, and 4, ensuring that each number appears exactly once in each row and each column.

Here's the initial grid:

+---+---+---+---+
| 2 |   |   | 3 |
+---+---+---+---+
| 1 |   | 2 |   |
+---+---+---+---+
|   | 1 | 3 |   |
+---+---+---+---+
|   |   |   | 1 |
+---+---+---+---+

Step 1: Analyze the First Row

  • First Row: 2 | | | 3
    • Missing numbers: 1 and 4

Step 2: Analyze the First Column

  • First Column:
    • Row 1: 2
    • Row 2: 1
    • Row 3: Empty
    • Row 4: Empty
    • Already used numbers: 1, 2
    • Missing numbers: 3 and 4

Step 3: Analyze the Second Row

  • Second Row: 1 | | 2 |
    • Missing numbers: 3 and 4

Step 4: Analyze the Third Row

  • Third Row: | 1 | 3 |
    • Missing numbers: 2 and 4

Step 5: Analyze the Fourth Row

  • Fourth Row: | | | 1
    • Missing numbers: 2, 3, and 4
    • Column 1: Already has 1 and 2 → Cannot be 2 or 4. Therefore, must be 3.
    • Column 2: Already has 1 → Can be 2, 3, or 4.
    • Column 3: Already has 3 → Can be 2 or 4.
    • Column 4: Already has 1 → Can be 2, 3, or 4.

Step 6: Analyze the Third Column

  • Third Column: | 2 | 3 |
    • Missing numbers: 1 and 4
    • Since the first row's third column is empty and the third row's third column is 3, let's see possible values.
    • First Row, Third Column: Must be 1 or 4.
    • Third Row, First Column: If we set it to 3 (from Step 5), then First Row, Third Column must be 1 or 4.

Step 7: Determine Third Row, First Column

  • Third Row, First Column:
    • Already has 1 in column 2 and 3 in column 4.
    • Possible numbers: 2 and 4.
    • But column 1 already has 2 in row 2, so it must be 4.

Thus:

+---+---+---+---+
| 2 |   |   | 3 |
+---+---+---+---+
| 1 |   | 2 |   |
+---+---+---+---+
| 4 | 1 | 3 |   |
+---+---+---+---+
|   |   |   | 1 |
+---+---+---+---+

Step 8: Determine First Row, Third Column

  • First Row, Third Column:
    • Missing numbers: 1 and 4.
    • Since column 1 has 2 and 3, and row 1 has 2 and 3, it must be 1.

Thus:

+---+---+---+---+
| 2 |   | 1 | 3 |
+---+---+---+---+
| 1 |   | 2 |   |
+---+---+---+---+
| 4 | 1 | 3 |   |
+---+---+---+---+
|   |   |   | 1 |
+---+---+---+---+

Step 9: Determine First Row, Second Column

  • First Row, Second Column:
    • Missing numbers: 4.

Thus:

+---+---+---+---+
| 2 | 4 | 1 | 3 |
+---+---+---+---+
| 1 |   | 2 |   |
+---+---+---+---+
| 4 | 1 | 3 |   |
+---+---+---+---+
|   |   |   | 1 |
+---+---+---+---+

Step 10: Determine Second Row, Second and Fourth Columns

  • Second Row: Missing numbers: 3 and 4.
    • Second Row, Second Column:
      • Column 2 already has 4 in row 1.
      • Therefore, it must be 3.
    • Second Row, Fourth Column:
      • Missing number: 4.

Thus:

+---+---+---+---+
| 2 | 4 | 1 | 3 |
+---+---+---+---+
| 1 | 3 | 2 | 4 |
+---+---+---+---+
| 4 | 1 | 3 |   |
+---+---+---+---+
|   |   |   | 1 |
+---+---+---+---+

Step 11: Determine Third Row, Fourth Column

  • Third Row, Fourth Column:
    • Missing numbers: 2 and 4.
    • Column 4 already has 3 and 4.
    • Therefore, it must be 2.

Thus:

+---+---+---+---+
| 2 | 4 | 1 | 3 |
+---+---+---+---+
| 1 | 3 | 2 | 4 |
+---+---+---+---+
| 4 | 1 | 3 | 2 |
+---+---+---+---+
|   |   |   | 1 |
+---+---+---+---+

Step 12: Determine Fourth Row, First, Second, and Third Columns

  • Fourth Row: Missing numbers: 2, 3, and 4.
    • Fourth Row, First Column:
      • Column 1 already has 2, 1, and 4.
      • Therefore, it must be 3.
    • Fourth Row, Second Column:
      • Column 2 already has 4, 3, and 1.
      • Therefore, it must be 2.
    • Fourth Row, Third Column:
      • Column 3 already has 1, 2, and 3.
      • Therefore, it must be 4.

Thus:

+---+---+---+---+
| 2 | 4 | 1 | 3 |
+---+---+---+---+
| 1 | 3 | 2 | 4 |
+---+---+---+---+
| 4 | 1 | 3 | 2 |
+---+---+---+---+
| 3 | 2 | 4 | 1 |
+---+---+---+---+

Final Grid

Here is the completed puzzle:

+---+---+---+---+
| 2 | 4 | 1 | 3 |
+---+---+---+---+
| 1 | 3 | 2 | 4 |
+---+---+---+---+
| 4 | 1 | 3 | 2 |
+---+---+---+---+
| 3 | 2 | 4 | 1 |
+---+---+---+---+

Verification

Let's verify that each row and column contains the numbers 1 through 4 without repetition.

  • Rows:

    • Row 1: 2, 4, 1, 3 ✔️
    • Row 2: 1, 3, 2, 4 ✔️
    • Row 3: 4, 1, 3, 2 ✔️
    • Row 4: 3, 2, 4, 1 ✔️
  • Columns:

    • Column 1: 2, 1, 4, 3 ✔️
    • Column 2: 4, 3, 1, 2 ✔️
    • Column 3: 1, 2, 3, 4 ✔️
    • Column 4: 3, 4, 2, 1 ✔️

All rows and columns are correctly filled.

Conclusion

The puzzle is solved correctly, and there is one unique solution.

\boxed{ \begin{array}{|c|c|c|c|} \hline 2 & 4 & 1 & 3 \ \hline 1 & 3 & 2 & 4 \ \hline 4 & 1 & 3 & 2 \ \hline 3 & 2 & 4 & 1 \ \hline \end{array} }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment