diff options
Diffstat (limited to 'checkouts.c')
-rw-r--r-- | checkouts.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/checkouts.c b/checkouts.c index 5062ecf..a0bfaf2 100644 --- a/checkouts.c +++ b/checkouts.c @@ -1,7 +1,29 @@ -#ifndef CHECKOUT_H -#define CHECKOUT_H +#include "board.h" +#include "checkouts.h" -#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +char *checkouts_suggested(int rem) +{ + if (rem < 2 || rem > 170) + return NULL; + + char *str = NULL, *p = NULL; + char *target; + int i = 3, trem = rem; + while (i && trem && (target = CHECKOUTS[--i][trem - 1])) { + if (i == 2) + p = str = malloc(3 * SEGMENT_MAX_LEN); + else + *p++ = '-'; + p = stpcpy(p, target); + + trem -= segment_points(segment_from_name(target)); + } + + return str; +} char *CHECKOUTS[][170] = { { @@ -715,5 +737,3 @@ char *SETUP_SHOTS[191] = { "T20", // 190 "T19", // 191 }; - -#endif |