Challenge #5

Part One:
Rubble Trouble

You travel for days along the diagonal path, gathering valuables as you go. At last, exhausted but triumphant, you reach the next village.

The moment you arrive, the first thing you see is a colossal structure built of beautiful stones unlike any you've ever encountered. As you admire their grandeur, a man comes barreling around the corner and nearly crashes into you.

He steadies himself, breathing hard. His name is Watu, and panic rolls off him in waves.

Between gasps, he explains that the magnificent structure you were marveling at has been damaged in numerous places. The culprits, he says, were acolytes of a deity named Eos.

The mere mention of that name sends a shiver down your spine.

You've definitely heard of Eos: the Goddess of the Dawn. Perhaps it should come as no surprise that her worship stretches across multiple ages. You try to get answers from Watu, but he is too distraught, pacing and muttering about missing stones and structural failures.

He tells you the acolytes have destroyed parts of his walls to steal material for constructing great moving statues to guard Eos' Grand Temple.

You want desperately to learn more, but you can see Watu is in no state to talk. Better to help him first and press for information later.

Watu shows you a detailed map of his walls, your puzzle input, including the crumbled areas. Each square of the map is represented with a number:

  1. No Wall
  2. East West Wall
  3. North South Wall
  4. North East Corner
  1. South East Corner
  2. South West Corner
  3. North West Corner
  4. Broken Wall

Fortunately, Eos' acolytes were careless in one regard: no two adjacent walls were destroyed. This means each crumbled section sits between intact walls, allowing you to deduce exactly which wall shape used to stand there by looking at its neighbors to the North, South, East, and West.

There are many destroyed segments; far too many for Watu to analyze alone. He admits he's been staring at the map for hours, wringing his hands, convinced it will take him days to count the correct replacement stones. He looks up at you with desperate hope and you know what comes next.

You'll need to:

For example:

With walls like:

Your map would look like:

71717
20002
70417
20700
71600

For every broken wall, look at the neighbors that connect to it and match the missing wall that connects these neighbors.

Your map now looks like:

41115
20002
20416
20200
31600

For this map, you have to order 1 type-1 wall, 2 type-2 walls, 1 type-3 wall, 1 type-4 wall, 1 type-5 wall, and 1 type-6 wall.

Concatenating these counts together, in order, gives you 121111.

Here is your map: