diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..318dd74 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.out +*~ diff --git a/11/' b/11/' deleted file mode 100644 index 0f9d26a..0000000 --- a/11/' +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include -#include -#include - -struct list { - int num; - struct list *next; -}; - -bool even_digits(int x) -{ - int i = 0; - while (x /= 10) - i++; - return i % 2; -} - -void split_stone(struct list *stones) { - int digits = 0; - int x = stones->num; - while (x /= 10) - digits++; - - int a = stones->num; - int b = 0; - for (int i = 0; i < digits; i++) { - b = b * 10 + a % 10; - a /= 10; - } - - struct list *tmp = stones->next; - stones->next = malloc(sizeof(struct list)); - stones->num = a; - stones->next->num = b; - stones->next->next = tmp; -} - -int main () -{ - // figure out data dimensions - FILE *input = fopen("./inputDemo", "r"); - unsigned int tmp; - unsigned int array[10]; - for (int i = 0; i < 10; i++) - array[i] = -1; - for (int i = 0; fscanf(input, "%d", &tmp) == 1; i++) { - array[i] = tmp; - } - fclose(input); - - // put stones into list - struct list *stones = malloc(sizeof(struct list)); - stones->num = array[0]; - stones->next = NULL; - struct list *current = stones; - for (int i = 1; array[i] != -1; i++) { - while (current->next != NULL) - current = current->next; - current->next = malloc(sizeof(struct list)); - current->next->next = NULL; - current->next->num = array[i]; - } - - // loop through list - for (int i = 0; i < 6; i++) { - current = stones; - while (current) { - // 0 => make 1 - if (current->num == 0) - current->num = 1; - // even number of digits => split, fix list shit - else if (even_digits(current->num)) - split_stone(current); - // (point first split onto second split, second split onto old ptr) - // else => mult 2024 - else - current->num *= 2024; - - current = current->next; - } - } - current = stones; - int sum = 0; - printf("Stones: "); - while (current) { - printf("%d ", current->num); - sum++; - current = current->next; - } - printf("%d\n", sum); -} diff --git a/11/a.out b/11/a.out index c18907f..73be5a2 100755 Binary files a/11/a.out and b/11/a.out differ diff --git a/11/main.c b/11/main.c index dce1f15..afc4287 100644 --- a/11/main.c +++ b/11/main.c @@ -69,7 +69,7 @@ int main () } // loop through list - for (int i = 0; i < 75; i++) { + for (int i = 0; i < 25; i++) { current = stones; bool last = false; while (current) { diff --git a/11/mainB.c b/11/mainB.c new file mode 100644 index 0000000..d4d7c9d --- /dev/null +++ b/11/mainB.c @@ -0,0 +1,117 @@ +#include +#include +#include +#include + +struct list { + unsigned long int num; + unsigned long int solution; + int i; + struct list *next; +}; +struct pair { + unsigned long int a; + unsigned long int b; +}; + +struct list *solutions; +struct list *current; + +bool even_digits(unsigned long int x) +{ + int i = 0; + while (x /= 10) + i++; + return i % 2; +} +// power! x to the y! +int pow(int x, int y) +{ + int ans = 1; + for (int i = 0; i < y; i++) ans *= x; + return ans; +} +void split_stone(unsigned long int stone, struct pair *pair) { + int digits = 1; + unsigned long int x = stone; + while (x /= 10) + digits++; + + unsigned long int a = stone; + int b = 0; + for (int i = 0; i < digits / 2; i++) { + b += (a % 10) * pow(10, i); + a /= 10; + } + + pair->a = a; + pair->b = b; +} + +unsigned long int solve_stone(unsigned long int stone, int i) +{ + i--; + if (i == 0) + return 1; + // check / add to solved list + current = solutions; + while (current->next && !(current->num == stone && current->i == i)) { + current = current->next; + } + if (current->num == stone && current->i == i) { + printf("ay found repetition\n"); + return current->solution; + } + + int sum = 0; + // if not solved, split / multiply / set to 1 and send to solve + // 0 => make 1 + if (stone == 0) + sum = solve_stone(1, i); + // even number of digits => split, fix list shit + else if (even_digits(stone)) { + struct pair *pair = malloc(sizeof(struct pair)); + split_stone(stone, pair); + sum += solve_stone(pair->a, i); + sum += solve_stone(pair->b, i); + free(pair); + } + // (point first split onto second split, second split onto old ptr) + // else => mult 2024 + else + sum = solve_stone(stone * 2024, i); + + while (current->next && current->num != -1) {} + current->next = malloc(sizeof(struct list)); + current = current->next; + current->num = stone; + current->i = i; + current->solution = sum; + + return sum; +} + +int main () +{ + // figure out data dimensions + FILE *input = fopen("./input", "r"); + unsigned int tmp; + unsigned int array[10]; + for (int i = 0; i < 10; i++) + array[i] = -1; + for (int i = 0; fscanf(input, "%d", &tmp) == 1; i++) { + array[i] = tmp; + } + fclose(input); + + solutions = malloc(sizeof(struct list)); + solutions->num = -1; + solutions->next = NULL; + + unsigned long int sum = 0; + for (int i = 0; array[i] != -1; i++) { + sum += solve_stone(array[i], 6); + } + + printf("total: %d\n", sum); +} diff --git a/12/input b/12/input new file mode 100644 index 0000000..7b75ca1 --- /dev/null +++ b/12/input @@ -0,0 +1,140 @@ +LLLLLLLLFFFFFFFFFFFFFFIIIIIIIIVVVZZZZZZEEEEEEEEEEEENNKAAKKRRRRRRRRPPPPPPPUIIIIIIIIIIIILLLLLLLLLLLLLUUUUUUUUOOOOOOOOOOOOOOOOSSSSSSDDDDDDDDDDD +LLLLLLLLLLLFFFFFFFFFFFFIIIIIVVVVVVZZEEEEEEEEEEEEEEENKKKKKKKRRRRRRPPPPPPPPIIIIIIIIIIIIZLLLLLLLLLLLLUUUUUUUUUUOOOOOOOOOOOOOOOUSSSSSSSDDDDDDDDD +LLLLLLFLLFFFFFFFFFFFFIIIIIIIIIVVVZZZZEEEEEEEEEEEEEENKKKKKKKRRRRRRPPPPPPPPPPPPIIIIIILZZLLLLLLLLLLLLUUUUUUUUUUOOOOOOOOOOOOOOOSSSSSSSLRRDDDDDDD +LLLLLLFFFFFFFFFFFFFFIIIIIIIIVVVVZZZZZEEEEEEEEEEEEXKKKKKKKKKRRRRPPPPPPPPPPPPPPPIIIIILLLLLLLLLLLLLLLUUUUUUUUOOOOOOOOOOOOOOOOOOSSSSSSRRDDDDDDDD +LLLLLLLFFWFFFFFFFFFHHIIIIIIVVVVVVVZVEEEEEEEUEEEEEEYKKKKKKKKKRRRRPPPPPPPPPPPPPIIIIIILLLLLLLLLLLLOOUUUUUUUUUOOOOOOKOOOOOOOOOIUSSSSSSRRDDDDDDDD +LLLLLLLLLFFFFFFFFFHHHHHIIIIIVVVVVVVVESEEUUUUEEUUEEEKKKKKKKKWRRRRPPPPPPPPPPPPPIIXXXXMLLLLLLLLLLOOUUUUUUUUUUKKKKOKKOO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KKKKKKQQQQQQQQQQQQQQQQQQQUUUUUFFFFFFFFFFFEEEEEEEEEEEEEEEEMEEUUUUUUUUUU +RRRRRPPPPPPPPPPPPPPPPPPPPPPPPFFFFHHHHGGGGGGGGGGGGGGGGPPQQQQQKKKNNNNKKKKKKKKQQQQQQQQQQQQQQQQQQQQUUUUFFFFFFFFFIFFEEEEEEEEEEEEEEEEEEEEUUUUUUUUU +RRRRRPPPPPPPPPPPPPPPPPPPPPPFFFFFFHGGGGGGGGGGGGGGGGGGGGPQQQQQQQNNNNNKKKKKKZKCCQQQQQQQQQQQQQQQQQQQUUUUUFFFFFFFFFFEEEEEEEEEEEEEEMEEEUUUUUUUUUUU diff --git a/12/inputDemo b/12/inputDemo new file mode 100644 index 0000000..85b768f --- /dev/null +++ b/12/inputDemo @@ -0,0 +1,10 @@ +RRRRIICCFF +RRRRIICCCF +VVRRRCCFFF +VVRCCCJFFF +VVVVCJJCFE +VVIVCCJJEE +VVIIICJJEE +MIIIIIJJEE +MIIISIJEEE +MMMISSJEEE diff --git a/12/inputDemo2 b/12/inputDemo2 new file mode 100644 index 0000000..50a7304 --- /dev/null +++ b/12/inputDemo2 @@ -0,0 +1,5 @@ +OOOOO +OXOXO +OOOOO +OXOXO +OOOOO diff --git a/12/main.c b/12/main.c new file mode 100644 index 0000000..95ab593 --- /dev/null +++ b/12/main.c @@ -0,0 +1,176 @@ +#include +#include +#include +#include + +struct list { + char type; + struct square *tiles; + unsigned int area; + unsigned int perimeter; + struct list *next; +}; +struct square { + int x; + int y; + struct square *next; +}; + +bool tile_in_list(int x, int y, struct list *plot) +{ + if (!plot) + return 0; + struct square *current = plot->tiles; + while (current) { + if (current->x == x && current->y == y) { + return 1; + } + current = current->next; + } + return 0; +} + +bool plot_exists (int x, int y, struct list *plots) +{ + struct list *current = plots; + while (current) { + if (tile_in_list(x, y, current)) + return 1; + current = current->next; + } + return 0; +} + +void add_tile(int x, int y, struct list *plot) +{ + if (plot->tiles == NULL) { + plot->tiles = malloc(sizeof(struct square)); + plot->tiles->x = x; + plot->tiles->y = y; + plot->tiles->next = NULL; + return; + } + + struct square *tiles = plot->tiles; + while (tiles->next) + tiles = tiles->next; + + tiles->next = malloc(sizeof(struct square)); + tiles->next->x = x; + tiles->next->y = y; + tiles->next->next = NULL; +} + +struct list *check_plot(int x, int y, int width, int height, char **map, struct list *plot, bool daddy) +{ + int dir[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; + int perimeter = 0; + // daddy simply states if this function was called from the outside, + // since the main loop will never send grids in the same plot + // should actually be solved by handling the list outside this func + + struct list *prevPlot = plot; + while (plot && plot->type != map[x][y]) { + prevPlot = plot; + plot = plot->next; + } + // create list of every tile in this plot + // init list + if (plot == NULL || daddy) { + plot = malloc(sizeof(struct list)); + plot->type = map[x][y]; + plot->area = 0; + plot->perimeter = 0; + plot->tiles = NULL; + plot->next = NULL; + if (prevPlot) + prevPlot->next = plot; + } + // check if current tile is in this list + // if yes, return + if (tile_in_list(x, y, plot)) + return NULL; + // else, add, then check all surrounding tiles with this function + add_tile(x, y, plot); + plot->area++; + + // look in every direction for same type, recurse it + for (int i = 0; i < 4; i++) { + if (x + dir[i][0] >= 0 && + x + dir[i][0] < width && + y + dir[i][1] >= 0 && + y + dir[i][1] < height) { + if (map[x + dir[i][0]][y + dir[i][1]] == map[x][y]) { + check_plot(x + dir[i][0], y + dir[i][1], + width, height, map, plot, false); + } else { + plot->perimeter++; + } + } else + plot->perimeter++; + } + return plot; +} + +int main () +{ + // figure out data dimensions + FILE *input = fopen("./input", "r"); + int width = 0; + int height = 1; + while (fgetc(input) != '\n') width++; + for (char c = fgetc(input); c != EOF; c = fgetc(input)) { + if (c == '\n') + height++; + } + rewind(input); + printf("Dimensions: %d x %d\n", width, height); + + // make 2d array + char **map = malloc(width * sizeof(char*)); + map[0] = malloc(width * height); + for (int i = 1; i < width; i++) { + map[i] = map[0] + i * height; + } + + // put the data in the array + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + map[j][i] = fgetc(input); + } + fgetc(input); + } + fclose(input); + + int scoreSum = 0; + // find plots not in list, check their score + struct list *plots = NULL; + struct list *current = NULL; + char prevType = 0; + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + // nasty if. prev type, skip. first, init head. + // else, if tile is already in plot-list, skip + // else, add a new plot to the list from current tile + if (map[j][i] == prevType) + continue; + if (i == 0 && j == 0) { + plots = check_plot(j,i, width, height, map, plots, true); + current = plots; + } + else if (plot_exists(j, i, plots)) + continue; + else + current = check_plot(j,i, width, height, map, current, true); + } + } + current = plots; + int sum = 0; + while (current) { + printf("plot %c is area %d and perimeter %d\n", current->type, current->area, current->perimeter); + sum += current->area * current->perimeter; + current = current->next; + } + + printf("total score: %d\n", sum); +} diff --git a/12/test b/12/test new file mode 100644 index 0000000..6e31417 --- /dev/null +++ b/12/test @@ -0,0 +1,593 @@ +plot L is area 116 and perimeter 94 +plot F is area 93 and perimeter 70 +plot I is area 54 and perimeter 52 +plot V is area 83 and perimeter 60 +plot Z is area 18 and perimeter 28 +plot E is area 78 and perimeter 62 +plot N is area 4 and perimeter 10 +plot K is area 82 and perimeter 60 +plot A is area 2 and perimeter 6 +plot R is area 37 and perimeter 34 +plot P is area 148 and perimeter 82 +plot U is area 1 and perimeter 4 +plot I is area 45 and perimeter 44 +plot L is area 85 and perimeter 60 +plot U is area 108 and perimeter 64 +plot O is area 106 and perimeter 62 +plot S is area 35 and perimeter 34 +plot D is area 71 and perimeter 52 +plot Z is area 3 and perimeter 8 +plot U is area 1 and perimeter 4 +plot L is area 1 and perimeter 4 +plot R is area 178 and perimeter 112 +plot X is area 1 and perimeter 4 +plot W is area 1 and perimeter 4 +plot H is area 77 and perimeter 64 +plot U is area 60 and perimeter 46 +plot Y is area 1 and perimeter 4 +plot O is area 18 and perimeter 26 +plot K is area 76 and perimeter 64 +plot I is area 1 and perimeter 4 +plot U is area 34 and perimeter 44 +plot S is area 88 and perimeter 82 +plot W is area 2 and perimeter 6 +plot X is area 112 and perimeter 84 +plot M is area 1 and perimeter 4 +plot Z is area 76 and perimeter 78 +plot X is area 1 and perimeter 4 +plot H is area 8 and perimeter 16 +plot S is area 1 and perimeter 4 +plot K is area 67 and perimeter 70 +plot X is area 6 and perimeter 14 +plot I is area 25 and perimeter 40 +plot W is area 105 and perimeter 64 +plot I is area 1 and perimeter 4 +plot M is area 6 and perimeter 10 +plot A is area 2 and perimeter 8 +plot S is area 10 and perimeter 14 +plot N is area 116 and perimeter 84 +plot Q is area 50 and perimeter 46 +plot E is area 14 and perimeter 20 +plot G is area 3 and perimeter 8 +plot D is area 18 and perimeter 22 +plot S is area 19 and perimeter 28 +plot C is area 30 and perimeter 36 +plot Y is area 8 and perimeter 14 +plot U is area 2 and perimeter 6 +plot N is area 1 and perimeter 4 +plot P is area 1 and perimeter 4 +plot D is area 1 and perimeter 4 +plot M is area 8 and perimeter 16 +plot I is area 1 and perimeter 4 +plot Q is area 2 and perimeter 6 +plot E is area 46 and perimeter 58 +plot R is area 1 and perimeter 4 +plot K is area 1 and perimeter 4 +plot N is area 39 and perimeter 52 +plot C is area 14 and perimeter 18 +plot X is area 3 and perimeter 8 +plot A is area 143 and perimeter 150 +plot D is area 28 and perimeter 34 +plot C is area 1 and perimeter 4 +plot S is area 44 and perimeter 38 +plot X is area 73 and perimeter 68 +plot J is area 3 and perimeter 10 +plot U is area 1 and perimeter 4 +plot X is area 1 and perimeter 4 +plot H is area 97 and perimeter 90 +plot N is area 2 and perimeter 6 +plot G is area 81 and perimeter 64 +plot F is area 4 and perimeter 8 +plot H is area 122 and perimeter 74 +plot W is area 58 and perimeter 56 +plot E is area 115 and perimeter 96 +plot R is area 2 and perimeter 6 +plot F is area 2 and perimeter 6 +plot W is area 83 and perimeter 66 +plot G is area 1 and perimeter 4 +plot U is area 138 and perimeter 80 +plot B is area 26 and perimeter 28 +plot T is area 130 and perimeter 88 +plot M is area 1 and perimeter 4 +plot J is area 1 and perimeter 4 +plot I is area 1 and perimeter 4 +plot U is area 75 and perimeter 76 +plot C is area 4 and perimeter 8 +plot P is area 1 and perimeter 4 +plot Y is area 1 and perimeter 4 +plot J is area 1 and perimeter 4 +plot H is area 1 and perimeter 4 +plot E is area 78 and perimeter 78 +plot P is area 1 and perimeter 4 +plot V is area 1 and perimeter 4 +plot K is area 1 and perimeter 4 +plot P is area 77 and perimeter 64 +plot F is area 1 and perimeter 4 +plot S is area 86 and perimeter 72 +plot K is area 120 and perimeter 56 +plot H is area 1 and perimeter 4 +plot O is area 52 and perimeter 50 +plot I is area 18 and perimeter 24 +plot J is area 71 and perimeter 36 +plot M is area 1 and perimeter 4 +plot W is area 1 and perimeter 4 +plot Z is area 3 and perimeter 8 +plot U is area 1 and perimeter 4 +plot N is area 107 and perimeter 80 +plot F is area 1 and perimeter 4 +plot P is area 100 and perimeter 74 +plot V is area 1 and perimeter 4 +plot G is area 26 and perimeter 34 +plot Y is area 53 and perimeter 44 +plot W is area 55 and perimeter 48 +plot J is area 7 and perimeter 12 +plot C is area 2 and perimeter 6 +plot Z is area 2 and perimeter 6 +plot C is area 1 and perimeter 4 +plot M is area 1 and perimeter 4 +plot P is area 1 and perimeter 4 +plot V is area 92 and perimeter 110 +plot P is area 25 and perimeter 30 +plot Q is area 2 and perimeter 6 +plot S is area 17 and perimeter 26 +plot J is area 1 and perimeter 4 +plot T is area 130 and perimeter 88 +plot F is area 5 and perimeter 12 +plot Y is area 25 and perimeter 36 +plot G is area 85 and perimeter 56 +plot Z is area 13 and perimeter 22 +plot G is area 3 and perimeter 8 +plot N is area 3 and perimeter 8 +plot A is area 2 and perimeter 6 +plot N is area 54 and perimeter 48 +plot W is area 70 and perimeter 52 +plot A is area 113 and perimeter 90 +plot O is area 91 and perimeter 66 +plot V is area 2 and perimeter 8 +plot O is area 1 and perimeter 4 +plot B is area 1 and perimeter 4 +plot U is area 104 and perimeter 70 +plot H is area 1 and perimeter 4 +plot A is area 1 and perimeter 4 +plot S is area 6 and perimeter 14 +plot J is area 1 and perimeter 4 +plot D is area 1 and perimeter 4 +plot A is area 3 and perimeter 8 +plot G is area 1 and perimeter 4 +plot X is area 117 and perimeter 62 +plot Q is area 2 and perimeter 6 +plot R is area 1 and perimeter 4 +plot M is area 1 and perimeter 4 +plot B is area 15 and perimeter 24 +plot L is area 58 and perimeter 48 +plot F is area 1 and perimeter 4 +plot R is area 4 and perimeter 8 +plot K is area 121 and perimeter 82 +plot M is area 1 and perimeter 4 +plot L is area 99 and perimeter 58 +plot Z is area 2 and perimeter 6 +plot B is area 6 and perimeter 12 +plot X is area 6 and perimeter 14 +plot P is area 40 and perimeter 34 +plot F is area 1 and perimeter 4 +plot H is area 4 and perimeter 10 +plot V is area 5 and perimeter 10 +plot J is area 1 and perimeter 4 +plot E is area 52 and perimeter 52 +plot T is area 69 and perimeter 60 +plot P is area 173 and perimeter 60 +plot A is area 1 and perimeter 4 +plot R is area 10 and perimeter 18 +plot P is area 5 and perimeter 10 +plot L is area 69 and perimeter 62 +plot Q is area 1 and perimeter 4 +plot U is area 1 and perimeter 4 +plot A is area 1 and perimeter 4 +plot L is area 2 and perimeter 6 +plot U is area 1 and perimeter 4 +plot B is area 2 and perimeter 6 +plot O is area 5 and perimeter 10 +plot F is area 22 and perimeter 34 +plot K is area 26 and perimeter 32 +plot V is area 2 and perimeter 6 +plot M is area 23 and perimeter 24 +plot T is area 1 and perimeter 4 +plot F is area 26 and perimeter 34 +plot Z is area 7 and perimeter 12 +plot D is area 85 and perimeter 60 +plot G is area 2 and perimeter 6 +plot B is area 42 and perimeter 40 +plot E is area 1 and perimeter 4 +plot P is area 136 and perimeter 64 +plot F is area 85 and perimeter 72 +plot I is area 55 and perimeter 46 +plot Q is area 79 and perimeter 72 +plot S is area 1 and perimeter 4 +plot D is area 101 and perimeter 56 +plot Z is area 3 and perimeter 8 +plot K is area 144 and perimeter 110 +plot Z is area 9 and perimeter 18 +plot U is area 116 and perimeter 74 +plot O is area 4 and perimeter 10 +plot I is area 52 and perimeter 46 +plot A is area 252 and perimeter 158 +plot H is area 3 and perimeter 8 +plot M is area 2 and perimeter 6 +plot A is area 24 and perimeter 28 +plot N is area 1 and perimeter 4 +plot M is area 10 and perimeter 18 +plot Y is area 1 and perimeter 4 +plot N is area 1 and perimeter 4 +plot A is area 1 and perimeter 4 +plot D is area 4 and perimeter 10 +plot B is area 105 and perimeter 68 +plot E is area 1 and perimeter 4 +plot T is area 3 and perimeter 8 +plot A is area 15 and perimeter 24 +plot F is area 7 and perimeter 12 +plot C is area 1 and perimeter 4 +plot L is area 79 and perimeter 56 +plot G is area 68 and perimeter 48 +plot V is area 24 and perimeter 24 +plot E is area 1 and perimeter 4 +plot K is area 1 and perimeter 4 +plot S is area 1 and perimeter 4 +plot B is area 27 and perimeter 32 +plot O is area 45 and perimeter 40 +plot C is area 1 and perimeter 4 +plot U is area 107 and perimeter 84 +plot F is area 12 and perimeter 18 +plot E is area 1 and perimeter 4 +plot T is area 2 and perimeter 6 +plot P is area 1 and perimeter 4 +plot F is area 16 and perimeter 20 +plot X is area 1 and perimeter 4 +plot Y is area 55 and perimeter 42 +plot W is area 11 and perimeter 18 +plot D is area 20 and perimeter 26 +plot W is area 60 and perimeter 54 +plot L is area 34 and perimeter 32 +plot A is area 1 and perimeter 4 +plot F is area 1 and perimeter 4 +plot N is area 50 and perimeter 48 +plot B is area 1 and perimeter 4 +plot R is area 2 and perimeter 6 +plot K is area 82 and perimeter 76 +plot V is area 1 and perimeter 4 +plot H is area 6 and perimeter 14 +plot N is area 35 and perimeter 38 +plot J is area 5 and perimeter 10 +plot R is area 19 and perimeter 22 +plot H is area 1 and perimeter 4 +plot C is area 103 and perimeter 94 +plot V is area 2 and perimeter 6 +plot X is area 10 and perimeter 22 +plot Z is area 47 and perimeter 44 +plot J is area 4 and perimeter 10 +plot Z is area 2 and perimeter 6 +plot J is area 32 and perimeter 32 +plot Q is area 52 and perimeter 50 +plot D is area 31 and perimeter 36 +plot X is area 3 and perimeter 8 +plot I is area 21 and perimeter 30 +plot V is area 142 and perimeter 78 +plot L is area 1 and perimeter 4 +plot F is area 4 and perimeter 8 +plot H is area 2 and perimeter 6 +plot Z is area 56 and perimeter 40 +plot U is area 16 and perimeter 24 +plot I is area 1 and perimeter 4 +plot A is area 2 and perimeter 6 +plot M is area 129 and perimeter 74 +plot R is area 6 and perimeter 12 +plot Z is area 3 and perimeter 8 +plot E is area 6 and perimeter 12 +plot K is area 1 and perimeter 4 +plot S is area 27 and perimeter 30 +plot D is area 2 and perimeter 6 +plot E is area 3 and perimeter 8 +plot U is area 97 and perimeter 72 +plot Q is area 7 and perimeter 12 +plot P is area 2 and perimeter 6 +plot Z is area 119 and perimeter 72 +plot Y is area 41 and perimeter 42 +plot C is area 136 and perimeter 76 +plot K is area 71 and perimeter 60 +plot Q is area 3 and perimeter 8 +plot N is area 6 and perimeter 10 +plot D is area 50 and perimeter 48 +plot S is area 1 and perimeter 4 +plot B is area 96 and perimeter 64 +plot G is area 2 and perimeter 6 +plot Q is area 26 and perimeter 32 +plot X is area 1 and perimeter 4 +plot W is area 9 and perimeter 18 +plot L is area 1 and perimeter 4 +plot G is area 61 and perimeter 48 +plot B is area 2 and perimeter 6 +plot E is area 1 and perimeter 4 +plot Z is area 57 and perimeter 56 +plot P is area 118 and perimeter 76 +plot T is area 2 and perimeter 6 +plot A is area 11 and perimeter 24 +plot I is area 16 and perimeter 28 +plot M is area 11 and perimeter 22 +plot A is area 126 and perimeter 70 +plot P is area 124 and perimeter 74 +plot A is area 1 and perimeter 4 +plot T is area 4 and perimeter 10 +plot F is area 79 and perimeter 66 +plot A is area 1 and perimeter 4 +plot W is area 17 and perimeter 26 +plot Y is area 1 and perimeter 4 +plot B is area 1 and perimeter 4 +plot H is area 1 and perimeter 4 +plot U is area 10 and perimeter 18 +plot Y is area 25 and perimeter 36 +plot P is area 49 and perimeter 48 +plot R is area 3 and perimeter 8 +plot T is area 19 and perimeter 24 +plot H is area 33 and perimeter 38 +plot T is area 1 and perimeter 4 +plot H is area 21 and perimeter 32 +plot D is area 88 and perimeter 68 +plot E is area 1 and perimeter 4 +plot X is area 170 and perimeter 100 +plot N is area 6 and perimeter 12 +plot U is area 90 and perimeter 84 +plot S is area 1 and perimeter 4 +plot B is area 142 and perimeter 152 +plot X is area 105 and perimeter 86 +plot S is area 8 and perimeter 14 +plot B is area 62 and perimeter 54 +plot S is area 1 and perimeter 4 +plot I is area 1 and perimeter 4 +plot G is area 6 and perimeter 12 +plot M is area 177 and perimeter 88 +plot J is area 153 and perimeter 86 +plot N is area 1 and perimeter 4 +plot U is area 1 and perimeter 4 +plot X is area 1 and perimeter 4 +plot O is area 18 and perimeter 32 +plot D is area 71 and perimeter 60 +plot R is area 1 and perimeter 4 +plot A is area 1 and perimeter 4 +plot O is area 14 and perimeter 26 +plot G is area 282 and perimeter 132 +plot I is area 1 and perimeter 4 +plot W is area 38 and perimeter 36 +plot R is area 44 and perimeter 56 +plot P is area 1 and perimeter 4 +plot O is area 2 and perimeter 6 +plot H is area 77 and perimeter 64 +plot J is area 94 and perimeter 54 +plot E is area 1 and perimeter 4 +plot Q is area 1 and perimeter 4 +plot U is area 4 and perimeter 10 +plot K is area 108 and perimeter 60 +plot W is area 3 and perimeter 8 +plot K is area 20 and perimeter 28 +plot W is area 31 and perimeter 34 +plot I is area 179 and perimeter 122 +plot G is area 1 and perimeter 4 +plot B is area 1 and perimeter 4 +plot S is area 1 and perimeter 4 +plot J is area 1 and perimeter 4 +plot U is area 1 and perimeter 4 +plot H is area 41 and perimeter 44 +plot J is area 2 and perimeter 6 +plot V is area 1 and perimeter 4 +plot Q is area 127 and perimeter 76 +plot T is area 109 and perimeter 58 +plot A is area 1 and perimeter 4 +plot U is area 12 and perimeter 22 +plot I is area 1 and perimeter 4 +plot Q is area 137 and perimeter 70 +plot G is area 101 and perimeter 80 +plot T is area 1 and perimeter 4 +plot U is area 1 and perimeter 4 +plot I is area 1 and perimeter 4 +plot K is area 12 and perimeter 14 +plot B is area 1 and perimeter 4 +plot P is area 172 and perimeter 144 +plot H is area 2 and perimeter 6 +plot Q is area 1 and perimeter 4 +plot E is area 2 and perimeter 6 +plot V is area 238 and perimeter 116 +plot R is area 4 and perimeter 8 +plot E is area 17 and perimeter 24 +plot J is area 1 and perimeter 4 +plot O is area 29 and perimeter 26 +plot J is area 84 and perimeter 64 +plot Q is area 2 and perimeter 6 +plot H is area 2 and perimeter 6 +plot E is area 16 and perimeter 22 +plot S is area 105 and perimeter 80 +plot O is area 22 and perimeter 28 +plot A is area 5 and perimeter 12 +plot L is area 1 and perimeter 4 +plot V is area 1 and perimeter 4 +plot K is area 128 and perimeter 70 +plot F is area 42 and perimeter 38 +plot Q is area 1 and perimeter 4 +plot T is area 1 and perimeter 4 +plot S is area 2 and perimeter 6 +plot B is area 130 and perimeter 82 +plot L is area 1 and perimeter 4 +plot U is area 107 and perimeter 82 +plot T is area 141 and perimeter 78 +plot D is area 3 and perimeter 8 +plot J is area 2 and perimeter 6 +plot Q is area 43 and perimeter 48 +plot J is area 306 and perimeter 102 +plot Z is area 1 and perimeter 4 +plot U is area 1 and perimeter 4 +plot S is area 59 and perimeter 52 +plot O is area 36 and perimeter 36 +plot R is area 2 and perimeter 8 +plot I is area 9 and perimeter 18 +plot O is area 2 and perimeter 6 +plot W is area 4 and perimeter 8 +plot J is area 3 and perimeter 8 +plot U is area 1 and perimeter 4 +plot M is area 1 and perimeter 4 +plot Y is area 5 and perimeter 12 +plot S is area 111 and perimeter 64 +plot U is area 62 and perimeter 46 +plot O is area 1 and perimeter 4 +plot R is area 1 and perimeter 4 +plot X is area 33 and perimeter 36 +plot D is area 57 and perimeter 46 +plot U is area 1 and perimeter 4 +plot X is area 1 and perimeter 4 +plot H is area 2 and perimeter 6 +plot Q is area 3 and perimeter 8 +plot Y is area 112 and perimeter 72 +plot R is area 3 and perimeter 8 +plot O is area 2 and perimeter 6 +plot N is area 1 and perimeter 4 +plot S is area 1 and perimeter 4 +plot G is area 115 and perimeter 66 +plot P is area 2 and perimeter 6 +plot F is area 12 and perimeter 18 +plot W is area 1 and perimeter 4 +plot Q is area 5 and perimeter 12 +plot T is area 5 and perimeter 12 +plot F is area 16 and perimeter 22 +plot G is area 1 and perimeter 4 +plot K is area 4 and perimeter 8 +plot U is area 15 and perimeter 24 +plot C is area 6 and perimeter 14 +plot L is area 1 and perimeter 4 +plot G is area 1 and perimeter 4 +plot D is area 13 and perimeter 20 +plot A is area 211 and perimeter 142 +plot V is area 41 and perimeter 38 +plot N is area 110 and perimeter 64 +plot P is area 15 and perimeter 24 +plot R is area 102 and perimeter 72 +plot D is area 5 and perimeter 12 +plot O is area 2 and perimeter 6 +plot B is area 56 and perimeter 54 +plot Z is area 17 and perimeter 24 +plot P is area 5 and perimeter 12 +plot Z is area 1 and perimeter 4 +plot C is area 106 and perimeter 110 +plot E is area 1 and perimeter 4 +plot L is area 81 and perimeter 60 +plot M is area 1 and perimeter 4 +plot L is area 3 and perimeter 8 +plot W is area 25 and perimeter 32 +plot Y is area 1 and perimeter 4 +plot P is area 7 and perimeter 16 +plot W is area 1 and perimeter 4 +plot F is area 1 and perimeter 4 +plot U is area 3 and perimeter 8 +plot R is area 1 and perimeter 4 +plot E is area 3 and perimeter 8 +plot P is area 3 and perimeter 8 +plot W is area 1 and perimeter 4 +plot Q is area 76 and perimeter 62 +plot E is area 123 and perimeter 88 +plot R is area 26 and perimeter 28 +plot C is area 1 and perimeter 4 +plot T is area 45 and perimeter 48 +plot W is area 3 and perimeter 8 +plot M is area 5 and perimeter 12 +plot O is area 2 and perimeter 6 +plot T is area 1 and perimeter 4 +plot D is area 75 and perimeter 62 +plot H is area 1 and perimeter 4 +plot I is area 1 and perimeter 4 +plot F is area 1 and perimeter 4 +plot W is area 107 and perimeter 78 +plot M is area 16 and perimeter 30 +plot Q is area 1 and perimeter 4 +plot Y is area 18 and perimeter 28 +plot L is area 232 and perimeter 134 +plot G is area 141 and perimeter 70 +plot W is area 49 and perimeter 58 +plot V is area 1 and perimeter 4 +plot O is area 60 and perimeter 42 +plot X is area 66 and perimeter 54 +plot R is area 12 and perimeter 16 +plot I is area 1 and perimeter 4 +plot F is area 2 and perimeter 8 +plot P is area 1 and perimeter 4 +plot E is area 21 and perimeter 26 +plot M is area 4 and perimeter 12 +plot W is area 1 and perimeter 4 +plot N is area 30 and perimeter 36 +plot V is area 1 and perimeter 4 +plot J is area 11 and perimeter 20 +plot V is area 77 and perimeter 72 +plot O is area 42 and perimeter 52 +plot B is area 1 and perimeter 4 +plot G is area 1 and perimeter 4 +plot C is area 126 and perimeter 100 +plot L is area 13 and perimeter 20 +plot U is area 156 and perimeter 84 +plot W is area 8 and perimeter 18 +plot L is area 1 and perimeter 4 +plot U is area 92 and perimeter 58 +plot P is area 84 and perimeter 72 +plot C is area 1 and perimeter 4 +plot X is area 42 and perimeter 52 +plot P is area 146 and perimeter 84 +plot U is area 1 and perimeter 4 +plot Y is area 40 and perimeter 50 +plot I is area 2 and perimeter 6 +plot A is area 1 and perimeter 4 +plot D is area 1 and perimeter 4 +plot Q is area 1 and perimeter 4 +plot F is area 116 and perimeter 76 +plot U is area 61 and perimeter 54 +plot S is area 7 and perimeter 16 +plot O is area 1 and perimeter 4 +plot I is area 59 and perimeter 50 +plot G is area 116 and perimeter 94 +plot M is area 1 and perimeter 4 +plot Q is area 145 and perimeter 80 +plot M is area 2 and perimeter 6 +plot U is area 126 and perimeter 82 +plot T is area 1 and perimeter 4 +plot N is area 20 and perimeter 22 +plot F is area 4 and perimeter 10 +plot R is area 3 and perimeter 8 +plot E is area 4 and perimeter 10 +plot H is area 57 and perimeter 50 +plot K is area 106 and perimeter 74 +plot Q is area 1 and perimeter 4 +plot S is area 4 and perimeter 10 +plot L is area 2 and perimeter 6 +plot E is area 142 and perimeter 90 +plot W is area 1 and perimeter 4 +plot S is area 2 and perimeter 6 +plot W is area 10 and perimeter 18 +plot M is area 1 and perimeter 4 +plot P is area 106 and perimeter 82 +plot S is area 1 and perimeter 4 +plot R is area 1 and perimeter 4 +plot S is area 2 and perimeter 6 +plot C is area 1 and perimeter 4 +plot R is area 27 and perimeter 26 +plot G is area 10 and perimeter 16 +plot K is area 1 and perimeter 4 +plot G is area 3 and perimeter 8 +plot T is area 8 and perimeter 18 +plot H is area 1 and perimeter 4 +plot D is area 1 and perimeter 4 +plot A is area 2 and perimeter 6 +plot S is area 1 and perimeter 4 +plot W is area 2 and perimeter 6 +plot B is area 1 and perimeter 4 +plot K is area 1 and perimeter 4 +plot F is area 12 and perimeter 18 +plot X is area 1 and perimeter 4 +plot Q is area 13 and perimeter 20 +plot M is area 1 and perimeter 4 +plot N is area 9 and perimeter 14 +plot I is area 1 and perimeter 4 +plot Z is area 1 and perimeter 4 +plot C is area 2 and perimeter 6 +plot M is area 1 and perimeter 4 diff --git a/12/test2 b/12/test2 new file mode 100644 index 0000000..e52b11f --- /dev/null +++ b/12/test2 @@ -0,0 +1,385 @@ + 10 plot A is area 1 and perimeter 4 + 1 plot A is area 11 and perimeter 24 + 1 plot A is area 113 and perimeter 90 + 1 plot A is area 126 and perimeter 70 + 1 plot A is area 143 and perimeter 150 + 1 plot A is area 15 and perimeter 24 + 4 plot A is area 2 and perimeter 6 + 1 plot A is area 2 and perimeter 8 + 1 plot A is area 211 and perimeter 142 + 1 plot A is area 24 and perimeter 28 + 1 plot A is area 252 and perimeter 158 + 1 plot A is area 3 and perimeter 8 + 1 plot A is area 5 and perimeter 12 + 7 plot B is area 1 and perimeter 4 + 1 plot B is area 105 and perimeter 68 + 1 plot B is area 130 and perimeter 82 + 1 plot B is area 142 and perimeter 152 + 1 plot B is area 15 and perimeter 24 + 2 plot B is area 2 and perimeter 6 + 1 plot B is area 26 and perimeter 28 + 1 plot B is area 27 and perimeter 32 + 1 plot B is area 42 and perimeter 40 + 1 plot B is area 56 and perimeter 54 + 1 plot B is area 6 and perimeter 12 + 1 plot B is area 62 and perimeter 54 + 1 plot B is area 96 and perimeter 64 + 7 plot C is area 1 and perimeter 4 + 1 plot C is area 103 and perimeter 94 + 1 plot C is area 106 and perimeter 110 + 1 plot C is area 126 and perimeter 100 + 1 plot C is area 136 and perimeter 76 + 1 plot C is area 14 and perimeter 18 + 2 plot C is area 2 and perimeter 6 + 1 plot C is area 30 and perimeter 36 + 1 plot C is area 4 and perimeter 8 + 1 plot C is area 6 and perimeter 14 + 4 plot D is area 1 and perimeter 4 + 1 plot D is area 101 and perimeter 56 + 1 plot D is area 13 and perimeter 20 + 1 plot D is area 18 and perimeter 22 + 1 plot D is area 2 and perimeter 6 + 1 plot D is area 20 and perimeter 26 + 1 plot D is area 28 and perimeter 34 + 1 plot D is area 3 and perimeter 8 + 1 plot D is area 31 and perimeter 36 + 1 plot D is area 4 and perimeter 10 + 1 plot D is area 5 and perimeter 12 + 1 plot D is area 50 and perimeter 48 + 1 plot D is area 57 and perimeter 46 + 1 plot D is area 71 and perimeter 52 + 1 plot D is area 71 and perimeter 60 + 1 plot D is area 75 and perimeter 62 + 1 plot D is area 85 and perimeter 60 + 1 plot D is area 88 and perimeter 68 + 8 plot E is area 1 and perimeter 4 + 1 plot E is area 115 and perimeter 96 + 1 plot E is area 123 and perimeter 88 + 1 plot E is area 14 and perimeter 20 + 1 plot E is area 142 and perimeter 90 + 1 plot E is area 16 and perimeter 22 + 1 plot E is area 17 and perimeter 24 + 1 plot E is area 2 and perimeter 6 + 1 plot E is area 21 and perimeter 26 + 2 plot E is area 3 and perimeter 8 + 1 plot E is area 4 and perimeter 10 + 1 plot E is area 46 and perimeter 58 + 1 plot E is area 52 and perimeter 52 + 1 plot E is area 6 and perimeter 12 + 1 plot E is area 78 and perimeter 62 + 1 plot E is area 78 and perimeter 78 + 7 plot F is area 1 and perimeter 4 + 1 plot F is area 116 and perimeter 76 + 3 plot F is area 12 and perimeter 18 + 1 plot F is area 16 and perimeter 20 + 1 plot F is area 16 and perimeter 22 + 1 plot F is area 2 and perimeter 6 + 1 plot F is area 2 and perimeter 8 + 1 plot F is area 22 and perimeter 34 + 1 plot F is area 26 and perimeter 34 + 1 plot F is area 4 and perimeter 10 + 2 plot F is area 4 and perimeter 8 + 1 plot F is area 42 and perimeter 38 + 1 plot F is area 5 and perimeter 12 + 1 plot F is area 7 and perimeter 12 + 1 plot F is area 79 and perimeter 66 + 1 plot F is area 85 and perimeter 72 + 1 plot F is area 93 and perimeter 70 + 6 plot G is area 1 and perimeter 4 + 1 plot G is area 10 and perimeter 16 + 1 plot G is area 101 and perimeter 80 + 1 plot G is area 115 and perimeter 66 + 1 plot G is area 116 and perimeter 94 + 1 plot G is area 141 and perimeter 70 + 2 plot G is area 2 and perimeter 6 + 1 plot G is area 26 and perimeter 34 + 1 plot G is area 282 and perimeter 132 + 3 plot G is area 3 and perimeter 8 + 1 plot G is area 6 and perimeter 12 + 1 plot G is area 61 and perimeter 48 + 1 plot G is area 68 and perimeter 48 + 1 plot G is area 81 and perimeter 64 + 1 plot G is area 85 and perimeter 56 + 7 plot H is area 1 and perimeter 4 + 1 plot H is area 122 and perimeter 74 + 4 plot H is area 2 and perimeter 6 + 1 plot H is area 21 and perimeter 32 + 1 plot H is area 3 and perimeter 8 + 1 plot H is area 33 and perimeter 38 + 1 plot H is area 4 and perimeter 10 + 1 plot H is area 41 and perimeter 44 + 1 plot H is area 57 and perimeter 50 + 1 plot H is area 6 and perimeter 14 + 2 plot H is area 77 and perimeter 64 + 1 plot H is area 8 and perimeter 16 + 1 plot H is area 97 and perimeter 90 + 12 plot I is area 1 and perimeter 4 + 1 plot I is area 16 and perimeter 28 + 1 plot I is area 179 and perimeter 122 + 1 plot I is area 18 and perimeter 24 + 1 plot I is area 2 and perimeter 6 + 1 plot I is area 21 and perimeter 30 + 1 plot I is area 25 and perimeter 40 + 1 plot I is area 45 and perimeter 44 + 1 plot I is area 52 and perimeter 46 + 1 plot I is area 54 and perimeter 52 + 1 plot I is area 55 and perimeter 46 + 1 plot I is area 59 and perimeter 50 + 1 plot I is area 9 and perimeter 18 + 7 plot J is area 1 and perimeter 4 + 1 plot J is area 11 and perimeter 20 + 1 plot J is area 153 and perimeter 86 + 2 plot J is area 2 and perimeter 6 + 1 plot J is area 3 and perimeter 10 + 1 plot J is area 3 and perimeter 8 + 1 plot J is area 306 and perimeter 102 + 1 plot J is area 32 and perimeter 32 + 1 plot J is area 4 and perimeter 10 + 1 plot J is area 5 and perimeter 10 + 1 plot J is area 7 and perimeter 12 + 1 plot J is area 71 and perimeter 36 + 1 plot J is area 84 and perimeter 64 + 1 plot J is area 94 and perimeter 54 + 6 plot K is area 1 and perimeter 4 + 1 plot K is area 106 and perimeter 74 + 1 plot K is area 108 and perimeter 60 + 1 plot K is area 12 and perimeter 14 + 1 plot K is area 120 and perimeter 56 + 1 plot K is area 121 and perimeter 82 + 1 plot K is area 128 and perimeter 70 + 1 plot K is area 144 and perimeter 110 + 1 plot K is area 20 and perimeter 28 + 1 plot K is area 26 and perimeter 32 + 1 plot K is area 4 and perimeter 8 + 1 plot K is area 67 and perimeter 70 + 1 plot K is area 71 and perimeter 60 + 1 plot K is area 76 and perimeter 64 + 1 plot K is area 82 and perimeter 60 + 1 plot K is area 82 and perimeter 76 + 7 plot L is area 1 and perimeter 4 + 1 plot L is area 116 and perimeter 94 + 1 plot L is area 13 and perimeter 20 + 2 plot L is area 2 and perimeter 6 + 1 plot L is area 232 and perimeter 134 + 1 plot L is area 3 and perimeter 8 + 1 plot L is area 34 and perimeter 32 + 1 plot L is area 58 and perimeter 48 + 1 plot L is area 69 and perimeter 62 + 1 plot L is area 79 and perimeter 56 + 1 plot L is area 81 and perimeter 60 + 1 plot L is area 85 and perimeter 60 + 1 plot L is area 99 and perimeter 58 + 12 plot M is area 1 and perimeter 4 + 1 plot M is area 10 and perimeter 18 + 1 plot M is area 11 and perimeter 22 + 1 plot M is area 129 and perimeter 74 + 1 plot M is area 16 and perimeter 30 + 1 plot M is area 177 and perimeter 88 + 2 plot M is area 2 and perimeter 6 + 1 plot M is area 23 and perimeter 24 + 1 plot M is area 4 and perimeter 12 + 1 plot M is area 5 and perimeter 12 + 1 plot M is area 6 and perimeter 10 + 1 plot M is area 8 and perimeter 16 + 5 plot N is area 1 and perimeter 4 + 1 plot N is area 107 and perimeter 80 + 1 plot N is area 110 and perimeter 64 + 1 plot N is area 116 and perimeter 84 + 1 plot N is area 2 and perimeter 6 + 1 plot N is area 20 and perimeter 22 + 1 plot N is area 3 and perimeter 8 + 1 plot N is area 30 and perimeter 36 + 1 plot N is area 35 and perimeter 38 + 1 plot N is area 39 and perimeter 52 + 1 plot N is area 4 and perimeter 10 + 1 plot N is area 50 and perimeter 48 + 1 plot N is area 54 and perimeter 48 + 1 plot N is area 6 and perimeter 10 + 1 plot N is area 6 and perimeter 12 + 1 plot N is area 9 and perimeter 14 + 3 plot O is area 1 and perimeter 4 + 1 plot O is area 106 and perimeter 62 + 1 plot O is area 14 and perimeter 26 + 1 plot O is area 18 and perimeter 26 + 1 plot O is area 18 and perimeter 32 + 5 plot O is area 2 and perimeter 6 + 1 plot O is area 22 and perimeter 28 + 1 plot O is area 29 and perimeter 26 + 1 plot O is area 36 and perimeter 36 + 1 plot O is area 4 and perimeter 10 + 1 plot O is area 42 and perimeter 52 + 1 plot O is area 45 and perimeter 40 + 1 plot O is area 5 and perimeter 10 + 1 plot O is area 52 and perimeter 50 + 1 plot O is area 60 and perimeter 42 + 1 plot O is area 91 and perimeter 66 + 7 plot P is area 1 and perimeter 4 + 1 plot P is area 100 and perimeter 74 + 1 plot P is area 106 and perimeter 82 + 1 plot P is area 118 and perimeter 76 + 1 plot P is area 124 and perimeter 74 + 1 plot P is area 136 and perimeter 64 + 1 plot P is area 146 and perimeter 84 + 1 plot P is area 148 and perimeter 82 + 1 plot P is area 15 and perimeter 24 + 1 plot P is area 172 and perimeter 144 + 1 plot P is area 173 and perimeter 60 + 2 plot P is area 2 and perimeter 6 + 1 plot P is area 25 and perimeter 30 + 1 plot P is area 3 and perimeter 8 + 1 plot P is area 40 and perimeter 34 + 1 plot P is area 49 and perimeter 48 + 1 plot P is area 5 and perimeter 10 + 1 plot P is area 5 and perimeter 12 + 1 plot P is area 7 and perimeter 16 + 1 plot P is area 77 and perimeter 64 + 1 plot P is area 84 and perimeter 72 + 7 plot Q is area 1 and perimeter 4 + 1 plot Q is area 127 and perimeter 76 + 1 plot Q is area 13 and perimeter 20 + 1 plot Q is area 137 and perimeter 70 + 1 plot Q is area 145 and perimeter 80 + 4 plot Q is area 2 and perimeter 6 + 1 plot Q is area 26 and perimeter 32 + 2 plot Q is area 3 and perimeter 8 + 1 plot Q is area 43 and perimeter 48 + 1 plot Q is area 5 and perimeter 12 + 1 plot Q is area 50 and perimeter 46 + 1 plot Q is area 52 and perimeter 50 + 1 plot Q is area 7 and perimeter 12 + 1 plot Q is area 76 and perimeter 62 + 1 plot Q is area 79 and perimeter 72 + 6 plot R is area 1 and perimeter 4 + 1 plot R is area 10 and perimeter 18 + 1 plot R is area 102 and perimeter 72 + 1 plot R is area 12 and perimeter 16 + 1 plot R is area 178 and perimeter 112 + 1 plot R is area 19 and perimeter 22 + 2 plot R is area 2 and perimeter 6 + 1 plot R is area 2 and perimeter 8 + 1 plot R is area 26 and perimeter 28 + 1 plot R is area 27 and perimeter 26 + 3 plot R is area 3 and perimeter 8 + 1 plot R is area 37 and perimeter 34 + 2 plot R is area 4 and perimeter 8 + 1 plot R is area 44 and perimeter 56 + 1 plot R is area 6 and perimeter 12 + 10 plot S is area 1 and perimeter 4 + 1 plot S is area 10 and perimeter 14 + 1 plot S is area 105 and perimeter 80 + 1 plot S is area 111 and perimeter 64 + 1 plot S is area 17 and perimeter 26 + 1 plot S is area 19 and perimeter 28 + 3 plot S is area 2 and perimeter 6 + 1 plot S is area 27 and perimeter 30 + 1 plot S is area 35 and perimeter 34 + 1 plot S is area 4 and perimeter 10 + 1 plot S is area 44 and perimeter 38 + 1 plot S is area 59 and perimeter 52 + 1 plot S is area 6 and perimeter 14 + 1 plot S is area 7 and perimeter 16 + 1 plot S is area 8 and perimeter 14 + 1 plot S is area 86 and perimeter 72 + 1 plot S is area 88 and perimeter 82 + 6 plot T is area 1 and perimeter 4 + 1 plot T is area 109 and perimeter 58 + 2 plot T is area 130 and perimeter 88 + 1 plot T is area 141 and perimeter 78 + 1 plot T is area 19 and perimeter 24 + 2 plot T is area 2 and perimeter 6 + 1 plot T is area 3 and perimeter 8 + 1 plot T is area 4 and perimeter 10 + 1 plot T is area 45 and perimeter 48 + 1 plot T is area 5 and perimeter 12 + 1 plot T is area 69 and perimeter 60 + 1 plot T is area 8 and perimeter 18 + 13 plot U is area 1 and perimeter 4 + 1 plot U is area 10 and perimeter 18 + 1 plot U is area 104 and perimeter 70 + 1 plot U is area 107 and perimeter 82 + 1 plot U is area 107 and perimeter 84 + 1 plot U is area 108 and perimeter 64 + 1 plot U is area 116 and perimeter 74 + 1 plot U is area 12 and perimeter 22 + 1 plot U is area 126 and perimeter 82 + 1 plot U is area 138 and perimeter 80 + 1 plot U is area 15 and perimeter 24 + 1 plot U is area 156 and perimeter 84 + 1 plot U is area 16 and perimeter 24 + 1 plot U is area 2 and perimeter 6 + 1 plot U is area 3 and perimeter 8 + 1 plot U is area 34 and perimeter 44 + 1 plot U is area 4 and perimeter 10 + 1 plot U is area 60 and perimeter 46 + 1 plot U is area 61 and perimeter 54 + 1 plot U is area 62 and perimeter 46 + 1 plot U is area 75 and perimeter 76 + 1 plot U is area 90 and perimeter 84 + 1 plot U is area 92 and perimeter 58 + 1 plot U is area 97 and perimeter 72 + 7 plot V is area 1 and perimeter 4 + 1 plot V is area 142 and perimeter 78 + 2 plot V is area 2 and perimeter 6 + 1 plot V is area 2 and perimeter 8 + 1 plot V is area 238 and perimeter 116 + 1 plot V is area 24 and perimeter 24 + 1 plot V is area 41 and perimeter 38 + 1 plot V is area 5 and perimeter 10 + 1 plot V is area 77 and perimeter 72 + 1 plot V is area 83 and perimeter 60 + 1 plot V is area 92 and perimeter 110 + 7 plot W is area 1 and perimeter 4 + 1 plot W is area 10 and perimeter 18 + 1 plot W is area 105 and perimeter 64 + 1 plot W is area 107 and perimeter 78 + 1 plot W is area 11 and perimeter 18 + 1 plot W is area 17 and perimeter 26 + 2 plot W is area 2 and perimeter 6 + 1 plot W is area 25 and perimeter 32 + 2 plot W is area 3 and perimeter 8 + 1 plot W is area 31 and perimeter 34 + 1 plot W is area 38 and perimeter 36 + 1 plot W is area 4 and perimeter 8 + 1 plot W is area 49 and perimeter 58 + 1 plot W is area 55 and perimeter 48 + 1 plot W is area 58 and perimeter 56 + 1 plot W is area 60 and perimeter 54 + 1 plot W is area 70 and perimeter 52 + 1 plot W is area 8 and perimeter 18 + 1 plot W is area 83 and perimeter 66 + 1 plot W is area 9 and perimeter 18 + 8 plot X is area 1 and perimeter 4 + 1 plot X is area 10 and perimeter 22 + 1 plot X is area 105 and perimeter 86 + 1 plot X is area 112 and perimeter 84 + 1 plot X is area 117 and perimeter 62 + 1 plot X is area 170 and perimeter 100 + 2 plot X is area 3 and perimeter 8 + 1 plot X is area 33 and perimeter 36 + 1 plot X is area 42 and perimeter 52 + 2 plot X is area 6 and perimeter 14 + 1 plot X is area 66 and perimeter 54 + 1 plot X is area 73 and perimeter 68 + 5 plot Y is area 1 and perimeter 4 + 1 plot Y is area 112 and perimeter 72 + 1 plot Y is area 18 and perimeter 28 + 2 plot Y is area 25 and perimeter 36 + 1 plot Y is area 40 and perimeter 50 + 1 plot Y is area 41 and perimeter 42 + 1 plot Y is area 5 and perimeter 12 + 1 plot Y is area 53 and perimeter 44 + 1 plot Y is area 55 and perimeter 42 + 1 plot Y is area 8 and perimeter 14 + 3 plot Z is area 1 and perimeter 4 + 1 plot Z is area 119 and perimeter 72 + 1 plot Z is area 13 and perimeter 22 + 1 plot Z is area 17 and perimeter 24 + 1 plot Z is area 18 and perimeter 28 + 3 plot Z is area 2 and perimeter 6 + 4 plot Z is area 3 and perimeter 8 + 1 plot Z is area 47 and perimeter 44 + 1 plot Z is area 56 and perimeter 40 + 1 plot Z is area 57 and perimeter 56 + 1 plot Z is area 7 and perimeter 12 + 1 plot Z is area 76 and perimeter 78 + 1 plot Z is area 9 and perimeter 18 diff --git a/5/a.out b/5/a.out index 64e90b1..aee010b 100755 Binary files a/5/a.out and b/5/a.out differ diff --git a/5/mainB.c b/5/mainB.c new file mode 100644 index 0000000..5f5c58f --- /dev/null +++ b/5/mainB.c @@ -0,0 +1,156 @@ +#include +#include +#include +#include + +#define LINES 1000 + +struct page { + int page; + int *illegalPrec; + int ruleLen; + struct page *next; +}; + +void shuffle(int *array, size_t n) +{ + if (n > 1) + { + size_t i; + for (i = 0; i < n - 1; i++) + { + size_t j = i + rand() / (RAND_MAX / (n - i) + 1); + int t = array[j]; + array[j] = array[i]; + array[i] = t; + } + } +} + +void add_page(struct page *head, int page) +{ + // traverse list until last member + while(head->next) head = head->next; + + // allocate and store ptr + head->next = malloc(sizeof(struct page)); + + // allocate illegalArray + head->next->illegalPrec = calloc(16, sizeof(int)); + head->next->ruleLen = 16; + + // store page number in new item + head->next->page = page; + head->next->next = 0; +} +void add_rule (struct page *page, int illegal) +{ + // make sure you wont go oob + int i = 0; + for (i = 0; i < page->ruleLen && page->illegalPrec[i] != 0; i++); + // if oob, realloc illegalPrec and change ruleLen-size + if (i >= page->ruleLen - 1) { + page->illegalPrec = realloc(page->illegalPrec, + page->ruleLen * 2 * sizeof(int)); + page->ruleLen *= 2; + } + // store illegal page + page->illegalPrec[i] = illegal; +} + +// power! x to the y! +int pow(int x, int y) +{ + int ans = 1; + for (int i = 0; i < y; i++) ans *= x; + return ans; +} +// parse string into array of numbers +int parse_numbers(char *str_row, int *row, int n) +{ + int i = 0; + for (; str_row[i] != '\n'; i++); + for (; i >= 0; i--) { + int pos = 0; + for (; str_row[i] >= '0' && str_row[i] <= '9' && i >= 0; i--) { + row[n] += (str_row[i] - '0') * pow(10, pos); + pos++; + } + n--; + } + + return 1; +} + +bool check_report (int *updates, int len, struct page *rules) +{ + for (int i = len - 1; i >= 0; i--) { + struct page *current = rules; + // for each array member, try to find it in rules + while (current->page != updates[i] && current->next) + current = current->next; + if (current->page != updates[i]) + continue; + // if found, for each lower array member, + // iterate through current->illegalPrec + // if match, illegal report + for (int j = i - 1; j >= 0; j--) { + for (int k = 0; k < current->ruleLen; k++) { + if (updates[j] == current->illegalPrec[k]) + return 0; + } + } + } + return 1; +} + +int main () +{ + FILE *input = fopen("input", "r"); + // create list of pages, each with arrays of pages that must be BEFORE them + struct page *pages = malloc(sizeof(struct page)); + struct page *current = pages; + // find pair. + int left = 0; + int right = 0; + // init head + fscanf(input, "%d|%d", &left, &right); + current->page = left; + current->ruleLen = 16; + current->illegalPrec = calloc(16, sizeof(int)); + add_rule(current, right); + while (fscanf(input, "%d|%d", &left, &right) == 2) { + // check if left exists in list + while (current->next && current->page != left) + current = current->next; + if (current->page == left) { + add_rule(current, right); + } + else { + add_page(pages, left); + add_rule(current->next, right); + } + current = pages; + } + fseek(input, -2, SEEK_CUR); + // take in line. Parse numbers until newline. + char line[100]; + int sum_reports = 0; + while (fgets(line, 100, input)) { + int numbers = 1; + for (int c = 0; line[c]; c++) numbers += (line[c] == ','); + int *updates = (int *)calloc(numbers, sizeof(int)); + parse_numbers(line, updates, numbers); + + while (!check_report(updates, numbers, pages)) { + shuffle(updates, numbers); + if (check_report(updates, numbers, pages)) + sum_reports += updates[numbers / 2]; + } + } + // Remember how many numbers you got this line, we'll iterate backwards! + // for each number in update, iterate through page-rules til you find it + // if found, make sure it isnt preceded by any page in its list? + // probably best to work completely backwards? rules can only ban pages from being before others + printf("sum: %d\n", sum_reports); +} diff --git a/5/mainBShuffle.c b/5/mainBShuffle.c new file mode 100644 index 0000000..5f5c58f --- /dev/null +++ b/5/mainBShuffle.c @@ -0,0 +1,156 @@ +#include +#include +#include +#include + +#define LINES 1000 + +struct page { + int page; + int *illegalPrec; + int ruleLen; + struct page *next; +}; + +void shuffle(int *array, size_t n) +{ + if (n > 1) + { + size_t i; + for (i = 0; i < n - 1; i++) + { + size_t j = i + rand() / (RAND_MAX / (n - i) + 1); + int t = array[j]; + array[j] = array[i]; + array[i] = t; + } + } +} + +void add_page(struct page *head, int page) +{ + // traverse list until last member + while(head->next) head = head->next; + + // allocate and store ptr + head->next = malloc(sizeof(struct page)); + + // allocate illegalArray + head->next->illegalPrec = calloc(16, sizeof(int)); + head->next->ruleLen = 16; + + // store page number in new item + head->next->page = page; + head->next->next = 0; +} +void add_rule (struct page *page, int illegal) +{ + // make sure you wont go oob + int i = 0; + for (i = 0; i < page->ruleLen && page->illegalPrec[i] != 0; i++); + // if oob, realloc illegalPrec and change ruleLen-size + if (i >= page->ruleLen - 1) { + page->illegalPrec = realloc(page->illegalPrec, + page->ruleLen * 2 * sizeof(int)); + page->ruleLen *= 2; + } + // store illegal page + page->illegalPrec[i] = illegal; +} + +// power! x to the y! +int pow(int x, int y) +{ + int ans = 1; + for (int i = 0; i < y; i++) ans *= x; + return ans; +} +// parse string into array of numbers +int parse_numbers(char *str_row, int *row, int n) +{ + int i = 0; + for (; str_row[i] != '\n'; i++); + for (; i >= 0; i--) { + int pos = 0; + for (; str_row[i] >= '0' && str_row[i] <= '9' && i >= 0; i--) { + row[n] += (str_row[i] - '0') * pow(10, pos); + pos++; + } + n--; + } + + return 1; +} + +bool check_report (int *updates, int len, struct page *rules) +{ + for (int i = len - 1; i >= 0; i--) { + struct page *current = rules; + // for each array member, try to find it in rules + while (current->page != updates[i] && current->next) + current = current->next; + if (current->page != updates[i]) + continue; + // if found, for each lower array member, + // iterate through current->illegalPrec + // if match, illegal report + for (int j = i - 1; j >= 0; j--) { + for (int k = 0; k < current->ruleLen; k++) { + if (updates[j] == current->illegalPrec[k]) + return 0; + } + } + } + return 1; +} + +int main () +{ + FILE *input = fopen("input", "r"); + // create list of pages, each with arrays of pages that must be BEFORE them + struct page *pages = malloc(sizeof(struct page)); + struct page *current = pages; + // find pair. + int left = 0; + int right = 0; + // init head + fscanf(input, "%d|%d", &left, &right); + current->page = left; + current->ruleLen = 16; + current->illegalPrec = calloc(16, sizeof(int)); + add_rule(current, right); + while (fscanf(input, "%d|%d", &left, &right) == 2) { + // check if left exists in list + while (current->next && current->page != left) + current = current->next; + if (current->page == left) { + add_rule(current, right); + } + else { + add_page(pages, left); + add_rule(current->next, right); + } + current = pages; + } + fseek(input, -2, SEEK_CUR); + // take in line. Parse numbers until newline. + char line[100]; + int sum_reports = 0; + while (fgets(line, 100, input)) { + int numbers = 1; + for (int c = 0; line[c]; c++) numbers += (line[c] == ','); + int *updates = (int *)calloc(numbers, sizeof(int)); + parse_numbers(line, updates, numbers); + + while (!check_report(updates, numbers, pages)) { + shuffle(updates, numbers); + if (check_report(updates, numbers, pages)) + sum_reports += updates[numbers / 2]; + } + } + // Remember how many numbers you got this line, we'll iterate backwards! + // for each number in update, iterate through page-rules til you find it + // if found, make sure it isnt preceded by any page in its list? + // probably best to work completely backwards? rules can only ban pages from being before others + printf("sum: %d\n", sum_reports); +}