Part 2 done!

master
sigonasr2 12 months ago
parent 661a6268b8
commit 3c207d50eb
  1. 14
      Day 5/main.cpp

@ -24,7 +24,7 @@ void wait(int pauseMs=0){
#pragma endregion #pragma endregion
const int DAY = 5; const int DAY = 5;
Run runInput=FILE1; Run runInput=FILE2;
struct Seed{ struct Seed{
long long val; long long val;
@ -101,18 +101,20 @@ void doStuff(){
} }
for(Seed&seed:seeds){ for(Seed&seed:seeds){
for(long long seedNumb=seed.val;seedNumb<seed.val+seed.range;seedNumb++){ for(long long originalNumb=seed.val;originalNumb<seed.val+seed.range;originalNumb++){
std::cout<<"Initial Number: "<<seedNumb<<' '; long long seedNumb=originalNumb;
//std::cout<<"Initial Number: "<<seedNumb<<' ';
for(std::vector<Transform>&transformList:transforms){ for(std::vector<Transform>&transformList:transforms){
for(Transform&transform:transformList){ for(Transform&transform:transformList){
if(seedNumb>=transform.source&&seedNumb<transform.source+transform.range){ if(seedNumb>=transform.source&&seedNumb<transform.source+transform.range){
seedNumb+=transform.dest-transform.source; seedNumb+=transform.dest-transform.source;
continue; break;
} }
} }
//std::cout<<seedNumb<<" ";
} }
std::cout<<"Number Out: "<<seedNumb<<std::endl; //std::cout<<"Number Out: "<<seedNumb<<std::endl;
if(seedNumb<smallest)seedNumb=smallest; if(seedNumb<smallest)smallest=seedNumb;
} }
} }
std::cout<<smallest<<std::endl; std::cout<<smallest<<std::endl;

Loading…
Cancel
Save