Day 5 + changes in tests

This commit is contained in:
Bizcochito 2022-12-05 10:50:03 +01:00
parent 837e429cc3
commit 864f0dac87
12 changed files with 4251 additions and 3645 deletions

4
Cargo.lock generated
View File

@ -18,6 +18,10 @@ version = "0.1.0"
name = "day04"
version = "0.1.0"
[[package]]
name = "day05"
version = "0.1.0"
[[package]]
name = "tiesto"
version = "0.1.0"

View File

@ -6,7 +6,7 @@ members = [
"day02",
"day03",
"day04",
# "day05",
"day05",
# "day06",
# "day07",
# "day08",

View File

@ -41,10 +41,7 @@ fn get_max_3_elf(elfs: &mut Vec<u32>) -> u32{
#[cfg(test)]
mod test {
use super::*;
#[test]
fn it_works() {
let input = r#"1000
const INPUT: &str = r#"1000
2000
3000
@ -58,26 +55,15 @@ mod test {
9000
10000"#;
let tst = get_elfs(input);
use super::*;
#[test]
fn calories1() {
let tst = get_elfs(INPUT);
assert_eq!(get_max_elf(&tst), 24000);
}
#[test]
fn it_works2() {
let input = r#"1000
2000
3000
4000
5000
6000
7000
8000
9000
10000"#;
let mut tst = get_elfs(input);
fn calories2() {
let mut tst = get_elfs(INPUT);
assert_eq!(get_max_3_elf(&mut tst), 45000);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -61,19 +61,16 @@ fn get_points(input: &str, f: &dyn Fn(&str,&str) -> i32) -> i32 {
#[cfg(test)]
mod test {
const INPUT: &str = r#"A Y
B X
C Z"#;
use super::*;
#[test]
fn it_works() {
let input = r#"A Y
B X
C Z"#;
assert_eq!(get_points(input, &get_round), 15);
fn rps1() {
assert_eq!(get_points(INPUT, &get_round), 15);
}
#[test]
fn it_works2() {
let input = r#"A Y
B X
C Z"#;
assert_eq!(get_points(input, &get_true_round), 12);
fn rps2() {
assert_eq!(get_points(INPUT, &get_true_round), 12);
}
}

View File

@ -1,300 +1,300 @@
ZNNvFWHqLNPZHHqPTHHnTGBhrrpjvmwfMmpfpjBjwpmw
sbdzQgzgssgbglRtmjlwhjBlfrSrMt
zgsCRzJbsdRVQCDbcgLGWWL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jgnTnDTHRDhqjRR
WfMWfCNCjWWHNTccMjRjfRcMbqSwfVwqwsfGGbssrJSrswVw
llLFQLlvlPFnhQBPBZQBqvBwzSzGGhShJVwShmsJbbmzSG
lnPqvQZBFFBnnpgplFvtvHDjTdcTjTMMjCRNCMWgRC
rprFNFFNjNLmMdgcqL
BvzCQQbBQgffsDbvVHMdbcVqmLVqlmqq
JvJCzBDJwnsRnQDszCBnnnQBrjZPjFpgZFTFZRpTrpZFGFtT
wBHQQZHVCcpwDgdZdMsZjvMZFn
GPSzlNlJLfzzzvsWdWLMmFWLMM
NfqGSfrTNzRTqJfRbptQHFQFrwrFHBHw
sNjVMVNVMzPzQgghcMsNzJtjSJtTFDTJtJnnDLjDnL
CHwrdCpvCrwrWdpZqcpFttJSFJTLLHLJfbnbfD
qrlZCwlqZrqqpWdlRqCRqdqcVNsVMzQzmNgNPBsRhVQVVzMs

View File

@ -39,10 +39,10 @@ fn grup_repeat(grup: &Vec<&str>) -> char{
};
for c in repeated {
if let Some(i) = grup[2].find(c){
return (grup[2].chars().nth(i).expect("should have failed before"));
return grup[2].chars().nth(i).expect("should have failed before");
}
};
return panic!();
panic!("Should not get here")
}
fn get_repeat(s: &str) -> char{
@ -54,30 +54,24 @@ fn get_repeat(s: &str) -> char{
return s2.chars().nth(i).expect("should have failed before");
}
};
return panic!();
panic!("Should not get here")
}
#[cfg(test)]
mod test {
const INPUT: &str =r#"vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw"#;
use super::*;
#[test]
fn it_works() {
let input = r#"vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw"#;
assert_eq!(input.lines().map(|l| get_priori(get_repeat(l))).sum::<u32>(), 157);
fn backpacks1() {
assert_eq!(INPUT.lines().map(|l| get_priori(get_repeat(l))).sum::<u32>(), 157);
}
#[test]
fn it_works2() {
let input = r#"vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw"#;
assert_eq!(get_groups(input).iter().map(|g| get_priori(grup_repeat(g))).sum::<u32>(), 70);
fn backpacks2() {
assert_eq!(get_groups(INPUT).iter().map(|g| get_priori(grup_repeat(g))).sum::<u32>(), 70);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -31,25 +31,19 @@ fn get_range(s: &str) -> (u32, u32){
#[cfg(test)]
mod test {
const INPUT: &str = r#"2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8"#;
use super::*;
#[test]
fn it_works() {
let input = r#"2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8"#;
assert_eq!(input.lines().map(|l| get_ranges(l)).filter(|t| ranges_contain(t.0,t.1)).count(), 2);
fn ranges1() {
assert_eq!(INPUT.lines().map(|l| get_ranges(l)).filter(|t| ranges_contain(t.0,t.1)).count(), 2);
}
#[test]
fn it_works2() {
let input = r#"2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8"#;
assert_eq!(input.lines().map(|l| get_ranges(l)).filter(|t| ranges_overlap(t.0,t.1)).count(), 4);
fn ranges2() {
assert_eq!(INPUT.lines().map(|l| get_ranges(l)).filter(|t| ranges_overlap(t.0,t.1)).count(), 4);
}
}

8
day05/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "day05"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

514
day05/input Normal file
View File

@ -0,0 +1,514 @@
[V] [B] [F]
[N] [Q] [W] [R] [B]
[F] [D] [S] [B] [L] [P]
[S] [J] [C] [F] [C] [D] [G]
[M] [M] [H] [L] [P] [N] [P] [V]
[P] [L] [D] [C] [T] [Q] [R] [S] [J]
[H] [R] [Q] [S] [V] [R] [V] [Z] [S]
[J] [S] [N] [R] [M] [T] [G] [C] [D]
1 2 3 4 5 6 7 8 9
move 1 from 8 to 4
move 1 from 7 to 8
move 1 from 6 to 3
move 2 from 6 to 5
move 8 from 5 to 1
move 5 from 3 to 8
move 1 from 7 to 8
move 8 from 1 to 2
move 3 from 3 to 9
move 13 from 8 to 7
move 2 from 1 to 2
move 1 from 6 to 2
move 2 from 1 to 7
move 4 from 4 to 2
move 10 from 9 to 4
move 7 from 4 to 1
move 1 from 6 to 7
move 2 from 4 to 5
move 1 from 5 to 2
move 1 from 5 to 8
move 3 from 1 to 5
move 2 from 4 to 6
move 2 from 6 to 4
move 2 from 4 to 5
move 5 from 1 to 5
move 1 from 9 to 5
move 1 from 8 to 5
move 14 from 2 to 6
move 12 from 7 to 4
move 4 from 6 to 7
move 3 from 6 to 4
move 4 from 4 to 9
move 2 from 4 to 6
move 2 from 9 to 3
move 9 from 4 to 3
move 2 from 1 to 6
move 5 from 7 to 3
move 4 from 7 to 8
move 2 from 6 to 7
move 3 from 6 to 7
move 10 from 5 to 8
move 8 from 8 to 9
move 10 from 9 to 7
move 12 from 7 to 5
move 1 from 1 to 5
move 3 from 7 to 2
move 10 from 3 to 7
move 6 from 5 to 7
move 2 from 6 to 1
move 12 from 2 to 7
move 3 from 3 to 1
move 1 from 6 to 5
move 10 from 5 to 7
move 3 from 3 to 4
move 34 from 7 to 1
move 2 from 6 to 9
move 1 from 6 to 3
move 3 from 1 to 3
move 1 from 7 to 3
move 3 from 3 to 6
move 1 from 4 to 3
move 22 from 1 to 6
move 2 from 9 to 7
move 2 from 4 to 9
move 12 from 6 to 8
move 1 from 7 to 6
move 4 from 8 to 2
move 1 from 7 to 1
move 6 from 8 to 9
move 1 from 2 to 5
move 1 from 2 to 7
move 13 from 1 to 2
move 2 from 3 to 1
move 4 from 7 to 5
move 3 from 9 to 4
move 1 from 1 to 8
move 4 from 5 to 2
move 12 from 6 to 2
move 3 from 1 to 3
move 1 from 4 to 1
move 9 from 8 to 5
move 6 from 5 to 7
move 2 from 4 to 5
move 5 from 9 to 6
move 5 from 3 to 7
move 30 from 2 to 6
move 11 from 7 to 9
move 36 from 6 to 3
move 10 from 9 to 3
move 1 from 6 to 5
move 3 from 5 to 2
move 2 from 5 to 2
move 28 from 3 to 4
move 6 from 4 to 1
move 1 from 2 to 3
move 2 from 5 to 2
move 6 from 1 to 7
move 1 from 1 to 6
move 6 from 3 to 5
move 6 from 7 to 2
move 1 from 6 to 4
move 2 from 2 to 6
move 8 from 2 to 1
move 3 from 2 to 4
move 2 from 3 to 4
move 4 from 3 to 4
move 1 from 6 to 1
move 2 from 1 to 8
move 1 from 6 to 4
move 1 from 9 to 3
move 2 from 5 to 4
move 1 from 8 to 7
move 1 from 7 to 9
move 1 from 3 to 5
move 1 from 8 to 6
move 34 from 4 to 9
move 13 from 9 to 8
move 1 from 8 to 2
move 1 from 2 to 1
move 4 from 5 to 1
move 9 from 8 to 7
move 11 from 1 to 3
move 1 from 4 to 2
move 1 from 6 to 7
move 1 from 9 to 4
move 1 from 4 to 1
move 1 from 5 to 3
move 5 from 7 to 8
move 1 from 2 to 5
move 1 from 5 to 1
move 21 from 9 to 5
move 19 from 3 to 4
move 17 from 4 to 6
move 2 from 8 to 4
move 2 from 6 to 8
move 2 from 6 to 9
move 2 from 7 to 6
move 1 from 4 to 9
move 6 from 5 to 6
move 1 from 9 to 8
move 8 from 5 to 7
move 15 from 6 to 2
move 1 from 9 to 7
move 2 from 1 to 6
move 3 from 4 to 7
move 1 from 1 to 6
move 3 from 5 to 4
move 2 from 5 to 6
move 2 from 4 to 1
move 13 from 7 to 8
move 2 from 6 to 4
move 3 from 2 to 4
move 2 from 7 to 6
move 5 from 4 to 6
move 4 from 2 to 6
move 1 from 1 to 9
move 18 from 8 to 3
move 1 from 4 to 5
move 1 from 2 to 7
move 15 from 3 to 1
move 1 from 5 to 1
move 3 from 3 to 4
move 1 from 5 to 4
move 1 from 5 to 6
move 1 from 6 to 8
move 2 from 8 to 2
move 3 from 1 to 8
move 6 from 2 to 8
move 1 from 7 to 6
move 12 from 8 to 5
move 2 from 9 to 6
move 6 from 1 to 5
move 9 from 5 to 3
move 1 from 2 to 8
move 20 from 6 to 9
move 3 from 6 to 7
move 1 from 7 to 1
move 7 from 3 to 4
move 2 from 7 to 2
move 1 from 8 to 7
move 8 from 4 to 1
move 11 from 1 to 7
move 10 from 7 to 6
move 2 from 4 to 9
move 21 from 9 to 3
move 6 from 5 to 9
move 6 from 3 to 2
move 1 from 4 to 5
move 1 from 7 to 9
move 8 from 3 to 2
move 9 from 2 to 1
move 14 from 1 to 6
move 1 from 1 to 7
move 4 from 3 to 8
move 3 from 8 to 7
move 5 from 7 to 4
move 3 from 6 to 9
move 2 from 3 to 7
move 3 from 5 to 6
move 1 from 5 to 6
move 2 from 7 to 9
move 1 from 8 to 3
move 22 from 6 to 5
move 3 from 9 to 4
move 3 from 6 to 1
move 5 from 4 to 6
move 9 from 2 to 8
move 4 from 6 to 1
move 1 from 3 to 2
move 1 from 2 to 3
move 6 from 8 to 1
move 2 from 4 to 3
move 10 from 1 to 7
move 2 from 8 to 7
move 1 from 9 to 6
move 4 from 3 to 5
move 1 from 8 to 3
move 4 from 9 to 8
move 1 from 4 to 3
move 1 from 3 to 8
move 3 from 7 to 6
move 1 from 1 to 5
move 10 from 5 to 9
move 5 from 6 to 4
move 5 from 8 to 5
move 4 from 9 to 8
move 3 from 3 to 9
move 2 from 8 to 6
move 5 from 7 to 5
move 1 from 4 to 1
move 1 from 1 to 2
move 2 from 8 to 6
move 1 from 2 to 1
move 1 from 7 to 2
move 1 from 1 to 5
move 28 from 5 to 9
move 3 from 6 to 1
move 1 from 6 to 9
move 1 from 2 to 9
move 2 from 1 to 2
move 2 from 7 to 5
move 1 from 7 to 5
move 1 from 2 to 5
move 3 from 1 to 9
move 1 from 5 to 8
move 15 from 9 to 2
move 11 from 9 to 4
move 11 from 4 to 7
move 2 from 4 to 1
move 7 from 7 to 8
move 1 from 1 to 4
move 20 from 9 to 1
move 2 from 7 to 8
move 1 from 4 to 6
move 1 from 6 to 2
move 2 from 7 to 5
move 1 from 9 to 6
move 1 from 4 to 9
move 4 from 5 to 2
move 1 from 6 to 8
move 1 from 4 to 9
move 11 from 8 to 3
move 1 from 1 to 9
move 1 from 5 to 9
move 1 from 2 to 6
move 4 from 9 to 8
move 4 from 8 to 7
move 10 from 1 to 6
move 7 from 1 to 5
move 8 from 3 to 4
move 2 from 3 to 5
move 3 from 7 to 4
move 1 from 4 to 5
move 2 from 1 to 6
move 9 from 2 to 6
move 1 from 7 to 9
move 1 from 3 to 2
move 7 from 4 to 3
move 3 from 3 to 7
move 5 from 2 to 3
move 1 from 1 to 9
move 2 from 2 to 7
move 1 from 4 to 6
move 3 from 5 to 6
move 4 from 7 to 6
move 1 from 7 to 4
move 1 from 4 to 7
move 1 from 2 to 8
move 1 from 7 to 1
move 27 from 6 to 2
move 1 from 4 to 1
move 7 from 5 to 7
move 1 from 4 to 1
move 1 from 8 to 3
move 3 from 7 to 3
move 2 from 1 to 6
move 2 from 9 to 1
move 18 from 2 to 1
move 2 from 7 to 5
move 12 from 3 to 4
move 1 from 5 to 6
move 3 from 6 to 1
move 24 from 1 to 8
move 9 from 2 to 4
move 3 from 2 to 1
move 2 from 6 to 3
move 1 from 6 to 9
move 1 from 5 to 6
move 1 from 6 to 2
move 1 from 1 to 7
move 1 from 2 to 1
move 1 from 1 to 2
move 3 from 7 to 2
move 2 from 1 to 4
move 8 from 4 to 5
move 22 from 8 to 1
move 1 from 8 to 1
move 13 from 4 to 1
move 1 from 8 to 5
move 3 from 3 to 1
move 1 from 2 to 7
move 38 from 1 to 6
move 27 from 6 to 1
move 2 from 2 to 9
move 3 from 9 to 8
move 2 from 8 to 6
move 1 from 8 to 3
move 1 from 2 to 1
move 1 from 3 to 6
move 1 from 2 to 3
move 1 from 7 to 6
move 7 from 6 to 3
move 20 from 1 to 4
move 6 from 1 to 6
move 17 from 4 to 7
move 3 from 6 to 5
move 14 from 7 to 9
move 8 from 5 to 7
move 3 from 1 to 6
move 3 from 3 to 1
move 2 from 4 to 1
move 4 from 5 to 1
move 9 from 6 to 2
move 3 from 6 to 4
move 4 from 7 to 8
move 4 from 1 to 6
move 2 from 3 to 1
move 6 from 6 to 7
move 4 from 8 to 7
move 4 from 2 to 1
move 4 from 2 to 3
move 4 from 9 to 5
move 8 from 9 to 5
move 1 from 9 to 5
move 1 from 2 to 1
move 16 from 7 to 2
move 10 from 2 to 9
move 11 from 9 to 8
move 4 from 3 to 5
move 3 from 1 to 4
move 13 from 5 to 7
move 10 from 8 to 5
move 2 from 1 to 5
move 11 from 7 to 4
move 2 from 3 to 6
move 3 from 7 to 6
move 1 from 3 to 2
move 1 from 1 to 8
move 2 from 8 to 4
move 3 from 1 to 2
move 4 from 6 to 1
move 7 from 1 to 9
move 1 from 6 to 7
move 2 from 5 to 8
move 1 from 2 to 9
move 1 from 7 to 8
move 5 from 5 to 8
move 1 from 2 to 3
move 4 from 2 to 5
move 17 from 4 to 1
move 10 from 5 to 9
move 2 from 4 to 2
move 2 from 4 to 1
move 1 from 4 to 9
move 1 from 3 to 7
move 1 from 7 to 8
move 12 from 9 to 2
move 1 from 2 to 4
move 1 from 4 to 1
move 1 from 1 to 9
move 1 from 8 to 1
move 8 from 8 to 3
move 2 from 5 to 1
move 3 from 1 to 9
move 1 from 2 to 6
move 4 from 3 to 7
move 1 from 7 to 6
move 10 from 9 to 2
move 1 from 5 to 9
move 1 from 9 to 3
move 17 from 1 to 6
move 2 from 1 to 2
move 11 from 6 to 7
move 2 from 2 to 9
move 2 from 9 to 5
move 12 from 7 to 9
move 20 from 2 to 7
move 5 from 9 to 5
move 21 from 7 to 1
move 2 from 6 to 4
move 11 from 1 to 4
move 5 from 4 to 6
move 1 from 7 to 8
move 5 from 9 to 3
move 5 from 2 to 8
move 3 from 9 to 3
move 2 from 8 to 7
move 2 from 1 to 7
move 10 from 6 to 3
move 1 from 2 to 6
move 2 from 8 to 5
move 1 from 6 to 5
move 2 from 4 to 9
move 1 from 4 to 5
move 8 from 1 to 6
move 4 from 4 to 8
move 6 from 8 to 4
move 21 from 3 to 9
move 5 from 9 to 2
move 4 from 7 to 9
move 22 from 9 to 3
move 9 from 6 to 4
move 2 from 2 to 6
move 2 from 2 to 1
move 2 from 5 to 7
move 7 from 5 to 4
move 22 from 4 to 2
move 2 from 5 to 4
move 16 from 2 to 5
move 2 from 6 to 2
move 13 from 3 to 4
move 5 from 5 to 7
move 15 from 4 to 7
move 3 from 2 to 3
move 3 from 2 to 5
move 1 from 1 to 2
move 1 from 2 to 4
move 6 from 5 to 9
move 4 from 3 to 6
move 2 from 5 to 9
move 1 from 2 to 7
move 1 from 1 to 9
move 2 from 4 to 5
move 19 from 7 to 8
move 1 from 6 to 5
move 1 from 5 to 1
move 1 from 9 to 4
move 5 from 8 to 1
move 3 from 8 to 1
move 7 from 5 to 6
move 3 from 7 to 1
move 1 from 2 to 5
move 4 from 9 to 8
move 2 from 5 to 6
move 10 from 1 to 4
move 1 from 7 to 2
move 6 from 3 to 4
move 9 from 4 to 3
move 2 from 2 to 8
move 2 from 9 to 5
move 5 from 8 to 3
move 1 from 1 to 5
move 2 from 5 to 6
move 1 from 1 to 7
move 2 from 9 to 7
move 8 from 4 to 7
move 3 from 3 to 9
move 4 from 6 to 3
move 1 from 5 to 3
move 1 from 7 to 2
move 1 from 2 to 1
move 1 from 6 to 5
move 1 from 5 to 2
move 10 from 7 to 4
move 10 from 4 to 1
move 10 from 1 to 8
move 1 from 9 to 6
move 1 from 1 to 4
move 11 from 8 to 1
move 2 from 9 to 5
move 5 from 6 to 3
move 1 from 3 to 8
move 4 from 1 to 3
move 5 from 3 to 8
move 1 from 4 to 7
move 1 from 7 to 2
move 13 from 3 to 5
move 2 from 2 to 1
move 4 from 3 to 1
move 4 from 5 to 6
move 3 from 6 to 2
move 4 from 5 to 4
move 8 from 8 to 7
move 1 from 3 to 9

109
day05/src/main.rs Normal file
View File

@ -0,0 +1,109 @@
use std::fs;
use std::str::FromStr;
fn main() {
const FILE_PATH: &str = "input";
println!("Hi this is the fifth day of AOC2022, first we will read the file {}", FILE_PATH);
let contents = fs::read_to_string(FILE_PATH)
.expect("Should have been able to read the file");
println!("First we parse this mess");
let (snacks, moves) = parse(&contents);
println!("Then we do the moves as told!");
let snacks = operate9000(snacks, moves);
println!("Aaaand, the top crates are: {}", peek(&snacks));
println!("Aw, it was a CrateMover 9001, no problem we make snacks!");
let (snacks, moves) = parse(&contents);
println!("Then we do the moves as told, this time the correct way!");
let snacks = operate9001(snacks, moves);
println!("Aaaand, the top crates are: {}", peek(&snacks));
}
fn peek(snacks: &Vec<Vec<char>>) -> String{
let mut top = String::new();
for s in snacks{
let ptr = s.len()-1;
top.push(s[ptr]);
}
top
}
fn operate9000(snacks: Vec<Vec<char>>, moves: Vec<(usize, usize, usize)>) -> Vec<Vec<char>>{
let mut snacks = snacks.to_owned();
for mov in moves{
for _ in 0..mov.0{
let c = snacks[mov.1-1].pop().expect("You must be able to do the isntruction");
snacks[mov.2-1].push(c);
}
}
snacks
}
fn operate9001(snacks: Vec<Vec<char>>, moves: Vec<(usize, usize, usize)>) -> Vec<Vec<char>>{
let mut snacks = snacks.to_owned();
for mov in moves{
let mut c = Vec::new();
for _ in 0..mov.0{
c.push(snacks[mov.1-1].pop().expect("You must be able to do the isntruction"));
}
for _ in 0..c.len(){
snacks[mov.2-1].push(c.pop().expect("Always full here lemao"));
}
}
snacks
}
fn parse(s: &str) -> (Vec<Vec<char>>, Vec<(usize, usize, usize)>){
let mut s = s.split("\n\n");
let mut snacks = Vec::new();
let mut moves = Vec::new();
//Stacks
let mut stacks = s.next().expect("there must be things in the stacks").lines().rev();
let n: Vec<char> = stacks.next().expect("REASON").chars().rev().collect();
let n: usize = n[1].to_digit(10).expect("Must be a number") as usize;
for _ in 0..n{
snacks.push(Vec::new())
}
for line in stacks{
let line: Vec<char> = line.chars().collect();
for i in 0..n{
let caja = line[i*4+1];
if caja != ' '{
snacks[i].push(caja);
}
}
}
//Moves
for line in s.next().expect("There must be instructions").lines(){
let line: Vec<&str> = line.split(" ").collect();
moves.push((usize::from_str(line[1]).expect("Must be a number"), usize::from_str(line[3]).expect("Must be a number"), usize::from_str(line[5]).expect("Must be a number")));
}
(snacks, moves)
}
#[cfg(test)]
mod test {
const INPUT: &str = r#" [D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2"#;
use super::*;
#[test]
fn stacks1() {
let (snacks, moves) = parse(INPUT);
let snacks = operate9000(snacks, moves);
assert_eq!(peek(&snacks), "CMZ");
}
#[test]
fn stacks2() {
let (snacks, moves) = parse(INPUT);
let snacks = operate9001(snacks, moves);
assert_eq!(peek(&snacks), "MCD");
}
}