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'}' => {
31 depth -= 1;
32 }
33 _ => (),
34 }
35 }
36
37 (groups, characters)
38}
39
40pub fn part1(input: &Input) -> u32 {
41 input.0
42}
43
44pub fn part2(input: &Input) -> u32 {
45 input.1
46}