Renamed tests

This commit is contained in:
Fabian Schmidt 2024-10-30 11:34:40 +01:00
parent 3486d23f09
commit b55df3d448
18 changed files with 93 additions and 26 deletions

View File

@ -0,0 +1,9 @@
Vixen can fly 19 km/s for 7 seconds, but then must rest for 124 seconds.
Rudolph can fly 3 km/s for 15 seconds, but then must rest for 28 seconds.
Donner can fly 19 km/s for 9 seconds, but then must rest for 164 seconds.
Blitzen can fly 19 km/s for 9 seconds, but then must rest for 158 seconds.
Comet can fly 13 km/s for 7 seconds, but then must rest for 82 seconds.
Cupid can fly 25 km/s for 6 seconds, but then must rest for 145 seconds.
Dasher can fly 14 km/s for 3 seconds, but then must rest for 38 seconds.
Dancer can fly 3 km/s for 16 seconds, but then must rest for 37 seconds.
Prancer can fly 25 km/s for 6 seconds, but then must rest for 143 seconds.

20
y2015/src/bin/d14.rs Normal file
View File

@ -0,0 +1,20 @@
use std::fs;
use y2015::days::d14;
fn main() {
part1();
part2();
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/14_input.txt")).unwrap();
println!("{}", d14::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/14_input.txt")).unwrap();
println!("{}", d14::process_part2(&content));
}

View File

@ -39,11 +39,11 @@ pub fn process_part2(input: &str) -> i32 {
}
#[cfg(test)]
mod tests_1 {
mod tests {
use super::*;
#[test]
fn it_works() {
fn part1() {
let result = process_part1("(())");
assert_eq!(result, 0);
let result = process_part1("(())");

View File

@ -38,11 +38,11 @@ fn look_and_say(number: &str) -> String {
}
#[cfg(test)]
mod tests_10 {
mod tests {
use super::*;
#[test]
fn it_works() {
fn part1() {
let result = look_and_say("1");
assert_eq!(result, "11".to_string());
let result = look_and_say("11");

View File

@ -126,11 +126,11 @@ fn find_close(string: &str) -> u32 {
}
#[cfg(test)]
mod tests_12 {
mod tests {
use super::*;
#[test]
fn it_works() {
fn part1() {
let result_a = process_part1("[1,2,3]");
let result_b = process_part1(r#"{"a":2,"b":4}"#);
assert_eq!(result_a, 6);

View File

@ -159,7 +159,7 @@ pub fn process_part2(input: &str) -> i32 {
}
#[cfg(test)]
mod tests_13 {
mod tests {
use super::*;
const INPUT: &str = "Alice would gain 54 happiness units by sitting next to Bob.
@ -176,7 +176,7 @@ David would lose 7 happiness units by sitting next to Bob.
David would gain 41 happiness units by sitting next to Carol.";
#[test]
fn it_works() {
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 330);
}

37
y2015/src/days/d14.rs Normal file
View File

@ -0,0 +1,37 @@
pub fn process_part1(input: &str) -> i32 {
0
}
pub fn process_part2(input: &str) -> i32 {
0
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "Alice would gain 54 happiness units by sitting next to Bob.
Alice would lose 79 happiness units by sitting next to Carol.
Alice would lose 2 happiness units by sitting next to David.
Bob would gain 83 happiness units by sitting next to Alice.
Bob would lose 7 happiness units by sitting next to Carol.
Bob would lose 63 happiness units by sitting next to David.
Carol would lose 62 happiness units by sitting next to Alice.
Carol would gain 60 happiness units by sitting next to Bob.
Carol would gain 55 happiness units by sitting next to David.
David would gain 46 happiness units by sitting next to Alice.
David would lose 7 happiness units by sitting next to Bob.
David would gain 41 happiness units by sitting next to Carol.";
#[test]
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 330);
}
#[test]
fn part2() {
let result = process_part2(INPUT);
assert_eq!(result, 0);
}
}

View File

@ -37,14 +37,14 @@ pub fn process_part2(input: &str) -> i64 {
}
#[cfg(test)]
mod tests_2 {
mod tests {
use super::*;
const INPUT: &str = "2x3x4
1x1x10";
#[test]
fn it_works() {
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 101);
}

View File

@ -75,7 +75,7 @@ pub fn process_part2(input: &str) -> i64 {
}
#[cfg(test)]
mod tests_3 {
mod tests {
use super::*;
const INPUT: &str = ">
@ -84,7 +84,7 @@ mod tests_3 {
^v^v^v^v^v";
#[test]
fn it_works() {
fn part1() {
let mut lines = INPUT.lines();
let result = process_part1(lines.next().unwrap());
assert_eq!(result, 2);

View File

@ -56,14 +56,14 @@ pub fn process_part2(input: &str) -> i64 {
}
#[cfg(test)]
mod tests_4 {
mod tests {
use super::*;
const INPUT1: &str = "abcdef";
const INPUT2: &str = "pqrstuv";
#[test]
fn it_works() {
fn part1() {
let result = process_part1(INPUT1);
assert_eq!(result, 609043);
let result = process_part1(INPUT2);

View File

@ -76,7 +76,7 @@ pub fn process_part2(input: &str) -> i32 {
}
#[cfg(test)]
mod tests_5 {
mod tests {
use super::*;
const INPUT1: &str = "ugknbfddgicrmopn
@ -86,7 +86,7 @@ haegwjzuvuyypxyu
dvszwmarrgswjxmb";
#[test]
fn it_works() {
fn part1() {
let result = process_part1(INPUT1);
assert_eq!(result, 2);
}

View File

@ -98,7 +98,7 @@ pub fn process_part2(input: &str) -> u32 {
}
#[cfg(test)]
mod tests_6 {
mod tests {
use super::*;
const INPUT1: &str = "turn on 0,0 through 999,999";
@ -106,7 +106,7 @@ mod tests_6 {
const INPUT3: &str = "turn off 499,499 through 500,500";
#[test]
fn it_works() {
fn part1() {
let result = process_part1(INPUT1);
assert_eq!(result, 1_000_000);
let result = process_part1(format!("{INPUT1}\n{INPUT2}").as_str());

View File

@ -101,7 +101,7 @@ pub fn process_part2(input: &str) -> HashMap<String, u16> {
}
#[cfg(test)]
mod tests_7 {
mod tests {
use super::*;
const INPUT: &str = "123 -> x
@ -114,7 +114,7 @@ NOT y -> i
456 -> y";
#[test]
fn it_works() {
fn part1() {
let mut expected = HashMap::new();
expected.insert("d".to_string(), 72);
expected.insert("e".to_string(), 507);

View File

@ -41,7 +41,7 @@ pub fn process_part2(input: &str) -> u32 {
}
#[cfg(test)]
mod tests_8 {
mod tests {
use super::*;
const INPUT: &str = r#"""
@ -51,7 +51,7 @@ mod tests_8 {
"#;
#[test]
fn it_works() {
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 12);
}

View File

@ -104,7 +104,7 @@ pub fn process_part2(input: &str) -> u32 {
}
#[cfg(test)]
mod tests_9 {
mod tests {
use super::*;
const INPUT: &str = "London to Dublin = 464
@ -112,7 +112,7 @@ London to Belfast = 518
Dublin to Belfast = 141";
#[test]
fn it_works() {
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 605);
}

View File

@ -3,6 +3,7 @@ pub mod d10;
pub mod d11;
pub mod d12;
pub mod d13;
pub mod d14;
pub mod d2;
pub mod d3;
pub mod d4;

View File

@ -36,7 +36,7 @@ mod tests {
10000";
#[test]
fn it_works() {
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 24000);
}

View File

@ -93,7 +93,7 @@ B X
C Z";
#[test]
fn it_works() {
fn part1() {
let result = process_part1(INPUT);
assert_eq!(result, 15);
}