Skip to content

Commit

Permalink
Completed day 12 part 1... part 2 is still computing :/
Browse files Browse the repository at this point in the history
  • Loading branch information
aforgiel committed Dec 13, 2023
1 parent fd5122f commit 866601d
Show file tree
Hide file tree
Showing 11 changed files with 4,994 additions and 77 deletions.
21 changes: 0 additions & 21 deletions AdventOfCodeDay11/AdventOfCodeDay11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,52 +228,31 @@ Map::ExpandCoordinates(std::map<int, int>& coordinates, int max, int increment)
it1 = coordinates.find(value);
if (it1 == coordinates.end())
{
#if COMMENT == true
printf("\t%d:", value);
#endif
for (expended = value + 1; expended <= max; expended++)
{
it2 = coordinates.find(expended);
if (it2 != coordinates.end())
{
it2->second += increment;
#if COMMENT == true
printf(" %d=>%d", expended, it2->second);
#endif
}
}
#if COMMENT == true
printf("\n");
#endif
}
}
}


int64_t
Map::FindSolution(int increment)
{
int64_t result = 0;

for (int i = 0; i < 2; i++)
{
#if COMMENT == true
printf("Expension of %s\n", i == X ? "X" : "Y");
#endif
ExpandCoordinates(coordinates[i], max[i], increment);
}

int i, j;

for (i = 0; i < (galaxies.size() - 1); i++)
for (j = i + 1; j < galaxies.size(); j++)
{
#if COMMENT == true
printf("[%d,%d] ", i + 1, j + 1);
printf("%d\n", Distance(galaxies[i], galaxies[j]));
#endif
result += Distance(galaxies[i], galaxies[j]);
}

return result;
}
Expand Down
Loading

0 comments on commit 866601d

Please sign in to comment.