Base structure for development

This commit is contained in:
zv0n 2022-11-30 18:27:20 +01:00
commit b372144171
2 changed files with 43 additions and 0 deletions

16
2022/base/Makefile Normal file
View File

@ -0,0 +1,16 @@
CXX ?= c++
CXXFLAGS ?= -std=c++11 -Wall -Wextra -pedantic -O2
PROJECT = PROJECT_NAME
all: ${PROJECT}
${PROJECT}: main.cpp
${CXX} ${CXXFLAGS} -o $@ $^
test: ${PROJECT}
./${PROJECT}
clean:
${RM} *.o ${PROJECT}
.PHONY: all clean test

27
2022/base/main.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <vector>
std::vector<int> getInput( std::ifstream &file ) {
std::vector<int> ret{};
int tmp = 0;
std::string str;
while ( std::getline( file, str ) ) {
std::stringstream ss( str );
ss >> tmp;
ret.push_back( tmp );
}
return ret;
}
int main() {
std::ifstream input_file( "input" );
auto input = getInput( input_file );
int part1 = input[0];
int part2 = input[0]+1;
std::cout << "Part 1 result is \033[91;1m" << part1
<< "\033[0m." << std::endl;
std::cout << "Part 2 result is \033[91;1m" << part2
<< "\033[0m." << std::endl;
}