Skip to content

Commit

Permalink
trim input for day 15
Browse files Browse the repository at this point in the history
  • Loading branch information
kcaffrey committed Dec 15, 2023
1 parent 1e0032a commit 59539c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ Solutions for [Advent of Code](https://adventofcode.com/) in [Rust](https://www.
| [Day 12](./src/bin/12.rs) | `137.9µs` | `618.3µs` |
| [Day 13](./src/bin/13.rs) | `12.3µs` | `15.9µs` |
| [Day 14](./src/bin/14.rs) | `26.4µs` | `4.3ms` |
| [Day 15](./src/bin/15.rs) | `30.6µs` | `152.2µs` |
| [Day 15](./src/bin/15.rs) | `29.0µs` | `143.0µs` |

**Total: 6.89ms**
**Total: 6.88ms**
<!--- benchmarking table --->

---
Expand Down
3 changes: 2 additions & 1 deletion src/bin/15.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ advent_of_code::solution!(15);
pub fn part_one(input: &str) -> Option<u32> {
Some(
input
.trim()
.as_bytes()
.split(|&ch| ch == b',')
.map(|s| {
s.iter()
.copied()
.filter(|&ch| ch != b'\n')
.fold(0, |acc, ch| ((acc + ch as u32) * 17) % 256)
})
.sum(),
Expand All @@ -18,6 +18,7 @@ pub fn part_one(input: &str) -> Option<u32> {
pub fn part_two(input: &str) -> Option<u32> {
let mut map = LensMap::new();
for op in input
.trim()
.as_bytes()
.split(|&ch| ch == b',')
.map(Operation::from)
Expand Down

0 comments on commit 59539c8

Please sign in to comment.