diff --git a/Day 6/Day 6.vcxproj b/Day 6/Day 6.vcxproj new file mode 100644 index 0000000..e3bd8e5 --- /dev/null +++ b/Day 6/Day 6.vcxproj @@ -0,0 +1,138 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {605f77bc-3c33-45b8-94c3-932481a79a75} + Day_6 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/Day 6/Day 6.vcxproj.filters b/Day 6/Day 6.vcxproj.filters new file mode 100644 index 0000000..96d9e76 --- /dev/null +++ b/Day 6/Day 6.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + + + Source Files + + + \ No newline at end of file diff --git a/Day 6/day6_1.txt b/Day 6/day6_1.txt new file mode 100644 index 0000000..b39f49d --- /dev/null +++ b/Day 6/day6_1.txt @@ -0,0 +1,2 @@ +Time: 7 15 30 +Distance: 9 40 200 \ No newline at end of file diff --git a/Day 6/day6_2.txt b/Day 6/day6_2.txt new file mode 100644 index 0000000..4aba926 --- /dev/null +++ b/Day 6/day6_2.txt @@ -0,0 +1,2 @@ +Time: 51 69 98 78 +Distance: 377 1171 1224 1505 \ No newline at end of file diff --git a/Day 6/main.cpp b/Day 6/main.cpp new file mode 100644 index 0000000..a5c4db6 --- /dev/null +++ b/Day 6/main.cpp @@ -0,0 +1,151 @@ +#pragma region Hidden Setup Stuff +#define OLC_PGE_APPLICATION +#include "olcPixelGameEngine.h" + +using namespace olc; + +enum Run{ + FILE1, + FILE2 +}; + +// Override base class with your custom functionality +class AoC2023 : public olc::PixelGameEngine +{ +std::vectorlines; +bool waitForRender=false; + +void wait(int pauseMs=0){ + waitForRender=true; + while(waitForRender); + std::this_thread::sleep_for(std::chrono::milliseconds(pauseMs)); +} + +#pragma endregion + +const int DAY = 6; +Run runInput=FILE1; + +std::vectortime; +std::vectordistance; + +void doStuff(){ + while(true){ //lines is accessible as a global. + bool firstLine=true; + for(std::string&line:lines){ + if(firstLine){//Time line. + std::string data=line.substr(5); + std::string numb=""; + while(data.length()>0){ + if(data[0]>='0'&&data[0]<='9'){ + numb+=data[0]; + }else + if(numb.length()>0){ + time.push_back(std::stoi(numb)); + numb=""; + } + data=data.substr(1); + } + if(numb.length()>0){ + time.push_back(std::stoi(numb)); + numb=""; + } + firstLine=false; + }else{//Distance line. + std::string data=line.substr(9); + std::string numb=""; + while(data.length()>0){ + if(data[0]>='0'&&data[0]<='9'){ + numb+=data[0]; + }else + if(numb.length()>0){ + distance.push_back(std::stoi(numb)); + numb=""; + } + data=data.substr(1); + } + if(numb.length()>0){ + distance.push_back(std::stoi(numb)); + numb=""; + } + } + } + long sum=0; + for(int i=0;itargetDist){ + wins++; + } + } + if(sum==0){ + sum=wins; + }else{ + sum*=wins; + } + } + std::cout<