# Advent of Code: Day 18 Solution

This year, I’m posting my solutions to the puzzles in the Advent of Code.

Click the link to view the puzzle and code, along with a link to the solution on Github.

And now, on with the solution:

### Day 18, part 1

Simplified problem:

You are in a room with safe or trapped floor tiles. The tiles are arranged into rows that are all the same width; you take note of the safe tiles (`.`) and traps (`^`) in the first row (your puzzle input).

The type of tile (trapped or safe) in each row is based on the types of the tiles in the same position, and to either side of that position, in the previous row. (If either side is off either end of the row, it counts as “safe” because there isn’t a trap embedded in the wall.)

A new tile is a trap only in one of the following situations:

• Its left and center tiles are traps, but its right tile is not.
• Its center and right tiles are traps, but its left tile is not.
• Only its left tile is a trap.
• Only its right tile is a trap.

In any other situation, the new tile is safe.

How many safe tiles are there in 40 rows?

### Day 18, Part 2

How many safe tiles are there in 400,000 rows?

#### Solution

You can find the full solution on Github