Module aoc::y22d06

source ·
Expand description

Advent of Code 2022 Day 6: https://adventofcode.com/2022/day/6

This challenge essentially boils down to checking if (sliding) windows of n size are distinct. A start of packet/message starts when the preceding n characters are distinct. The solution is therefore to look at each window and add the elements to a std::collections::HashSet. If after adding all of the elements the size of the set is the size of the window then all elements are distinct and we’ve found the “start” and return the current counter plus the size as an offset to account for the size characters at the beginning of the string.

Functions§

  • The solution for the day six challenge.