Day 1
This commit is contained in:
parent
25fb122377
commit
95db0b1fa8
|
@ -0,0 +1,2 @@
|
|||
*/**
|
||||
!*/*.cpp
|
|
@ -0,0 +1,25 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::string line;
|
||||
int total = 0;
|
||||
int max = 0;
|
||||
while(std::getline(std::cin, line))
|
||||
{
|
||||
if (0 == line.size())
|
||||
{
|
||||
if (total > max)
|
||||
{
|
||||
max = total;
|
||||
}
|
||||
total = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
total += stoi(line);
|
||||
}
|
||||
}
|
||||
std::cout << max << std::endl;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::string line;
|
||||
int total = 0;
|
||||
std::vector<int> sums;
|
||||
while(std::getline(std::cin, line))
|
||||
{
|
||||
if (0 == line.size())
|
||||
{
|
||||
sums.push_back(total);
|
||||
total = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
total += stoi(line);
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(sums.begin(), sums.end(), std::greater<>());
|
||||
std::cout << sums[0] + sums[1] + sums[2] << std::endl;
|
||||
}
|
10
README.md
10
README.md
|
@ -2,12 +2,6 @@
|
|||
|
||||
Advent of Code for 2022
|
||||
|
||||
## How to contribute
|
||||
# Branch format
|
||||
|
||||
To contribute to the Advent of Code 2022, please pull master and create a branch with your name.
|
||||
|
||||
Recommended folder structure is `{Day}\{Language}\{Part}`
|
||||
|
||||
## Tips
|
||||
|
||||
It is recommended to include small document on how the program works and how to compile & run the program.
|
||||
Uploading code files at partX.cpp in each days folder. Compile the part with `g++ partX.cpp -o partX`. Download your input file as `inptuX` and run the program with `./partX < inputX`.
|
Loading…
Reference in New Issue