From db2686c798378738020a0951a521358586e21aa0 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Fri, 9 Feb 2024 11:42:04 +0100 Subject: Add day2 in OCaml --- 2023/day15/src/lib.rs | 56 --------------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 2023/day15/src/lib.rs (limited to '2023/day15/src') diff --git a/2023/day15/src/lib.rs b/2023/day15/src/lib.rs deleted file mode 100644 index e9d36eb..0000000 --- a/2023/day15/src/lib.rs +++ /dev/null @@ -1,56 +0,0 @@ -pub fn part1(input: &str) -> u32 { - let mut res: u32 = 0; - - let inputs: Vec = input.trim_end().split(',').map(|x| x.to_string()).collect(); - - for i in inputs { - let mut s = 0; - for ch in i.chars() { - s += ch as u32; - s *= 17; - s %= 256; - } - res += s; - } - - res -} - -pub fn part2(input: &str) -> u32 { - let mut res: u32 = 0; - - res -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn example_part1() { - let input = include_str!("../example.txt"); - let result = part1(input); - assert_eq!(result, 1320); - } - - #[test] - fn input_part1() { - let input = include_str!("../input.txt"); - let result = part1(input); - assert_eq!(result, 2331); - } - - // #[test] - // fn example_part2() { - // let input = include_str!("../example.txt"); - // let result = part2(input); - // assert_eq!(result, 2286); - // } - // - // #[test] - // fn input_part2() { - // let input = include_str!("../input.txt"); - // let result = part2(input); - // assert_eq!(result, 71585); - // } -} -- cgit v1.2.3-18-g5258