Johann Woelper 5 years ago
commit
1b273709e6
5 changed files with 98 additions and 0 deletions
  1. 3 0
      .gitignore
  2. 6 0
      Cargo.lock
  3. 9 0
      Cargo.toml
  4. 69 0
      src/day_3.rs
  5. 11 0
      src/main.rs

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+/target
+**/*.rs.bk
+.history/

+ 6 - 0
Cargo.lock

@@ -0,0 +1,6 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "aoc19"
+version = "0.1.0"
+

+ 9 - 0
Cargo.toml

@@ -0,0 +1,9 @@
+[package]
+name = "aoc19"
+version = "0.1.0"
+authors = ["Johann Woelper <woelper@gmail.com>"]
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]

+ 69 - 0
src/day_3.rs

@@ -0,0 +1,69 @@
+use std::collections::HashMap;
+
+fn spawn_points(start: (i32, i32), pattern: &str) -> Vec<(i32, i32)> {
+    
+    let mut pts = vec![];
+
+    let digits = pattern
+        .chars()
+        .filter(|x| x.is_numeric())
+        .collect::<String>()
+        .parse()
+        .unwrap();
+
+    let direction: String = pattern.chars().filter(|x| !x.is_numeric()).collect();
+
+    match direction.as_ref() {
+        "R" => {
+            for d in 0..digits {
+                let mut s = start;
+                s.0 += d;
+                pts.push(s);
+            }
+        }
+        "L" => {
+            for d in 0..digits {
+                let mut s = start;
+                s.0 -= d;
+                pts.push(s);
+            }
+        }
+        "U" => {
+            for d in 0..digits {
+                let mut s = start;
+                s.1 += d;
+                pts.push(s);
+            }
+        }
+        "D" => {
+            for d in 0..digits {
+                let mut s = start;
+                s.1 -= d;
+                pts.push(s);
+            }
+        }
+        _ => {}
+
+    }
+    pts
+
+}
+
+
+fn solve() {
+    // R75,D30,R83,U83,L12,D49,R71,U7,L72
+
+    // Hashmap that has a 2d point as key and a vec for wire indices
+    let grid: HashMap<(i32,i32), Vec<usize>> = HashMap::new();
+
+    let p = spawn_points((0,0), "R10");
+    dbg!(p);
+}
+
+
+
+
+
+pub fn main() {
+    solve();
+}

+ 11 - 0
src/main.rs

@@ -0,0 +1,11 @@
+
+mod day_3;
+
+
+
+
+
+
+fn main() {
+    day_3::main();
+}