Skip to content

Commit

Permalink
shorten
Browse files Browse the repository at this point in the history
  • Loading branch information
majcn committed Dec 15, 2023
1 parent 8694de4 commit 9a8fe9b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/bin/15.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ fn parse_data(input: &str) -> Vec<&str> {
}

fn calc_hash(data: &str) -> u32 {
let mut result = 0;
for ascii in data.bytes() {
result = (result + ascii as u32) * 17 % 256;
}
result
data.bytes().fold(0, |acc, x| (acc + x as u32) * 17 % 256)
}

pub fn part_one(input: &str) -> Option<u32> {
Expand Down

0 comments on commit 9a8fe9b

Please sign in to comment.