This commit is contained in:
Daniel Flanagan 2022-12-02 00:00:00 -06:00
parent 1d6cf18ff2
commit 39c904e8aa
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4

View file

@ -48,16 +48,50 @@ fn part1(input: &str) -> i32 {
input input
.lines() .lines()
.map(|s| { .map(|s| {
println!("{:?}", s);
println!("{:?}", s.chars().nth(2));
let mut c = s.chars(); let mut c = s.chars();
rps(c.nth(0).unwrap(), c.nth(1).unwrap()) rps(c.nth(0).unwrap(), c.nth(1).unwrap())
}) })
.sum() .sum()
} }
fn rps2(a: char, b: char) -> i32 {
match b {
'X' => {
0 + match a {
'A' => 3,
'B' => 1,
'C' => 2,
_ => 1000000,
}
}
'Y' => {
3 + match a {
'A' => 1,
'B' => 2,
'C' => 3,
_ => 1000000,
}
}
'Z' => {
6 + match a {
'A' => 2,
'B' => 3,
'C' => 1,
_ => 1000000,
}
}
_ => 1000000,
}
}
fn part2(input: &str) -> i32 { fn part2(input: &str) -> i32 {
0 input
.lines()
.map(|s| {
let mut c = s.chars();
rps2(c.nth(0).unwrap(), c.nth(1).unwrap())
})
.sum()
} }
#[cfg(test)] #[cfg(test)]
@ -73,8 +107,8 @@ C Z";
assert_eq!(part1(TEST_INPUT), 15) assert_eq!(part1(TEST_INPUT), 15)
} }
// #[test] #[test]
// fn test_part2() { fn test_part2() {
// assert_eq!(part2(TEST_INPUT), 10000) assert_eq!(part2(TEST_INPUT), 12)
// } }
} }