summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Spragg <adam@spra.gg>2023-01-15 10:43:17 +0000
committerAdam Spragg <adam@spra.gg>2023-01-15 10:43:17 +0000
commit6b991ae9dae2e6f91b94964674ab4c564ccf51f9 (patch)
tree3d3a0d5a45ca04ce26acee6c1619a63d16bfa54d
parent8528013fb10ae7aedb6a40f5ece5ee08eb42e9df (diff)
Puzzle 5: Add `-p` option to choose part 1/2 solution
Like the later puzzles
-rw-r--r--5.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/5.c b/5.c
index 993c555..df7c8bd 100644
--- a/5.c
+++ b/5.c
@@ -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;