summaryrefslogtreecommitdiff
path: root/aoc19
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2022-04-19 20:22:56 +0200
committerJustin Wernick <justin@worthe-it.co.za>2022-04-19 20:23:15 +0200
commit174772b5b8d9f5bf5e3c8e8152adfd89f0e83f6b (patch)
treea003b748ee939b30a2bcd3caf2378228baa304c1 /aoc19
parentfd75b3fb95ad049b0025cb8fc0b3459b8f872d61 (diff)
Refile for merging repos
Diffstat (limited to 'aoc19')
-rw-r--r--aoc19/Cargo.lock4
-rw-r--r--aoc19/Cargo.toml6
-rw-r--r--aoc19/src/main.rs42
3 files changed, 0 insertions, 52 deletions
diff --git a/aoc19/Cargo.lock b/aoc19/Cargo.lock
deleted file mode 100644
index 7dc8a26..0000000
--- a/aoc19/Cargo.lock
+++ /dev/null
@@ -1,4 +0,0 @@
-[root]
-name = "aoc19"
-version = "0.1.0"
-
diff --git a/aoc19/Cargo.toml b/aoc19/Cargo.toml
deleted file mode 100644
index 17889e3..0000000
--- a/aoc19/Cargo.toml
+++ /dev/null
@@ -1,6 +0,0 @@
-[package]
-name = "aoc19"
-version = "0.1.0"
-authors = ["Justin Worthe <justin.worthe@gmail.com>"]
-
-[dependencies]
diff --git a/aoc19/src/main.rs b/aoc19/src/main.rs
deleted file mode 100644
index 1930d8d..0000000
--- a/aoc19/src/main.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-fn main() {
- part1();
- part2();
-}
-
-fn part1() {
- let mut elves = (0..3017957).map(|i| i+1).collect::<Vec<_>>();
-
- let mut eliminate_mod = 1;
-
- while elves.len() > 1 {
- let next_mod = if elves.len() % 2 == eliminate_mod { 0 } else { 1 };
- elves = elves.iter()
- .enumerate()
- .filter(|&(i, _)| i % 2 != eliminate_mod)
- .map(|(_, &e)| e)
- .collect();
- eliminate_mod = next_mod;
- }
-
- let elf = elves[0];
- println!("Elf {} gets all the presents in part 1", elf);
-}
-
-fn part2() {
- let mut elves = (0..3017957).map(|i| i+1).collect::<Vec<_>>();
-
- let mut i = 0;
- while elves.len() > 1 {
- i = i % elves.len();
- let to_eliminate = (i + elves.len() / 2) % elves.len();
-// println!("Elf {} is taking presents from elf {}", elves[i], elves[to_eliminate]);
- elves.remove(to_eliminate);
- if to_eliminate > i {
- i += 1;
- }
- }
-
- let elf = elves[0];
- println!("Elf {} gets all the presents in part 2", elf);
-
-}