y2024d21p1 very hard

This commit is contained in:
Fabian Schmidt 2024-12-23 15:29:58 +01:00
parent 911a60ab6c
commit 466d79e81a

View File

@ -396,8 +396,6 @@ impl From<&str> for Keypad {
#[cfg(test)]
mod tests {
use rayon::result;
use super::*;
const INPUT_1: &str = "029A";
@ -406,12 +404,12 @@ mod tests {
const INPUT_4: &str = "456A";
const INPUT_5: &str = "379A";
//const INPUT_1_BACK: &str =
// "<vA<AA>>^AvAA<^A>A<v<A>>^AvA^A<vA>^A<v<A>^A>AAvA^A<v<A>A>^AAAvA<^A>A";
//const INPUT_2_BACK: &str = "<v<A>>^AAAvA^A<vA<AA>>^AvAA<^A>A<v<A>A>^AAAvA<^A>A<vA>^A<A>A";
//const INPUT_3_BACK: &str =
// "<v<A>>^A<vA<A>>^AAvAA<^A>A<v<A>>^AAvA^A<vA>^AA<A>A<v<A>A>^AAAvA<^A>A";
//const INPUT_4_BACK: &str = "<v<A>>^AA<vA<A>>^AAvAA<^A>A<vA>^A<A>A<vA>^A<A>A<v<A>A>^AAvA<^A>A";
const INPUT_1_BACK: &str =
"<vA<AA>>^AvAA<^A>A<v<A>>^AvA^A<vA>^A<v<A>^A>AAvA^A<v<A>A>^AAAvA<^A>A";
const INPUT_2_BACK: &str = "<v<A>>^AAAvA^A<vA<AA>>^AvAA<^A>A<v<A>A>^AAAvA<^A>A<vA>^A<A>A";
const INPUT_3_BACK: &str =
"<v<A>>^A<vA<A>>^AAvAA<^A>A<v<A>>^AAvA^A<vA>^AA<A>A<v<A>A>^AAAvA<^A>A";
const INPUT_4_BACK: &str = "<v<A>>^AA<vA<A>>^AAvAA<^A>A<vA>^A<A>A<vA>^A<A>A<v<A>A>^AAvA<^A>A";
const INPUT_5_BACK: &str = "<v<A>>^AvA^A<vA<AA>>^AAvA<^A>AAvA^A<vA>^AA<A>A<v<A>A>^AAAvA<^A>A";
#[test]
@ -459,37 +457,45 @@ mod tests {
assert_eq!(keypad_1.sequence, "<Av<AA>>^A");
}
//#[test]
//fn part1_1_back() {
// let result = Keypad::revert_from(INPUT_1_BACK);
// let result = Keypad::revert_from(&result);
// let result = Numpad::revert_from(&result);
// assert_eq!(result, "029A");
//}
#[test]
fn part1_1_back() {
let result = Keypad::revert_from(INPUT_1_BACK);
println!("back 1 {result}");
let result = Keypad::revert_from(&result);
println!("back 2 {result}");
let result = Numpad::revert_from(&result);
assert_eq!(result, "029A");
}
//#[test]
//fn part1_2_back() {
// let result = Keypad::revert_from(INPUT_2_BACK);
// let result = Keypad::revert_from(&result);
// let result = Numpad::revert_from(&result);
// assert_eq!(result, "980A");
//}
#[test]
fn part1_2_back() {
let result = Keypad::revert_from(INPUT_2_BACK);
println!("back 1 {result}");
let result = Keypad::revert_from(&result);
println!("back 2 {result}");
let result = Numpad::revert_from(&result);
assert_eq!(result, "980A");
}
//#[test]
//fn part1_3_back() {
// let result = Keypad::revert_from(INPUT_3_BACK);
// let result = Keypad::revert_from(&result);
// let result = Numpad::revert_from(&result);
// assert_eq!(result, "179A");
//}
#[test]
fn part1_3_back() {
let result = Keypad::revert_from(INPUT_3_BACK);
println!("back 1 {result}");
let result = Keypad::revert_from(&result);
println!("back 2 {result}");
let result = Numpad::revert_from(&result);
assert_eq!(result, "179A");
}
//#[test]
//fn part1_4_back() {
// let result = Keypad::revert_from(INPUT_4_BACK);
// let result = Keypad::revert_from(&result);
// let result = Numpad::revert_from(&result);
// assert_eq!(result, "456A");
//}
#[test]
fn part1_4_back() {
let result = Keypad::revert_from(INPUT_4_BACK);
println!("back 1 {result}");
let result = Keypad::revert_from(&result);
println!("back 2 {result}");
let result = Numpad::revert_from(&result);
assert_eq!(result, "456A");
}
#[test]
fn part1_5_back() {