diff options
author | Adam Spragg <adam@spra.gg> | 2023-01-15 10:43:17 +0000 |
---|---|---|
committer | Adam Spragg <adam@spra.gg> | 2023-01-15 10:43:17 +0000 |
commit | 6b991ae9dae2e6f91b94964674ab4c564ccf51f9 (patch) | |
tree | 3d3a0d5a45ca04ce26acee6c1619a63d16bfa54d | |
parent | 8528013fb10ae7aedb6a40f5ece5ee08eb42e9df (diff) |
Puzzle 5: Add `-p` option to choose part 1/2 solution
Like the later puzzles
-rw-r--r-- | 5.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -119,8 +119,24 @@ main(int argc, char ** argv) struct crate ** stack = NULL; regex_t movecmd; - while ((i = getopt(argc, argv, "m:")) != -1) { + while ((i = getopt(argc, argv, "p:m:")) != -1) { switch (i) { + case 'p': + switch (atoi(optarg)) { + case 1: + crates_move = crates_move_9000; + break; + + case 2: + crates_move = crates_move_9001; + break; + + default: + fprintf(stderr, "Unexpected puzzle part %s\n", optarg); + return -1; + } + break; + case 'm': if (strcmp(optarg, "9000") == 0) crates_move = crates_move_9000; |