Explorar o código

Initialize advent of code repo

Andrew Swistak %!s(int64=6) %!d(string=hai) anos
achega
8e4e3ad3c4
Modificáronse 9 ficheiros con 278 adicións e 0 borrados
  1. 2 0
      .gitignore
  2. 112 0
      Cargo.lock
  3. 9 0
      Cargo.toml
  4. 17 0
      src/cli.yml
  5. 2 0
      src/day_1/mod.rs
  6. 3 0
      src/day_1/puzzle_1.rs
  7. 100 0
      src/day_1/puzzle_1.txt
  8. 3 0
      src/day_1/puzzle_2.rs
  9. 30 0
      src/main.rs

+ 2 - 0
.gitignore

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

+ 112 - 0
Cargo.lock

@@ -0,0 +1,112 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "advent-of-code-2019"
+version = "0.1.0"
+dependencies = [
+ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "ansi_term"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "atty"
+version = "0.2.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "bitflags"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "clap"
+version = "2.33.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.66"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "strsim"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "textwrap"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "unicode-width"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "vec_map"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "winapi"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "yaml-rust"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[metadata]
+"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
+"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"
+"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
+"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
+"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
+"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
+"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
+"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
+"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
+"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
+"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992"

+ 9 - 0
Cargo.toml

@@ -0,0 +1,9 @@
+[package]
+name = "advent-of-code-2019"
+version = "0.1.0"
+authors = ["Andrew Swistak <andrew@andrewswistak.com>"]
+edition = "2018"
+
+[dependencies.clap]
+version = "~2.33"
+features = ["yaml"]

+ 17 - 0
src/cli.yml

@@ -0,0 +1,17 @@
+name: aoc
+version: "1.0"
+author: Andrew Swistak <andrew@andrewswistak.com>
+about: Does awesome things
+args:
+    - day:
+        short: d
+        long: day
+        value_name: day number
+        help: The day of advent of code to run puzzles for
+        takes_value: true
+    - puzzle:
+        short: p
+        long: puzzle
+        value_name: puzzle number
+        help: Puzzle one or puzzle two to run for the given day
+        takes_value: true

+ 2 - 0
src/day_1/mod.rs

@@ -0,0 +1,2 @@
+pub mod puzzle_1;
+pub mod puzzle_2;

+ 3 - 0
src/day_1/puzzle_1.rs

@@ -0,0 +1,3 @@
+pub fn solve() {
+    println!("NYI");
+}

+ 100 - 0
src/day_1/puzzle_1.txt

@@ -0,0 +1,100 @@
+137569
+146535
+74662
+133844
+99969
+86606
+76237
+52902
+106211
+141865
+50865
+101011
+75956
+67501
+142146
+107706
+83492
+137253
+56296
+141256
+118232
+127402
+67455
+64062
+72416
+109547
+106144
+54832
+57057
+74884
+80923
+85121
+60461
+92743
+134175
+65671
+90198
+134055
+59568
+146576
+134488
+130355
+54782
+51370
+55501
+56555
+62140
+99558
+80875
+113451
+71048
+64890
+94481
+87468
+148972
+81742
+79471
+100999
+106741
+142433
+130225
+58789
+134365
+81310
+102004
+92736
+105542
+63097
+92747
+109214
+103305
+143659
+68254
+126409
+71724
+50284
+125431
+132227
+125600
+99131
+96598
+101007
+123104
+82215
+97310
+135824
+117379
+81546
+109472
+85571
+89292
+109530
+127656
+56654
+132463
+101948
+118835
+59125
+116089
+61605

+ 3 - 0
src/day_1/puzzle_2.rs

@@ -0,0 +1,3 @@
+pub fn solve() {
+    println!("NYI");
+}

+ 30 - 0
src/main.rs

@@ -0,0 +1,30 @@
+#[macro_use]
+extern crate clap;
+
+mod day_1;
+
+fn main() {
+    use clap::App;
+
+    let yml = load_yaml!("cli.yml");
+    let matches = App::from_yaml(yml).get_matches();
+
+    let day = opt_str_to_int(matches.value_of("day"));
+    let puzzle = opt_str_to_int(matches.value_of("puzzle"));
+
+    match day {
+        d if d == 1 => match puzzle {
+            p if p == 1 => day_1::puzzle_1::solve(),
+            p if p == 2 => day_1::puzzle_2::solve(),
+            _ => println!("unavailable puzzle given!"),
+        },
+        _ => println!("unavailable day given!"),
+    }
+}
+
+fn opt_str_to_int(val: Option<&str>) -> i32 {
+    match val {
+        Some(val) => val.parse::<i32>().unwrap(),
+        None => panic!("value not supplied! type --help"),
+    }
+}