1type Input = (u32, u32);
5
6pub fn parse(input: &str) -> Input {
7 let mut iter = input.bytes();
8 let mut groups = 0;
9 let mut depth = 1;
10 let mut characters = 0;
11
12 while let Some(b) = iter.next() {
13 match b {
14 b'<' => {
15 while let Some(b) = iter.next() {
17 match b {
18 b'!' => {
19 iter.next();
20 }
21 b'>' => break,
22 _ => characters += 1,
23 }
24 }
25 }
26 b'{' => {
27 groups += depth;
28 depth += 1;
29 }
30 b'}' => depth -= 1,
31 _ => (),
32 }
33 }
34
35 (groups, characters)
36}
37
38pub fn part1(input: &Input) -> u32 {
39 input.0
40}
41
42pub fn part2(input: &Input) -> u32 {
43 input.1
44}