diff options
Diffstat (limited to 'aoc13')
-rw-r--r-- | aoc13/Cargo.lock | 98 | ||||
-rw-r--r-- | aoc13/Cargo.toml | 7 | ||||
-rw-r--r-- | aoc13/src/main.rs | 64 |
3 files changed, 0 insertions, 169 deletions
diff --git a/aoc13/Cargo.lock b/aoc13/Cargo.lock deleted file mode 100644 index d60f2c7..0000000 --- a/aoc13/Cargo.lock +++ /dev/null @@ -1,98 +0,0 @@ -[root] -name = "aoc13" -version = "0.1.0" -dependencies = [ - "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "aho-corasick" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "libc" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "memchr" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex" -version = "0.1.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "thread-id" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "thread_local" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "utf8-ranges" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a51822fc847e7a8101514d1d44e354ba2ffa7d4c194dcab48870740e327cac70" -"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" -"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" -"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" -"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" -"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" -"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/aoc13/Cargo.toml b/aoc13/Cargo.toml deleted file mode 100644 index 347a1a4..0000000 --- a/aoc13/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "aoc13" -version = "0.1.0" -authors = ["Justin Worthe <justin.worthe@entelect.co.za>"] - -[dependencies] -regex = "0.1"
\ No newline at end of file diff --git a/aoc13/src/main.rs b/aoc13/src/main.rs deleted file mode 100644 index 2c0e70e..0000000 --- a/aoc13/src/main.rs +++ /dev/null @@ -1,64 +0,0 @@ -extern crate regex; -use regex::Regex; - -use std::io::BufReader; -use std::io::prelude::*; -use std::fs::File; -use std::collections::HashMap; - -fn main() { - //let target = (7, 4); - let target = (31,39); - - let mut states: HashMap<(i32, i32), u32> = HashMap::new(); - states.insert((1, 1), 0); - let mut moves = 0; - while moves < 50 { -/* if states.iter().any(|(&state, _)| state == target) { - break; - } -*/ - let new_states: Vec<(i32, i32)> = states.iter().filter(|&(_, &x)| x == moves).flat_map(|(state, _)| available_steps(state)).collect(); - - moves += 1; - - for state in new_states { - if !states.contains_key(&state) { - states.insert(state, moves); - } - } - } - - println!("Moves required: {}", moves); - println!("Possible destinations: {}", states.iter().count()); -} - - -fn available_steps(current: &(i32, i32)) -> Vec<(i32, i32)> { - let &(x0, y0) = current; - let mut results = Vec::new(); - for &(x, y) in [(x0-1, y0), (x0+1, y0), (x0, y0-1), (x0, y0+1)].iter() { - if x >= 0 && y >= 0 && !is_wall(x, y) { - results.push((x, y)); - } - } - results -} - -fn print_map() { - for y in 0..10 { - for x in 0..10 { - print!("{}", if is_wall(x, y) {'#'} else {'.'}); - } - println!(""); - } -} - -fn is_wall(x: i32, y: i32) -> bool { -// let favourite_number = 10; - let favourite_number = 1352; - let funny_num = x*x + 3*x + 2*x*y + y + y*y + favourite_number; - let bin = format!("{:b}", funny_num); - let number_of_ones = bin.chars().filter(|&c| c == '1').count(); - number_of_ones % 2 == 1 -} |