Tim Giroux

Day 2 Advent of Code 2025

Link to puzzle

Approach: Given a string s, create an equal length string using copies of a prefix of s, then check equality with s.

Example: 123123 (length 6)

Original:  1 2 3 1 2 3
Length:    6
Check substring lengths where 6 is divisible by length (1, 2, 3)
  Substring:  [1 2 3]
  Repeat 2x:  1 2 3 | 1 2 3
  Original:   1 2 3   1 2 3  // EQUAL

  Substring:  [1 2]
  Repeat 3x:  1 2 | 1 2 | 1 2
  Original:   1 2   3 1   2 3  // not equal

  Substring:  [1]
  Repeat 6x:  1 | 1 | 1 | 1 | 1 | 1
  Original:   1   2   3   1   2   3  // not equal