From cbabfe67e29d6bff028fd13e1867332a00e46b84 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Wed, 15 Dec 2021 15:29:40 +0100 Subject: [PATCH] add some comments --- 15b.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/15b.c b/15b.c index 26881a3..029d305 100644 --- a/15b.c +++ b/15b.c @@ -15,11 +15,9 @@ int maxy = 0; int get_grid(int x, int y) { - if (x == 0 && y == 0) - return 0; int r = grid[y%maxy][x%maxx] + y/maxy + x/maxx; - while (r > 9) - r -= 9; + if (r > 9) + return r % 9; return r; } @@ -73,6 +71,7 @@ int main() int alt = dist[u.y][u.x] + get_grid(v->key.x, v->key.y); if (alt < dist[v->key.y][v->key.x]) { dist[v->key.y][v->key.x] = alt; + //Reinsert with in correct position HASH_DELETE(hh, q, v); HASH_ADD_INORDER(hh, q, key, sizeof(struct point), v, qcmp); } -- 2.20.1