Renamed tests
This commit is contained in:
parent
3486d23f09
commit
b55df3d448
9
y2015/resources/14_input.txt
Normal file
9
y2015/resources/14_input.txt
Normal 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
20
y2015/src/bin/d14.rs
Normal 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));
|
||||||
|
}
|
@ -39,11 +39,11 @@ pub fn process_part2(input: &str) -> i32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_1 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = process_part1("(())");
|
let result = process_part1("(())");
|
||||||
assert_eq!(result, 0);
|
assert_eq!(result, 0);
|
||||||
let result = process_part1("(())");
|
let result = process_part1("(())");
|
||||||
|
@ -38,11 +38,11 @@ fn look_and_say(number: &str) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_10 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = look_and_say("1");
|
let result = look_and_say("1");
|
||||||
assert_eq!(result, "11".to_string());
|
assert_eq!(result, "11".to_string());
|
||||||
let result = look_and_say("11");
|
let result = look_and_say("11");
|
||||||
|
@ -126,11 +126,11 @@ fn find_close(string: &str) -> u32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_12 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result_a = process_part1("[1,2,3]");
|
let result_a = process_part1("[1,2,3]");
|
||||||
let result_b = process_part1(r#"{"a":2,"b":4}"#);
|
let result_b = process_part1(r#"{"a":2,"b":4}"#);
|
||||||
assert_eq!(result_a, 6);
|
assert_eq!(result_a, 6);
|
||||||
|
@ -159,7 +159,7 @@ pub fn process_part2(input: &str) -> i32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_13 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INPUT: &str = "Alice would gain 54 happiness units by sitting next to Bob.
|
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.";
|
David would gain 41 happiness units by sitting next to Carol.";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = process_part1(INPUT);
|
let result = process_part1(INPUT);
|
||||||
assert_eq!(result, 330);
|
assert_eq!(result, 330);
|
||||||
}
|
}
|
||||||
|
37
y2015/src/days/d14.rs
Normal file
37
y2015/src/days/d14.rs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -37,14 +37,14 @@ pub fn process_part2(input: &str) -> i64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_2 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INPUT: &str = "2x3x4
|
const INPUT: &str = "2x3x4
|
||||||
1x1x10";
|
1x1x10";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = process_part1(INPUT);
|
let result = process_part1(INPUT);
|
||||||
assert_eq!(result, 101);
|
assert_eq!(result, 101);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ pub fn process_part2(input: &str) -> i64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_3 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INPUT: &str = ">
|
const INPUT: &str = ">
|
||||||
@ -84,7 +84,7 @@ mod tests_3 {
|
|||||||
^v^v^v^v^v";
|
^v^v^v^v^v";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let mut lines = INPUT.lines();
|
let mut lines = INPUT.lines();
|
||||||
let result = process_part1(lines.next().unwrap());
|
let result = process_part1(lines.next().unwrap());
|
||||||
assert_eq!(result, 2);
|
assert_eq!(result, 2);
|
||||||
|
@ -56,14 +56,14 @@ pub fn process_part2(input: &str) -> i64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_4 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INPUT1: &str = "abcdef";
|
const INPUT1: &str = "abcdef";
|
||||||
const INPUT2: &str = "pqrstuv";
|
const INPUT2: &str = "pqrstuv";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = process_part1(INPUT1);
|
let result = process_part1(INPUT1);
|
||||||
assert_eq!(result, 609043);
|
assert_eq!(result, 609043);
|
||||||
let result = process_part1(INPUT2);
|
let result = process_part1(INPUT2);
|
||||||
|
@ -76,7 +76,7 @@ pub fn process_part2(input: &str) -> i32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_5 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INPUT1: &str = "ugknbfddgicrmopn
|
const INPUT1: &str = "ugknbfddgicrmopn
|
||||||
@ -86,7 +86,7 @@ haegwjzuvuyypxyu
|
|||||||
dvszwmarrgswjxmb";
|
dvszwmarrgswjxmb";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = process_part1(INPUT1);
|
let result = process_part1(INPUT1);
|
||||||
assert_eq!(result, 2);
|
assert_eq!(result, 2);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ pub fn process_part2(input: &str) -> u32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_6 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INPUT1: &str = "turn on 0,0 through 999,999";
|
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";
|
const INPUT3: &str = "turn off 499,499 through 500,500";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = process_part1(INPUT1);
|
let result = process_part1(INPUT1);
|
||||||
assert_eq!(result, 1_000_000);
|
assert_eq!(result, 1_000_000);
|
||||||
let result = process_part1(format!("{INPUT1}\n{INPUT2}").as_str());
|
let result = process_part1(format!("{INPUT1}\n{INPUT2}").as_str());
|
||||||
|
@ -101,7 +101,7 @@ pub fn process_part2(input: &str) -> HashMap<String, u16> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_7 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INPUT: &str = "123 -> x
|
const INPUT: &str = "123 -> x
|
||||||
@ -114,7 +114,7 @@ NOT y -> i
|
|||||||
456 -> y";
|
456 -> y";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let mut expected = HashMap::new();
|
let mut expected = HashMap::new();
|
||||||
expected.insert("d".to_string(), 72);
|
expected.insert("d".to_string(), 72);
|
||||||
expected.insert("e".to_string(), 507);
|
expected.insert("e".to_string(), 507);
|
||||||
|
@ -41,7 +41,7 @@ pub fn process_part2(input: &str) -> u32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_8 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INPUT: &str = r#"""
|
const INPUT: &str = r#"""
|
||||||
@ -51,7 +51,7 @@ mod tests_8 {
|
|||||||
"#;
|
"#;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = process_part1(INPUT);
|
let result = process_part1(INPUT);
|
||||||
assert_eq!(result, 12);
|
assert_eq!(result, 12);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ pub fn process_part2(input: &str) -> u32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_9 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INPUT: &str = "London to Dublin = 464
|
const INPUT: &str = "London to Dublin = 464
|
||||||
@ -112,7 +112,7 @@ London to Belfast = 518
|
|||||||
Dublin to Belfast = 141";
|
Dublin to Belfast = 141";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = process_part1(INPUT);
|
let result = process_part1(INPUT);
|
||||||
assert_eq!(result, 605);
|
assert_eq!(result, 605);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ pub mod d10;
|
|||||||
pub mod d11;
|
pub mod d11;
|
||||||
pub mod d12;
|
pub mod d12;
|
||||||
pub mod d13;
|
pub mod d13;
|
||||||
|
pub mod d14;
|
||||||
pub mod d2;
|
pub mod d2;
|
||||||
pub mod d3;
|
pub mod d3;
|
||||||
pub mod d4;
|
pub mod d4;
|
||||||
|
@ -36,7 +36,7 @@ mod tests {
|
|||||||
10000";
|
10000";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = process_part1(INPUT);
|
let result = process_part1(INPUT);
|
||||||
assert_eq!(result, 24000);
|
assert_eq!(result, 24000);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ B X
|
|||||||
C Z";
|
C Z";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn part1() {
|
||||||
let result = process_part1(INPUT);
|
let result = process_part1(INPUT);
|
||||||
assert_eq!(result, 15);
|
assert_eq!(result, 15);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user