summaryrefslogtreecommitdiffstats
path: root/2015/rs/code/three
diff options
context:
space:
mode:
authoralyx <alyx@aleteoryx.me>2023-11-20 17:12:15 -0500
committeralyx <alyx@aleteoryx.me>2023-11-20 17:12:15 -0500
commitccf1a5828fc26a82545c7accf1ce7916daa08a2d (patch)
tree2428c1374e8f9bcbfd00c8090606f4781d083401 /2015/rs/code/three
parent4810e24657a5931ea79be3fc3ee3e108fe40282e (diff)
downloadadventofcode-ccf1a5828fc26a82545c7accf1ce7916daa08a2d.tar.gz
adventofcode-ccf1a5828fc26a82545c7accf1ce7916daa08a2d.tar.bz2
adventofcode-ccf1a5828fc26a82545c7accf1ce7916daa08a2d.zip
Reorganize using workspaces
Diffstat (limited to '2015/rs/code/three')
-rw-r--r--2015/rs/code/three/Cargo.toml8
-rw-r--r--2015/rs/code/three/src/input.txt1
-rw-r--r--2015/rs/code/three/src/main.rs29
3 files changed, 38 insertions, 0 deletions
diff --git a/2015/rs/code/three/Cargo.toml b/2015/rs/code/three/Cargo.toml
new file mode 100644
index 0000000..6c6d234
--- /dev/null
+++ b/2015/rs/code/three/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "three"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/2015/rs/code/three/src/input.txt b/2015/rs/code/three/src/input.txt
new file mode 100644
index 0000000..55f286f
--- /dev/null
+++ b/2015/rs/code/three/src/input.txt
@@ -0,0 +1 @@
+^><^>>>^<^v<v^^vv^><<^<><<vv^<>^<^v>^vv<>v><vv^^<>>^^^v<<vv><<^>^<^v<^>^v><<<v^<v<<<v<<vv<v<^><^>><>v>v^<<v^^<^v<><^>^<<^^^>v>>v^^<v>>^>vv><v>>^>>v^>^v>^<^^v>^>^^v<v>^^<v<>>v^^v><^><^<<>v^<^<^v<v>v^>>>v^v^>^<>^v<^^vv<v>^>^<>^^<vv^<><<v<^<^^>vv<>^>v<^>^v>v^>^v<>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v>>v>v^<<<>^>^>^<>v<^^vv><^v<<^v<vvv^vv>v<^<<^^vv^^>vv<^>v>^^<<v^<<^^v<>^>v<<^^<^>^^^v^^<v<^<^>>>v^vv^<^v>^<>^<^<v<^v>>>^<^v<><v<^vv<v>v><v^v^^v<vv><^^<><>^>v<^<^vv>><^v><v<>^<>^^>^<><<<v^>>^<>><<><v>vvv^<<^<vv<v><v<^<<<^>^>>v<^>>vv>^v^^^v<>v<>><>^vv^>vv^
diff --git a/2015/rs/code/three/src/main.rs b/2015/rs/code/three/src/main.rs
new file mode 100644
index 0000000..770fc10
--- /dev/null
+++ b/2015/rs/code/three/src/main.rs
@@ -0,0 +1,29 @@
+use std::collections::HashSet;
+
+static INPUT: &'static str = include_str!("input.txt");
+
+fn main() {
+ let valueified = INPUT.chars().map(|c| match c { '<' => (-1, 0), '>' => (1, 0), '^' => (0, 1), 'v' => (0, -1), _ => (0, 0) });
+
+ let mut visited = HashSet::new();
+ append_visits(valueified.clone(), &mut visited);
+ println!("Number visited normally: {}", visited.len());
+
+ let santa_iter = valueified.clone().step_by(2);
+ let robot_iter = valueified.skip(1).step_by(2);
+
+ let mut visited = HashSet::new();
+ append_visits(santa_iter.clone(), &mut visited);
+ append_visits(robot_iter.clone(), &mut visited);
+ println!("Number visited w/ robot: {}", visited.len());
+}
+
+fn append_visits<I: Iterator<Item = (i32, i32)>>(iter: I, visited: &mut HashSet<(i32, i32)>) {
+ let (mut x, mut y) = (0, 0);
+ visited.insert((0, 0));
+ for (move_x, move_y) in iter {
+ x += move_x;
+ y += move_y;
+ visited.insert((x, y));
+ }
+}