diff --git a/2025/Cpp/AdventOfCode.slnx b/2025/Cpp/AdventOfCode.slnx index ec5c5e1..2c1498f 100644 --- a/2025/Cpp/AdventOfCode.slnx +++ b/2025/Cpp/AdventOfCode.slnx @@ -7,4 +7,5 @@ + diff --git a/2025/Cpp/Day02/Day02.cpp b/2025/Cpp/Day02/Day02.cpp index be01ad2..a8045fa 100644 --- a/2025/Cpp/Day02/Day02.cpp +++ b/2025/Cpp/Day02/Day02.cpp @@ -24,8 +24,8 @@ public: { } - inline range_t left() const { return mMinValue; } - inline range_t right() const { return mMaxValue; } + inline range_t left() const { return mMinValue; } + inline range_t right() const { return mMaxValue; } private: const range_t mMinValue; @@ -147,7 +147,7 @@ public: } }; -int main(const char* argv[], int argc) +int main() { Day02Solution solution; solution.SolveAll(); diff --git a/2025/Cpp/Day03/Day03.cpp b/2025/Cpp/Day03/Day03.cpp new file mode 100644 index 0000000..309332c --- /dev/null +++ b/2025/Cpp/Day03/Day03.cpp @@ -0,0 +1,109 @@ +#include "AdventHelpers/AdventOfCodeSolution.h" + +#include +#include +#include +#include +#include +#include + +class BatteryBank { +public: + using joltage_t = uint64_t; + using bank_t = std::vector; + + BatteryBank(std::string bankinput) + { + mBank.reserve(bankinput.length()); + + for (const auto& c : bankinput) { + const int value = c - '0'; + + mBankCounts[value]++; + mBank.push_back(value); + } + + mJoltage = calculateJoltage(); + } + + inline std::vector bank() const { return mBank; } + inline joltage_t joltage() const { return mJoltage; } + + void printMd() const { + for (int i = 0; i < mBank.size(); i++) { + if (i == mLeftIndex || i == mRightIndex) { + std::cout << "**" << std::to_string(mBank[i]) << "**"; + } + else { + std::cout << std::to_string(mBank[i]); + } + } + std::cout << std::endl; + } + +private: + joltage_t calculateJoltage() { + // Find the max value, excluding the last + const auto maxIter = std::max_element(mBank.begin(), mBank.end()-1); + const auto maxVal = *maxIter; + + // Find the farthest left that's the max + auto leftIter = mBank.begin(); + while (*leftIter != maxVal) leftIter++; + + // Roll right and figure out what's the next biggest and send that + const auto rightIter = std::max_element(leftIter + 1, mBank.end()); + const auto rightVal = *rightIter; + + mLeftIndex = leftIter - mBank.begin(); + mRightIndex = rightIter - mBank.begin(); + + return (maxVal * 10) + rightVal; + } + + joltage_t calculateJoltageWithFriction() { + + + } + + std::unordered_map mBankCounts; + bank_t mBank; + joltage_t mJoltage; + size_t mLeftIndex, mRightIndex; + std::vector mEnabledBatteries; +}; + +class Day03Solution : public AdventHelpers::AdventOfCodeSolution +{ +public: + + + virtual std::string SolveProblem01(AdventHelpers::InputFileHelper& inputFile) override { + std::vector batteries; + unsigned int joltage = 0; + + for (const auto& line : inputFile) { + batteries.push_back(line); + } + + for (const auto& battery : batteries) { + battery.printMd(); + joltage += battery.joltage(); + } + + return std::to_string(joltage); + } + + virtual std::string SolveProblem02(AdventHelpers::InputFileHelper& inputFile) override { + return "todo"; + } +}; + +int main() +{ + Day03Solution solution; + solution.SolveAll(); + + return 0; +} + diff --git a/2025/Cpp/Day03/Day03.vcxproj b/2025/Cpp/Day03/Day03.vcxproj new file mode 100644 index 0000000..aba7a67 --- /dev/null +++ b/2025/Cpp/Day03/Day03.vcxproj @@ -0,0 +1,141 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 18.0 + Win32Proj + {0b37e901-f560-4ed0-961e-63a719574006} + Day03 + 10.0 + + + + Application + true + v145 + Unicode + + + Application + false + v145 + true + Unicode + + + Application + true + v145 + Unicode + true + + + Application + false + v145 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp20 + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp20 + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp20 + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp20 + + + Console + true + + + + + + + + {df572ffd-18c6-4b8d-8d35-4855f9a05376} + + + + + + \ No newline at end of file diff --git a/2025/Cpp/Day03/Day03.vcxproj.filters b/2025/Cpp/Day03/Day03.vcxproj.filters new file mode 100644 index 0000000..a6ae4a9 --- /dev/null +++ b/2025/Cpp/Day03/Day03.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {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 + + + + + Source Files + + + \ No newline at end of file diff --git a/2025/Cpp/Day03/example-input.txt b/2025/Cpp/Day03/example-input.txt new file mode 100644 index 0000000..6b1df6a --- /dev/null +++ b/2025/Cpp/Day03/example-input.txt @@ -0,0 +1,4 @@ +987654321111111 +811111111111119 +234234234234278 +818181911112111 \ No newline at end of file diff --git a/2025/Cpp/Day03/puzzle-input.txt b/2025/Cpp/Day03/puzzle-input.txt new file mode 100644 index 0000000..739b1ea --- /dev/null +++ b/2025/Cpp/Day03/puzzle-input.txt @@ -0,0 +1,200 @@ +5313313222133223232222173222221322232243522222432422223223232222322322332122525322132232325523243253 +4643434435498557235534365243244542574323553443425455373394347524417545656554254323477646362565332393 +4368355334455444324446443344964445436444444535543564974449455835134465344446457442431444949546837554 +1233222462842264836222323343438133241441433342523522523433233433172523212124472129323343343262452654 +2362522134224321232821151357232125226816156225282228424322226621235652111622222622122733334222262326 +2233213332243221223233334332333533226334323334233232331331333333433321332222323233334913323234443332 +1225233313422232542132242222222233324233322232223233414222321423223214222225334433212352432131235222 +3342347334543433942543737451273434433333343233432323333382732246334543743854334544343335563723323543 +3222132322624622253922334553132235283125122222313123512332223224232223222223224132222242335132223222 +3282814631552455223845495229522528935222522885339443346562862666812722932213358593727594192835645138 +3233316363352423323332643133432127332324513346673332272324223322322342333234215127235142133323223462 +7562776979756656658387595988498688486988985756767968894866858377993945635544787883888848346383698495 +2423342523233632333433246335237343533433233334333444443323353132313343633463333465332326351333333334 +6344263232422272242424224422515334244122441742373344127332642244342423253336652334455642233444244221 +4263222346764242353521553213434222362433623533235353535585333465253355334342446845362314533328455267 +2352965611464332545522224622622269132252542635626322524376442226625438554233234622342433435545433313 +7323327223321312222431322512122333293352222353221313233745233349244221322155228222227632222422232171 +4326155213655552256512115121566354636136336552412561526153523121311531121533431451212556162545643789 +5754355435343324253533474525445715255295353443643538443532445356253335444352435635433353534535334354 +1271122342123362222212332537262221711532123232227721212522222212322732151753735243123225224213212252 +6463363666333363333325623339132554532136343563335757733633631363253322631433333154335335363493339532 +2523333425344543443444643443342325444544444423494444236854344233243432334344432722242473453433534366 +2332332333312227122221115322332223423336224332223211112222323332222212232123112122222221322233233333 +3352123122422232333233232124423212223323231335334223224334431722223211233214322221225332223132221434 +2122222213221221122322222312222222122232121242222212223611122112232322122123222221242212322221122313 +4743535342523226355254245435553345242623344255654364336533333535437534333314533534534253164436442541 +3112443243433125642325443346222222234447122132242422333224222433434142332224433443223222322252422312 +2314223441352322235351313332813662334232336242421232625625125235342524315124328232632322353381752532 +1321312113522222222132428255822223431534222333222322127222222232462423273962121334337252226533329322 +3221624624232121223222123232131234221232221224211222222212223232442132223121442315222221342125252622 +4483394723635394396667347743455135692368657265583357786648362838632545678857725656526543435876486652 +1224184722344322735523331333244222143233234322725232332323232242823123727222222332124228713215634312 +2275392555547777262322627451576277225376642682278371683162746494667733537762746466661465734845254313 +4222332231231222223113322422232143221122223222232232222422222226222332222233221112221212423423335232 +3222222232213221222422234222121222322253221223432112227122223222222323322323121222222211225232222222 +2422122242211222323222221522132322231221422244212322233411322212443351228413222332221512223222222213 +5245543633253455535554552764544455427555664448115455531542265564635526566445465155353554542386664233 +5434346922335634653243472353213634535334323432227224252436227334324223344444623367423532254235384343 +4633342333532432473433333124334233233233323334832333332366334435134337434224343414938345333344343314 +2221222225212225442422232562222222322222112522212481212211215222212213212541223112222211222122222222 +5694776587383666549676857664776588476789497745567875666757688657557536667667676644655867778623875796 +2534337328354633343333338223225332738313322421432622343766359535233382832633398836333343633433334386 +1446633435234129323323221224324462623226232241125233222422226222232223425732455224343262332222513423 +4512222213322123232132212223444112325322123223523422222231222222625222322222618122414227221225232227 +2122322223222112152242254122222322222222121322232231441324222232322223125221232222232212211221221432 +6863545545464444555563676447546566665474647664456666634564545557666345664476667556444246656467666764 +2326676167724331422152357465746376732174525361276522582166545431561612168556327256243745256151254862 +1332333337323333337233643113232334332223432337323424312247233341126533333328332233333223382233123332 +4212215222232222232522235232123212112432224222121224111333122122234222121212212229222212224212222234 +2114142122131222122222329222222248233225234422562244222234233632321432342222322442223231421111123223 +2542222322222212351222223214512221222222222521222112112222212221222222222222222222222162223222221212 +3313272252433343232332224323233222332332314246443723243374234843432354322341323234423233331138422343 +8666775223668486264566665663754476385565425443653176855516453564536561654562445534468566555536643535 +9324623423322324432342333223231214223142334342232224324224373223312232332531311223421323335133332622 +5343552231633243453333254445914343224433413434633535554436524544161255444413464434476433432434393423 +7445434345312445263153553445434553731434553545435344734334346533653534233554294335326233332533333455 +3333344253342224454424324323242242333312543563444522333424532463444333142234233233444234323323234333 +2222531222222122122263322152342226241435532222525152122222252224255635263522221225226522772333312253 +2444624232244222222452543534523323222273332525238435434333253632223555314414422253372123232252455334 +4343222323243233231323332253332252321222333316432433315232332223224233113133232243542533232354324413 +5224323342423422643424522434452255434322212233334112323323413224112226726433324433342352473455124343 +3112342322222342233533253714232224332332424323123422346222324313433231444325322122434723422332442554 +4364626518148264863562242812855688268522322247837437343228747282724856376242744465514322353826275872 +4325563352246244452433843593844543872752655444596652253552425557442644658443535454644685555455545444 +4443233444431333346334313443332632132534434233755647455245634222245643443373443134314345433347257424 +3213222314444543152212345232552225322623945438343222443122226234435213217222262225332243131325431222 +2612643726266132352434213214225746772323262528344341422532736612437156235752722312513426144384213248 +6554245235343623374545322322232262352555355522253233434322535644616853431515312625523235222535252755 +4764453447465444554744564468453445356567434465264427435564465445376455656446434155445364844444545343 +8329422757353332339343335433557333346673532333555333235384665634883354747324384233363444333224233943 +2344441231242244223145423332321122251245332222342244524334531445222422345332422321422422353542442242 +2821284232112182221222232221122322362222224521322125231132328222144224512212227563231222233285267321 +4133423113342242213471222132223233222222221432224514252232333342322223222222222133225522231232122231 +6667777665767355577246667364868645658666573745577566547645568555546565644553572373357556688665356765 +2223352425163222261223631221242221362234132273472242166222222222272111232421262241222212271346212522 +2323223221633322314222292224212432252233331122221221421432322222122332723332424123233232123324222232 +5681454748886666436471666564865678656675685966455454978755964956588668495844345578655659778568577466 +2221212222252222222222121212222122322122211223211243521222222212212322222226123232322311221222232322 +4244436433344343747644967434443475474445434443454444347344443554356454343374544465554546455844724454 +4444542723545444253244342343314344714434344254244425354345453433323334544545323435544552343315433523 +2282222222232133322242232636243222426235251422511621622722524231517141122721418134262744345224464225 +4432544222242233222111323152422231422232322322323361313223225122222332326253122212312322123323223335 +8315342534563353445532515535545454225455442254525233515524214643524535252463324363433225552452155243 +3243333835232464629333333332133583345433322234545337333333233634432723337233424273332322331335524333 +7775836675257852656788586747666366795765955166755556555772443557476865744173737584646524636425586865 +6327732564242541717416565362153666714464334551223621665633215652523557674541676136113627724371251189 +7222413125333492222735335259894222222331784522235235233866392234133632143112135223343312324732734633 +3133599854653544633254452743223448574448524324341526544353424265236453422227944343325624335523523325 +3383233563353254363233252335446452233332314545225233331435246223325432344235241231215233243335321351 +5283743532356243382754443234323567363433683225432663313823326385344472336333223722863266813332331633 +3333333533333333243353333433233533433333333333334232524333432131333333133334325338233228323353434332 +2434522444334824232333834328633434432133547433442433222332732536231454133433328345243365332243442412 +5346744554322474546253146563323334934333673654253435545756445352134675346364744683223263633468553436 +9446241324454384553612154626334344354243423546426264387136579523252425452434115354254542444142322233 +5142224237522322263334653243232348631322322444624135226212365224432622233532326432252332532245523535 +2242312122222121222232222222422222232226212222321222222112222223212221222222143122222122224232131222 +4333213324315223323233332233223322433122322311334232332252325222334334513333224333353432322333315312 +3243431133321223123234443341413122311332144212111213241233324222113123423324433133433234113443456789 +5634667657647674764669664544455657555666894556795878648554676765469766346396546553956654664655979766 +8884588655466862587662757746273847883588687578486487693633664783553366539688656385784482558866824855 +4343233343232323331332525353132334234335253241332533323351323332222242333313433433532422333332343423 +2129322211472244125422725182523531632212225322224131322322762232173632262323336322217223222622323153 +3542323413332225154323121162742394423634343233323214333353352524425353832242937512533543525433345533 +3237354332352464326312357272332445323323722232245136555453733322234232233323323741332623722293338684 +8512475943622147162342421121444912125783325125253254326125611215244322291724476821524822623256222222 +6468546755356443538763275555555555555456275557157665765544554645745575455555554544655655457567747437 +3338753777552335737725738336127712286276448275224477577712275676257222827162372462785782576242527236 +3313123324221222263523313421232255432444442433236534344224223344521455343122124523223443363322541224 +1422322222963322866243556212348351267311532817223522466422742623223457828642532858974243522536553236 +5873951548443384213834966659455347423246348444342245438642636548325424563576265654545351674256376354 +6763663447569764557434684366554576556676763667476583777466774764348559636743663455287456456434255763 +6454574422127464322262131647527465222425545544286744456557252376446536312254222467422542413427254652 +2473544522272316212365555264456557373514242343359245213441334225723226526942364553662563355112831425 +2321121222322227232233312133322121223136324322223252132122323382444414112312342311844215122212143311 +8243445458852357472743563536446344365346465648358779484458766885347745627348566646394356775368573435 +3162521122244233322235333552425353136244552363322213154463443223332222346545323545222521524231345635 +4344424442444544444455643434344424576475556544344554255676734554444444644344425445546444434354645255 +6667545212351333847832222239533536337252521261536621126756321326622558234635632272751321223285226616 +7214212321222232321352344242217226231341327232253252122531542325122222122423552433232322219243322142 +2223343313112133432232123231332934423222263433233421422224282333234434323224728348172212232223133322 +2122212322232122222123242112222112222123222221222212322222121221323321221222222221222232222222212222 +4344645754635444545432443444653483434462655345644734533934423445346544887344444445343434344544447444 +8316246323427554234525264232545334223354333162652543236443234322535346441153333355352246236244426635 +5244422547344354454229422453543414546164455567212443424414432464422354445534354254242325482364444456 +2355236225222335412227136543442431536357752222235421626423536515815556364666542636442245151647713365 +3223343242334432834443123652412444442243623323347432735214134211344543452423714244445532623333354442 +2433211424331433131532323343233333233224434223232163413533432232233333361232342343353335324333332334 +2322322535653232132222326225333262433232222232135322627231233734231433222272712332531126323222313223 +2232622342213132315332236213523242224732653216544222522531223336711822224215231232124355622154134332 +4127341542551574132245222482455744534244345555342254214553434778328333252564442225235753454447321536 +2112222223222122512222412224251242212121253241222322421222221222232122132212221422262252222326322322 +3325322223332222122522332251272231322323241331115344353122232233423222231143335323321321223233332222 +5456374666596265542483652232976185654885418526439262254942626272386274543886646498165662662214296812 +2246522121222326841695223326322235241524522462412352242544212282234224227296251633223266132215562422 +4144334241319533314341323444244424123542424323224132433321432524443531345414324244334144454324422434 +3333348233343314322733335632431333432324343232733333334233453333636644333333254337323323233362539344 +5423535541445444526555335543475294443555265555334264253325432552455615555452475442243455443443554234 +3312322431332232322332423221123122123232254226232212242311323233322322231221232431213123222223331223 +2325467754555585565274353593447365455848353586845687456693833374633573677635354581653264583535263885 +2421233333223223642235723422223322318514328152739122362516332163129531341222352438252321421131662331 +8665965876994267365676677376236997476634596655554665368657875557666473647656777526385667647367425584 +3133232142312334144222212112353533232323365332623235242322622511322325312352421532253223222232222322 +2262251526236223222223275212352821772226226423243243323233822253822222373222233222371212216224262628 +3542432433524543836543352634583533428425264673784442763828346442334626648419329447394236152253895378 +3544383254746247446333443384556256644475448345376355333434212544334433354558865635424442825556564464 +9244854223333374433435443333353432823832365529344434222432825432422343434632224337224345322322423443 +3413444421136432442453246443464224663313311422344646274363473232326253144343462443444144386334322422 +3323622322252422312523222272228622121321722322152624226321252123361231152633332242425133322226222223 +2535395444854232434443441332423233353333715614536494345422443347332326523253415515441424312333423232 +3353525353783717336364265137223323773332722358333835295335543323422483283345327333237343533735365631 +2322222222534215865212222122221231312222212222222522222252221131223612142212222125226322522312521211 +8274757447565774566446877657776757547777876676726767757576677756748747667556676765795894647775676836 +3522322221443342352423244313354452412244343332352511321453442334323332433234353242242324323332244432 +3323653373223526335437495214343223368332262373327353176335153315364323343354332344225553323555862233 +5445572947276342475814553155614653426422125322225233532421555724225352473827682732352724732427624323 +2122212242222223222224222222225222222212221223212222221222122532272223312223211233412122222224252225 +4352383274336353343535563343453422543314823333534736336333338338336533434335234334423432233233446622 +3334234442343254424613423534444422453452434433235434414121352243512344233324434332513422475311832834 +3412442414143435354145322151351331121135354455434344151134422352541141441245254315435234435254516789 +7146243721132655922232142237322352212135232224734312142342123462432526565424226335533632213265326635 +1332235443332212363424324412228131864368242362332437122326262334342424212223543132243125629253243237 +1241736336562322675336625225423232634164232756225624612532743393323262166256511543273232262352716843 +3246333641434544333433343332544564333334331364354544333336333333263335343352435434334433334423443465 +6664444256354363495923666453638624436445866437966554895395589523436734547329585797233523483374725535 +2423733111235432321533333333343422222362235325233223122252123233232132434311522352632243332272322213 +2352142632153322232352222212255237213322223332233322422323236222322521235222323222324263222432313652 +6544442443424443423243431343542343411444512445343354134413444454424244344344423354445524384433937445 +5412433423244153443344369233424262344242434633541422334212633222232333434535442333464333331132343222 +3333732536553464934346543544722383365364834463627647434734646941254332423346343533323333473367488336 +1122332831432322231322642522332132222463222325231322131222313132223233221343223222122234335532524224 +4622322276147552262222522728514856263223237235621322222643628642112662422624626225218573717222221922 +2322622235211311722226222212222211253124322532322322152252222121312222412423213212251423211323412232 +5252223531122212522225341126257232324322622222322111222441273222341324322242422531235532242262242526 +3658445242623474644526466256442365856444464234633345551145462562562334444343554563363633346522343266 +2242333914327222422113223321332323231933334522323334113434323432333221333324262322533632332312213247 +2344128112677718625645641532155754881773581838513447337486625733777145383315287587274773844365727619 +1242626433932672998226851243323432222434221923744223622541434243233694224382433273233232487222439584 +1462122315221312642621363923346132232212251232322223222126322313334237256135223335342233532252423212 +3365322623124412616561578136634323435236473533247126333573335324243562323453532338321737227463322232 +4732333477336442363335144333625313972472233442533784331233274327346464524264742232373353322216332547 +3653325425525435222613282623323232136322246323222663221342413333522324332322242313222332322333351255 +4344333444433443432324132432124243644432335524424343333323313441454434341442543334233463323422444342 +1222253173224471356324445225337153316472125262721252552222722335252724211445254454512122431236423138 +7325226344367293663534935678334434334522894833232535632273132462432251726579355732227666546387733253 +5222235422311142231235252326224322723222227692233542223236627222537359237336182127427223332422622571 +1212324222212212231555142461225442123322224245222124212225222222554252235231262145222254246612222132 +3343456333334233326163422222436333341413333343223442444324233213323323233222233324333342362433433243 +5242324222472544522514513253223342522623412125322545123522422229462325562234225242652322232152522322 +3123222211323452222232324122222222144112353242235323126122252212414252234212222242232222222612213322 +4222223222612222212123443321232423441232422222123222324227241134244482222221331212122212232113464222 +2574442644525476475523759156245365523735357423645472354523537363465644737342547739554443552352544555 +6797796758669666866778699666597896979669998887768676759476676746966678986876575596887566986678789896 +3533463434153424244341352523214855244345324452544333534244455345554574535422243445327231522548153423 +8945435632654655555569524588542955383154653525565464767465282865453459744946354566622666433846655545 +4443643245326134443243455215352322224563634172144223324622713454322452635263242244324451224524542481 +2332351412223525223322222222122132321213314322122433212231232321331422124441121122224223222242212212 +8347746465549236644542999639825787796367996837855363266895862457593656589493494366731898836266662777 +4424354676333339442474444434444431444464349769463134635934583654444544325845361424874634496848144343 +2212334322343334333444423132132353333334343332232343333332323434233533333335432322312333223332223434 +4536334834426354666653548333733764333733325524343558454435334323934332564372337559263534255825234943