Day 7 cleanup

+ Removed an unused sort function
+ Removed unused fuel calc
main
Joey Hines 2021-12-07 19:25:21 -07:00
parent d7a79f15f2
commit d22ae126a9
No known key found for this signature in database
GPG Key ID: 80F567B5C968F91B
1 changed files with 0 additions and 23 deletions

View File

@ -16,25 +16,6 @@ int int64_t_cmp(const void * a, const void * b) {
return (int)*a_int - (int)*b_int; return (int)*a_int - (int)*b_int;
} }
int int64_t_cmp_exp(const void * a, const void * b) {
int64_t * a_int = (int64_t *)a;
int64_t * b_int = (int64_t *)b;
int64_t dist = ((int)*a_int - (int)*b_int);
int64_t exp_dist = 0;
for (int i = 0; i < labs(dist); i++) {
exp_dist += i;
}
if (dist < 0) {
return -(int)exp_dist;
}
else {
return (int)exp_dist;
}
}
static int64_t part_1(int64_t *positions, uint16_t len) { static int64_t part_1(int64_t *positions, uint16_t len) {
int64_t median; int64_t median;
int64_t fuel_cost = 0; int64_t fuel_cost = 0;
@ -78,10 +59,6 @@ static int64_t part_2(const int64_t *positions, uint16_t len) {
return best_fuel_cost; return best_fuel_cost;
} }
int64_t part_2_fuel_calc(int64_t median, int64_t crab_pos) {
return labs(crab_pos - median);
}
int day_7() { int day_7() {
int64_t positions[MAX_POSITIONS] = {0}; int64_t positions[MAX_POSITIONS] = {0};
uint16_t len; uint16_t len;