Advent of Code 2025: Solving Puzzles with Industrial Ladder Logic
Taking an unconventional approach to Advent of Code by solving puzzles using Allen-Bradley Micro870 PLCs and ladder logic programming
Contents
- The Challenge: Advent of Code Meets Industrial Automation
- Hardware Setup
- Day 1: Secret Entrance
- The Problem
- Video Demonstrations
- Day 1 Part 1
- Day 1 Part 2
- Part 1 Solution
- Rung 0 - Reset
- Rung 1 - Start Processing
- Rung 2 - Check If Complete
- Rung 3 - Get Direction From Array
- Rung 4 - Get Distance From Array
- Rung 5 - Subtract (Direction = Left)
- Rung 6 - Modulo Wraparound
- Rung 7 - Handle Negative Values
- Rung 8 - Count Zeros
- Rung 9 - Advance Step
- Part 2 Solution
- Rung 10 - Zero Crossing Calculation
- Rung 11 - Part 2 Processing
- Rung 12 - Part 2 Advance
The Challenge: Advent of Code Meets Industrial Automation#
What happens when you combine Advent of Code with industrial control systems? Ladder logic solutions running on actual PLCs.
This year, I solved Advent of Code 2025 puzzles using ladder logic on an Allen-Bradley Micro870 PLC, with a FactoryTalk Optix HMI for visualization.
Github Repo with Code: https://github.com/ladderlogix/Advent-of-Code-2025
Hardware Setup#
| Component | Model |
|---|---|
| PLC | Allen-Bradley Micro870 (2080-L70E-24QBBN) |
| HMI | FactoryTalk Optix |
| Communication | Ethernet/IP |
Day 1: Secret Entrance#
The Problem#
You arrive at the secret entrance to the North Pole base, but the password has changed. A safe with a dial (numbers 0-99) holds the answer. Your puzzle input contains rotation instructions like L68 (left 68 clicks) or R48 (right 48 clicks).
The dial starts at 50 and wraps around (left from 0 goes to 99, right from 99 goes to 0).
Part 1: Count how many times the dial ends on position 0 after a rotation.
Part 2: Count how many times the dial passes through or lands on position 0 during ALL rotations (including mid-rotation).
Video Demonstrations#
Day 1 Part 1#
Day 1 Part 2#
Part 1 Solution#
The algorithm processes 4,146 rotation instructions, tracking position on a circular 0-99 dial.
Rung 0 - Reset#

Rung 1 - Start Processing#

Rung 2 - Check If Complete#

Rung 3 - Get Direction From Array#

Rung 4 - Get Distance From Array#

Rung 5 - Subtract (Direction = Left)#

Rung 6 - Modulo Wraparound#

Rung 7 - Handle Negative Values#

Rung 8 - Count Zeros#

Rung 9 - Advance Step#

Part 2 Solution#
Part 2 requires counting every time the dial crosses position 0, not just when it lands there. This adds significant complexity with 6 different cases to handle.
Rung 10 - Zero Crossing Calculation#
This massive branching rung handles all the edge cases for counting zero crossings:

Rung 11 - Part 2 Processing#

Rung 12 - Part 2 Advance#

Stay tuned for more days of Advent of Code solved with ladder logic!