aoc/2023/15/15.rs

15 lines
324 B
Rust
Raw Normal View History

2024-03-05 09:32:18 +00:00
fn hash(s: &str) -> u32 {
let mut value: u8 = 0;
for c in s.chars() {
value = value.wrapping_add(c as u8);
value = value.wrapping_mul(17);
}
value as u32
}
fn main() {
let input: &str = include_str!("input.txt");
let steps = input.split(",");
let part1: &u32 = &steps.map(hash).sum();
println!("{:?}", part1);
}