advent-of-code

advent of code attempts
git clone git://bvnf.space/advent-of-code.git
Log | Files | Refs

commit 62c49540721a687a0ad0f81c2dffc64ce74dbc14
parent a16869892ffbd4a43473e5ffd0cce452287a1ae5
Author: aabacchus <ben@bvnf.space>
Date:   Mon,  5 Dec 2022 19:03:27 +0000

22.5 in C (cheated initialisation parsing)

Diffstat:
A2022/05/Makefile | 10++++++++++
A2022/05/a.c | 132+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2022/05/b.c | 129+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2022/05/input | 513+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2022/05/input-modified | 503+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 1287 insertions(+), 0 deletions(-)

diff --git a/2022/05/Makefile b/2022/05/Makefile @@ -0,0 +1,10 @@ +.POSIX: + +CFLAGS = -Wall -Wextra -pedantic -Og -g -D_XOPEN_SOURCE=500 + +all: a b +a: a.c +b: b.c + +clean: + rm -f a b diff --git a/2022/05/a.c b/2022/05/a.c @@ -0,0 +1,132 @@ +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +#define NUM_STACKS 9 + +struct stack { + char c; + struct stack *next; +}; + +struct stack *stacks[NUM_STACKS]; + +void +stack_init(unsigned n) { + /* NULL means bottom of the stack. */ + stacks[n-1] = NULL; +} + +char +stack_pop(unsigned n) { + char c; + struct stack *old; + + if (stacks[n-1] == NULL) { + fprintf(stderr, "stack underflow!\n"); + exit(1); + } + + c = stacks[n-1]->c; + old = stacks[n-1]; + stacks[n-1] = stacks[n-1]->next; + free(old); + return c; +} + +void +stack_push(unsigned n, char c) { + struct stack *new = malloc(sizeof (struct stack)); + if (new == NULL) { + perror("malloc"); + exit(1); + } + new->c = c; + new->next = stacks[n-1]; + stacks[n-1] = new; +} + +void +stack_destroy(unsigned n) { + struct stack *j, *i = stacks[n-1]; + while (i != NULL) { + j = i->next; + free(i); + i = j; + } +} + +int +main(int argc, char **argv) { + char *buf = NULL; + size_t buflen = 0; + ssize_t n; + FILE *f; + + for (int i = 1; i <= NUM_STACKS; i++) + stack_init(i); + + if (argc != 2) { + fprintf(stderr, "usage: %s input\n", argv[0]); + return 1; + } + + f = fopen(argv[1], "r"); + if (f == NULL) { + perror(argv[1]); + return 1; + } + + /* initialise stacks */ + char inits[][9] = { + "QMGCL", + "RDLCTFHG", + "VJFNMTWR", + "JFDVQP", + "NFMSLBT", + "RNVHCDP", + "HCT", + "GSJVZNHP", + "ZFHG"}; + for (unsigned i = 0; i < sizeof(inits)/sizeof(inits[0]); i++) { + for (int j = 0; inits[i][j] != '\0'; j++) { + stack_push(i+1, inits[i][j]); + } + } + + + while ((n = getline(&buf, &buflen, f)) != -1) { + if (buf[n - 1] == '\n') { + buf[n - 1] = '\0'; + n--; + } + unsigned num_to_move, from, to; + int ret; + if ((ret = sscanf(buf, "move %u from %u to %u", &num_to_move, &from, &to)) != 3) { + fprintf(stderr, "couldn't parse line \"%s\"\n", buf); + free(buf); + exit(1); + } + else if (ret == EOF) { + perror("sscanf"); + free(buf); + exit(1); + } + + for (unsigned i = 0; i < num_to_move; i++) { + char c = stack_pop(from); + stack_push(to, c); + } + } + + free(buf); + fclose(f); + + for (int i = 1; i <= NUM_STACKS; i++) { + printf("%c", stacks[i-1]->c); + stack_destroy(i); + } + printf("\n"); + + return 0; +} diff --git a/2022/05/b.c b/2022/05/b.c @@ -0,0 +1,129 @@ +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +#define NUM_STACKS 9 + +struct stack { + char c; + struct stack *next; +}; + +struct stack *stacks[NUM_STACKS]; + +void +stack_init(unsigned n) { + /* NULL means bottom of the stack. */ + stacks[n-1] = NULL; +} + +char +stack_pop(unsigned n) { + char c; + struct stack *old; + + if (stacks[n-1] == NULL) { + fprintf(stderr, "stack underflow!\n"); + exit(1); + } + + c = stacks[n-1]->c; + old = stacks[n-1]; + stacks[n-1] = stacks[n-1]->next; + free(old); + return c; +} + +void +stack_push(unsigned n, char c) { + struct stack *new = malloc(sizeof (struct stack)); + if (new == NULL) { + perror("malloc"); + exit(1); + } + new->c = c; + new->next = stacks[n-1]; + stacks[n-1] = new; +} + +void +stack_destroy(unsigned n) { + struct stack *j, *i = stacks[n-1]; + while (i != NULL) { + j = i->next; + free(i); + i = j; + } +} + +int +main(int argc, char **argv) { + char *buf = NULL; + size_t buflen = 0; + ssize_t n; + FILE *f; + + for (int i = 1; i <= NUM_STACKS; i++) + stack_init(i); + + if (argc != 2) { + fprintf(stderr, "usage: %s input\n", argv[0]); + return 1; + } + + f = fopen(argv[1], "r"); + if (f == NULL) { + perror(argv[1]); + return 1; + } + + /* initialise stacks */ + char inits[][9] = { + "QMGCL", + "RDLCTFHG", + "VJFNMTWR", + "JFDVQP", + "NFMSLBT", + "RNVHCDP", + "HCT", + "GSJVZNHP", + "ZFHG"}; + for (unsigned i = 0; i < sizeof(inits)/sizeof(inits[0]); i++) { + for (int j = 0; inits[i][j] != '\0'; j++) { + stack_push(i+1, inits[i][j]); + } + } + + + while ((n = getline(&buf, &buflen, f)) != -1) { + if (buf[n - 1] == '\n') { + buf[n - 1] = '\0'; + n--; + } + unsigned num_to_move, from, to; + if (sscanf(buf, "move %u from %u to %u", &num_to_move, &from, &to) != 3) { + perror("sscanf"); + free(buf); + exit(1); + } + char to_push[num_to_move]; + for (unsigned i = 0; i < num_to_move; i++) { + char c = stack_pop(from); + to_push[i] = c; + } + for (int i = num_to_move-1; i >= 0; i--) { + stack_push(to, to_push[i]); + } + } + + free(buf); + fclose(f); + + for (int i = 1; i <= NUM_STACKS; i++) { + printf("%c", stacks[i-1]->c); + stack_destroy(i); + } + printf("\n"); + + return 0; +} diff --git a/2022/05/input b/2022/05/input @@ -0,0 +1,513 @@ + [G] [R] [P] + [H] [W] [T] [P] [H] + [F] [T] [P] [B] [D] [N] +[L] [T] [M] [Q] [L] [C] [Z] +[C] [C] [N] [V] [S] [H] [V] [G] +[G] [L] [F] [D] [M] [V] [T] [J] [H] +[M] [D] [J] [F] [F] [N] [C] [S] [F] +[Q] [R] [V] [J] [N] [R] [H] [G] [Z] + 1 2 3 4 5 6 7 8 9 + +move 5 from 8 to 2 +move 2 from 4 to 5 +move 3 from 3 to 9 +move 4 from 1 to 8 +move 5 from 9 to 1 +move 3 from 3 to 8 +move 2 from 4 to 7 +move 6 from 6 to 5 +move 5 from 2 to 4 +move 2 from 9 to 1 +move 1 from 7 to 1 +move 4 from 7 to 3 +move 5 from 1 to 5 +move 3 from 1 to 4 +move 8 from 5 to 3 +move 7 from 3 to 2 +move 10 from 4 to 7 +move 1 from 7 to 3 +move 1 from 6 to 2 +move 3 from 8 to 4 +move 4 from 3 to 2 +move 1 from 1 to 2 +move 4 from 3 to 1 +move 2 from 1 to 7 +move 3 from 5 to 1 +move 7 from 8 to 4 +move 9 from 5 to 1 +move 9 from 2 to 7 +move 6 from 4 to 9 +move 14 from 7 to 5 +move 2 from 1 to 4 +move 6 from 7 to 1 +move 4 from 4 to 9 +move 6 from 2 to 8 +move 2 from 4 to 9 +move 2 from 9 to 3 +move 3 from 8 to 3 +move 5 from 9 to 4 +move 1 from 2 to 9 +move 5 from 5 to 3 +move 3 from 2 to 7 +move 1 from 1 to 4 +move 3 from 7 to 5 +move 4 from 9 to 6 +move 2 from 9 to 3 +move 5 from 1 to 6 +move 7 from 6 to 5 +move 1 from 2 to 3 +move 10 from 1 to 5 +move 1 from 8 to 3 +move 14 from 3 to 7 +move 1 from 8 to 4 +move 2 from 6 to 1 +move 28 from 5 to 9 +move 1 from 2 to 1 +move 5 from 4 to 6 +move 2 from 4 to 3 +move 13 from 7 to 8 +move 1 from 3 to 5 +move 1 from 5 to 2 +move 1 from 3 to 6 +move 1 from 5 to 6 +move 22 from 9 to 1 +move 1 from 2 to 7 +move 3 from 9 to 5 +move 2 from 7 to 5 +move 18 from 1 to 4 +move 7 from 8 to 3 +move 4 from 6 to 8 +move 2 from 5 to 8 +move 5 from 3 to 9 +move 2 from 5 to 1 +move 3 from 6 to 8 +move 1 from 5 to 9 +move 2 from 3 to 6 +move 10 from 1 to 5 +move 15 from 8 to 6 +move 10 from 6 to 8 +move 1 from 9 to 4 +move 1 from 1 to 3 +move 4 from 4 to 3 +move 5 from 3 to 5 +move 9 from 5 to 6 +move 13 from 6 to 5 +move 8 from 5 to 7 +move 8 from 9 to 6 +move 2 from 6 to 4 +move 2 from 6 to 2 +move 3 from 7 to 4 +move 2 from 2 to 8 +move 1 from 5 to 4 +move 3 from 7 to 9 +move 1 from 5 to 9 +move 5 from 6 to 9 +move 10 from 8 to 3 +move 3 from 8 to 1 +move 5 from 9 to 2 +move 1 from 6 to 4 +move 4 from 5 to 6 +move 7 from 3 to 7 +move 5 from 6 to 5 +move 19 from 4 to 8 +move 15 from 8 to 3 +move 2 from 1 to 5 +move 7 from 5 to 9 +move 2 from 7 to 2 +move 3 from 3 to 8 +move 5 from 5 to 8 +move 10 from 9 to 3 +move 1 from 4 to 2 +move 10 from 8 to 3 +move 29 from 3 to 2 +move 2 from 3 to 4 +move 1 from 1 to 5 +move 2 from 8 to 4 +move 1 from 9 to 1 +move 1 from 3 to 9 +move 1 from 1 to 9 +move 2 from 3 to 4 +move 33 from 2 to 1 +move 2 from 2 to 4 +move 1 from 3 to 1 +move 22 from 1 to 2 +move 6 from 4 to 9 +move 4 from 7 to 1 +move 16 from 1 to 4 +move 3 from 7 to 6 +move 2 from 9 to 4 +move 1 from 5 to 2 +move 9 from 4 to 2 +move 1 from 6 to 5 +move 7 from 4 to 2 +move 6 from 9 to 8 +move 4 from 4 to 9 +move 4 from 8 to 3 +move 2 from 4 to 3 +move 2 from 2 to 5 +move 2 from 5 to 2 +move 1 from 5 to 6 +move 3 from 9 to 5 +move 1 from 6 to 8 +move 2 from 6 to 5 +move 1 from 3 to 2 +move 1 from 8 to 4 +move 2 from 8 to 2 +move 5 from 5 to 6 +move 44 from 2 to 8 +move 1 from 4 to 8 +move 3 from 6 to 8 +move 2 from 6 to 2 +move 37 from 8 to 3 +move 1 from 9 to 4 +move 1 from 2 to 5 +move 5 from 8 to 6 +move 1 from 4 to 6 +move 1 from 2 to 4 +move 16 from 3 to 2 +move 1 from 4 to 5 +move 1 from 8 to 3 +move 4 from 8 to 2 +move 1 from 8 to 7 +move 2 from 5 to 8 +move 15 from 2 to 4 +move 5 from 6 to 3 +move 1 from 7 to 4 +move 1 from 8 to 9 +move 1 from 6 to 7 +move 1 from 8 to 3 +move 2 from 2 to 8 +move 1 from 9 to 3 +move 2 from 8 to 4 +move 1 from 4 to 6 +move 33 from 3 to 7 +move 1 from 6 to 3 +move 1 from 4 to 8 +move 1 from 8 to 9 +move 4 from 4 to 3 +move 9 from 4 to 7 +move 3 from 4 to 8 +move 11 from 7 to 2 +move 14 from 7 to 6 +move 1 from 8 to 3 +move 1 from 9 to 5 +move 1 from 5 to 1 +move 8 from 2 to 9 +move 1 from 8 to 7 +move 6 from 3 to 6 +move 18 from 6 to 4 +move 1 from 2 to 7 +move 1 from 3 to 6 +move 14 from 4 to 2 +move 4 from 4 to 3 +move 3 from 6 to 3 +move 19 from 2 to 6 +move 16 from 6 to 8 +move 1 from 1 to 8 +move 16 from 8 to 7 +move 3 from 9 to 4 +move 3 from 6 to 2 +move 3 from 4 to 7 +move 4 from 3 to 2 +move 2 from 2 to 4 +move 4 from 9 to 8 +move 5 from 2 to 8 +move 29 from 7 to 5 +move 6 from 8 to 2 +move 2 from 3 to 4 +move 2 from 2 to 6 +move 1 from 3 to 5 +move 4 from 2 to 6 +move 8 from 7 to 5 +move 1 from 7 to 5 +move 2 from 8 to 6 +move 1 from 8 to 7 +move 6 from 6 to 1 +move 2 from 7 to 6 +move 1 from 9 to 7 +move 3 from 1 to 7 +move 3 from 6 to 1 +move 1 from 7 to 6 +move 3 from 1 to 6 +move 1 from 1 to 5 +move 4 from 6 to 3 +move 2 from 4 to 2 +move 38 from 5 to 6 +move 3 from 3 to 8 +move 4 from 8 to 6 +move 22 from 6 to 8 +move 1 from 7 to 8 +move 2 from 6 to 2 +move 2 from 5 to 2 +move 2 from 2 to 1 +move 2 from 4 to 6 +move 2 from 2 to 1 +move 1 from 1 to 9 +move 2 from 8 to 5 +move 2 from 2 to 8 +move 2 from 5 to 2 +move 2 from 7 to 2 +move 1 from 3 to 1 +move 4 from 1 to 8 +move 1 from 9 to 5 +move 1 from 1 to 7 +move 1 from 2 to 8 +move 29 from 8 to 3 +move 15 from 3 to 2 +move 12 from 2 to 5 +move 1 from 1 to 6 +move 3 from 2 to 1 +move 6 from 3 to 8 +move 2 from 3 to 9 +move 1 from 6 to 7 +move 12 from 5 to 8 +move 2 from 7 to 1 +move 2 from 1 to 4 +move 2 from 4 to 2 +move 1 from 5 to 8 +move 1 from 3 to 6 +move 2 from 3 to 4 +move 3 from 1 to 4 +move 5 from 8 to 9 +move 4 from 4 to 2 +move 5 from 9 to 6 +move 26 from 6 to 8 +move 7 from 2 to 8 +move 3 from 3 to 1 +move 1 from 6 to 4 +move 14 from 8 to 6 +move 2 from 1 to 2 +move 1 from 1 to 3 +move 18 from 8 to 5 +move 15 from 8 to 2 +move 5 from 6 to 8 +move 4 from 5 to 8 +move 7 from 2 to 5 +move 2 from 9 to 6 +move 1 from 2 to 1 +move 7 from 2 to 3 +move 7 from 8 to 1 +move 2 from 6 to 3 +move 1 from 4 to 6 +move 2 from 8 to 6 +move 10 from 3 to 9 +move 18 from 5 to 8 +move 1 from 4 to 6 +move 2 from 1 to 9 +move 12 from 6 to 9 +move 1 from 6 to 9 +move 9 from 8 to 4 +move 6 from 1 to 2 +move 3 from 8 to 9 +move 14 from 9 to 8 +move 5 from 4 to 9 +move 2 from 4 to 5 +move 16 from 8 to 5 +move 12 from 5 to 4 +move 7 from 5 to 1 +move 1 from 1 to 8 +move 1 from 5 to 8 +move 1 from 4 to 9 +move 8 from 2 to 7 +move 12 from 4 to 3 +move 2 from 2 to 5 +move 1 from 3 to 2 +move 3 from 5 to 4 +move 1 from 4 to 8 +move 3 from 4 to 9 +move 18 from 9 to 8 +move 8 from 3 to 1 +move 5 from 8 to 1 +move 1 from 2 to 5 +move 3 from 7 to 1 +move 3 from 7 to 5 +move 1 from 8 to 9 +move 5 from 9 to 7 +move 2 from 3 to 6 +move 16 from 1 to 4 +move 14 from 8 to 6 +move 2 from 5 to 6 +move 4 from 1 to 6 +move 3 from 4 to 9 +move 15 from 6 to 1 +move 5 from 4 to 3 +move 2 from 8 to 2 +move 6 from 4 to 3 +move 15 from 1 to 5 +move 14 from 5 to 3 +move 5 from 6 to 2 +move 2 from 4 to 7 +move 1 from 1 to 6 +move 2 from 3 to 4 +move 3 from 8 to 1 +move 1 from 5 to 1 +move 5 from 7 to 1 +move 7 from 1 to 3 +move 3 from 6 to 2 +move 4 from 9 to 5 +move 2 from 4 to 3 +move 4 from 7 to 9 +move 8 from 2 to 9 +move 1 from 9 to 1 +move 2 from 2 to 8 +move 11 from 9 to 1 +move 6 from 5 to 1 +move 21 from 3 to 2 +move 1 from 8 to 5 +move 5 from 1 to 7 +move 12 from 1 to 8 +move 1 from 5 to 2 +move 5 from 3 to 2 +move 4 from 7 to 2 +move 1 from 7 to 8 +move 13 from 2 to 5 +move 13 from 2 to 5 +move 2 from 2 to 1 +move 1 from 1 to 9 +move 26 from 5 to 4 +move 3 from 2 to 7 +move 2 from 3 to 9 +move 1 from 1 to 6 +move 5 from 3 to 2 +move 2 from 9 to 6 +move 1 from 1 to 8 +move 3 from 1 to 6 +move 24 from 4 to 9 +move 13 from 9 to 1 +move 2 from 6 to 2 +move 3 from 7 to 5 +move 2 from 9 to 7 +move 8 from 8 to 3 +move 4 from 8 to 5 +move 2 from 7 to 2 +move 8 from 9 to 4 +move 10 from 1 to 2 +move 1 from 9 to 1 +move 1 from 9 to 2 +move 4 from 3 to 2 +move 4 from 1 to 8 +move 3 from 4 to 8 +move 12 from 2 to 3 +move 3 from 4 to 6 +move 5 from 3 to 2 +move 9 from 3 to 9 +move 4 from 2 to 9 +move 1 from 3 to 7 +move 6 from 8 to 2 +move 4 from 6 to 8 +move 1 from 3 to 8 +move 6 from 9 to 1 +move 2 from 1 to 8 +move 5 from 5 to 8 +move 3 from 6 to 8 +move 1 from 5 to 1 +move 7 from 8 to 2 +move 1 from 1 to 4 +move 1 from 4 to 6 +move 1 from 9 to 4 +move 1 from 5 to 9 +move 1 from 4 to 7 +move 12 from 8 to 2 +move 4 from 4 to 3 +move 2 from 3 to 1 +move 1 from 7 to 2 +move 1 from 6 to 8 +move 1 from 8 to 6 +move 4 from 9 to 3 +move 1 from 9 to 3 +move 13 from 2 to 3 +move 3 from 1 to 7 +move 2 from 9 to 4 +move 2 from 1 to 9 +move 2 from 7 to 2 +move 1 from 4 to 1 +move 2 from 7 to 5 +move 14 from 3 to 8 +move 1 from 8 to 5 +move 2 from 1 to 4 +move 2 from 3 to 4 +move 2 from 3 to 4 +move 10 from 8 to 3 +move 2 from 4 to 8 +move 1 from 9 to 3 +move 3 from 2 to 3 +move 16 from 2 to 4 +move 1 from 8 to 5 +move 11 from 3 to 4 +move 2 from 3 to 7 +move 3 from 5 to 1 +move 1 from 1 to 2 +move 3 from 2 to 5 +move 1 from 1 to 9 +move 2 from 7 to 4 +move 8 from 4 to 3 +move 1 from 6 to 7 +move 1 from 8 to 6 +move 1 from 5 to 1 +move 6 from 3 to 5 +move 2 from 1 to 3 +move 5 from 5 to 7 +move 2 from 7 to 2 +move 2 from 3 to 4 +move 4 from 7 to 1 +move 1 from 6 to 8 +move 1 from 2 to 1 +move 3 from 1 to 6 +move 2 from 9 to 6 +move 8 from 2 to 1 +move 2 from 6 to 2 +move 2 from 6 to 3 +move 6 from 3 to 5 +move 2 from 4 to 6 +move 2 from 2 to 9 +move 1 from 8 to 6 +move 2 from 6 to 5 +move 1 from 9 to 1 +move 11 from 5 to 8 +move 7 from 8 to 6 +move 23 from 4 to 1 +move 1 from 5 to 9 +move 1 from 4 to 6 +move 2 from 4 to 8 +move 1 from 3 to 1 +move 6 from 8 to 3 +move 2 from 9 to 6 +move 3 from 6 to 1 +move 3 from 8 to 7 +move 1 from 3 to 6 +move 18 from 1 to 2 +move 5 from 3 to 8 +move 13 from 2 to 9 +move 5 from 9 to 7 +move 1 from 8 to 6 +move 5 from 2 to 6 +move 2 from 1 to 7 +move 9 from 7 to 8 +move 11 from 8 to 6 +move 2 from 9 to 4 +move 16 from 6 to 1 +move 2 from 4 to 6 +move 1 from 8 to 9 +move 1 from 7 to 6 +move 8 from 1 to 5 +move 3 from 6 to 5 +move 8 from 6 to 4 +move 7 from 9 to 5 +move 1 from 8 to 1 +move 6 from 5 to 1 +move 9 from 5 to 7 +move 4 from 7 to 9 +move 1 from 4 to 8 +move 1 from 8 to 3 +move 1 from 1 to 8 +move 1 from 8 to 7 +move 22 from 1 to 3 +move 1 from 6 to 7 +move 2 from 9 to 4 +move 1 from 9 to 6 +move 1 from 9 to 4 +move 10 from 4 to 3 +move 1 from 1 to 2 +move 2 from 5 to 4 +move 27 from 3 to 8 +move 5 from 3 to 9 diff --git a/2022/05/input-modified b/2022/05/input-modified @@ -0,0 +1,503 @@ +move 5 from 8 to 2 +move 2 from 4 to 5 +move 3 from 3 to 9 +move 4 from 1 to 8 +move 5 from 9 to 1 +move 3 from 3 to 8 +move 2 from 4 to 7 +move 6 from 6 to 5 +move 5 from 2 to 4 +move 2 from 9 to 1 +move 1 from 7 to 1 +move 4 from 7 to 3 +move 5 from 1 to 5 +move 3 from 1 to 4 +move 8 from 5 to 3 +move 7 from 3 to 2 +move 10 from 4 to 7 +move 1 from 7 to 3 +move 1 from 6 to 2 +move 3 from 8 to 4 +move 4 from 3 to 2 +move 1 from 1 to 2 +move 4 from 3 to 1 +move 2 from 1 to 7 +move 3 from 5 to 1 +move 7 from 8 to 4 +move 9 from 5 to 1 +move 9 from 2 to 7 +move 6 from 4 to 9 +move 14 from 7 to 5 +move 2 from 1 to 4 +move 6 from 7 to 1 +move 4 from 4 to 9 +move 6 from 2 to 8 +move 2 from 4 to 9 +move 2 from 9 to 3 +move 3 from 8 to 3 +move 5 from 9 to 4 +move 1 from 2 to 9 +move 5 from 5 to 3 +move 3 from 2 to 7 +move 1 from 1 to 4 +move 3 from 7 to 5 +move 4 from 9 to 6 +move 2 from 9 to 3 +move 5 from 1 to 6 +move 7 from 6 to 5 +move 1 from 2 to 3 +move 10 from 1 to 5 +move 1 from 8 to 3 +move 14 from 3 to 7 +move 1 from 8 to 4 +move 2 from 6 to 1 +move 28 from 5 to 9 +move 1 from 2 to 1 +move 5 from 4 to 6 +move 2 from 4 to 3 +move 13 from 7 to 8 +move 1 from 3 to 5 +move 1 from 5 to 2 +move 1 from 3 to 6 +move 1 from 5 to 6 +move 22 from 9 to 1 +move 1 from 2 to 7 +move 3 from 9 to 5 +move 2 from 7 to 5 +move 18 from 1 to 4 +move 7 from 8 to 3 +move 4 from 6 to 8 +move 2 from 5 to 8 +move 5 from 3 to 9 +move 2 from 5 to 1 +move 3 from 6 to 8 +move 1 from 5 to 9 +move 2 from 3 to 6 +move 10 from 1 to 5 +move 15 from 8 to 6 +move 10 from 6 to 8 +move 1 from 9 to 4 +move 1 from 1 to 3 +move 4 from 4 to 3 +move 5 from 3 to 5 +move 9 from 5 to 6 +move 13 from 6 to 5 +move 8 from 5 to 7 +move 8 from 9 to 6 +move 2 from 6 to 4 +move 2 from 6 to 2 +move 3 from 7 to 4 +move 2 from 2 to 8 +move 1 from 5 to 4 +move 3 from 7 to 9 +move 1 from 5 to 9 +move 5 from 6 to 9 +move 10 from 8 to 3 +move 3 from 8 to 1 +move 5 from 9 to 2 +move 1 from 6 to 4 +move 4 from 5 to 6 +move 7 from 3 to 7 +move 5 from 6 to 5 +move 19 from 4 to 8 +move 15 from 8 to 3 +move 2 from 1 to 5 +move 7 from 5 to 9 +move 2 from 7 to 2 +move 3 from 3 to 8 +move 5 from 5 to 8 +move 10 from 9 to 3 +move 1 from 4 to 2 +move 10 from 8 to 3 +move 29 from 3 to 2 +move 2 from 3 to 4 +move 1 from 1 to 5 +move 2 from 8 to 4 +move 1 from 9 to 1 +move 1 from 3 to 9 +move 1 from 1 to 9 +move 2 from 3 to 4 +move 33 from 2 to 1 +move 2 from 2 to 4 +move 1 from 3 to 1 +move 22 from 1 to 2 +move 6 from 4 to 9 +move 4 from 7 to 1 +move 16 from 1 to 4 +move 3 from 7 to 6 +move 2 from 9 to 4 +move 1 from 5 to 2 +move 9 from 4 to 2 +move 1 from 6 to 5 +move 7 from 4 to 2 +move 6 from 9 to 8 +move 4 from 4 to 9 +move 4 from 8 to 3 +move 2 from 4 to 3 +move 2 from 2 to 5 +move 2 from 5 to 2 +move 1 from 5 to 6 +move 3 from 9 to 5 +move 1 from 6 to 8 +move 2 from 6 to 5 +move 1 from 3 to 2 +move 1 from 8 to 4 +move 2 from 8 to 2 +move 5 from 5 to 6 +move 44 from 2 to 8 +move 1 from 4 to 8 +move 3 from 6 to 8 +move 2 from 6 to 2 +move 37 from 8 to 3 +move 1 from 9 to 4 +move 1 from 2 to 5 +move 5 from 8 to 6 +move 1 from 4 to 6 +move 1 from 2 to 4 +move 16 from 3 to 2 +move 1 from 4 to 5 +move 1 from 8 to 3 +move 4 from 8 to 2 +move 1 from 8 to 7 +move 2 from 5 to 8 +move 15 from 2 to 4 +move 5 from 6 to 3 +move 1 from 7 to 4 +move 1 from 8 to 9 +move 1 from 6 to 7 +move 1 from 8 to 3 +move 2 from 2 to 8 +move 1 from 9 to 3 +move 2 from 8 to 4 +move 1 from 4 to 6 +move 33 from 3 to 7 +move 1 from 6 to 3 +move 1 from 4 to 8 +move 1 from 8 to 9 +move 4 from 4 to 3 +move 9 from 4 to 7 +move 3 from 4 to 8 +move 11 from 7 to 2 +move 14 from 7 to 6 +move 1 from 8 to 3 +move 1 from 9 to 5 +move 1 from 5 to 1 +move 8 from 2 to 9 +move 1 from 8 to 7 +move 6 from 3 to 6 +move 18 from 6 to 4 +move 1 from 2 to 7 +move 1 from 3 to 6 +move 14 from 4 to 2 +move 4 from 4 to 3 +move 3 from 6 to 3 +move 19 from 2 to 6 +move 16 from 6 to 8 +move 1 from 1 to 8 +move 16 from 8 to 7 +move 3 from 9 to 4 +move 3 from 6 to 2 +move 3 from 4 to 7 +move 4 from 3 to 2 +move 2 from 2 to 4 +move 4 from 9 to 8 +move 5 from 2 to 8 +move 29 from 7 to 5 +move 6 from 8 to 2 +move 2 from 3 to 4 +move 2 from 2 to 6 +move 1 from 3 to 5 +move 4 from 2 to 6 +move 8 from 7 to 5 +move 1 from 7 to 5 +move 2 from 8 to 6 +move 1 from 8 to 7 +move 6 from 6 to 1 +move 2 from 7 to 6 +move 1 from 9 to 7 +move 3 from 1 to 7 +move 3 from 6 to 1 +move 1 from 7 to 6 +move 3 from 1 to 6 +move 1 from 1 to 5 +move 4 from 6 to 3 +move 2 from 4 to 2 +move 38 from 5 to 6 +move 3 from 3 to 8 +move 4 from 8 to 6 +move 22 from 6 to 8 +move 1 from 7 to 8 +move 2 from 6 to 2 +move 2 from 5 to 2 +move 2 from 2 to 1 +move 2 from 4 to 6 +move 2 from 2 to 1 +move 1 from 1 to 9 +move 2 from 8 to 5 +move 2 from 2 to 8 +move 2 from 5 to 2 +move 2 from 7 to 2 +move 1 from 3 to 1 +move 4 from 1 to 8 +move 1 from 9 to 5 +move 1 from 1 to 7 +move 1 from 2 to 8 +move 29 from 8 to 3 +move 15 from 3 to 2 +move 12 from 2 to 5 +move 1 from 1 to 6 +move 3 from 2 to 1 +move 6 from 3 to 8 +move 2 from 3 to 9 +move 1 from 6 to 7 +move 12 from 5 to 8 +move 2 from 7 to 1 +move 2 from 1 to 4 +move 2 from 4 to 2 +move 1 from 5 to 8 +move 1 from 3 to 6 +move 2 from 3 to 4 +move 3 from 1 to 4 +move 5 from 8 to 9 +move 4 from 4 to 2 +move 5 from 9 to 6 +move 26 from 6 to 8 +move 7 from 2 to 8 +move 3 from 3 to 1 +move 1 from 6 to 4 +move 14 from 8 to 6 +move 2 from 1 to 2 +move 1 from 1 to 3 +move 18 from 8 to 5 +move 15 from 8 to 2 +move 5 from 6 to 8 +move 4 from 5 to 8 +move 7 from 2 to 5 +move 2 from 9 to 6 +move 1 from 2 to 1 +move 7 from 2 to 3 +move 7 from 8 to 1 +move 2 from 6 to 3 +move 1 from 4 to 6 +move 2 from 8 to 6 +move 10 from 3 to 9 +move 18 from 5 to 8 +move 1 from 4 to 6 +move 2 from 1 to 9 +move 12 from 6 to 9 +move 1 from 6 to 9 +move 9 from 8 to 4 +move 6 from 1 to 2 +move 3 from 8 to 9 +move 14 from 9 to 8 +move 5 from 4 to 9 +move 2 from 4 to 5 +move 16 from 8 to 5 +move 12 from 5 to 4 +move 7 from 5 to 1 +move 1 from 1 to 8 +move 1 from 5 to 8 +move 1 from 4 to 9 +move 8 from 2 to 7 +move 12 from 4 to 3 +move 2 from 2 to 5 +move 1 from 3 to 2 +move 3 from 5 to 4 +move 1 from 4 to 8 +move 3 from 4 to 9 +move 18 from 9 to 8 +move 8 from 3 to 1 +move 5 from 8 to 1 +move 1 from 2 to 5 +move 3 from 7 to 1 +move 3 from 7 to 5 +move 1 from 8 to 9 +move 5 from 9 to 7 +move 2 from 3 to 6 +move 16 from 1 to 4 +move 14 from 8 to 6 +move 2 from 5 to 6 +move 4 from 1 to 6 +move 3 from 4 to 9 +move 15 from 6 to 1 +move 5 from 4 to 3 +move 2 from 8 to 2 +move 6 from 4 to 3 +move 15 from 1 to 5 +move 14 from 5 to 3 +move 5 from 6 to 2 +move 2 from 4 to 7 +move 1 from 1 to 6 +move 2 from 3 to 4 +move 3 from 8 to 1 +move 1 from 5 to 1 +move 5 from 7 to 1 +move 7 from 1 to 3 +move 3 from 6 to 2 +move 4 from 9 to 5 +move 2 from 4 to 3 +move 4 from 7 to 9 +move 8 from 2 to 9 +move 1 from 9 to 1 +move 2 from 2 to 8 +move 11 from 9 to 1 +move 6 from 5 to 1 +move 21 from 3 to 2 +move 1 from 8 to 5 +move 5 from 1 to 7 +move 12 from 1 to 8 +move 1 from 5 to 2 +move 5 from 3 to 2 +move 4 from 7 to 2 +move 1 from 7 to 8 +move 13 from 2 to 5 +move 13 from 2 to 5 +move 2 from 2 to 1 +move 1 from 1 to 9 +move 26 from 5 to 4 +move 3 from 2 to 7 +move 2 from 3 to 9 +move 1 from 1 to 6 +move 5 from 3 to 2 +move 2 from 9 to 6 +move 1 from 1 to 8 +move 3 from 1 to 6 +move 24 from 4 to 9 +move 13 from 9 to 1 +move 2 from 6 to 2 +move 3 from 7 to 5 +move 2 from 9 to 7 +move 8 from 8 to 3 +move 4 from 8 to 5 +move 2 from 7 to 2 +move 8 from 9 to 4 +move 10 from 1 to 2 +move 1 from 9 to 1 +move 1 from 9 to 2 +move 4 from 3 to 2 +move 4 from 1 to 8 +move 3 from 4 to 8 +move 12 from 2 to 3 +move 3 from 4 to 6 +move 5 from 3 to 2 +move 9 from 3 to 9 +move 4 from 2 to 9 +move 1 from 3 to 7 +move 6 from 8 to 2 +move 4 from 6 to 8 +move 1 from 3 to 8 +move 6 from 9 to 1 +move 2 from 1 to 8 +move 5 from 5 to 8 +move 3 from 6 to 8 +move 1 from 5 to 1 +move 7 from 8 to 2 +move 1 from 1 to 4 +move 1 from 4 to 6 +move 1 from 9 to 4 +move 1 from 5 to 9 +move 1 from 4 to 7 +move 12 from 8 to 2 +move 4 from 4 to 3 +move 2 from 3 to 1 +move 1 from 7 to 2 +move 1 from 6 to 8 +move 1 from 8 to 6 +move 4 from 9 to 3 +move 1 from 9 to 3 +move 13 from 2 to 3 +move 3 from 1 to 7 +move 2 from 9 to 4 +move 2 from 1 to 9 +move 2 from 7 to 2 +move 1 from 4 to 1 +move 2 from 7 to 5 +move 14 from 3 to 8 +move 1 from 8 to 5 +move 2 from 1 to 4 +move 2 from 3 to 4 +move 2 from 3 to 4 +move 10 from 8 to 3 +move 2 from 4 to 8 +move 1 from 9 to 3 +move 3 from 2 to 3 +move 16 from 2 to 4 +move 1 from 8 to 5 +move 11 from 3 to 4 +move 2 from 3 to 7 +move 3 from 5 to 1 +move 1 from 1 to 2 +move 3 from 2 to 5 +move 1 from 1 to 9 +move 2 from 7 to 4 +move 8 from 4 to 3 +move 1 from 6 to 7 +move 1 from 8 to 6 +move 1 from 5 to 1 +move 6 from 3 to 5 +move 2 from 1 to 3 +move 5 from 5 to 7 +move 2 from 7 to 2 +move 2 from 3 to 4 +move 4 from 7 to 1 +move 1 from 6 to 8 +move 1 from 2 to 1 +move 3 from 1 to 6 +move 2 from 9 to 6 +move 8 from 2 to 1 +move 2 from 6 to 2 +move 2 from 6 to 3 +move 6 from 3 to 5 +move 2 from 4 to 6 +move 2 from 2 to 9 +move 1 from 8 to 6 +move 2 from 6 to 5 +move 1 from 9 to 1 +move 11 from 5 to 8 +move 7 from 8 to 6 +move 23 from 4 to 1 +move 1 from 5 to 9 +move 1 from 4 to 6 +move 2 from 4 to 8 +move 1 from 3 to 1 +move 6 from 8 to 3 +move 2 from 9 to 6 +move 3 from 6 to 1 +move 3 from 8 to 7 +move 1 from 3 to 6 +move 18 from 1 to 2 +move 5 from 3 to 8 +move 13 from 2 to 9 +move 5 from 9 to 7 +move 1 from 8 to 6 +move 5 from 2 to 6 +move 2 from 1 to 7 +move 9 from 7 to 8 +move 11 from 8 to 6 +move 2 from 9 to 4 +move 16 from 6 to 1 +move 2 from 4 to 6 +move 1 from 8 to 9 +move 1 from 7 to 6 +move 8 from 1 to 5 +move 3 from 6 to 5 +move 8 from 6 to 4 +move 7 from 9 to 5 +move 1 from 8 to 1 +move 6 from 5 to 1 +move 9 from 5 to 7 +move 4 from 7 to 9 +move 1 from 4 to 8 +move 1 from 8 to 3 +move 1 from 1 to 8 +move 1 from 8 to 7 +move 22 from 1 to 3 +move 1 from 6 to 7 +move 2 from 9 to 4 +move 1 from 9 to 6 +move 1 from 9 to 4 +move 10 from 4 to 3 +move 1 from 1 to 2 +move 2 from 5 to 4 +move 27 from 3 to 8 +move 5 from 3 to 9