diff --git a/Day 2/Day 2.vcxproj b/Day 2/Day 2.vcxproj new file mode 100644 index 0000000..95ff479 --- /dev/null +++ b/Day 2/Day 2.vcxproj @@ -0,0 +1,138 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {fc99e3f2-b7d0-44f4-8f65-e390976ac73b} + Day_2 + 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 2/Day 2.vcxproj.filters b/Day 2/Day 2.vcxproj.filters new file mode 100644 index 0000000..96d9e76 --- /dev/null +++ b/Day 2/Day 2.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 2/Day2_1.txt b/Day 2/Day2_1.txt new file mode 100644 index 0000000..1cd7d33 --- /dev/null +++ b/Day 2/Day2_1.txt @@ -0,0 +1,5 @@ +Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green +Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue +Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red +Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red +Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green \ No newline at end of file diff --git a/Day 2/Day2_2.txt b/Day 2/Day2_2.txt new file mode 100644 index 0000000..6101b82 --- /dev/null +++ b/Day 2/Day2_2.txt @@ -0,0 +1,100 @@ +Game 1: 9 red, 5 blue, 6 green; 6 red, 13 blue; 2 blue, 7 green, 5 red +Game 2: 6 red, 2 green, 2 blue; 12 green, 11 red, 17 blue; 2 blue, 10 red, 11 green; 13 green, 17 red; 15 blue, 20 red, 3 green; 3 blue, 11 red, 1 green +Game 3: 20 green, 1 blue, 7 red; 20 green, 7 blue; 18 red, 8 green, 3 blue; 7 red, 6 blue, 11 green; 11 red, 6 blue, 16 green +Game 4: 6 blue, 6 green; 2 blue, 5 green, 1 red; 9 blue, 1 red, 1 green; 1 red, 6 green, 8 blue; 4 green, 1 red, 1 blue +Game 5: 5 red, 4 blue, 11 green; 10 green, 3 blue, 18 red; 13 red, 13 green, 2 blue +Game 6: 1 blue, 15 green, 7 red; 2 blue, 4 green, 1 red; 1 blue, 13 green, 11 red; 2 blue, 10 red, 9 green +Game 7: 8 green, 1 blue, 1 red; 2 red, 2 green, 3 blue; 2 red, 1 blue +Game 8: 5 green, 9 blue, 2 red; 7 green, 3 red, 1 blue; 7 blue, 2 red, 1 green; 4 blue, 2 red, 14 green; 1 red, 5 blue, 12 green; 7 green, 9 blue, 3 red +Game 9: 11 red, 6 blue; 2 blue, 8 red, 9 green; 8 green, 13 red, 14 blue; 2 blue, 7 red, 9 green +Game 10: 3 red, 3 blue, 4 green; 4 red, 3 green, 2 blue; 13 red, 4 blue, 3 green; 6 blue, 5 green, 8 red; 10 red, 5 blue, 3 green +Game 11: 8 blue, 2 green, 4 red; 2 red, 13 blue, 2 green; 7 red, 3 green, 13 blue; 8 blue, 4 red; 12 blue, 6 red; 18 blue, 3 red, 1 green +Game 12: 15 red, 2 blue; 3 red, 5 green, 1 blue; 2 blue, 3 green, 6 red; 9 red, 4 green, 4 blue; 3 green +Game 13: 3 red, 3 green, 14 blue; 3 red, 14 blue, 1 green; 3 green, 4 blue; 7 blue, 1 red, 4 green +Game 14: 1 green, 2 red, 4 blue; 3 green, 5 blue, 11 red; 12 red, 2 green; 1 blue, 3 green, 4 red +Game 15: 1 red, 3 green, 4 blue; 2 red, 3 green, 2 blue; 10 green, 3 red, 3 blue; 5 red, 11 green, 3 blue +Game 16: 5 red, 12 blue, 12 green; 8 red, 5 blue; 11 green, 5 blue, 12 red; 4 green, 10 blue, 1 red; 1 blue +Game 17: 18 green, 15 red, 5 blue; 5 blue, 4 green, 14 red; 4 red, 7 blue, 9 green +Game 18: 2 red, 12 blue, 2 green; 15 blue, 4 red; 14 red; 11 red, 5 green, 5 blue +Game 19: 4 red, 2 blue, 4 green; 5 red; 7 green, 1 blue; 1 green, 4 red, 2 blue +Game 20: 5 green, 1 blue; 3 blue, 9 green; 14 blue, 7 green; 7 green, 1 red, 1 blue; 7 green, 2 blue +Game 21: 6 blue, 3 green, 8 red; 9 red, 1 green, 1 blue; 4 green, 7 red; 1 blue, 1 green, 12 red; 4 green, 9 red, 5 blue +Game 22: 1 red, 3 blue, 2 green; 12 green, 5 blue, 1 red; 1 green, 3 blue, 3 red; 1 red, 8 green, 2 blue +Game 23: 2 blue, 9 red, 14 green; 7 blue, 10 red; 7 blue, 7 green, 1 red +Game 24: 19 red, 3 green; 7 blue, 4 green, 12 red; 14 red, 3 green, 1 blue; 3 green, 14 red; 5 green, 7 blue, 18 red +Game 25: 12 red, 4 green, 3 blue; 3 blue, 12 red, 11 green; 3 red, 11 green, 2 blue +Game 26: 11 green, 2 red; 5 blue, 4 red; 1 green, 6 blue, 3 red; 9 red, 7 blue; 1 blue, 6 red, 1 green +Game 27: 10 red, 8 blue, 7 green; 6 green, 7 blue; 4 red, 10 green, 9 blue; 9 red, 2 green, 1 blue; 11 blue, 15 red, 9 green +Game 28: 3 blue, 2 red, 8 green; 3 red, 10 green; 11 green, 1 blue; 5 blue, 6 green, 7 red; 3 blue, 2 green +Game 29: 18 red, 1 blue; 3 red, 4 blue, 7 green; 1 blue, 16 green, 2 red; 3 blue, 6 green, 15 red; 1 red, 1 blue; 17 red, 6 green +Game 30: 10 red, 6 blue, 13 green; 2 green, 10 red, 4 blue; 4 red, 2 green, 2 blue +Game 31: 5 red, 13 green, 5 blue; 5 green, 12 blue, 5 red; 5 red, 3 green, 5 blue; 2 green, 3 red, 14 blue +Game 32: 2 blue, 14 red, 13 green; 11 red, 3 green, 1 blue; 9 red, 2 blue, 2 green; 5 blue, 3 red, 2 green; 4 blue, 8 green, 6 red; 12 red, 4 green, 5 blue +Game 33: 1 green, 15 blue; 1 red, 4 blue; 1 red, 1 green, 5 blue +Game 34: 1 green, 2 blue, 3 red; 11 red, 10 blue; 6 blue, 3 red +Game 35: 2 blue, 3 red, 1 green; 1 green, 9 blue, 8 red; 2 blue, 5 red; 2 green, 2 red, 2 blue; 1 red, 10 blue; 5 red, 9 blue +Game 36: 8 green, 1 red, 2 blue; 7 red, 5 green, 9 blue; 1 red, 10 green, 13 blue; 1 red, 10 green +Game 37: 1 green, 1 red; 2 green, 2 red; 2 green, 6 red; 7 red; 1 blue, 2 red +Game 38: 8 red, 7 green, 11 blue; 6 green, 10 blue, 11 red; 13 blue, 18 green, 7 red; 2 red, 7 blue, 12 green +Game 39: 4 blue, 8 red; 1 blue, 11 red, 2 green; 2 green, 3 blue, 12 red; 6 red, 1 green, 9 blue; 6 red, 1 blue, 1 green +Game 40: 2 blue, 17 red, 2 green; 4 red, 7 green; 4 blue, 1 green, 10 red; 6 green, 2 red; 6 red, 1 blue, 4 green; 5 green, 9 red, 4 blue +Game 41: 1 red, 8 blue; 3 green, 5 red, 3 blue; 8 blue, 1 green; 1 red, 9 blue; 5 red, 3 blue; 1 green, 4 red, 3 blue +Game 42: 7 green, 1 red, 10 blue; 11 blue, 1 green; 1 red, 17 blue, 2 green; 1 red, 4 green; 1 green, 3 blue; 11 blue, 1 red +Game 43: 5 green, 1 red; 5 blue, 3 green, 14 red; 7 green, 2 red, 11 blue; 3 red, 10 green, 4 blue; 5 green, 3 blue, 9 red; 8 green, 3 blue, 2 red +Game 44: 10 blue, 1 red, 2 green; 5 blue, 2 green, 2 red; 2 red, 2 green, 5 blue; 7 blue, 14 red, 1 green; 1 red, 2 green, 5 blue +Game 45: 16 green, 11 blue, 7 red; 6 blue, 8 red, 9 green; 7 green, 8 blue, 10 red; 13 red, 15 green, 8 blue; 3 red, 12 green +Game 46: 7 red, 2 green, 4 blue; 3 green, 7 blue; 2 blue, 5 red, 2 green; 3 green, 8 blue, 2 red +Game 47: 6 blue, 5 red; 5 red, 4 green, 5 blue; 4 green, 8 red; 5 red, 4 blue, 4 green; 5 blue, 5 green, 3 red; 5 blue, 2 green, 3 red +Game 48: 11 blue, 7 green, 2 red; 3 red, 8 green, 1 blue; 3 red +Game 49: 8 blue, 1 green, 3 red; 2 blue, 4 red; 6 red, 1 green; 2 red, 10 blue, 10 green +Game 50: 1 red, 8 green; 1 blue, 2 red, 8 green; 7 red, 1 blue; 7 red, 1 blue, 5 green; 6 green, 3 red +Game 51: 10 blue, 6 red; 10 red; 12 red, 5 blue; 11 red, 3 green, 3 blue +Game 52: 11 green, 7 red, 3 blue; 1 red, 9 blue, 8 green; 16 green, 2 blue, 8 red; 8 blue, 6 green; 3 blue, 5 red, 10 green; 8 red, 9 blue, 12 green +Game 53: 1 green, 4 blue, 11 red; 1 green, 12 red, 6 blue; 1 green, 5 red, 12 blue; 5 red, 11 blue; 1 blue, 11 red; 8 blue, 4 red, 1 green +Game 54: 3 blue, 2 green, 8 red; 2 blue, 5 red; 3 blue, 2 red, 2 green; 1 red, 9 blue; 5 red +Game 55: 1 green, 11 blue, 5 red; 16 blue, 11 green, 8 red; 16 blue, 2 red, 13 green +Game 56: 8 green, 6 blue, 6 red; 10 blue, 6 red, 9 green; 3 green, 13 blue, 6 red; 4 green, 5 blue, 3 red +Game 57: 6 green, 6 blue; 1 green, 1 red; 14 green, 1 blue +Game 58: 1 blue; 1 red; 1 red, 3 green, 1 blue; 1 red +Game 59: 5 green, 10 red; 1 green, 2 blue, 6 red; 8 red, 3 green, 2 blue; 4 green, 1 blue +Game 60: 2 red, 8 green; 1 blue, 3 green, 1 red; 2 green, 1 blue, 5 red; 1 red, 13 green, 1 blue; 4 red, 6 green, 1 blue +Game 61: 2 red, 2 green; 15 red, 1 green, 3 blue; 20 red; 7 red, 2 blue; 8 red, 5 blue, 1 green +Game 62: 4 green, 12 red, 14 blue; 11 red, 3 blue, 13 green; 6 green, 16 blue, 7 red; 7 red, 10 blue, 11 green +Game 63: 2 green, 8 red, 3 blue; 1 red; 2 blue, 8 red; 5 blue, 2 red; 1 green, 5 blue, 10 red; 1 green, 3 blue, 11 red +Game 64: 12 blue, 2 red, 4 green; 4 green, 3 red, 5 blue; 9 blue, 1 red, 4 green; 7 green, 7 blue, 1 red; 1 red, 10 blue, 2 green +Game 65: 4 blue, 2 green, 1 red; 1 blue, 4 red, 3 green; 5 green, 3 red; 1 red, 2 green, 15 blue; 3 blue, 3 red +Game 66: 1 red, 7 blue, 1 green; 3 red, 1 green, 1 blue; 1 green, 9 red, 2 blue; 2 green, 2 blue; 5 red, 3 green, 3 blue; 1 blue, 5 red +Game 67: 6 green; 17 green, 5 blue; 3 blue, 3 red, 9 green; 2 green, 4 blue; 1 red, 15 green +Game 68: 1 blue, 11 red, 8 green; 17 green, 3 blue, 8 red; 5 green, 8 red; 18 green, 7 red, 2 blue; 6 green +Game 69: 12 green, 13 blue, 2 red; 4 red, 14 green, 1 blue; 11 red, 15 green, 5 blue; 15 green, 9 red; 4 blue, 1 red, 5 green; 10 red, 20 green, 13 blue +Game 70: 6 red, 8 green, 7 blue; 5 blue, 1 red, 17 green; 2 red, 3 blue, 6 green; 7 blue, 1 red, 14 green; 7 red, 6 blue, 16 green +Game 71: 3 green, 3 blue, 3 red; 1 blue, 11 red, 2 green; 1 blue, 11 red +Game 72: 9 red, 17 blue, 1 green; 20 red, 3 green, 2 blue; 14 blue, 4 green, 11 red; 2 red, 12 blue, 7 green; 18 red, 13 blue, 7 green +Game 73: 6 green, 12 blue, 1 red; 10 blue, 5 red; 6 green, 17 blue, 3 red +Game 74: 1 green, 2 blue, 13 red; 2 blue, 2 green, 1 red; 2 green, 1 blue, 7 red; 1 red, 1 green +Game 75: 10 red, 2 green; 3 blue, 4 green; 9 red, 1 green +Game 76: 1 red, 3 green, 1 blue; 3 blue, 4 green, 6 red; 9 blue, 12 green, 2 red; 5 green, 1 red, 1 blue +Game 77: 3 blue, 4 red, 11 green; 8 green, 5 red; 7 blue, 11 green; 1 green, 3 blue, 6 red +Game 78: 15 blue, 5 green; 7 green, 9 blue; 7 green, 3 red, 2 blue +Game 79: 9 green, 6 red, 4 blue; 4 blue, 2 red, 14 green; 17 green, 2 blue, 4 red; 1 red, 2 green; 3 red, 3 green, 2 blue +Game 80: 1 green; 15 green, 1 red; 1 blue, 20 green, 1 red; 3 red, 15 green, 1 blue; 4 red, 3 green; 2 red, 18 green +Game 81: 4 blue, 1 green, 13 red; 13 blue, 19 red; 4 red, 13 blue; 8 blue, 10 red; 13 blue, 5 red; 1 green, 7 blue, 12 red +Game 82: 5 red, 3 blue; 4 red, 3 green, 9 blue; 19 blue, 1 green, 5 red; 5 green, 3 red, 10 blue +Game 83: 9 red, 3 blue, 5 green; 1 blue, 1 green, 11 red; 2 blue, 6 green, 18 red +Game 84: 2 green; 6 green, 5 red; 3 green, 1 red, 1 blue +Game 85: 2 blue, 6 red; 9 green, 5 red, 15 blue; 7 green, 10 red, 2 blue; 10 red, 6 blue, 2 green; 8 green, 5 red, 12 blue; 6 green, 5 blue, 6 red +Game 86: 2 blue, 12 red, 3 green; 3 red, 2 blue; 1 green, 2 blue, 2 red; 7 blue, 3 red, 1 green; 1 green, 2 blue, 5 red; 3 green, 14 red, 4 blue +Game 87: 3 blue, 1 green; 3 red, 2 blue, 1 green; 1 red, 3 blue; 10 red, 3 green; 5 red, 2 blue +Game 88: 3 blue, 9 red, 9 green; 9 blue, 11 red; 2 green, 11 blue; 2 blue, 14 red, 1 green; 7 green, 11 blue, 8 red; 9 red, 8 green, 3 blue +Game 89: 3 red, 1 blue, 16 green; 5 blue, 4 red, 3 green; 3 blue, 5 red, 5 green; 5 green, 8 blue, 2 red; 4 green, 2 red, 1 blue; 4 red, 1 green, 6 blue +Game 90: 7 green, 8 red; 1 blue, 7 green, 5 red; 4 green, 6 red +Game 91: 3 green, 6 red, 4 blue; 2 green, 9 red, 10 blue; 3 green, 12 blue; 1 red, 4 blue +Game 92: 12 green, 8 blue, 16 red; 6 red, 14 green, 4 blue; 3 green, 3 red, 10 blue; 9 blue, 6 red, 15 green; 14 green, 9 blue, 10 red +Game 93: 4 blue, 4 red, 9 green; 2 blue, 2 green, 6 red; 1 blue, 7 red; 7 blue, 17 red; 2 blue, 13 red, 10 green +Game 94: 4 green, 10 red; 9 red; 1 green, 3 blue, 14 red +Game 95: 9 green, 5 red; 3 blue, 11 red, 6 green; 4 red, 1 green; 13 green, 3 blue, 5 red; 1 red, 6 blue, 12 green; 7 red, 7 green +Game 96: 6 blue; 5 green, 2 blue, 2 red; 14 blue, 3 green +Game 97: 1 blue, 2 green, 5 red; 2 green, 8 blue, 9 red; 1 green, 8 blue, 6 red; 1 blue, 17 red; 2 green, 10 blue, 11 red +Game 98: 3 red, 12 blue, 2 green; 3 green, 4 blue, 4 red; 1 red, 11 blue, 2 green; 1 blue, 3 red +Game 99: 2 green, 9 red; 8 red, 4 green, 9 blue; 8 blue, 13 red; 10 green, 8 blue, 6 red; 11 green, 2 red, 13 blue +Game 100: 5 blue, 2 green, 7 red; 14 red, 15 green, 1 blue; 3 blue, 3 red; 8 green, 10 red, 6 blue; 6 blue, 4 red, 8 green \ No newline at end of file diff --git a/Day 2/main.cpp b/Day 2/main.cpp new file mode 100644 index 0000000..2924465 --- /dev/null +++ b/Day 2/main.cpp @@ -0,0 +1,231 @@ +#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 +#include + +const int DAY = 2; +Run runInput=FILE2; + +void doStuff2(){ + while(true){ //lines is accessible as a global. + int id=1; + long powerSum=0; + for(std::string&line:lines){ + bool allowed=true; + std::string strippedLine=line.substr(line.find(':')+2); + size_t semiColon=strippedLine.find(';'); + int min_red=0,min_green=0,min_blue=0; + #pragma region Parse by Semi-Colon + while(semiColon!=std::string::npos){ + std::string pull=strippedLine.substr(0,semiColon); + + #pragma region Parse by Spaces + size_t space=pull.find(' '); + while(space!=std::string::npos){ + std::string numb=pull.substr(0,space); + int number=atoi(numb.c_str()); + if(pull[space+1]=='b'){ + if(number>min_blue)min_blue=number; + }else + if(pull[space+1]=='g'){ + if(number>min_green)min_green=number; + }else + if(pull[space+1]=='r'){ + if(number>min_red)min_red=number; + } + if(pull.find(' ',space)==std::string::npos)break; + pull=pull.substr(pull.find(' ',space)+1); + space=pull.find(' '); + } + #pragma endregion + + strippedLine=strippedLine.substr(semiColon+2); + semiColon=strippedLine.find(';'); + } + #pragma endregion + #pragma region Parse by Spaces + std::string pull=strippedLine; + size_t space=pull.find(' '); + while(space!=std::string::npos){ + std::string numb=pull.substr(0,space); + int number=atoi(numb.c_str()); + if(pull[space+1]=='b'){ + if(number>min_blue)min_blue=number; + }else + if(pull[space+1]=='g'){ + if(number>min_green)min_green=number; + }else + if(pull[space+1]=='r'){ + if(number>min_red)min_red=number; + } + if(pull.find(' ',space)==std::string::npos)break; + pull=pull.substr(pull.find(' ',space)+1); + space=pull.find(' '); + } + #pragma endregion + + uint32_t power=min_red*min_green*min_blue; + std::cout<<"======="<limit_red||green>limit_green||blue>limit_blue); + + strippedLine=strippedLine.substr(semiColon+2); + semiColon=strippedLine.find(';'); + } + #pragma endregion + #pragma region Parse by Spaces + int red=0,green=0,blue=0; + std::string pull=strippedLine; + size_t space=pull.find(' '); + while(space!=std::string::npos){ + std::string numb=pull.substr(0,space); + int number=atoi(numb.c_str()); + if(pull[space+1]=='b'){ + blue=number; + }else + if(pull[space+1]=='g'){ + green=number; + }else + if(pull[space+1]=='r'){ + red=number; + } + if(pull.find(' ',space)==std::string::npos)break; + pull=pull.substr(pull.find(' ',space)+1); + space=pull.find(' '); + } + #pragma endregion + + std::cout<<"Pulled out "<limit_red||green>limit_green||blue>limit_blue); + std::cout<<"======="<