aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml1
-rw-r--r--src/day1.rs4
-rw-r--r--src/day2.rs4
-rw-r--r--src/day3.rs4
-rw-r--r--src/day4.rs10
-rw-r--r--src/day5.rs4
-rw-r--r--src/day6.rs7
-rw-r--r--src/main.rs2
8 files changed, 19 insertions, 17 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 86cecea..102099b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,5 +2,6 @@
name = "advent-of-code-2018"
version = "0.1.0"
authors = ["alecdwm <alec@owls.io>"]
+edition = "2018"
[dependencies]
diff --git a/src/day1.rs b/src/day1.rs
index 4b2e014..2383df8 100644
--- a/src/day1.rs
+++ b/src/day1.rs
@@ -39,7 +39,7 @@ enum FrequencyOperation {
///
/// Starting with a frequency of zero, what is the resulting frequency after all of the changes in frequency have been applied?
pub fn part1() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let changes = build_changes(input);
let mut frequency: i64 = 0;
@@ -76,7 +76,7 @@ pub fn part1() {
///
/// What is the first frequency your device reaches twice?
pub fn part2() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let changes = build_changes(input);
let mut frequency: i64 = 0;
diff --git a/src/day2.rs b/src/day2.rs
index 5ee9200..da2bb89 100644
--- a/src/day2.rs
+++ b/src/day2.rs
@@ -24,7 +24,7 @@ use std::collections::BTreeMap;
///
/// What is the checksum for your list of box IDs?
pub fn part1() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let mut two_letter_checksum_component: i64 = 0;
let mut three_letter_checksum_component: i64 = 0;
@@ -80,7 +80,7 @@ pub fn part1() {
///
/// What letters are common between the two correct box IDs? (In the example above, this is found by removing the differing character from either ID, producing fgij.)
pub fn part2() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let matches = find_part2_matches(input).expect("No matches found");
diff --git a/src/day3.rs b/src/day3.rs
index eb2ec85..a41506a 100644
--- a/src/day3.rs
+++ b/src/day3.rs
@@ -46,7 +46,7 @@ use std::str::FromStr;
///
/// If the Elves all proceed with their own plans, none of them will have enough fabric. How many square inches of fabric are within two or more claims?
pub fn part1() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let mut fabric: BTreeMap<(i64, i64), u8> = BTreeMap::new();
@@ -74,7 +74,7 @@ pub fn part1() {
///
/// What is the ID of the only claim that doesn't overlap?
pub fn part2() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let mut fabric: BTreeMap<(i64, i64), u8> = BTreeMap::new();
let mut claims: Vec<FabricClaim> = Vec::new();
diff --git a/src/day4.rs b/src/day4.rs
index 8251040..f3a7593 100644
--- a/src/day4.rs
+++ b/src/day4.rs
@@ -51,7 +51,7 @@ use std::collections::BTreeMap;
///
/// What is the ID of the guard you chose multiplied by the minute you chose? (In the above example, the answer would be 10 * 24 = 240.)
pub fn part1() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let mut sorted_input: Vec<_> = input.lines().collect();
sorted_input.sort();
@@ -66,7 +66,8 @@ pub fn part1() {
} else {
most_slept
}
- }).1;
+ })
+ .1;
let mut slept_minutes: BTreeMap<i64, i64> = BTreeMap::new();
for minute in &sleep_schedule.get(&most_slept_guard).unwrap().1 {
@@ -81,7 +82,8 @@ pub fn part1() {
} else {
most_slept
}
- }).0;
+ })
+ .0;
println!(
"the id of the guard ({}) multiplied by the minute ({}): {}",
@@ -97,7 +99,7 @@ pub fn part1() {
///
/// What is the ID of the guard you chose multiplied by the minute you chose? (In the above example, the answer would be 99 * 45 = 4455.)
pub fn part2() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let mut sorted_input: Vec<_> = input.lines().collect();
sorted_input.sort();
diff --git a/src/day5.rs b/src/day5.rs
index 00a8779..2b836d8 100644
--- a/src/day5.rs
+++ b/src/day5.rs
@@ -22,7 +22,7 @@
///
/// How many units remain after fully reacting the polymer you scanned?
pub fn part1() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let mut polymer: Vec<_> = input.trim().chars().collect();
@@ -51,7 +51,7 @@ pub fn part1() {
///
/// What is the length of the shortest polymer you can produce by removing all units of exactly one type and fully reacting the result?
pub fn part2() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let polymer: Vec<_> = input.trim().chars().collect();
let mut shortest_polymer = polymer.len();
diff --git a/src/day6.rs b/src/day6.rs
index da48d3e..4cf93e1 100644
--- a/src/day6.rs
+++ b/src/day6.rs
@@ -53,7 +53,7 @@ use std::i64;
///
/// What is the size of the largest area that isn't infinite?
pub fn part1() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let coords = input_to_coords(input);
let bounds = get_bounds(&coords);
@@ -100,7 +100,7 @@ pub fn part1() {
///
/// What is the size of the region containing all locations which have a total distance to all given coordinates of less than 10000?
pub fn part2() {
- let input = ::common::read_stdin_to_string();
+ let input = crate::common::read_stdin_to_string();
let coords = input_to_coords(input);
let bounds = get_bounds(&coords);
@@ -121,7 +121,8 @@ fn input_to_coords(input: String) -> Vec<(i64, i64)> {
split[0].trim().parse().unwrap(),
split[1].trim().parse().unwrap(),
)
- }).collect()
+ })
+ .collect()
}
fn get_bounds(coords: &[(i64, i64)]) -> ((i64, i64), (i64, i64)) {
diff --git a/src/main.rs b/src/main.rs
index b0fdc88..e270688 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,3 @@
-extern crate advent_of_code_2018;
-
use std::collections::BTreeMap;
fn main() {