Start day8
This commit is contained in:
parent
a6416e3877
commit
6d02265ca1
4 changed files with 258 additions and 199 deletions
10
day8/data/testInput.txt
Normal file
10
day8/data/testInput.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe
|
||||
edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc
|
||||
fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg
|
||||
fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb
|
||||
aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea
|
||||
fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb
|
||||
dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe
|
||||
bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef
|
||||
egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb
|
||||
gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce
|
BIN
day8/day8Part1
Executable file
BIN
day8/day8Part1
Executable file
Binary file not shown.
49
day8/day8Part1.cpp
Normal file
49
day8/day8Part1.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
int main (void)
|
||||
{
|
||||
string rawInput;
|
||||
int valueCounter = 0;
|
||||
int charCount = 0;
|
||||
int lineValueCounter = 0;
|
||||
bool print = false;
|
||||
ifstream readFile ("data/input.txt", ios::in);
|
||||
|
||||
//Read file into arrays
|
||||
while(getline(readFile, rawInput))
|
||||
{
|
||||
charCount = 0;
|
||||
lineValueCounter = 0;
|
||||
print = false;
|
||||
for(int i=0;i<=rawInput.size();i++)
|
||||
{
|
||||
switch (rawInput[i])
|
||||
{
|
||||
case ' ':
|
||||
if(charCount == 2 || charCount == 3 || charCount == 4 || charCount == 7)
|
||||
{
|
||||
if(print) cout << charCount << "\t";
|
||||
lineValueCounter++;
|
||||
}
|
||||
charCount = 0;
|
||||
break;
|
||||
case '|':
|
||||
print = true;
|
||||
lineValueCounter = 0;
|
||||
//cout << endl << "----------" << endl;
|
||||
break;
|
||||
default:
|
||||
charCount++;
|
||||
}
|
||||
}
|
||||
valueCounter += lineValueCounter;
|
||||
cout << endl << "*********" << endl << "Current Count: " << valueCounter << endl << "*********" << endl;
|
||||
}
|
||||
cout << valueCounter << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue