# two of A, B and C in each row column and diagonal

This puzzle comes from a book called "Braintraining Puzzles" (The one with a blue-green cover). It involves a 6x6 grid which needs to be filled with two copies of A, B and C in each row, column and diagonal. There are certain restrictions given at the start of the puzzle. For this puzzle:

In row:

4: The As are right of the Cs
5: The Cs are between the Bs

In column:

3: The As are between the Cs
5: The Bs are lower than the As

I am looking for a complete solution that explains how to solve the puzzle step by step (avoiding brute force/trial and error). (If I just wanted the solution, I could just look at the back of the book where the solutions are.)

The puzzle:

• Does X right of Y mean immediately to the right of or anywhere to the right of? – Wen1now Jun 15 '17 at 5:32
• @Wen1now Good question. I took it to mean that both Xs are on the right of both Ys. So YYXX would be fine, but YXYX wouldn't. – Lawrence Jun 15 '17 at 5:38
• @Wen1now both anywere to the right of both, this means XYXY is indeed invalid – micsthepick Jun 15 '17 at 5:48
• @micsthepick Okay, thanks, but just to clarify: Is XXYY also valid? – Wen1now Jun 15 '17 at 5:58
• Where on the grid is Row 1 and Column 1? Bottom Left? – LeppyR64 Jun 15 '17 at 11:05

I was able to solve it with using only one guess. Using notation (row,column)

Eliminate all the starting values from the rules.

Guess: If (4,4) is a C then (4,5) and (4,6) are As, and then (5,5) & (6,5) are Bs.

Eliminate via the rules, then make this step:

Either (5,4) and (6,4) are As or (2,4) is an A. If (5,4) and (6,4) are As then the (1,6) to (6,1) diagonal won't have enough As because (2,5) and (3,4) and (5,2) would be eliminated. This means (2,4) is an A.

The rest is straight elimination via the rules.

My solution:

Next steps: Eliminate the need for the guess.

Final answer and strategy. (thanks for making me waste a few good hours :D).

Solution:

Strategy

Start by filling in a 6x6 grid will ABC in all the columns.

Then, using the restrictions eliminate the values that are not possible.
You get this

After this point you cannot use only logic. You have to make assumptions. Work on that assumption and if it goes wrong, go back and make an other assumption.
What can go wrong? You end up with 3 Bs on one row. You end up with only one cell that can be A and so on.
My idea of a starting point was column 4: "As are next to each other". There are only 5 possible combinations.
It took me a while, because ...

... like an idiot I started trying with As in the last 2 rows of the 4th column and work my way up. WHICH WAS WRONG.
of course the good option was As on the first 2 rows, which I tested last. I will explain only that. There is not need to see all the wrong cases I went through.

So let's go. Now we have:

going through the rules again we can see:
all the other values on column D cannot be A. (we already set 2 As)
row2 implies A2, B2, F2 cannot be A
column 6 implies F1 cannot be A
We now have

Again. I could not do anything else and had to make a different assumption.

now we have columns that have 2 possible values in them. Just pick one to which we could apply as many of the rules and eliminate values.
After a few failed tries I focused on E2 = A. This way I could make the rule on row 2.
Immediately we see that row 2 cannot have any more As.
Time for the next shot in the dark.
I chose column 5 because If I set E1 to C it would allow me to remove a lot of other values. (this one I got the first try :D).

Recap:

further we can use the rules to do:
column 5 => E5 is B.
row 5 => F5 = A.
column 6 => F3 cannot be A.

Again we need a shot in the dark:

make use of the As that have to be next to each other on column 6 and assume F4 = A. (I tried with F6 = A and failed).
F6 cannot be A (we already have 2 As)
C4 cannot be A (we already have 2 As)
The only possible cells on column 3 for an A are now C3 and C5.
row 5 => A5 = B.
we now have 2 As and 2Bs on row 5. Fill in the rest with Cs main diagonal can only have an A on A1. we now have 2 As on row 1.
column 3 rule => C4 = B (we cannot have c between As).
row 4, A is possible now only in E4.
we now have 2 As in column 5 so E3 cannot be A.
secondary diagonal, we can only place the second A in A6.
column 2 has only 2 cells where an A can be placed. B3 and B6.
we now have 2 As on column 1 so A3 cannot be A.
column 5 rule makes 3 to be C (B must be below As.)
We now have 5 cells set on column 5. So make E5 = B.
rule column 4 (As between Cs) makes C6 = C since C5 = A.

Seems like I'm on the right track. Only a few to go.
Time for an other blind stab. This is easier since there are only a few values left and you can see fast if something goes wrong.

I chose to make F6 = C since that will make me fill in a row and remove other values from the main diagonal.
Immediately D6 = 4 because it's the only one left.

Again we can afford to stab blindly.

I focused on the main diagonal and made D4 = C.
This makes D3 = B (only one left).
On the main diagonal B2 can only be B (the only one left)
on the secondary diagonal F1 can only be C.
Rest of the values can be filled in following the rules.

And you end up with the solution listed at the top.

Start with a grid like this where all the cells are filled with all the possible values:

Then start eliminating values.
For example "4: The As are right of the Cs" means that the cells A4 and B4 cannot have the value A. And E4 and F4 cannot be C.
Not the grid looks like this

Going through all the restrictions you end up with this grid.

Now you have to take again the restrictions and see if you can eliminate values from other cells.
The point is to end up with cells that have only one possible value.

[Update 1]
I don's see any other possible logical ways to eliminate possible values you I think a leap of faith is required.
Idea: You can make use of the 2 statements that say the As are next to each other on a column or a row. You can start trying with 2 As on row 2 or columns 4 or 6. and see where this goes.
I tried about 2 places and I didn't reach anything conclusive. I will explore this path further.

[Update 2]
I blindly tried to fit 2 consecutive As according to the restrictions but keep getting to a step where I need an other leap of faith. I quit.

[Update 3] Maybe someone has more luck than me.
As you can see, I'm using a google spreasheet.
As shown above we can see that leaps of faith have to be made.
So I'm doing this.
I make an assumption (for example, on row 2 the As go on 5th and 6th position). Then in a separate cell I write the number 1. This means I made an assumption. I go down that path with all the logic findings I can. If I reach a contradiction, I CTRL-Z until the number 1 I wrote separately is deleted and make an other assumption.
If I don't reach a contradiction, and I need to make an other assumption, I do it and write the number 2 under the 1 mentioned above and repeat the process until I reach a solution (which didn't happen until now) or until I need to rollback again.

• where can C go in column 3 if you need to have CAAC in that order? – micsthepick Jun 15 '17 at 8:13
• I was not sure about that rule. "The As are between the Cs" means CAAC or it can also mean CBAAC? – Marius Jun 15 '17 at 8:55
• And C can go anywhere in column 3. Since you can have these combinations CAACBB, BCAACB, BBCAAC. – Marius Jun 15 '17 at 9:02
• Ah, anywhere, not a strict pattern. Well, full on logic is pretty much out of the question then. You pretty much need to trial the consecutive As as you said. This would happen in a few steps more even if the patterns were strict BCCB etc. – Jakob Pamp Bengtsson Jun 15 '17 at 10:50
• @Marius I asked for clarification about row 1 being on top or bottom. That changes some interactions with Column 5 and Row 2. – LeppyR64 Jun 15 '17 at 11:37