15 lines
324 B
Rust
15 lines
324 B
Rust
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);
|
|
} |