# Calculation Sudoku

Here is a new quiz from my daily quiz calendar. I'm trying to find a way to solve it.

The numbers 1-6 should be filled in. And like a sudoku, each row and each column should contain each number exactly one time. Moreover the colored fields are used for calculation.

For example: if the light grey field's numbers are summed up the result should be 20.

- for subtraction,

x for multiplication,

/ for division.

Is there a logical way to solve this?

My attempt was trial and error but I wasn't able to find the right solution.

I observed that

• for the dark grey 18+ the 3+4+5+6 is the only combination which could be filled in.
• So in the light grey 20+ the first column must be 1 and 2.
• And the 5 / can only consist of 5 and 1.

Moreover I am not sure if the solution is unique.

• Are colored areas allowed to repeat a digit, if it's not the same row/column? Commented Mar 30, 2021 at 13:09
• There is no restriction in the description so I guess this is allowed. Commented Mar 30, 2021 at 13:10
• Don't be afraid to ask "silly questions". It's always possible someone happened to publish an egregiously bad puzzle. The worst one I saw was the front cover of a cheap book. My friend and I stared for a good five minutes with no progress whatsoever, until we realised the grid already had two Nines in the same box Commented Mar 30, 2021 at 21:16
• For what's it's worth, this type of puzzle is called "Ken Ken", not Sudoku, so the title is potentially misleading. The similarity of rules is still the same of course. Commented Mar 31, 2021 at 14:22

Bass has shown that there are "obviously" multiple solutions. It appears that there are in fact exactly 24.

from pysmt.shortcuts import Symbol, LE, GE, And, Int, Equals, NotEquals, Plus, Minus, Times
from pysmt.typing import INT
grid = [[Symbol(f"g{row}{col}", INT) for col in range(6)] for row in range(6)]
inrange = And(And(GE(grid[row][col],Int(1)), LE(grid[row][col],Int(6))) for row in range(6) for col in range(6))
latinrows = And(NotEquals(grid[row][col1],grid[row][col2]) for row in range(6) for col1 in range(5) for col2 in range(col1+1,6))
latincols = And(NotEquals(grid[row1][col],grid[row2][col]) for col in range(6) for row1 in range(5) for row2 in range(row1+1,6))
boxes = And(Equals(Plus(grid[0][0],grid[0][1],grid[0][2],grid[1][0],grid[1][1],grid[1][2]),Int(20)),
Equals(Plus(grid[2][0],grid[3][0],grid[4][0],grid[5][0]),Int(18)),
Equals(Times(grid[0][3],grid[1][3],grid[1][4],grid[2][3]),Int(60)),
Equals(Times(grid[0][4],grid[0][5],grid[1][5]),Int(18)),
Equals(Times(grid[2][1],grid[2][2],grid[3][1]),Int(36)),
Or(Equals(Times(grid[4][1],Int(5)),grid[5][1]),Equals(Times(grid[5][1],Int(5)),grid[4][1])),
Equals(Plus(grid[3][2],grid[3][3],grid[3][4],grid[4][2],grid[5][2]),Int(15)),
Equals(Plus(grid[2][4],grid[2][5],grid[3][5]),Int(13)),
Equals(Plus(grid[4][3],grid[4][4],grid[5][3],grid[5][4]),Int(13)),
Or(Equals(Plus(grid[4][5],Int(3)),grid[5][5]),Equals(Plus(grid[5][5],Int(3)),grid[4][5])))
constraints = And(inrange, latinrows, latincols, boxes)
model = get_model(constraints)
n_sols = 0
con = constraints
while True:
model = get_model(con)
if not model: break
n_sols += 1
con = And(con, Or(NotEquals(grid[i][j],model[grid[i][j]]) for i in range(6) for j in range(6)))
if n_sols%20==0: print(f"{n_sols} so far")
print(f"{n_sols} in total")

yields

20 so far
24 in total

Note: the above is the result of copying-and-pasting what I actually entered, complete with mistakes, deleting the mistakes, and tidying a few things up. It is possible that I screwed up this process and the above will fail in some way :-).

Here are the solutions:

142563    246531    246531    246531    245361    125436
265341    125346    125346    125346    162453    246351
526134    532164    532164    532164    526134    532164
431256    461253    461253    461253    431526    461523
613425    653412    613425    314625    613245    354612
354612    314625    354612    653412    354612    613245

245361    245361    125463    245361    245361    142563
126543    126543    246351    162543    126543    265341
562134    562134    562134    526134    562134    526134
431256    431256    431526    431256    431256    431256
653412    354612    354612    613425    314625    653412
314625    613425    613245    354612    653412    314625

125436    142563    246531    142563    245361    245361
246351    265341    125346    265341    126453    162543
532164    526134    532164    526134    562134    526134
461523    431256    461253    431256    431526    431256
613245    354612    354612    314625    354612    314625
354612    613425    613425    653412    613245    653412

245361    125463    245361    245361    245361    245361
162453    246351    126453    126543    162543    162543
526134    562134    562134    562134    526134    526134
431526    431526    431526    431256    431256    431256
354612    613245    613245    613425    354612    653412
613245    354612    354612    354612    613425    314625
• Well would you look at that. I actually managed to get every single one of the five digits that are fixed in place. (Link is from my comment yesterday.)
– Bass
Commented Mar 31, 2021 at 5:17

I am officially an idiot.

I spent several hours figuring out brilliant deductions and got really good progress with many actual numbers on the grid, and even though I got stuck at places, there was always some clever bit that got me just that much forward.

In the end, I was just about to fill the grid in two different ways to show that the puzzle must be broken, when it finally hit me:

Look at the bottom two rows of the grid. Yes, without any numbers filled in.

Which restriction breaks, if you take the correct solution, and swap those rows?

The answer is, of course, to my utter horror and deep disgust,

none of them whatsoever. The solution cannot possibly be unique, and not a single one of my dozens of deductions was needed to see it. This puzzle absolutely cannot be solved by logic.

So in conclusion, OP is exactly right in questioning the puzzle, which is in its entirety made of steaming hot garbage, and whoever it was that set the puzzle should go stand in the corner for a VERY long time.

• I disagree with the first statement. The rest of it is good though. 😅 Commented Mar 30, 2021 at 19:24
• Ugh, I'm glad you've put me out of my misery; I've spent a lot of time this afternoon doing similar things to you with convoluted logic paths - and this was staring us all in the face the whole time!! Thanks for giving me my evening back at least :)
– Stiv
Commented Mar 30, 2021 at 19:48
• For the record, here's how far I got. (Well, maybe 5 actual digits doesn't qualify as "many"..) Notice in particular how r1c2 cannot be 6, because it is looking at two 36s, which can be shown to be different through the 13+ clue :-) Also, this grid should make it obvious that there can be no copout with "but what about the order of the numbers in the operation?": if the "5/" means "5 and 1, in that order", then the "3-" clue must also mean "5 and 2, in that order", and there's two fives on row 5.
– Bass
Commented Mar 30, 2021 at 19:56
• This puzzle is just missing a single thermo. 😅 Commented Mar 30, 2021 at 20:29
• Turns out, the picture in the comment above is pretty much exactly as far as you can get by logic. (Sorry, I know this sounds like bragging about my useless work, because it very much is.) Gareth posted a list of all the 24 possible solutions, and it shows that all the solutions fit the image, and furtherhencemorth, if my pencilmarks left more than one option for a square, there is a solution for every single one of the options. It seems I picked the 2nd best place to stop.
– Bass
Commented Mar 31, 2021 at 6:59

My interpretation for the two pairs connected with / and - is slightly different: I assume that the calculation is top cell by lower cell, or top cell minus lower cell.

So the conditions are that row 5, column 2 = 5 and row 6, column 2 = 1. And row 5, column 6 minus row 6, column 6 = 3. Since row 5, column 5 ≠ 5 and row 5, column 6 ≠ 1, these two cells are 6 and 3. But that means the three blue cells can't have a product of 18; the product can have at most one factor of 3, so there is no solution.

• Another way to see this is to solve the sudoku for several hours, and then note that the interpretation would put two 5s on row 5.
– Bass
Commented Apr 1, 2021 at 12:33
• One can also assume cages cannot repeat digits, solve for several hours and then realise the 20+ cage is immediately broken :D Commented Apr 1, 2021 at 21:46