my solutions to advent of code
aoc
advent-of-code
1fn main() {
2 let input: u64 = include_str!("../../input.txt")
3 .trim()
4 .parse()
5 .expect("bad input");
6 let input = input / 10;
7
8 let mut highest_house = (0, 0);
9 let mut house: u64 = 1;
10 // while highest_house.1 < input {
11 while house < 10 {
12 let presents = if house % 2 == 0 {
13 (1..house + 1).fold(0, |acc, elf| {
14 if house % elf == 0 { acc + elf } else { acc }
15 })
16 } else {
17 (1..house.div_ceil(2) + 1).fold(0, |acc, elf| {
18 if house % (elf * 2) == 0 {
19 acc + elf
20 } else {
21 acc
22 }
23 })
24 };
25 if presents > highest_house.1 {
26 highest_house = (house, presents);
27 }
28 house += 1;
29 println!("{} {}", house, presents);
30 }
31
32 println!("Part 1: {:?}", highest_house);
33}