Fill in the grid with the numbers $1$ to $6$ so that each number appears exactly once in each row and column. A horizontal gray line marks any cell when it is the middle cell of the three consecutive cells with the largest sum in that row. Similarly, a vertical gray line marks any cell when it is the middle of the three consecutive cells with the largest sum in that column. If there is a tie, multiple lines are drawn in the row or column. A cell can have both lines drawn, with the appearance of a plus sign.

For example, if a filled row had $1 5 4 2 3 6$, horizontal lines would be drawn in the two cells with $4$ and $3$, since out of $1 + 5 + 4, 5 + 4 + 2, 4 + 2 + 3,$ and $2 + 3 + 6,$ the largest sums are $5 + 4 + 2$ and $2 + 3 + 6$.

enter image description here

This contest puzzle is from: https://files.usamts.org/Problems_35_3.pdf

This contest’s submission deadline has passed.

  • 3
    $\begingroup$ This was a problem in the recent round of USAMTS problems that closed just yesterday. Posting this here clearly violates the terms of the contest: "Participants may not discuss the problems with others before the deadline for solution submission." You are also posting past USAMTS problems without attribution, giving the impression they are your own. Please desist. $\endgroup$
    – Stiv
    Commented Jan 5 at 0:15
  • $\begingroup$ @Stiv I was unaware of this tournament. Should I delete my answer? $\endgroup$
    – Toffee
    Commented Jan 5 at 10:53
  • $\begingroup$ @Toffee As was I - a keen-eyed user mentioned it in chat... I wouldn't delete right now - the contest has closed, we spotted it too late. If the mods think further action is required, they can arrange whatever deletions are necessary. You answered in good faith (it was a good-looking puzzle, I wouldn't have spotted the original source without prompting). $\endgroup$
    – Stiv
    Commented Jan 5 at 13:22

2 Answers 2


A very neat puzzle! Before we dive in, a couple of lemmas/corollaries:

Lemma 1: Consider the pattern:
lemma 1
We must have A > D

Corollaries: A cannot be 1 and D cannot be 6

Lemma 2: Consider the pattern:
lemma 2
We must have A+B = D+E

Armed with Lemma 1 we get:

step 1

Applying our corollary to column 3 forces

The 2 in R6C3 with some more cells coming as a result of lemma 1
step 2


To ensure the horizontal bar is in the correct place in column 2, the 3 must be placed in R5C2
step 3

This forces

Row 3 into this unique arrangement with respect to the vertical bar
step 4

This is where we bring in lemma 2

R2C3 must be one more than R5C3. The only consecutive pair of numbers that fit are 4 and 5
step 5

Let’s go back to lemma 1 to get

step 6


The 6 in row 5 can only go in one place to ensure the horizontal bar is in the correct place. This gives a lot more cells via the usual Latin square logic.
step 7

Finally, using lemma 2

In row 4 forces the final unique solution (which I slipped up on in my original submission - thanks Dante)

  • 1
    $\begingroup$ Sums of the two gray marks on the fourth row aren't equal. $\endgroup$
    – Dante
    Commented Jan 2 at 11:10

My solution, also showing the sums

enter image description here

A tally is kept of the numbers used in each row and column.
Starting with the bottom row, the available numbers are permuted.
For each valid arrangement, the maxima are checked to match the spec.
If the row is good, repeat for the next row up, until the top row is done.
Lastly, check the maxima for each column against the spec.
If they all match, there is a valid solution.

Found by recursive algorithm, before another answer was corrected. The solution is unique.

  • $\begingroup$ I didn't quite post it before the incorrect answer was edited. $\endgroup$ Commented Jan 2 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.