Skip to content

Commit

Permalink
remove unnecessary copy/paste from part2
Browse files Browse the repository at this point in the history
  • Loading branch information
kcaffrey committed Dec 18, 2023
1 parent 55b8f3c commit 585548f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Solutions for [Advent of Code](https://adventofcode.com/) in [Rust](https://www.
| [Day 15](./src/bin/15.rs) | `20.4µs` | `85.9µs` |
| [Day 16](./src/bin/16.rs) | `58.3µs` | `1.7ms` |
| [Day 17](./src/bin/17.rs) | `1.6ms` | `3.7ms` |
| [Day 18](./src/bin/18.rs) | `8.1µs` | `7.7µs` |
| [Day 18](./src/bin/18.rs) | `8.1µs` | `6.9µs` |

**Total: 14.09ms**
<!--- benchmarking table --->
Expand Down
10 changes: 3 additions & 7 deletions src/bin/18.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,9 @@ pub fn part_two(input: &str) -> Option<i64> {
{
let hex = &line[line.len() - 7..line.len() - 1];
let dir: Direction = hex[5].try_into().expect("valid direction");
let distance = hex[..5]
.iter()
.copied()
.take_while(|&ch| ch != b' ')
.fold(0, |acc, ch| {
acc * 16 + char::from(ch).to_digit(16).unwrap() as i64
});
let distance = hex[..5].iter().copied().fold(0, |acc, ch| {
acc * 16 + char::from(ch).to_digit(16).unwrap() as i64
});
let next = prev.move_in_dir(dir, distance);
area += prev.x * next.y - prev.y * next.x;
border_points += distance;
Expand Down

0 comments on commit 585548f

Please sign in to comment.