from tools.aoc import AOCDay from typing import Any class Day(AOCDay): test_solutions_p1 = [] test_solutions_p2 = [] def part1(self) -> Any: low, hi = self.getInputAsArraySplit("-", int) count = 0 for x in range(low, hi + 1): d0 = x // 100_000 d1 = x % 100_000 // 10_000 d2 = x % 10_000 // 1_000 d3 = x % 1_000 // 100 d4 = x % 100 // 10 d5 = x % 10 if d0 <= d1 <= d2 <= d3 <= d4 <= d5: if d0 == d1 or d1 == d2 or d2 == d3 or d3 == d4 or d4 == d5: count += 1 return count def part2(self) -> Any: low, hi = self.getInputAsArraySplit("-", int) count = 0 for x in range(low, hi + 1): d0 = x // 100_000 d1 = x % 100_000 // 10_000 d2 = x % 10_000 // 1_000 d3 = x % 1_000 // 100 d4 = x % 100 // 10 d5 = x % 10 if d0 <= d1 <= d2 <= d3 <= d4 <= d5: if (d0 == d1 and d1 != d2) \ or (d1 == d2 and d2 != d3 and d1 != d0) \ or (d2 == d3 and d3 != d4 and d2 != d1) \ or (d3 == d4 and d4 != d5 and d3 != d2) \ or (d4 == d5 and d4 != d3): count += 1 return count