# Barrel - Part 1

An entry in Fortnightly Topic Challenge #35: Restricted Title 1. Title based on the very first xkcd.
Continued in Barrel - Part 2, Barrel - Part 3, Barrel - Part 4, and Barrel - Part 5.

You manage a barrel warehouse. The warehouse is divided into an $8\times 8$ grid of cells. A barrel takes up one cell when upright, and two cells when laid down. You only remember where some of the barrels are in the warehouse, and you must determine where the rest of them are. Luckily, you remember two things that should help you out:

• There are indicators along each row/column representing the number of barrels that occupy at least one cell in that row/column.
• Barrels that are lying down have no room to roll to either side, i.e. there is a barrel or the wall stopping them from rolling on either side.

Here is a diagram of the warehouse, with the row/column indicators and the barrels you know for sure. Please determine where the remaining barrels are, and show your steps.

Step by step solution

The start of the puzzle. Several rows and columns are already completely filled, so let's shade them in:

R2C2, R2C4, R6C5, and R8C5 must be occupied by a barrel to prevent their adjacent barrels from rolling now since the other space can't be occupied. They could be in any orientation, but a barrel must exist there.

I counted the number of barrels remaining. The placing of these barrels nearly fills up row 2, 6, and 8, so many spaces can't be placed now:

R2C4 can't extend to R2C5 or it can roll north. Likewise R6C5 can't extend to R5C5 or it can roll east. In particular, R2C5 can't be occupied by another barrel either, since that would exceed row 2's barrel limit.

Therefore, R3C5 is a barrel to block the barrel to the east of it.

Now R5C5 can't be a barrel due to column 5's barrel restriction. R4C2 must be occupied to prevent the barrel west of it from rolling. R2C4 can't extend down due to row 3's barrels.

R4C2 can't extend east or it could slide up. R4C5 must be occupied by a barrel or else the barrel to the west of it could slide, importantly since column 5 is already at the barrel limit that means that R4C5 and R3C5 are part of the same barrel. This means that R3C4 isn't occupied due to row 3, and therefore both R6C5 and R8C5 extend left to satisfy column 4's restriction.

We do another inventory check of barrels remaining. We need 3 more barrels on columns, and 2 more barrels on rows. An interesting property is that upright barrels contribute 1 to both row and column counts, horizontal barrels contribute 1 to row counts, and 2 to column counts, and vertical barrels contribute 1 to column counts, and 1 to row counts. Hence we need at least one more horizontal barrel.

The only place we could place a horizontal barrel is R4C7-8 (R5C2-3 would slide south). The other barrels are therefore upright and we are done.

• Beat me by about a minute. :) +1 – Alconja May 30 '18 at 3:47
• Good job, you really got your <strike>bearings</strike> barrels straight! (crap, didn't know strikethrough doesn't work in comments) – Riley May 30 '18 at 3:57
• Good of you to share the step-by-step as well. – Phylyp May 30 '18 at 4:31
• @Phylyp The step-by-step was required as part of the question. – Riley May 30 '18 at 4:34
• @Riley F̶Y̶I̶ adamvarga.com/strike – Glorfindel Jun 3 '18 at 15:44