1
0
Fork 0

Pujan Day 1 Advent

This commit is contained in:
Pujan 2021-12-01 02:10:37 -05:00
parent a92879c27b
commit 023b85247e
3 changed files with 2043 additions and 0 deletions

2000
Day 1/Pujan/cpp/data.txt Normal file

File diff suppressed because it is too large Load Diff

BIN
Day 1/Pujan/cpp/main Executable file

Binary file not shown.

43
Day 1/Pujan/cpp/main.cpp Normal file
View File

@ -0,0 +1,43 @@
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
int main()
{
std::string filename("data.txt");
std::ifstream input{filename};
int prev = 0;
int current = 0;
int counter = 0;
if(!input.is_open())
{
std::cerr << "Couldn't read file: " << filename << "\n";
return 1;
}
for (std::string line; std::getline(input, line);)
{
if (prev == 0)
{
prev = std::stoi(line);
continue;
}
else
{
current = std::stoi(line);
if (prev < current)
{
counter ++;
}
prev = current;
}
}
std::cout << counter << std::endl;
}