diff --git a/src/bin/day18.rs b/src/bin/day18.rs index a71fbb3..7f15256 100644 --- a/src/bin/day18.rs +++ b/src/bin/day18.rs @@ -46,7 +46,12 @@ impl Day18 { where T: Iterator { - let mut points = vec![(0, 0)]; + let (low, high) = data.size_hint(); + let mut points = Vec::with_capacity( + high.unwrap_or(low) + 1 + ); + points.push((0, 0)); + let mut perimeter = 0; for (dist, (dir_x, dir_y)) in data { diff --git a/src/bin/day19.rs b/src/bin/day19.rs index 900a99b..1da23e5 100644 --- a/src/bin/day19.rs +++ b/src/bin/day19.rs @@ -80,8 +80,7 @@ impl Day19 { .unwrap(); let mut data = data .trim_end_matches('}') - .split(',') - .rev(); + .rsplit(','); let default = data .next() .unwrap();