Function advent_solutions::advent2017::day01::part1
[−]
[src]
pub fn part1(input: &str) -> u32
It goes on to explain that you may only leave by solving a captcha to prove you're not a human. Apparently, you only get one millisecond to solve the captcha: too fast for a normal human, but it feels like hours to you.
The captcha requires you to review a sequence of digits (your puzzle input) and find the sum of all digits that match the next digit in the list. The list is circular, so the digit after the last digit is the first digit in the list.
For example:
1122produces a sum of3(1+2) because the first digit (1) matches the second digit and the third digit (2) matches the fourth digit.assert_eq!(part1("1122"), 3);
1111produces4because each digit (all1) matches the next.assert_eq!(part1("1111"), 4);
1234produces0because no digit matches the next.assert_eq!(part1("1234"), 0);
91212129produces9because the only digit that matches the next one is the last digit,9.assert_eq!(part1("91212129"), 9);
What is the solution to your captcha?