mirror of
https://codeberg.org/andyscott/advent-of-code.git
synced 2024-11-09 13:50:50 -05:00
Compare commits
5 commits
46af70bb90
...
9bded90d7b
Author | SHA1 | Date | |
---|---|---|---|
9bded90d7b | |||
4288f36403 | |||
0e70725656 | |||
b0a7b6c07d | |||
42c37ff1c8 |
10 changed files with 7139 additions and 0 deletions
45
2022/1.c
Normal file
45
2022/1.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int comp(const void *a, const void *b) {
|
||||
int n = *(int *)a;
|
||||
int m = *(int *)b;
|
||||
return n - m;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "USAGE: %s input_file\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE *fd = fopen(argv[1], "r");
|
||||
if (!fd) {
|
||||
fprintf(stderr, "Error opening file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char line[50] = {0};
|
||||
int idx = 0, elves[1000] = {0};
|
||||
|
||||
while (fgets(line, sizeof line / sizeof *line, fd) != NULL) {
|
||||
if (strlen(line) == 1) {
|
||||
idx++;
|
||||
} else {
|
||||
elves[idx] += atoi(line);
|
||||
}
|
||||
}
|
||||
|
||||
qsort(elves, idx, sizeof(int), comp);
|
||||
|
||||
printf("Elf with the most calories: %d\n", elves[idx - 1]);
|
||||
printf("Elf with the 2nd most calories: %d\n", elves[idx - 2]);
|
||||
printf("Elf with the 3rd most calories: %d\n", elves[idx - 3]);
|
||||
printf("Total: %d\n",
|
||||
elves[idx - 1] + elves[idx - 2] + elves[idx - 3]);
|
||||
|
||||
fclose(fd);
|
||||
return 0;
|
||||
}
|
2250
2022/1.txt
Normal file
2250
2022/1.txt
Normal file
File diff suppressed because it is too large
Load diff
117
2022/2.c
Normal file
117
2022/2.c
Normal file
|
@ -0,0 +1,117 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
struct RPS_Game {
|
||||
// Part 1 Rock / Part 2 Lose
|
||||
const int X;
|
||||
// Part 1 Paper / Part 2 Draw
|
||||
const int Y;
|
||||
// Part 1 Scissors / Part 2 Win
|
||||
const int Z;
|
||||
// Outcomes
|
||||
const int draw;
|
||||
const int win;
|
||||
};
|
||||
|
||||
// Part 1 - Calculate score
|
||||
void process_round(struct RPS_Game *game, int *score, const char opponent_move,
|
||||
const char my_move) {
|
||||
|
||||
switch (my_move) {
|
||||
case 'X': // Rock
|
||||
*score += game->X;
|
||||
if (opponent_move == 'A') {
|
||||
*score += game->draw;
|
||||
} else if (opponent_move == 'C') {
|
||||
*score += game->win;
|
||||
}
|
||||
break;
|
||||
case 'Y': // Paper
|
||||
*score += game->Y;
|
||||
if (opponent_move == 'A') {
|
||||
*score += game->win;
|
||||
} else if (opponent_move == 'B') {
|
||||
*score += game->draw;
|
||||
}
|
||||
break;
|
||||
case 'Z': // Scissors
|
||||
*score += game->Z;
|
||||
if (opponent_move == 'B') {
|
||||
*score += game->win;
|
||||
} else if (opponent_move == 'C') {
|
||||
*score += game->draw;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Part 2 - Find move given a desired result, then calculate score
|
||||
void find_move(struct RPS_Game *game, int *score, const char opponent_move,
|
||||
const char result) {
|
||||
|
||||
char my_move = '\0';
|
||||
|
||||
switch (result) {
|
||||
case 'X': // need to lose
|
||||
if (opponent_move == 'A') {
|
||||
my_move = 'Z';
|
||||
} else if (opponent_move == 'B') {
|
||||
my_move = 'X';
|
||||
} else if (opponent_move == 'C') {
|
||||
my_move = 'Y';
|
||||
}
|
||||
break;
|
||||
case 'Y': // need a draw
|
||||
if (opponent_move == 'A') {
|
||||
my_move = 'X';
|
||||
} else if (opponent_move == 'B') {
|
||||
my_move = 'Y';
|
||||
} else if (opponent_move == 'C') {
|
||||
my_move = 'Z';
|
||||
}
|
||||
break;
|
||||
case 'Z': // need to win
|
||||
if (opponent_move == 'A') {
|
||||
my_move = 'Y';
|
||||
} else if (opponent_move == 'B') {
|
||||
my_move = 'Z';
|
||||
} else if (opponent_move == 'C') {
|
||||
my_move = 'X';
|
||||
}
|
||||
break;
|
||||
}
|
||||
process_round(game, score, opponent_move, my_move);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "USAGE: %s input_file\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE *file = fopen(argv[1], "r");
|
||||
if (!file) {
|
||||
fprintf(stderr, "Error opening file %s\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int part1_score = 0;
|
||||
int part2_score = 0;
|
||||
char round[5] = {0};
|
||||
struct RPS_Game game = {.X = 1, .Y = 2, .Z = 3, .draw = 3, .win = 6};
|
||||
|
||||
while (fgets(round, sizeof round / sizeof *round, file) != NULL) {
|
||||
if (strlen(round) == 1) {
|
||||
break;
|
||||
}
|
||||
process_round(&game, &part1_score, round[0], round[2]);
|
||||
find_move(&game, &part2_score, round[0], round[2]);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
printf("My part 1 score: %d\n", part1_score);
|
||||
printf("My part 2 score: %d\n", part2_score);
|
||||
|
||||
return 0;
|
||||
}
|
2500
2022/2.txt
Normal file
2500
2022/2.txt
Normal file
File diff suppressed because it is too large
Load diff
105
2022/3.c
Normal file
105
2022/3.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// Find badges for part 2
|
||||
char find_badge(char group[3][50]) {
|
||||
|
||||
for (int i = 0; i < strlen(group[0]); i++) {
|
||||
for (int j = 0; j < strlen(group[1]); j++) {
|
||||
for (int k = 0; k < strlen(group[2]); k++) {
|
||||
if (group[0][i] == group[1][j] && group[1][j] == group[2][k]) {
|
||||
return group[0][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Find items for part 1
|
||||
char find_item(char *items) {
|
||||
|
||||
int len = strlen(items);
|
||||
int mid = len / 2;
|
||||
|
||||
for (int i = 0; i < mid; i++) {
|
||||
for (int j = mid; j < len; j++) {
|
||||
if (items[i] == items[j]) {
|
||||
return items[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Updates item_sum / badge_sum when match is found
|
||||
void update_sum(const char c, int *sum) {
|
||||
|
||||
if (c > 64 && c < 91) {
|
||||
*sum += c - 38;
|
||||
} else if (c > 96 && c < 123) {
|
||||
*sum += c - 96;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "USAGE: %s input_file\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE *file = fopen(argv[1], "r");
|
||||
if (!file) {
|
||||
perror("fopen");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char items[50] = {0};
|
||||
char group[3][50] = {0};
|
||||
int item_sum = 0, badge_sum = 0, idx = 0;
|
||||
|
||||
while (fgets(items, sizeof items / sizeof *items, file) != NULL) {
|
||||
|
||||
if (strlen(items) == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Part 1 - find misplaced items
|
||||
items[strlen(items) - 1] = '\0';
|
||||
char match = find_item(items);
|
||||
if (!match) {
|
||||
fprintf(stderr, "Match not found: %s\n", items);
|
||||
}
|
||||
|
||||
update_sum(match, &item_sum);
|
||||
|
||||
// Part 2 - find badges among groups of 3
|
||||
memcpy(group[idx], items, strlen(items));
|
||||
idx++;
|
||||
|
||||
if (idx == 3) {
|
||||
idx = 0;
|
||||
char badge = find_badge(group);
|
||||
if (!badge) {
|
||||
fprintf(stderr,
|
||||
"Badge not found among the following group:\n%s\n%s\n%s\n",
|
||||
group[0], group[1], group[2]);
|
||||
}
|
||||
|
||||
update_sum(badge, &badge_sum);
|
||||
|
||||
for (int i = 0; i < sizeof group / sizeof *group; i++) {
|
||||
memset(group[i], 0, sizeof group[0] / sizeof *group[0]);
|
||||
}
|
||||
}
|
||||
memset(items, 0, sizeof items / sizeof *items);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
printf("Part 1 - Sum of item priorities: %d\n", item_sum);
|
||||
printf("Part 2 - Sum of badge priorities: %d\n", badge_sum);
|
||||
|
||||
return 0;
|
||||
}
|
300
2022/3.txt
Normal file
300
2022/3.txt
Normal file
|
@ -0,0 +1,300 @@
|
|||
DsPhSBQQQhqmBDhPDsFwjwsLjlRjlttvjvvtRb
|
||||
rNJMNNbrHrtjHLHjvwtg
|
||||
fNbNzZdrZnMnMPnQShFPDmnqFm
|
||||
QWVCFfQffgQCVZzVVpHsHJBqtpspJFRHqq
|
||||
mwDbmnnGNlNcwNDDNRbnNDlJTpBJBtJGtPTLsBGqTqqsqp
|
||||
MlSdnScRnnmmDjSdNSdCzvggWzrgzjvfvrgVzW
|
||||
gsMljbrjlZlWcWMJrWwTwbmwQbmmLDQQLhwL
|
||||
CdgpzdgpgnfThHfFRwhfRf
|
||||
SptgpSpnCNpVSGNPvPGSddcMWjMrjqBsJcWqMcBWcVlZ
|
||||
JcJLQQFWhQJPJpWcwjHvMQvnnlMvzBHd
|
||||
tCtGZrmVRmVGTVTtCfRTCHHNNvdNzmdMvMlNzvwdvw
|
||||
CTGGRftfSGtGTGDLbFchSgSWWWcM
|
||||
QcMFQrvrQbvtczbVbjbMzZzRpqmDDmqqnNzCDCDC
|
||||
SHHfPJssGLPSdHThLhHdRmqNmNssnNmNCNnpjmsn
|
||||
LhLJfTdLJwfgPTdfGccrtjcMrccwvcrrFr
|
||||
jFLLLqDGjbtqLCChpMMhMBvpwMTmffpZ
|
||||
ZnJHRncHHgnrsrZffTdMdMBfmMvfvR
|
||||
NWWPnZrVHrZPCDDQtzDCPLCq
|
||||
jpFjvBZhDFHZdwcmslcslBLLNl
|
||||
dVtTVVCzzfrrMPNLLcnVcPLRns
|
||||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gzwpPWMmPflmtt
|
90
2022/4.c
Normal file
90
2022/4.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct Assignment {
|
||||
char *range;
|
||||
int start;
|
||||
int end;
|
||||
};
|
||||
|
||||
// Split each line into 2 strings representing the assignment range for each elf
|
||||
void parse_assignments(char *assignments, struct Assignment *elf1,
|
||||
struct Assignment *elf2) {
|
||||
|
||||
elf1->range = strtok(assignments, ",");
|
||||
elf2->range = strtok(NULL, ",");
|
||||
}
|
||||
|
||||
// Split each assignment range into a start and end
|
||||
void parse_sections(struct Assignment *elf) {
|
||||
elf->start = atoi(strtok(elf->range, "-,"));
|
||||
elf->end = atoi(strtok(NULL, "-,"));
|
||||
}
|
||||
|
||||
// Count the number of assignments that fully contain the other
|
||||
void count_subsets(int *count, struct Assignment *elf1,
|
||||
struct Assignment *elf2) {
|
||||
|
||||
if ((elf1->start >= elf2->start && elf1->end <= elf2->end) ||
|
||||
(elf2->start >= elf1->start && elf2->end <= elf1->end)) {
|
||||
*count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Count the number of assignments with any overlapping sections
|
||||
void count_overlaps(int *count, struct Assignment *elf1,
|
||||
struct Assignment *elf2) {
|
||||
|
||||
if ((elf1->start <= elf2->end && elf1->end >= elf2->start) ||
|
||||
(elf2->start <= elf1->end && elf2->end >= elf1->start)) {
|
||||
*count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "USAGE: %s input_file\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE *file = fopen(argv[1], "r");
|
||||
if (!file) {
|
||||
perror("fopen");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int part1_count = 0;
|
||||
int part2_count = 0;
|
||||
char assignments[16] = {0};
|
||||
|
||||
while (fgets(assignments, sizeof assignments / sizeof *assignments, file)) {
|
||||
|
||||
if (strlen(assignments) == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
struct Assignment elf1;
|
||||
struct Assignment elf2;
|
||||
|
||||
assignments[strlen(assignments) - 1] = '\0';
|
||||
|
||||
// split input into starting and ending points
|
||||
parse_assignments(assignments, &elf1, &elf2);
|
||||
parse_sections(&elf1);
|
||||
parse_sections(&elf2);
|
||||
|
||||
// Part 1 - count sections that fully are fully contained by another
|
||||
count_subsets(&part1_count, &elf1, &elf2);
|
||||
|
||||
// Part 2 - count all overlapping sections
|
||||
count_overlaps(&part2_count, &elf1, &elf2);
|
||||
}
|
||||
|
||||
printf("Part 1 - %d ranges fully contain another\n", part1_count);
|
||||
printf("part 2 - %d assignments overlap\n", part2_count);
|
||||
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
1000
2022/4.txt
Normal file
1000
2022/4.txt
Normal file
File diff suppressed because it is too large
Load diff
220
2022/5.c
Normal file
220
2022/5.c
Normal file
|
@ -0,0 +1,220 @@
|
|||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_LINE 512
|
||||
#define NUM_LINES 512
|
||||
#define NUM_STACKS 9
|
||||
|
||||
struct Stack {
|
||||
int top;
|
||||
char items[MAX_LINE];
|
||||
};
|
||||
typedef struct Stack stack;
|
||||
|
||||
// Push onto a stack
|
||||
void push(stack *st, char crate) {
|
||||
if (st->top == MAX_LINE) {
|
||||
fprintf(stderr, "Stack is full\n");
|
||||
} else {
|
||||
st->top++;
|
||||
st->items[st->top] = crate;
|
||||
}
|
||||
}
|
||||
|
||||
// Pop from a stack
|
||||
char pop(stack *st) {
|
||||
char c = '\0';
|
||||
if (st->top == -1) {
|
||||
fprintf(stderr, "Stack is empty\n");
|
||||
return -1;
|
||||
} else {
|
||||
c = st->items[st->top];
|
||||
st->items[st->top] = '\0';
|
||||
st->top--;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
// Prints top index, top item, and each stack
|
||||
void print_crates(stack **crates) {
|
||||
for (size_t i = 0; i < NUM_STACKS; i++) {
|
||||
printf("\nStack %lu - Top: %d"
|
||||
"\n Top Crate: %c"
|
||||
"\n Crates: %s\n",
|
||||
i + 1, crates[i]->top, crates[i]->items[crates[i]->top],
|
||||
crates[i]->items);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate memeory and initialize stacks of crates with their initial order
|
||||
stack **crates_init() {
|
||||
|
||||
stack **crates = calloc(NUM_STACKS, sizeof(stack *));
|
||||
if (crates == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < NUM_STACKS; i++) {
|
||||
crates[i] = (stack *)malloc(sizeof(stack));
|
||||
if (crates[i] == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
crates[i]->top = -1;
|
||||
memset(crates[i]->items, 0, MAX_LINE);
|
||||
}
|
||||
|
||||
crates[0]->top = 7;
|
||||
strcpy(crates[0]->items, "PFMQWGRT");
|
||||
crates[1]->top = 2;
|
||||
strcpy(crates[1]->items, "HFR");
|
||||
crates[2]->top = 7;
|
||||
strcpy(crates[2]->items, "PZRVGHSD");
|
||||
crates[3]->top = 6;
|
||||
strcpy(crates[3]->items, "QHPBFWG");
|
||||
crates[4]->top = 4;
|
||||
strcpy(crates[4]->items, "PSMJH");
|
||||
crates[5]->top = 7;
|
||||
strcpy(crates[5]->items, "MZTHSRPL");
|
||||
crates[6]->top = 5;
|
||||
strcpy(crates[6]->items, "PTHNML");
|
||||
crates[7]->top = 3;
|
||||
strcpy(crates[7]->items, "FDQR");
|
||||
crates[8]->top = 6;
|
||||
strcpy(crates[8]->items, "DSCNLPH");
|
||||
|
||||
return crates;
|
||||
}
|
||||
|
||||
// Parses moves from input file and stores in an array
|
||||
void parse_moves(FILE *file, int moves[NUM_LINES][3], size_t *line_num) {
|
||||
|
||||
int idx = 0;
|
||||
char line[MAX_LINE] = {0};
|
||||
|
||||
while (fgets(line, MAX_LINE, file) != NULL) {
|
||||
|
||||
if (line[0] != 'm') {
|
||||
memset(line, 0, MAX_LINE);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < strlen(line); i++) {
|
||||
if (isdigit(line[i])) {
|
||||
if (isdigit(line[i + 1])) {
|
||||
char temp[2];
|
||||
temp[0] = line[i];
|
||||
temp[1] = line[i + 1];
|
||||
moves[*line_num][idx] = atoi(temp);
|
||||
i++;
|
||||
} else {
|
||||
moves[*line_num][idx] = atoi(&line[i]);
|
||||
}
|
||||
idx++;
|
||||
if (idx > 2) {
|
||||
*line_num += 1;
|
||||
idx = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
memset(line, 0, MAX_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
// Part 1 - Processes each move stored in the moves array one crate at a time
|
||||
void part1_moves(stack **crates, int moves[NUM_LINES][3], size_t move_count) {
|
||||
|
||||
size_t idx = 0;
|
||||
while (idx <= move_count) {
|
||||
|
||||
for (int i = 0; i < moves[idx][0]; i++) {
|
||||
|
||||
char c = pop(crates[moves[idx][1] - 1]);
|
||||
if (c == -1) {
|
||||
fprintf(stderr, "part1_moves: move num: %lu", idx);
|
||||
continue;
|
||||
}
|
||||
|
||||
push(crates[moves[idx][2] - 1], c);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
void crates_free(stack **crates) {
|
||||
for (size_t i = 0; i < NUM_STACKS; i++) {
|
||||
free(crates[i]);
|
||||
}
|
||||
free(crates);
|
||||
}
|
||||
|
||||
// Part 2 - Processes the moves array multiple crates at a time
|
||||
void part2_moves(stack **crates, int moves[NUM_LINES][3], size_t move_count) {
|
||||
|
||||
size_t idx = 0;
|
||||
while (idx <= move_count) {
|
||||
|
||||
char c_arr[moves[idx][0]];
|
||||
memset(c_arr, 0, moves[idx][0]);
|
||||
|
||||
for (int i = 0; i < moves[idx][0]; i++) {
|
||||
c_arr[i] = pop(crates[moves[idx][1] - 1]);
|
||||
if (c_arr[i] == -1) {
|
||||
fprintf(stderr, "part2_moves: move num: %lu", idx);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = moves[idx][0] - 1; j >= 0; j--) {
|
||||
push(crates[moves[idx][2] - 1], c_arr[j]);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "USAGE: %s input_file\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE *file = fopen(argv[1], "r");
|
||||
if (!file) {
|
||||
perror("fopen");
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t move_count = 0;
|
||||
int moves[NUM_LINES][3] = {0};
|
||||
stack **crates = crates_init();
|
||||
if (crates == NULL) {
|
||||
fprintf(stderr, "Part 2: unable to allocate memory for crates\n");
|
||||
fclose(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("\n--- PART 1 ---\n");
|
||||
parse_moves(file, moves, &move_count);
|
||||
part1_moves(crates, moves, move_count);
|
||||
print_crates(crates);
|
||||
|
||||
printf("\n--- PART 2 ---\n");
|
||||
crates_free(crates);
|
||||
crates = crates_init();
|
||||
if (crates == NULL) {
|
||||
fprintf(stderr, "Part 2: unable to allocate memory for crates\n");
|
||||
fclose(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
part2_moves(crates, moves, move_count);
|
||||
print_crates(crates);
|
||||
crates_free(crates);
|
||||
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
512
2022/5.txt
Normal file
512
2022/5.txt
Normal file
|
@ -0,0 +1,512 @@
|
|||
[T] [D] [L]
|
||||
[R] [S] [G] [P] [H]
|
||||
[G] [H] [W] [R] [L] [P]
|
||||
[W] [G] [F] [H] [S] [M] [L]
|
||||
[Q] [V] [B] [J] [H] [N] [R] [N]
|
||||
[M] [R] [R] [P] [M] [T] [H] [Q] [C]
|
||||
[F] [F] [Z] [H] [S] [Z] [T] [D] [S]
|
||||
[P] [H] [P] [Q] [P] [M] [P] [F] [D]
|
||||
1 2 3 4 5 6 7 8 9
|
||||
|
||||
move 3 from 8 to 9
|
||||
move 2 from 2 to 8
|
||||
move 5 from 4 to 2
|
||||
move 7 from 1 to 4
|
||||
move 3 from 8 to 2
|
||||
move 3 from 2 to 7
|
||||
move 1 from 7 to 4
|
||||
move 3 from 2 to 9
|
||||
move 4 from 7 to 9
|
||||
move 1 from 5 to 2
|
||||
move 2 from 3 to 4
|
||||
move 5 from 9 to 5
|
||||
move 6 from 9 to 3
|
||||
move 5 from 9 to 5
|
||||
move 1 from 9 to 7
|
||||
move 2 from 3 to 1
|
||||
move 7 from 3 to 9
|
||||
move 2 from 7 to 2
|
||||
move 5 from 2 to 4
|
||||
move 1 from 2 to 9
|
||||
move 2 from 1 to 9
|
||||
move 7 from 6 to 1
|
||||
move 2 from 7 to 3
|
||||
move 2 from 3 to 9
|
||||
move 1 from 7 to 4
|
||||
move 1 from 9 to 2
|
||||
move 3 from 1 to 8
|
||||
move 2 from 3 to 4
|
||||
move 5 from 9 to 2
|
||||
move 1 from 3 to 9
|
||||
move 8 from 5 to 7
|
||||
move 1 from 6 to 1
|
||||
move 15 from 4 to 1
|
||||
move 4 from 2 to 5
|
||||
move 5 from 9 to 7
|
||||
move 1 from 9 to 5
|
||||
move 5 from 1 to 2
|
||||
move 3 from 8 to 9
|
||||
move 1 from 7 to 6
|
||||
move 11 from 1 to 2
|
||||
move 7 from 5 to 3
|
||||
move 4 from 2 to 6
|
||||
move 7 from 3 to 4
|
||||
move 3 from 5 to 9
|
||||
move 2 from 2 to 5
|
||||
move 5 from 1 to 8
|
||||
move 2 from 6 to 8
|
||||
move 3 from 8 to 9
|
||||
move 9 from 4 to 9
|
||||
move 9 from 7 to 4
|
||||
move 2 from 8 to 1
|
||||
move 1 from 8 to 7
|
||||
move 6 from 2 to 7
|
||||
move 5 from 2 to 4
|
||||
move 5 from 7 to 2
|
||||
move 2 from 1 to 7
|
||||
move 2 from 6 to 4
|
||||
move 7 from 7 to 1
|
||||
move 3 from 2 to 6
|
||||
move 1 from 8 to 7
|
||||
move 2 from 9 to 3
|
||||
move 2 from 3 to 1
|
||||
move 1 from 2 to 5
|
||||
move 4 from 6 to 5
|
||||
move 2 from 2 to 3
|
||||
move 3 from 5 to 7
|
||||
move 1 from 5 to 3
|
||||
move 9 from 1 to 7
|
||||
move 2 from 9 to 5
|
||||
move 13 from 4 to 1
|
||||
move 5 from 7 to 2
|
||||
move 3 from 3 to 1
|
||||
move 2 from 2 to 9
|
||||
move 1 from 2 to 7
|
||||
move 5 from 5 to 6
|
||||
move 2 from 2 to 4
|
||||
move 5 from 1 to 3
|
||||
move 9 from 7 to 8
|
||||
move 2 from 9 to 5
|
||||
move 3 from 5 to 4
|
||||
move 5 from 9 to 2
|
||||
move 10 from 4 to 8
|
||||
move 1 from 4 to 1
|
||||
move 2 from 8 to 4
|
||||
move 4 from 8 to 2
|
||||
move 3 from 6 to 8
|
||||
move 7 from 8 to 7
|
||||
move 10 from 9 to 3
|
||||
move 7 from 3 to 2
|
||||
move 11 from 2 to 3
|
||||
move 13 from 3 to 9
|
||||
move 1 from 6 to 3
|
||||
move 1 from 1 to 2
|
||||
move 1 from 2 to 8
|
||||
move 3 from 3 to 4
|
||||
move 1 from 2 to 9
|
||||
move 1 from 4 to 1
|
||||
move 10 from 8 to 3
|
||||
move 11 from 9 to 7
|
||||
move 1 from 6 to 2
|
||||
move 14 from 7 to 1
|
||||
move 2 from 2 to 9
|
||||
move 4 from 7 to 6
|
||||
move 1 from 2 to 4
|
||||
move 3 from 4 to 2
|
||||
move 4 from 2 to 9
|
||||
move 10 from 3 to 4
|
||||
move 3 from 6 to 1
|
||||
move 5 from 9 to 5
|
||||
move 5 from 5 to 8
|
||||
move 1 from 9 to 7
|
||||
move 2 from 9 to 6
|
||||
move 1 from 9 to 8
|
||||
move 2 from 4 to 8
|
||||
move 1 from 4 to 5
|
||||
move 2 from 3 to 1
|
||||
move 2 from 3 to 7
|
||||
move 27 from 1 to 2
|
||||
move 2 from 7 to 1
|
||||
move 9 from 4 to 6
|
||||
move 9 from 6 to 5
|
||||
move 5 from 8 to 6
|
||||
move 26 from 2 to 3
|
||||
move 1 from 2 to 5
|
||||
move 1 from 2 to 7
|
||||
move 1 from 8 to 4
|
||||
move 1 from 7 to 8
|
||||
move 24 from 3 to 5
|
||||
move 1 from 8 to 5
|
||||
move 1 from 4 to 3
|
||||
move 1 from 7 to 1
|
||||
move 1 from 8 to 9
|
||||
move 7 from 1 to 7
|
||||
move 8 from 6 to 4
|
||||
move 4 from 7 to 6
|
||||
move 1 from 3 to 9
|
||||
move 2 from 9 to 1
|
||||
move 3 from 7 to 9
|
||||
move 8 from 4 to 6
|
||||
move 3 from 9 to 1
|
||||
move 1 from 3 to 6
|
||||
move 1 from 8 to 2
|
||||
move 10 from 5 to 4
|
||||
move 1 from 3 to 8
|
||||
move 13 from 5 to 3
|
||||
move 1 from 2 to 9
|
||||
move 1 from 8 to 9
|
||||
move 1 from 3 to 8
|
||||
move 1 from 9 to 2
|
||||
move 3 from 6 to 9
|
||||
move 7 from 4 to 9
|
||||
move 4 from 3 to 9
|
||||
move 2 from 6 to 8
|
||||
move 2 from 4 to 5
|
||||
move 10 from 9 to 3
|
||||
move 1 from 1 to 9
|
||||
move 1 from 4 to 8
|
||||
move 1 from 1 to 4
|
||||
move 1 from 4 to 5
|
||||
move 4 from 6 to 3
|
||||
move 1 from 9 to 5
|
||||
move 1 from 6 to 9
|
||||
move 2 from 6 to 5
|
||||
move 1 from 9 to 2
|
||||
move 1 from 6 to 7
|
||||
move 18 from 5 to 2
|
||||
move 22 from 3 to 7
|
||||
move 19 from 7 to 1
|
||||
move 3 from 8 to 5
|
||||
move 4 from 9 to 3
|
||||
move 2 from 7 to 2
|
||||
move 1 from 8 to 1
|
||||
move 19 from 1 to 3
|
||||
move 2 from 7 to 5
|
||||
move 13 from 3 to 9
|
||||
move 4 from 1 to 2
|
||||
move 3 from 5 to 1
|
||||
move 11 from 9 to 1
|
||||
move 11 from 2 to 8
|
||||
move 3 from 9 to 3
|
||||
move 3 from 5 to 2
|
||||
move 2 from 1 to 4
|
||||
move 5 from 2 to 7
|
||||
move 12 from 1 to 5
|
||||
move 2 from 4 to 5
|
||||
move 9 from 5 to 8
|
||||
move 1 from 5 to 3
|
||||
move 4 from 2 to 3
|
||||
move 2 from 7 to 5
|
||||
move 6 from 2 to 8
|
||||
move 17 from 8 to 9
|
||||
move 2 from 9 to 6
|
||||
move 2 from 7 to 1
|
||||
move 15 from 9 to 6
|
||||
move 2 from 2 to 4
|
||||
move 9 from 8 to 5
|
||||
move 2 from 1 to 3
|
||||
move 12 from 6 to 2
|
||||
move 2 from 3 to 9
|
||||
move 5 from 6 to 3
|
||||
move 4 from 5 to 3
|
||||
move 11 from 3 to 4
|
||||
move 2 from 9 to 4
|
||||
move 6 from 5 to 2
|
||||
move 13 from 4 to 3
|
||||
move 1 from 4 to 5
|
||||
move 1 from 4 to 8
|
||||
move 18 from 2 to 6
|
||||
move 2 from 5 to 3
|
||||
move 1 from 8 to 3
|
||||
move 1 from 2 to 5
|
||||
move 1 from 7 to 8
|
||||
move 28 from 3 to 6
|
||||
move 2 from 3 to 4
|
||||
move 3 from 5 to 9
|
||||
move 2 from 5 to 9
|
||||
move 3 from 9 to 3
|
||||
move 5 from 3 to 4
|
||||
move 1 from 9 to 3
|
||||
move 1 from 9 to 1
|
||||
move 1 from 3 to 4
|
||||
move 45 from 6 to 2
|
||||
move 1 from 8 to 3
|
||||
move 2 from 4 to 6
|
||||
move 5 from 4 to 2
|
||||
move 1 from 3 to 7
|
||||
move 3 from 2 to 9
|
||||
move 1 from 4 to 8
|
||||
move 3 from 6 to 1
|
||||
move 42 from 2 to 8
|
||||
move 2 from 9 to 2
|
||||
move 4 from 2 to 6
|
||||
move 2 from 2 to 7
|
||||
move 1 from 9 to 6
|
||||
move 2 from 8 to 9
|
||||
move 4 from 1 to 8
|
||||
move 1 from 6 to 4
|
||||
move 1 from 4 to 8
|
||||
move 1 from 2 to 5
|
||||
move 3 from 7 to 4
|
||||
move 39 from 8 to 3
|
||||
move 7 from 8 to 5
|
||||
move 8 from 5 to 7
|
||||
move 35 from 3 to 1
|
||||
move 4 from 3 to 7
|
||||
move 10 from 7 to 2
|
||||
move 2 from 9 to 6
|
||||
move 3 from 4 to 2
|
||||
move 1 from 7 to 5
|
||||
move 1 from 7 to 8
|
||||
move 1 from 5 to 4
|
||||
move 12 from 1 to 6
|
||||
move 1 from 8 to 1
|
||||
move 1 from 4 to 5
|
||||
move 14 from 6 to 8
|
||||
move 9 from 8 to 6
|
||||
move 5 from 6 to 1
|
||||
move 11 from 2 to 9
|
||||
move 1 from 9 to 8
|
||||
move 6 from 8 to 3
|
||||
move 6 from 9 to 2
|
||||
move 8 from 1 to 9
|
||||
move 3 from 3 to 6
|
||||
move 7 from 1 to 4
|
||||
move 1 from 5 to 9
|
||||
move 8 from 9 to 8
|
||||
move 7 from 6 to 8
|
||||
move 1 from 9 to 3
|
||||
move 3 from 6 to 4
|
||||
move 3 from 9 to 1
|
||||
move 4 from 3 to 2
|
||||
move 1 from 6 to 7
|
||||
move 1 from 4 to 2
|
||||
move 13 from 1 to 7
|
||||
move 6 from 4 to 8
|
||||
move 1 from 7 to 3
|
||||
move 1 from 4 to 6
|
||||
move 1 from 9 to 5
|
||||
move 1 from 3 to 5
|
||||
move 19 from 8 to 9
|
||||
move 1 from 6 to 5
|
||||
move 6 from 9 to 2
|
||||
move 2 from 5 to 8
|
||||
move 1 from 5 to 2
|
||||
move 4 from 1 to 4
|
||||
move 8 from 9 to 4
|
||||
move 3 from 9 to 8
|
||||
move 2 from 9 to 1
|
||||
move 6 from 7 to 5
|
||||
move 12 from 4 to 2
|
||||
move 6 from 8 to 3
|
||||
move 1 from 4 to 1
|
||||
move 1 from 3 to 1
|
||||
move 13 from 2 to 3
|
||||
move 4 from 5 to 3
|
||||
move 1 from 4 to 9
|
||||
move 1 from 8 to 9
|
||||
move 12 from 3 to 2
|
||||
move 1 from 9 to 1
|
||||
move 2 from 5 to 9
|
||||
move 3 from 9 to 5
|
||||
move 1 from 7 to 5
|
||||
move 3 from 7 to 3
|
||||
move 1 from 5 to 4
|
||||
move 1 from 5 to 8
|
||||
move 9 from 2 to 3
|
||||
move 2 from 2 to 3
|
||||
move 3 from 1 to 9
|
||||
move 1 from 8 to 9
|
||||
move 3 from 9 to 1
|
||||
move 9 from 2 to 6
|
||||
move 1 from 9 to 5
|
||||
move 6 from 2 to 3
|
||||
move 2 from 6 to 9
|
||||
move 3 from 6 to 3
|
||||
move 1 from 4 to 3
|
||||
move 2 from 9 to 6
|
||||
move 2 from 7 to 2
|
||||
move 2 from 2 to 8
|
||||
move 24 from 3 to 7
|
||||
move 2 from 5 to 6
|
||||
move 2 from 8 to 2
|
||||
move 7 from 2 to 8
|
||||
move 8 from 3 to 6
|
||||
move 2 from 1 to 3
|
||||
move 1 from 1 to 2
|
||||
move 1 from 5 to 2
|
||||
move 15 from 7 to 4
|
||||
move 9 from 7 to 9
|
||||
move 7 from 9 to 1
|
||||
move 5 from 8 to 1
|
||||
move 4 from 1 to 4
|
||||
move 19 from 4 to 3
|
||||
move 22 from 3 to 5
|
||||
move 1 from 7 to 5
|
||||
move 9 from 5 to 4
|
||||
move 6 from 1 to 3
|
||||
move 6 from 3 to 1
|
||||
move 4 from 5 to 4
|
||||
move 1 from 2 to 1
|
||||
move 1 from 2 to 6
|
||||
move 4 from 6 to 1
|
||||
move 1 from 3 to 6
|
||||
move 3 from 6 to 3
|
||||
move 2 from 9 to 8
|
||||
move 2 from 5 to 3
|
||||
move 2 from 5 to 1
|
||||
move 10 from 6 to 4
|
||||
move 4 from 4 to 9
|
||||
move 7 from 4 to 3
|
||||
move 2 from 8 to 7
|
||||
move 4 from 9 to 3
|
||||
move 5 from 5 to 7
|
||||
move 1 from 5 to 1
|
||||
move 1 from 6 to 3
|
||||
move 1 from 8 to 4
|
||||
move 1 from 8 to 3
|
||||
move 13 from 4 to 5
|
||||
move 1 from 1 to 8
|
||||
move 6 from 5 to 3
|
||||
move 1 from 7 to 6
|
||||
move 5 from 7 to 6
|
||||
move 9 from 1 to 8
|
||||
move 1 from 8 to 4
|
||||
move 1 from 7 to 1
|
||||
move 1 from 4 to 1
|
||||
move 5 from 3 to 7
|
||||
move 3 from 7 to 9
|
||||
move 1 from 5 to 4
|
||||
move 6 from 8 to 6
|
||||
move 1 from 9 to 3
|
||||
move 2 from 9 to 5
|
||||
move 7 from 5 to 9
|
||||
move 1 from 7 to 5
|
||||
move 2 from 5 to 3
|
||||
move 10 from 6 to 8
|
||||
move 2 from 6 to 1
|
||||
move 1 from 4 to 9
|
||||
move 1 from 7 to 5
|
||||
move 8 from 8 to 2
|
||||
move 1 from 1 to 7
|
||||
move 1 from 9 to 7
|
||||
move 1 from 5 to 1
|
||||
move 3 from 9 to 8
|
||||
move 7 from 8 to 7
|
||||
move 6 from 7 to 1
|
||||
move 1 from 8 to 7
|
||||
move 4 from 7 to 1
|
||||
move 16 from 3 to 7
|
||||
move 4 from 3 to 1
|
||||
move 5 from 7 to 8
|
||||
move 16 from 1 to 4
|
||||
move 9 from 1 to 7
|
||||
move 1 from 3 to 4
|
||||
move 15 from 4 to 8
|
||||
move 1 from 3 to 1
|
||||
move 2 from 1 to 6
|
||||
move 2 from 4 to 9
|
||||
move 17 from 8 to 2
|
||||
move 6 from 9 to 5
|
||||
move 8 from 7 to 8
|
||||
move 2 from 6 to 9
|
||||
move 4 from 5 to 7
|
||||
move 2 from 8 to 5
|
||||
move 1 from 5 to 9
|
||||
move 11 from 2 to 6
|
||||
move 4 from 6 to 1
|
||||
move 5 from 2 to 8
|
||||
move 2 from 9 to 2
|
||||
move 1 from 9 to 3
|
||||
move 3 from 1 to 8
|
||||
move 1 from 3 to 6
|
||||
move 7 from 6 to 9
|
||||
move 2 from 5 to 4
|
||||
move 6 from 7 to 4
|
||||
move 4 from 8 to 1
|
||||
move 1 from 5 to 2
|
||||
move 1 from 6 to 1
|
||||
move 7 from 9 to 8
|
||||
move 2 from 7 to 9
|
||||
move 9 from 2 to 9
|
||||
move 5 from 9 to 3
|
||||
move 3 from 2 to 8
|
||||
move 4 from 8 to 7
|
||||
move 9 from 7 to 2
|
||||
move 3 from 1 to 3
|
||||
move 14 from 8 to 1
|
||||
move 2 from 8 to 3
|
||||
move 1 from 9 to 4
|
||||
move 3 from 7 to 9
|
||||
move 8 from 3 to 9
|
||||
move 2 from 2 to 7
|
||||
move 12 from 1 to 8
|
||||
move 4 from 1 to 6
|
||||
move 2 from 6 to 7
|
||||
move 1 from 6 to 7
|
||||
move 9 from 4 to 7
|
||||
move 9 from 7 to 4
|
||||
move 1 from 1 to 6
|
||||
move 2 from 3 to 6
|
||||
move 2 from 6 to 8
|
||||
move 12 from 9 to 8
|
||||
move 2 from 6 to 9
|
||||
move 2 from 9 to 7
|
||||
move 1 from 8 to 5
|
||||
move 5 from 7 to 5
|
||||
move 1 from 9 to 1
|
||||
move 3 from 4 to 1
|
||||
move 5 from 4 to 8
|
||||
move 4 from 1 to 7
|
||||
move 1 from 4 to 2
|
||||
move 19 from 8 to 4
|
||||
move 2 from 7 to 5
|
||||
move 14 from 8 to 5
|
||||
move 2 from 7 to 8
|
||||
move 3 from 9 to 8
|
||||
move 19 from 4 to 2
|
||||
move 9 from 2 to 4
|
||||
move 2 from 7 to 8
|
||||
move 15 from 5 to 9
|
||||
move 15 from 9 to 8
|
||||
move 1 from 5 to 9
|
||||
move 11 from 8 to 7
|
||||
move 4 from 5 to 8
|
||||
move 1 from 5 to 9
|
||||
move 2 from 9 to 5
|
||||
move 2 from 2 to 6
|
||||
move 14 from 2 to 9
|
||||
move 12 from 8 to 9
|
||||
move 3 from 8 to 4
|
||||
move 7 from 9 to 2
|
||||
move 4 from 7 to 9
|
||||
move 1 from 6 to 9
|
||||
move 1 from 7 to 5
|
||||
move 1 from 6 to 2
|
||||
move 3 from 5 to 4
|
||||
move 19 from 9 to 4
|
||||
move 1 from 5 to 1
|
||||
move 1 from 9 to 8
|
||||
move 1 from 1 to 7
|
||||
move 1 from 8 to 9
|
||||
move 4 from 7 to 2
|
||||
move 3 from 7 to 6
|
||||
move 18 from 4 to 2
|
||||
move 17 from 2 to 3
|
||||
move 2 from 6 to 8
|
||||
move 17 from 3 to 6
|
||||
move 13 from 2 to 1
|
||||
move 2 from 8 to 3
|
||||
move 2 from 2 to 9
|
||||
move 6 from 1 to 9
|
||||
move 1 from 3 to 4
|
||||
move 1 from 3 to 9
|
||||
move 8 from 6 to 4
|
||||
move 20 from 4 to 8
|
||||
move 3 from 4 to 8
|
||||
move 15 from 8 to 2
|
||||
move 11 from 2 to 6
|
||||
move 2 from 1 to 7
|
||||
move 7 from 9 to 8
|
||||
move 6 from 9 to 3
|
||||
move 1 from 6 to 5
|
Loading…
Reference in a new issue