Skip to content

Commit

Permalink
decision trees
Browse files Browse the repository at this point in the history
  • Loading branch information
Alextopher committed Dec 8, 2023
1 parent 8e8600c commit cee51c5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ members = [
"advent-of-code-2023/d03-gear-ratios",
"advent-of-code-2023/d04-scratchcards",
"advent-of-code-2023/d05-if-you-give-a-seed-a-fertilizer",
"advent-of-code-2023/d06",
"advent-of-code-2023/d06-wait-for-it",
"advent-of-code-2023/d07-camel-cards",
"advent-of-code-2023/d08-haunted-wasteland",
"advent-of-code-2023/d09",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
aoc = { path = "../../aoc" }
File renamed without changes.
17 changes: 17 additions & 0 deletions advent-of-code-2023/d06-wait-for-it/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fn brute_force(time: i64, distance: i64) -> u64 {
(0..time).filter(|&t| t * (time - t) > distance).count() as u64
}

fn part1(inputs: impl Iterator<Item = (i64, i64)>) -> u64 {
inputs
.map(|(time, distance)| brute_force(time, distance))
.product::<u64>()
}

fn main() {
let input_one = &[(61, 430), (67, 1036), (75, 1307), (71, 1150)];
let input_two = (61677571, 430103613071150);

println!("Part 1: {}", part1(input_one.iter().copied()));
println!("Part 2: {}", brute_force(input_two.0, input_two.1));
}
3 changes: 0 additions & 3 deletions advent-of-code-2023/d06/src/main.rs

This file was deleted.

0 comments on commit cee51c5

Please sign in to comment.