Compare commits

..

No commits in common. '82bc109ecf808c935f2b7057e46f5d074ceaa7ac' and '0fb217fb22e4081d12266c6bc46a27427dfabcda' have entirely different histories.

  1. 12
      src/days/12/Day12.cpp
  2. 1
      src/days/12/Day12.h
  3. 5
      src/main.cpp
  4. 7
      src/util.h

@ -61,8 +61,8 @@ map<Day12::Vertex, uint64> Day12::dijkstra(Graph &graph, Vertex start) {
queue.erase(u);
for (const Vertex &v : graph.out[u]){
if (!queue.contains(v))
for (const Vertex &v : queue){
if (!graph.E.contains({u, v}))
continue;
size_t newDist = dist[u] + 1;
@ -100,14 +100,10 @@ Day12::Graph Day12::parseGraph(bool reverse) {
auto checkEdges = [&g, readChar, this](Vertex v1, Vertex v2){
char c1 = readChar(input[v1.second][v1.first]);
char c2 = readChar(input[v2.second][v2.first]);
if (c2 <= c1 + 1){
if (c2 <= c1 + 1)
g.E.insert({v1, v2});
g.out[v1].insert(v2);
}
if (c1 <= c2 + 1) {
if (c1 <= c2 + 1)
g.E.insert({v2, v1});
g.out[v2].insert(v1);
}
};
for (Vertex v : g.V){

@ -10,7 +10,6 @@ class Day12 : public Day {
struct Graph {
set<Vertex> V;
set<Edge> E;
map<Vertex, set<Vertex>> out;
};
map<Day12::Vertex, uint64> dijkstra(Graph&,Vertex);

@ -30,10 +30,7 @@ Input getInput(int day, string key, bool useTestInput, int testFetchIndex) {
string res = cpr::Get(cpr::Url{url}).text;
size_t i1 = findAll(res, "<code>")[testFetchIndex];
size_t i2 = findAll(res, "</code>")[testFetchIndex];
string codeContent = res.substr(i1 + 6, i2 - (i1 + 6));
removeAll(codeContent, "<em>");
removeAll(codeContent, "</em>");
file << codeContent;
file << res.substr(i1 + 6, i2 - (i1 + 6));
file.close();
}
}

@ -31,10 +31,3 @@ inline vector<size_t> findAll(const string& data, const string& toSearch){
return indices;
}
inline void removeAll(string& data, const string& toRemove) {
vector<size_t> indices = findAll(data, toRemove);
std::sort(indices.rbegin(), indices.rend());
for (size_t &i : indices)
data.erase(i, toRemove.size());
}
Loading…
Cancel
Save