advent2024

Advent of Code 2024
git clone git://bsandro.tech/advent2024
Log | Files | Refs

main.cpp (1239B)


      1 #include <iostream>
      2 #include <filesystem>
      3 #include <fstream>
      4 #include <vector>
      5 #include <cstring>
      6 #include <cstdio>
      7 #include <tuple>
      8 #include <algorithm>
      9 #include "utils.hpp"
     10 
     11 template<typename T>
     12 T read_file(const std::string &path) {
     13     std::ifstream ifs(path, std::ios::binary);
     14     if (!ifs.is_open()) {
     15         throw std::runtime_error(path+":"+std::strerror(errno));
     16     }
     17     //std::uintmax_t size = std::filesystem::file_size(path);
     18     T buf;
     19     /*while (1) {
     20         std::string str;
     21         std::getline(ifs, str);
     22         if (!str.empty()) buf.push_back(Box(str));
     23         if (!ifs) break;
     24     }*/
     25     /*if (!ifs.read((char *)buf.data(), buf.size())) {
     26         throw std::runtime_error(path+":"+std::strerror(errno));
     27     }*/
     28     return buf;
     29 }
     30 
     31 int64_t part1(Data &input [[ maybe_unused ]]) {
     32     return 0;
     33 }
     34 int64_t part2(Data &input [[ maybe_unused ]]) {
     35     return 0;
     36 }
     37 
     38 int main(int argc, char **argv) {
     39     Performance perf;
     40     const std::string fname = argc>1 ? argv[1] : "test1.txt";
     41     std::cout << "AoC 2024 day $DAY " << fname << std::endl;
     42     Data input = read_file<Data>(fname);
     43     std::cout << "part1: " << part1(input) << std::endl;
     44     std::cout << "part2: " << part2(input) << std::endl;
     45 
     46     return 0;
     47 }