Repo for my Advent of Code solutions.
package main

import "core:os"
import "core:fmt"
import "core:strings"
import "core:strconv"

Range :: struct { // Inclusive
    start: int,
    end: int,
}

rangeFront :: proc(range: Range) -> Range {
    return { range.start, range.start + ((range.end - range.start) / 2) };
}

rangeBack :: proc(range: Range) -> Range {
    return { range.start + ((range.end - range.start) / 2) + 1, range.end };
}

rangeLower :: rangeFront;
rangeUpper :: rangeBack;

calculateSeatId :: proc(row, col: int) -> int {
    return (row * 8) + col;
}

main :: proc() {
    input, err := os.read_entire_file("input.txt");
	inputStr := string(input);

    lines := strings.split(inputStr, "\n");

    highestSeatId: int;
    seats: [128 * 8]bool = {};

    for line in lines {
        line := strings.trim_space(line);

        rowRange := Range { 0, 127 };
        colRange := Range { 0, 7 };
        index := 0;
        for c in line {
            if index <= 6 {
                switch c {
                    case 'F':
                        rowRange = rangeFront(rowRange);
                    case 'B':
                        rowRange = rangeBack(rowRange);
                }
            } else {
                switch c {
                    case 'L':
                        colRange = rangeLower(colRange);
                    case 'R':
                        colRange = rangeUpper(colRange);
                }
            }

            index += 1;
        }

        row := rowRange.start;
        col := colRange.start;
        seatId := calculateSeatId(row, col);

        seats[seatId] = true;

        if seatId >= highestSeatId do highestSeatId = seatId;
    }

    fmt.println(highestSeatId);

    for i := 1; i < len(seats) - 1; i += 1 {
        if seats[i - 1] == true && seats[i] == false && seats[i + 1] == true {
            fmt.println(i + 1);
            return;
        }
    }
}