summaryrefslogtreecommitdiff
path: root/13.c
diff options
context:
space:
mode:
authorAdam Spragg <adam@spra.gg>2023-01-02 18:13:02 +0000
committerAdam Spragg <adam@spra.gg>2023-01-02 18:13:02 +0000
commitcfe696a7232012d89f56a9b2eb8775c14e0f5acf (patch)
tree60d63317e486ff7699c1ec2f6e0509a507d78a10 /13.c
parent05a0668a056ce5d67a956ff1b84531602eb32cba (diff)
Puzzle 13: Solve part 1 (finally!)
Diffstat (limited to '13.c')
-rw-r--r--13.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/13.c b/13.c
index 9d876b6..42113f7 100644
--- a/13.c
+++ b/13.c
@@ -99,14 +99,14 @@ node_cmp(struct node * l, struct node * r)
ret = l->val_int - r->val_int;
}
else if (node_isint(l)) {
- struct node * tmp = node_create_list(l);
+ struct node * tmp = node_create_list(node_create_int(l->val_int));
ret = node_cmp(tmp, r);
- free(tmp); // Not node_free(), because we don't want to delete the contents
+ node_free(tmp);
}
else if (node_isint(r)) {
- struct node * tmp = node_create_list(r);
+ struct node * tmp = node_create_list(node_create_int(r->val_int));
ret = node_cmp(l, tmp);
- free(tmp); // Not node_free(), because we don't want to delete the contents
+ node_free(tmp);
}
else if (l == LIST_EMPTY && r == LIST_EMPTY) {
return 0;
@@ -229,7 +229,7 @@ main()
if ((j = node_cmp(n->val_list, n->next->val_list)) < 0) {
index_sum += i;
}
-#if 1
+#if 0
node_dump(n->val_list); fputc('\n', stderr);
node_dump(n->next->val_list); fputc('\n', stderr);
fprintf(stderr, "Result: %d (%s)\n", j, j < 0 ? "yes" : "no");