summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--5/part2.c7
-rw-r--r--5/part2_fast.c7
-rw-r--r--9/part2.c5
3 files changed, 8 insertions, 11 deletions
diff --git a/5/part2.c b/5/part2.c
index 36364c2..396ea76 100644
--- a/5/part2.c
+++ b/5/part2.c
@@ -68,13 +68,12 @@ int missing_seat_id(const char *filename)
int max = 0;
while (fgets(buffer, 16, file)) {
int tmp = seat_id(buffer);
- if (tmp > max) {
- max = tmp;
- }
-
if (tmp < min) {
min = tmp;
}
+ else if (tmp > max) {
+ max = tmp;
+ }
table[tmp] = 1;
}
diff --git a/5/part2_fast.c b/5/part2_fast.c
index 9c4753e..2334390 100644
--- a/5/part2_fast.c
+++ b/5/part2_fast.c
@@ -59,13 +59,12 @@ int missing_seat_id(const char *filename)
int max = 0;
while (fgets(buffer, 16, file)) {
int tmp = seat_id(buffer);
- if (tmp > max) {
- max = tmp;
- }
-
if (tmp < min) {
min = tmp;
}
+ else if (tmp > max) {
+ max = tmp;
+ }
table[tmp] = 1;
}
diff --git a/9/part2.c b/9/part2.c
index e926a60..28c335e 100644
--- a/9/part2.c
+++ b/9/part2.c
@@ -49,7 +49,7 @@ int exe_program(const char *filename)
cur_num = nums;
do {
- uint64_t min = __LONG_LONG_MAX__;
+ uint64_t min = __UINT64_MAX__;
uint64_t max = 0;
uint64_t sum = 0;
uint64_t *p1 = cur_num;
@@ -57,8 +57,7 @@ int exe_program(const char *filename)
if (*p1 < min) {
min = *p1;
}
-
- if (*p1 > max) {
+ else if (*p1 > max) {
max = *p1;
}