solve_day3 :: (test: bool) {
    contents := read_entire_file(ifx test then "inputs/day3_test.txt" else "inputs/day3.txt");
    lines := split(contents, "\n");

    backpacks: [..]u64;

    part1 := 0;
    part2 := 0;

    for outer: lines {
        c1 := slice(outer, 0, outer.count / 2);
        c2 := slice(outer, outer.count / 2, outer.count / 2);

        bitfield_1: u64 = 0;
        bitfield_2: u64 = 0;

        for 0..c1.count - 1 {
            bitfield_1 |= cast(u64)1 << convert_to_priority(c1[it]);
            bitfield_2 |= cast(u64)1 << convert_to_priority(c2[it]);
        }

        part1 += xx get_prio(bitfield_1 & bitfield_2);

        array_add(*backpacks, bitfield_1 | bitfield_2);
    }

    for 0..(backpacks.count / 3) - 1 {
        part2 += xx get_prio(backpacks[it * 3 + 0] & backpacks[it * 3 + 1] & backpacks[it * 3 + 2]);
    }

    print("Part 1: %\n", part1);
    print("Part 2: %\n", part2);

}

get_prio :: (item: u64) -> u64 {
    for 0..63 {
        if (item >> it) & 1 {
            return xx it;
        }
    }

    return 0;
}

convert_to_priority :: (item: u8) -> u8 {
    if item >= #char "a" && item <= #char "z" {
        return item - #char "a" + 1;
    }
    if item >= #char "A" && item <= #char "Z" {
        return item - #char "A" + 27;
    }
    return 0;
}