Advent of Code 2025: Solving Puzzles with Industrial Ladder Logic

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

ComponentModel
PLCAllen-Bradley Micro870 (2080-L70E-24QBBN)
HMIFactoryTalk Optix
CommunicationEthernet/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.


Part 1 Solution

The algorithm processes 4,146 rotation instructions, tracking position on a circular 0-99 dial.

Rung 0 - Reset

Initializes all counters and position to starting state.

Rung 1 - Start Processing

Begins the scan cycle for processing instructions.

Rung 2 - Check If Complete

Compares current instruction index against total count (4,146).

Rung 3 - Get Direction From Array

Reads the direction value (L or R) from the instruction array.

Rung 4 - Get Distance From Array

Reads the rotation distance value from the instruction array.

Rung 5 - Add (Direction = Right)

For right rotations, adds the distance to current position.

Rung 6 - Subtract (Direction = Left)

For left rotations, subtracts the distance from current position.

Rung 7 - Modulo Wraparound

Applies modulo 100 to handle the circular dial wraparound.

Rung 8 - Handle Negative Values

Converts negative results from left rotations to positive equivalent.

Rung 9 - Count Zeros

Increments the zero counter if position equals 0.

Rung 10 - Advance Step

Moves to the next instruction and loops.


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 for zero crossings during rotation.


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