commit aa5470f8e16da0c38a03f8f2f4f58f08a3cfa4aa Author: kirreen Date: Tue Dec 3 13:13:13 2024 +0100 solved day 1 and 2 diff --git a/1/day1 b/1/day1 new file mode 100755 index 0000000..963b7a1 Binary files /dev/null and b/1/day1 differ diff --git a/1/day1B b/1/day1B new file mode 100755 index 0000000..9189aea Binary files /dev/null and b/1/day1B differ diff --git a/1/input b/1/input new file mode 100644 index 0000000..cb6af3c --- /dev/null +++ b/1/input @@ -0,0 +1,1000 @@ +14764 28773 +59598 86587 +63147 83451 +40514 98156 +87534 16479 +45973 70030 +54965 61736 +74648 96398 +74806 54303 +59928 90661 +20699 66537 +78761 92340 +98940 65476 +80802 95605 +60992 14776 +50682 24755 +50058 93707 +94284 24755 +12156 11378 +12570 11246 +80932 42425 +43285 34499 +12178 60368 +42769 14776 +84125 76989 +96147 56013 +59913 97498 +96516 73501 +50544 14989 +61563 30781 +77558 24755 +42975 16439 +15144 48888 +58682 54556 +26702 28773 +70122 84904 +63011 21879 +35169 61029 +24755 17273 +82821 84904 +72828 31150 +79206 14776 +33200 20410 +60784 31612 +83670 47240 +34804 33091 +60626 38038 +86976 14776 +52742 73610 +14475 89997 +38361 86278 +13676 47791 +55862 38300 +49359 88343 +65399 50107 +37680 70002 +18748 70030 +18194 60295 +47721 87961 +88751 81703 +43668 87575 +98122 81412 +40374 59406 +10728 70002 +16342 87961 +39219 60134 +49679 38882 +60516 42195 +24012 66048 +25680 58634 +43100 28773 +25474 63592 +96520 14989 +57777 48481 +79027 93493 +11616 31094 +78378 70069 +84632 41501 +56086 13252 +42233 14000 +91310 34109 +30039 70635 +51428 33091 +74252 27409 +47188 50437 +67840 82887 +51822 38041 +61288 11754 +28673 95998 +84464 18379 +19745 14989 +76538 69263 +48693 48158 +25824 26564 +47422 26702 +63260 55162 +50610 20088 +11246 14776 +36616 96398 +48715 37866 +40501 87961 +84018 11246 +11235 95605 +60766 84099 +56833 10632 +26052 24115 +86850 63187 +96807 97498 +36028 14776 +28835 44350 +80413 14989 +23361 94328 +73994 70570 +95782 14989 +50992 96398 +16452 24559 +23476 26026 +48928 20088 +65743 30914 +23934 97498 +44641 85863 +19631 73108 +95142 58795 +98765 54626 +63049 20977 +18870 96398 +39312 32124 +19723 24115 +75131 99521 +15390 25186 +73207 10585 +14040 51560 +29954 68086 +38712 70030 +85468 86587 +95155 85042 +67412 98156 +41035 94284 +83320 48158 +90483 86587 +56827 49101 +75118 26702 +41487 57022 +46320 14776 +66537 87961 +52715 83100 +38882 26936 +70814 43122 +70750 64345 +29589 44580 +37398 26936 +40837 70002 +16771 11659 +94208 28773 +87906 97482 +74664 86587 +90116 87961 +99992 14989 +34113 81703 +89349 24115 +98148 62403 +42448 66537 +96296 28773 +57152 68961 +11277 42577 +36095 95605 +74684 28773 +33845 70570 +38158 14989 +15582 49424 +43600 11804 +63053 13761 +24342 76970 +92512 70030 +54252 30763 +73129 84904 +28773 12682 +32819 91123 +49835 86136 +16933 48639 +33213 12919 +10645 57366 +98251 65105 +52576 92477 +69406 30133 +67892 97797 +72483 26702 +17769 33091 +56789 53884 +14989 98156 +24140 97478 +18359 90471 +12073 91310 +38574 55162 +33091 74847 +89381 14213 +49449 91310 +64091 70030 +39247 42425 +25923 14989 +71251 68086 +24345 96398 +51558 79525 +96411 47119 +89958 70570 +76933 62218 +55949 70002 +43038 17285 +28551 26702 +95390 18863 +14866 46054 +88996 66537 +26075 21233 +39333 24115 +76335 97498 +99707 53061 +42177 90193 +14331 14776 +50227 38217 +78702 65884 +68910 87030 +46977 11246 +48214 96398 +51071 63952 +10391 33023 +46218 70030 +87713 79687 +57826 54282 +39480 97498 +64702 58553 +30861 51958 +22562 20088 +87627 28773 +68916 98156 +57407 88060 +29689 23857 +65454 98968 +15700 37327 +26803 95605 +15017 29068 +40380 60403 +69860 26248 +66059 88561 +58318 38541 +17839 28773 +79014 14989 +33520 24755 +81719 99646 +97850 30945 +89786 33091 +38928 38882 +93407 94284 +69408 48928 +37881 70002 +32254 43523 +68247 28773 +54752 89267 +29214 20088 +98248 98156 +58405 14989 +19932 93969 +95299 11246 +34948 70635 +35574 70002 +61738 80387 +98156 84904 +70128 66075 +44319 37979 +24280 27624 +36470 47223 +62315 42425 +32292 56201 +52245 45780 +70839 32043 +34787 78810 +67967 21147 +47767 86498 +88861 60623 +81588 82803 +57939 81703 +31732 94284 +46639 74596 +39121 76377 +10454 94284 +46701 27665 +80935 48158 +93418 99233 +86078 49136 +55356 72518 +51235 48158 +94312 89985 +18379 76636 +82631 46202 +73383 72296 +30654 74007 +82162 80836 +81614 56019 +26936 14776 +64866 64944 +10826 89173 +85362 73676 +39371 46554 +68384 28773 +87889 38587 +14856 56658 +99573 51530 +91777 78669 +95150 97498 +49111 26038 +60208 97704 +69664 24755 +27678 84904 +48916 78231 +15557 89973 +90782 20088 +87961 84904 +42368 26702 +40844 81703 +40750 66537 +13745 87961 +20088 24115 +31234 63276 +17198 25020 +67865 53558 +16266 19730 +64250 15511 +34405 95190 +69368 81775 +90053 31704 +65374 97498 +91614 69998 +70733 62921 +48158 92224 +99303 26702 +51318 20088 +24507 70570 +21139 24682 +62476 16854 +35217 94943 +38613 85127 +65794 23397 +43762 98156 +38914 26702 +93827 95605 +18121 83482 +44552 70570 +94358 70635 +44248 87279 +93340 91862 +47094 80019 +12115 22286 +61446 66475 +22034 81703 +13882 64607 +42845 56734 +14983 98703 +42881 38664 +69071 58912 +84078 87961 +77528 28773 +65018 26702 +80503 27258 +40534 98156 +97419 27317 +61450 61386 +44217 78513 +35342 55289 +60439 70002 +72059 70570 +76006 70570 +86878 40854 +58404 38860 +49034 23075 +55592 38032 +38344 16697 +53897 33091 +72649 18979 +59214 18944 +92474 69727 +56370 36522 +20573 20088 +26285 11559 +15809 43925 +56727 92121 +84539 96398 +55090 41104 +77753 83370 +78169 44330 +62175 84776 +61410 67693 +26872 94284 +80145 33677 +63895 27014 +54436 94284 +27551 52234 +70275 97498 +83218 84328 +76355 42630 +47953 29593 +40172 70635 +29988 57720 +84694 45868 +14741 84904 +78418 32122 +19787 96398 +97191 75785 +62241 14110 +38111 49908 +16878 95565 +65882 87961 +27528 30687 +24926 66537 +66319 86032 +71326 82785 +33060 79631 +80025 17963 +73714 96398 +33135 74777 +68453 48928 +97498 24115 +86671 18667 +71089 40231 +88441 26416 +69505 18247 +84654 87513 +68724 98903 +89841 28773 +56212 21616 +17426 80476 +44666 38523 +91211 26702 +26105 70635 +21759 14776 +98944 26362 +71236 38797 +42913 58775 +88578 14776 +72715 43283 +28967 20088 +84103 76725 +99695 48928 +64085 28773 +73316 33493 +72198 48928 +49559 70002 +38910 48928 +17599 42425 +84904 78946 +22276 55162 +58705 96924 +49033 55841 +57127 69408 +14022 70002 +64371 26702 +97436 54477 +30953 95848 +52677 10733 +62159 48928 +88481 55753 +81171 66537 +57638 46475 +61383 79886 +88427 24420 +96594 50213 +11462 90266 +67963 73678 +17744 66537 +79612 95605 +93100 30264 +32749 20088 +94436 75277 +45034 39394 +51810 84904 +43770 87961 +59487 84904 +73654 20088 +76244 39669 +93096 41969 +61078 18532 +64038 68086 +80823 20926 +24219 33166 +64789 47154 +45656 59480 +96245 26702 +46975 96398 +21791 21720 +36832 25932 +40413 90256 +35647 56771 +85109 69081 +96428 95605 +63398 98448 +86469 81278 +34738 54568 +58332 69690 +29366 38882 +43612 26582 +20715 13081 +13296 22608 +73338 65201 +39693 75574 +55258 87961 +72724 68868 +78654 50140 +85411 31891 +60178 64075 +67363 80960 +37379 96429 +40440 52965 +82070 48657 +22042 17036 +77928 49874 +16662 96398 +39080 72090 +36754 90110 +52253 13816 +63630 48928 +68957 70819 +45100 25633 +82085 27847 +17126 28773 +37291 97173 +57062 11246 +12567 71707 +51113 75861 +89899 26702 +99628 26702 +75520 81811 +93558 13940 +49113 62910 +20958 87961 +77841 87019 +75297 48928 +57790 48928 +32002 77033 +42282 94284 +43678 84904 +31604 49493 +74565 28773 +22599 31143 +82887 59506 +39004 54574 +78978 79120 +90292 39855 +95502 99786 +21111 70626 +56784 92396 +13139 80974 +92819 25441 +73536 87961 +29862 24755 +99684 73955 +72968 89889 +13389 24733 +11304 81703 +21283 96196 +29316 10170 +39855 52810 +87865 93597 +97638 24115 +65813 70719 +60400 31888 +28931 32564 +39635 69408 +53198 87575 +26868 87575 +76903 38317 +65814 97018 +30920 33091 +17272 86587 +36064 40874 +60497 86587 +52751 94284 +98146 20555 +82591 71240 +80940 94284 +58866 60084 +19528 96398 +50171 42425 +83139 14776 +54987 84299 +86114 91310 +95215 20088 +33676 91776 +33258 84904 +94339 14989 +93998 30882 +12128 48129 +70002 20088 +17360 55991 +53459 95355 +86002 70002 +82138 79394 +77891 97498 +97857 56980 +80792 63735 +25421 58294 +35922 12614 +81854 32809 +53275 35517 +57944 58635 +87461 63921 +18830 65741 +71991 21238 +20578 14989 +30318 93736 +47800 78875 +70513 70570 +19497 23690 +85084 95631 +22048 86587 +81414 55666 +80731 69207 +18973 59682 +94485 48928 +77316 13319 +12204 51966 +70689 33091 +34924 22911 +96610 19455 +55203 24115 +75093 48158 +87356 14999 +18221 33578 +73385 48928 +81742 58221 +99442 82887 +28678 80624 +35197 87961 +35467 94284 +18508 51523 +14264 54207 +31053 40807 +64587 56579 +31857 72079 +80498 95581 +73182 87575 +38534 55162 +19889 76201 +62987 35692 +28009 48158 +62366 13329 +67690 14228 +87575 13596 +75924 66537 +43917 48158 +85815 28141 +12195 66537 +28926 26936 +28067 11246 +10649 83782 +90300 37607 +26829 33091 +97237 61393 +28274 87961 +81949 69715 +10148 86587 +20782 82454 +65121 86587 +35048 25761 +42425 98156 +49562 26702 +62240 64020 +97292 25754 +77339 95190 +96171 69408 +78515 44047 +23269 81703 +86257 11890 +53795 31884 +47860 69457 +27030 81703 +95995 46031 +88330 14776 +36227 95605 +71611 49839 +41787 68086 +98937 95605 +15634 78884 +38019 25226 +40301 68031 +64868 55162 +20353 28773 +52004 20088 +33605 36752 +52954 97498 +22677 92974 +35007 86399 +16229 14776 +92840 67007 +53192 70030 +14342 89825 +83874 20965 +67836 23984 +13168 89395 +45532 99100 +28527 26702 +11652 24115 +65046 72711 +24115 22371 +15313 14989 +46692 26702 +55036 14776 +47509 96398 +79999 58058 +75429 27911 +86289 83776 +40994 86587 +23698 49671 +60630 70567 +39923 14340 +41480 56160 +50015 85965 +20119 27795 +54647 79989 +32724 20334 +34408 48928 +13854 58826 +75114 43950 +45654 66537 +35904 14776 +97510 94203 +94288 70002 +62816 86587 +52333 95190 +56575 33091 +16125 96398 +72085 22071 +79557 70570 +88132 51844 +13717 72028 +59557 48158 +21409 10973 +84192 80904 +55868 24115 +84432 44699 +36959 87575 +76847 55162 +22567 24115 +67194 20088 +10465 86045 +30706 90300 +90253 64531 +75677 70115 +90677 80124 +16022 37893 +35712 73458 +49005 66248 +63561 62138 +39451 26233 +23062 75780 +88457 16642 +60392 76302 +10273 86587 +21677 70570 +36650 95605 +99569 14989 +70030 94284 +17260 81703 +26866 97440 +96514 96034 +96398 85529 +28702 79102 +79651 61560 +94067 31196 +71869 73932 +57996 50145 +35350 89987 +74905 77610 +42941 11246 +87385 28773 +32235 86698 +33758 84904 +75879 56926 +22019 92584 +21649 37986 +55926 84525 +74822 21112 +37702 70635 +62444 94284 +17072 12964 +80776 14776 +86143 84904 +90967 59199 +82007 95190 +61344 94380 +23060 62759 +71836 29181 +16696 86051 +23602 70030 +61274 61768 +35327 94433 +48285 55162 +19775 18482 +79268 18379 +66437 24755 +66155 44810 +54687 47121 +47590 10505 +49604 87575 +39448 14989 +70866 91310 +40876 88016 +38356 82887 +78821 87795 +60336 84904 +95020 18379 +92719 38882 +44432 70635 +55162 20864 +20330 57239 +68086 28020 +27630 63281 +86610 69601 +11026 90977 +88395 58295 +51282 39771 +27597 95605 +92765 48928 +75775 87961 +70635 94284 +24241 87961 +61618 20088 +16337 50458 +98080 39551 +28091 48158 +65880 66493 +24832 48928 +32253 27393 +27035 41482 +34239 96262 +31294 26702 +10102 12198 +36743 78333 +23284 75787 +87169 75720 +84151 87961 +26666 79650 +89818 40672 +70570 65623 +81552 84522 +56875 78429 +15373 28773 +77993 34110 +36591 96398 +61768 42887 +71478 68504 +25433 96100 +98896 81958 +93352 28773 +43847 93400 +60150 66441 +80559 70002 +45453 60573 +11057 26011 +40296 63705 +30537 95605 +95190 10399 +58593 11246 +23634 58654 +19831 48928 +60897 52279 +98886 87961 +18897 52942 +53785 10405 +58898 24115 +58346 24755 +42098 31963 +83994 80991 +22205 55162 +74702 66537 +95807 26702 +23781 92776 +49996 66296 +72776 81703 +31849 70570 +52068 87294 +98819 59638 +32585 48158 +51597 85464 +85824 75556 +27722 57980 +71157 14989 +43341 46516 +45946 45375 +20545 48928 +73393 32160 +13910 97316 +79218 96398 +44035 88007 +15597 79600 +15662 70002 +34269 49123 +37898 98156 +40216 26702 +92831 87961 +77463 70570 +89751 84904 +56728 88267 +55828 45038 +99410 96962 +27691 22801 +10416 70570 +47279 91310 +50204 14776 +56597 40834 +77705 43023 +72403 33091 +36921 51477 +62196 36387 +39460 42518 +86502 37844 +88097 38882 +62899 57280 +63482 20088 +51582 24115 +82873 70570 +81897 84904 +70932 24115 +47617 78694 +17894 48126 +66191 20440 +11809 14989 +28873 70002 +26808 98156 +57387 79775 +54906 33091 +51853 14776 +48424 84904 +62763 27546 +73121 54587 +95605 48158 +61687 86587 +31005 97498 +78477 78372 +35623 84904 +20589 77307 +78283 40059 +94194 43725 +44078 67834 +81703 31282 +99920 59468 +22742 37828 +55795 12750 +27345 14989 +91944 45458 +30545 19535 +20030 70570 +25018 69169 +12044 13251 +91516 82887 +91683 16178 +27731 86587 +80834 21540 +56421 26695 +60139 70002 +28612 95499 +75264 11246 +64380 66537 +56560 26702 +18126 47523 +71350 31211 +25426 65619 +24228 83125 +45887 70570 +10621 11246 +89105 70570 +53390 49454 +57017 81703 +76370 94284 +60258 85023 +51705 96398 +15492 37504 +55450 96398 +65708 91167 +37078 83486 +14776 10500 +99794 86587 +50029 87365 +47006 35798 +87658 85900 +80839 90300 +88943 94078 +33451 28773 +91207 86587 +33560 48158 +80832 43682 +86587 16558 +34637 42425 +40252 22905 +94463 63284 +13247 72402 +14825 48158 +60196 91310 +45730 14776 +85407 18493 +19771 50847 +30506 24755 +32174 68086 diff --git a/1/inputDemo b/1/inputDemo new file mode 100644 index 0000000..b8af9ad --- /dev/null +++ b/1/inputDemo @@ -0,0 +1,6 @@ +3 4 +4 3 +2 5 +1 3 +3 9 +3 3 diff --git a/1/main.c b/1/main.c new file mode 100644 index 0000000..50c449d --- /dev/null +++ b/1/main.c @@ -0,0 +1,49 @@ +#include +#include + +#define LINES 1000 + +int compare(const void *a, const void *b); + +int main() +{ + // populate arrays from file + FILE *input; + input = fopen("./input", "r"); + unsigned int left[LINES]; + unsigned int right[LINES]; + + for (int i = 0; i < LINES; i++) { + fscanf(input, "%d", &left[i]); + // printf("%d left: %d ", i, left[i]); + fscanf(input, "%d", &right[i]); + // printf("%d right: %d\n", i, right[i]); + } + + // sort arrays + qsort(left, LINES, sizeof(int), compare); + qsort(right, LINES, sizeof(int), compare); + /* + for (int i = 0; i < LINES; i++) { + printf("%d left: %d ", i, left[i]); + printf("%d right: %d\n", i, right[i]); + } + */ + + // compare each element n, add its difference to sum-var + unsigned long int distance = 0; + for (int i = 0; i < LINES; i++) { + distance += abs(left[i] - right[i]); + } + printf("distance: %d\n", distance); +} + +int compare(const void *a, const void *b) +{ + int int_a = * ((int*) a); + int int_b = * ((int*) b); + + if (int_a == int_b) return 0; + else if (int_a < int_b) return -1; + else return 1; +} diff --git a/1/mainB.c b/1/mainB.c new file mode 100644 index 0000000..930572f --- /dev/null +++ b/1/mainB.c @@ -0,0 +1,51 @@ +#include +#include + +#define LINES 1000 + +int compare(const void *a, const void *b); + +int main() +{ + // populate arrays from file + FILE *input; + input = fopen("./input", "r"); + unsigned int left[LINES]; + unsigned int right[LINES]; + + for (int i = 0; i < LINES; i++) { + fscanf(input, "%d", &left[i]); + // printf("%d left: %d ", i, left[i]); + fscanf(input, "%d", &right[i]); + // printf("%d right: %d\n", i, right[i]); + } + /* + for (int i = 0; i < LINES; i++) { + printf("%d left: %d ", i, left[i]); + printf("%d right: %d\n", i, right[i]); + } + */ + + // check how many times left[i] is in right[]. multiply left[i] by this. + // then sum it + unsigned long int sum = 0; + for (int i = 0; i < LINES; i++) { + int numRight = 0; + for (int j = 0; j < LINES; j++) { + numRight += left[i] == right[j]; + } + sum += left[i] * numRight; + } + + printf("sum: %d\n", sum); +} + +int compare(const void *a, const void *b) +{ + int int_a = * ((int*) a); + int int_b = * ((int*) b); + + if (int_a == int_b) return 0; + else if (int_a < int_b) return -1; + else return 1; +} diff --git a/2/' b/2/' new file mode 100644 index 0000000..da869e2 --- /dev/null +++ b/2/' @@ -0,0 +1,86 @@ +#include +#include + +#define LINES 1000 + +// 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; +} +// check if specific report is safe +int check_report(int *row, int len) +{ + // read number. Compare next number (higher, lower, +-1-2) + // if you get to row[i + 1]line, ++ + int rising = 0; + int first = 1; + for (int i = 0; i < len - 1; i++) { + // if difference isnt 1-3 + if (abs(row[i + 1] - row[i]) > 3 || abs(row[i + 1] - row[i]) < 1) + return 0; + // only for first comparison of row. Set direction. + if (first && ((row[i + 1] - row[i]) < 0)) + rising = 0; + else if (first) + rising = 1; + // for other comparisons, compare current direction to the previous. + if (!first && (rising != !((row[i + 1] - row[i]) < 0))) { + // printf("rising: %d while %d - %d is %d\n", rising, row[i + 1], row[i], row[i + 1] - row[i]); + return 0; + } + // get ready for the next comparisons! + first = 0; + } + return 1; +} + +int dampener(int *row, int len) +{ + if (check_report(row, len)) return 1; +} + +int main() +{ + int safe = 0; + // read input row into array, count elements + FILE *input; + input = fopen("./input", "r"); + char line[32]; + for (int i = 0; i < LINES; i++) { + // get string (line), count numbers, put into int array (row) + int numbers = 1; + fgets(line, sizeof(line), input); + // count number of numbers, allocate memory + for (int c = 0; line[c]; c++) numbers += (line[c] == ' '); + int *row = (int *)calloc(numbers, sizeof(int)); + // parse numbers into array + parse_numbers(line, row, numbers); + // for (int j = 0; j < numbers; j++) printf("%d ", row[j]); + // printf("\n\n"); + + // send elements and length to check_report, add result to sum + safe += check_report(row, numbers); + free(row); + } + + printf("%d\n", safe); +} diff --git a/2/B b/2/B new file mode 100755 index 0000000..2e7b16a Binary files /dev/null and b/2/B differ diff --git a/2/a.out b/2/a.out new file mode 100755 index 0000000..2ec387c Binary files /dev/null and b/2/a.out differ diff --git a/2/input b/2/input new file mode 100644 index 0000000..f577cd1 --- /dev/null +++ b/2/input @@ -0,0 +1,1000 @@ +73 75 78 81 80 +81 82 83 86 89 89 +66 67 68 71 75 +66 67 69 70 72 74 77 83 +88 90 93 90 91 92 +61 62 60 63 60 +39 41 44 47 48 45 47 47 +63 66 63 66 70 +92 95 92 93 98 +86 88 91 91 92 +39 41 41 42 44 46 49 46 +79 81 82 82 83 84 84 +58 60 63 65 67 67 71 +63 65 66 67 67 70 76 +83 85 88 90 94 96 97 +27 30 34 36 39 40 41 40 +76 78 82 85 86 88 90 90 +57 60 61 63 67 69 73 +63 66 70 71 73 74 80 +42 43 45 51 53 55 +82 85 86 89 92 98 97 +44 45 47 54 54 +31 33 40 43 47 +54 56 59 66 71 +84 82 83 84 85 88 90 +60 59 61 63 66 69 70 69 +33 31 34 35 35 +39 36 38 41 44 46 48 52 +82 81 84 87 93 +63 62 59 62 65 66 +20 18 21 19 17 +43 40 41 40 40 +88 86 87 90 88 91 94 98 +36 34 36 33 34 41 +17 15 16 18 18 20 23 24 +80 77 79 79 77 +93 92 93 95 95 95 +29 27 29 30 31 31 35 +30 29 31 34 36 36 38 43 +31 30 33 37 38 41 42 +12 10 11 15 16 13 +54 51 55 57 59 60 63 63 +60 58 61 65 66 70 +86 83 85 89 90 92 93 99 +28 27 33 36 37 40 42 +47 46 49 51 52 53 58 56 +22 21 23 24 27 34 37 37 +39 38 45 46 48 49 53 +54 51 53 54 57 64 69 +24 24 25 27 29 31 34 37 +69 69 72 75 77 78 77 +16 16 19 21 24 27 27 +26 26 27 29 32 36 +60 60 62 63 65 68 71 76 +71 71 72 73 74 72 75 77 +68 68 67 68 69 70 73 71 +53 53 52 55 58 58 +54 54 52 55 56 60 +32 32 34 35 38 40 38 45 +73 73 73 75 76 +5 5 7 8 8 10 9 +9 9 10 12 15 15 15 +5 5 7 7 10 14 +77 77 80 80 83 86 91 +73 73 77 78 80 83 +8 8 10 11 15 18 21 19 +22 22 24 26 30 30 +68 68 71 75 79 +83 83 87 88 90 95 +33 33 38 40 42 +71 71 74 79 76 +18 18 19 24 25 25 +85 85 90 92 96 +41 41 48 50 57 +54 58 59 61 62 +67 71 72 74 75 77 74 +24 28 31 32 32 +48 52 55 57 58 62 +68 72 74 75 77 78 83 +46 50 49 51 52 54 57 58 +5 9 10 9 10 9 +36 40 43 44 45 46 45 45 +28 32 34 33 35 37 41 +81 85 84 87 88 93 +5 9 12 15 15 17 +41 45 48 48 49 52 49 +8 12 13 15 18 18 18 +16 20 20 23 26 27 29 33 +75 79 80 80 87 +79 83 86 88 91 95 97 98 +59 63 67 70 69 +52 56 59 63 63 +8 12 14 17 20 22 26 30 +74 78 82 84 91 +79 83 85 86 91 92 93 +68 72 73 80 77 +71 75 77 84 86 87 89 89 +70 74 75 81 85 +2 6 11 14 19 +52 59 62 63 65 66 67 +74 80 83 85 86 89 88 +44 51 52 54 55 58 58 +58 64 65 68 69 70 74 +38 45 48 49 50 52 57 +45 51 54 57 60 62 59 60 +41 46 48 47 50 48 +18 23 25 27 26 28 29 29 +84 89 90 92 90 91 95 +28 33 36 34 37 44 +38 44 45 45 47 50 +5 11 12 12 14 17 16 +45 52 55 55 55 +78 84 86 86 88 91 95 +67 73 73 74 80 +1 8 11 12 16 18 +8 13 17 19 21 22 21 +48 54 58 60 63 65 65 +29 36 40 43 47 +14 21 23 24 28 35 +81 87 89 95 97 98 99 +43 50 57 60 62 61 +44 51 54 55 61 62 65 65 +18 25 32 33 37 +37 43 46 53 59 +72 69 66 64 61 59 56 59 +87 86 83 82 79 76 76 +82 80 78 76 75 73 70 66 +23 22 19 16 11 +59 58 57 55 58 56 53 50 +16 13 10 7 10 9 7 9 +93 92 90 91 91 +24 21 20 22 20 16 +49 47 46 47 44 43 37 +96 95 93 91 91 88 +94 91 90 90 89 92 +73 71 69 69 68 65 65 +57 54 51 51 47 +66 64 64 62 55 +26 25 21 18 16 15 13 12 +53 51 47 46 44 41 39 40 +32 29 27 23 22 20 20 +42 41 38 35 31 29 28 24 +36 33 30 28 24 22 17 +29 28 22 21 18 +77 75 73 70 65 62 61 63 +42 40 38 31 29 28 26 26 +38 35 30 27 24 20 +35 34 28 25 22 21 15 +12 13 10 8 6 +93 95 92 90 87 89 +63 65 63 62 60 57 57 +98 99 97 95 93 91 87 +58 61 59 56 53 51 44 +92 93 91 93 92 90 87 85 +82 85 84 83 80 83 86 +42 45 44 42 45 45 +42 43 41 44 41 38 34 +96 99 97 94 91 90 92 87 +96 98 95 95 93 92 +23 26 25 22 21 19 19 20 +35 36 34 31 31 31 +22 23 22 22 18 +57 58 57 54 54 51 46 +83 84 80 77 74 72 71 +69 70 67 63 66 +83 86 83 79 79 +14 17 16 12 9 7 5 1 +26 28 24 21 14 +66 67 62 61 60 57 +59 62 61 60 55 54 53 56 +23 25 20 17 16 14 11 11 +30 32 30 28 27 20 17 13 +62 65 64 57 55 52 51 44 +74 74 73 71 69 +59 59 58 55 57 +28 28 25 23 20 17 15 15 +32 32 31 30 27 26 22 +69 69 68 65 59 +27 27 25 24 26 24 23 +37 37 36 38 35 37 +10 10 11 8 8 +65 65 67 65 63 62 58 +76 76 75 77 71 +61 61 59 56 56 54 52 50 +18 18 16 15 14 13 13 14 +69 69 69 67 66 63 60 60 +72 72 70 67 65 62 62 58 +88 88 88 87 80 +69 69 66 63 59 58 +94 94 93 89 92 +85 85 81 78 78 +20 20 16 14 10 +77 77 74 72 70 66 60 +54 54 52 45 44 43 42 40 +40 40 33 32 34 +67 67 60 59 59 +19 19 14 12 8 +78 78 76 73 71 65 60 +35 31 28 27 24 +35 31 29 28 25 24 23 26 +58 54 52 51 49 49 +52 48 46 44 42 39 35 +51 47 44 42 41 34 +59 55 52 50 53 51 +45 41 43 40 41 +61 57 58 56 56 +25 21 24 23 21 20 16 +35 31 28 31 28 25 20 +23 19 16 16 15 +91 87 86 85 82 81 81 84 +57 53 53 51 50 49 49 +66 62 62 60 57 54 50 +56 52 49 49 48 45 38 +24 20 17 14 10 8 +23 19 16 15 13 10 6 8 +61 57 56 52 50 47 47 +83 79 77 75 71 67 +27 23 21 17 11 +74 70 68 63 62 61 59 57 +48 44 38 35 38 +50 46 45 39 39 +68 64 57 54 50 +78 74 73 72 67 61 +66 61 58 57 54 +37 30 28 26 28 +31 25 22 19 17 17 +79 73 71 68 67 63 +66 61 59 56 50 +34 28 26 24 25 24 22 +15 8 9 8 10 +71 66 65 64 61 63 61 61 +24 17 15 13 11 9 11 7 +97 90 88 87 89 84 +67 60 59 59 57 +46 41 39 36 36 39 +14 9 8 8 7 7 +86 79 78 75 75 74 70 +67 60 60 59 52 +92 87 86 83 80 76 74 73 +29 23 21 19 16 12 15 +83 76 72 70 70 +80 75 74 72 69 66 62 58 +47 40 39 35 32 26 +32 26 19 16 14 12 +40 34 33 27 26 25 23 26 +52 47 45 44 41 34 33 33 +20 14 13 11 5 1 +55 50 48 47 42 37 +52 55 56 57 60 61 63 62 +19 21 22 23 26 29 29 +70 73 75 78 81 83 87 +59 62 64 65 66 68 74 +47 48 50 49 52 +37 38 41 44 42 43 44 42 +18 20 19 22 24 27 27 +53 56 57 58 60 61 60 64 +57 59 60 58 59 66 +52 53 53 56 58 59 +45 48 49 49 50 47 +21 23 24 24 24 +26 28 31 31 32 34 38 +18 19 21 21 26 +52 54 56 60 63 65 66 69 +26 29 31 32 33 37 40 38 +31 32 35 39 42 42 +57 59 60 61 65 68 71 75 +41 44 47 51 53 59 +23 25 28 34 37 40 42 +59 60 62 63 65 72 69 +11 13 15 22 23 25 25 +35 36 42 43 45 48 50 54 +54 57 58 60 67 69 74 +44 41 42 43 45 +78 76 78 81 83 84 82 +48 45 46 48 51 54 54 +62 61 64 67 68 72 +26 23 24 26 29 30 37 +26 23 20 23 26 27 +45 43 45 46 48 47 48 47 +41 40 42 40 43 43 +22 21 18 21 23 24 25 29 +88 85 87 88 89 90 88 94 +40 38 39 39 40 43 45 +53 51 54 57 57 55 +53 52 54 54 54 +30 29 29 30 34 +17 16 16 17 24 +2 1 4 8 9 11 14 +56 53 54 58 61 60 +52 51 54 58 60 60 +43 42 45 49 53 +54 53 56 60 65 +62 60 66 69 72 +13 10 11 17 19 20 18 +11 10 11 14 17 24 26 26 +41 40 42 45 47 50 56 60 +45 44 50 51 56 +3 3 4 5 7 9 12 13 +74 74 75 76 79 78 +81 81 84 85 88 89 89 +28 28 29 31 33 34 38 +44 44 46 49 52 54 57 62 +5 5 8 7 9 +22 22 20 23 25 23 +51 51 50 51 54 57 57 +52 52 49 51 55 +28 28 30 29 36 +38 38 39 41 41 43 46 +53 53 54 54 56 54 +15 15 18 18 19 22 22 +9 9 9 11 14 18 +2 2 5 8 8 11 16 +49 49 50 53 54 58 59 60 +84 84 87 91 92 90 +4 4 8 11 11 +8 8 12 15 19 +52 52 55 59 60 66 +6 6 7 8 13 16 +67 67 68 74 73 +32 32 39 40 43 43 +43 43 46 53 55 58 61 65 +83 83 88 90 92 99 +70 74 77 78 81 82 85 +17 21 24 26 28 30 28 +43 47 49 52 52 +62 66 67 69 73 +55 59 62 63 65 68 73 +29 33 35 37 34 36 38 40 +54 58 55 57 60 58 +26 30 28 31 31 +41 45 47 46 49 53 +30 34 37 35 37 40 47 +71 75 77 79 82 82 83 +47 51 51 54 57 60 63 61 +82 86 88 89 89 89 +27 31 32 32 34 38 +39 43 44 44 47 48 54 +47 51 54 55 58 62 64 67 +23 27 28 32 33 30 +38 42 45 46 50 53 53 +25 29 33 36 39 43 +18 22 23 27 34 +80 84 86 87 88 95 98 +25 29 31 37 35 +30 34 36 37 44 44 +67 71 74 81 82 83 87 +20 24 27 34 37 42 +34 41 43 45 46 47 +41 46 48 51 53 54 55 52 +26 31 33 35 37 39 42 42 +62 69 72 73 76 80 +53 59 62 65 71 +41 46 47 48 49 50 47 49 +68 74 72 73 74 76 79 78 +42 49 47 50 51 52 54 54 +6 11 9 11 15 +19 26 25 27 29 34 +39 46 47 47 49 +82 88 91 93 96 96 98 95 +2 9 9 11 11 +60 66 67 67 71 +17 23 23 26 27 33 +5 11 14 15 19 20 22 +5 10 12 16 17 15 +63 70 74 77 77 +30 36 39 43 47 +6 11 15 16 17 24 +15 21 24 30 31 +72 79 81 88 87 +31 36 42 45 48 49 51 51 +18 24 31 32 36 +26 31 32 38 39 40 41 48 +43 41 39 36 35 38 +75 74 71 69 66 64 64 +39 36 33 32 29 26 25 21 +35 32 31 28 26 20 +24 23 22 24 23 20 19 18 +30 29 28 29 28 29 +62 60 59 58 57 60 60 +44 42 41 38 40 36 +89 88 87 85 83 84 81 74 +52 49 48 45 45 44 +41 38 37 37 35 32 31 34 +57 55 54 54 54 +46 45 44 42 40 40 36 +25 23 21 21 15 +74 73 70 66 63 60 +55 53 51 47 44 41 43 +69 67 66 62 60 60 +97 96 94 90 89 86 82 +44 41 40 36 35 32 25 +44 43 37 35 32 +74 72 65 62 60 63 +58 55 52 47 46 43 40 40 +89 87 81 78 77 73 +74 71 68 61 55 +31 32 31 28 27 25 +8 10 9 8 10 +79 80 78 76 74 72 72 +90 92 90 89 86 85 81 +92 95 94 93 91 90 87 82 +18 21 23 20 17 +69 70 67 65 67 64 66 +95 97 94 93 91 94 94 +39 41 44 41 39 35 +18 21 24 22 16 +3 5 4 4 2 1 +27 30 30 29 30 +6 9 8 7 7 7 +78 79 78 78 77 75 71 +98 99 98 97 96 96 89 +21 23 19 17 16 13 10 +44 46 44 41 39 36 32 35 +13 15 11 9 7 7 +78 81 77 74 70 +91 94 92 88 83 +85 88 85 79 78 +92 93 90 83 84 +85 88 86 80 78 77 75 75 +25 26 24 23 21 18 11 7 +17 18 11 10 9 2 +72 72 71 68 67 +64 64 62 60 62 +54 54 52 49 49 +95 95 94 91 90 86 +17 17 14 11 5 +37 37 38 35 34 +99 99 96 93 94 97 +78 78 81 78 75 73 73 +84 84 81 78 80 76 +85 85 83 85 82 79 77 71 +92 92 92 91 90 88 86 85 +75 75 75 74 71 70 67 69 +5 5 3 3 3 +64 64 62 62 59 55 +87 87 85 85 84 77 +40 40 39 35 34 +60 60 57 54 50 47 45 47 +44 44 42 40 37 36 32 32 +53 53 51 49 48 44 40 +56 56 55 52 51 47 42 +20 20 18 13 10 9 +18 18 13 10 9 7 6 8 +96 96 93 90 85 82 80 80 +68 68 65 59 57 53 +97 97 92 89 84 +53 49 46 43 40 37 35 +39 35 32 31 29 26 24 27 +32 28 27 26 25 24 24 +77 73 70 68 67 63 +46 42 41 38 36 34 29 +29 25 24 27 25 22 20 17 +54 50 51 49 46 48 +75 71 68 71 70 70 +20 16 19 16 12 +93 89 88 86 83 86 84 78 +58 54 54 53 50 +59 55 52 49 49 48 49 +75 71 71 70 67 67 +24 20 19 19 15 +54 50 48 48 43 +54 50 46 45 42 39 38 37 +22 18 14 13 14 +62 58 57 53 53 +21 17 14 10 8 4 +38 34 30 27 26 24 17 +61 57 55 54 47 44 +59 55 48 45 43 42 43 +71 67 64 61 56 55 53 53 +99 95 93 91 85 83 79 +85 81 80 78 71 65 +34 27 26 25 24 +44 39 37 34 37 +58 53 50 49 47 45 43 43 +25 18 15 14 10 +66 59 58 56 55 50 +46 41 38 37 35 37 34 31 +93 87 89 86 89 +18 11 10 11 9 7 6 6 +94 88 91 88 87 86 82 +30 24 23 21 22 15 +74 67 65 65 62 +78 73 72 72 75 +69 62 62 60 58 55 55 +90 83 83 80 78 74 +51 45 45 44 41 40 37 32 +33 27 23 21 18 16 +27 20 19 15 17 +92 87 83 82 79 77 77 +88 83 79 78 77 73 +46 41 37 34 32 29 23 +70 65 62 57 55 52 49 46 +95 88 81 80 83 +93 87 82 79 78 75 74 74 +98 91 86 84 83 79 +80 73 66 63 58 +21 14 11 8 1 +29 23 22 20 17 12 8 +39 41 39 38 34 32 29 +1 2 5 6 12 16 +23 29 31 35 37 35 +64 64 62 58 56 55 55 +80 78 76 75 74 75 +53 53 52 53 50 48 47 43 +70 72 78 79 81 83 +38 34 29 27 24 22 18 +46 47 46 43 40 39 37 +12 12 14 11 13 +13 18 21 26 30 +71 66 61 60 59 62 +32 29 32 33 34 36 40 +58 51 48 43 42 39 39 +5 5 6 5 7 +84 83 82 84 82 77 +60 53 49 48 45 44 37 +28 27 30 32 32 32 +11 15 15 16 17 23 +43 47 48 53 52 +67 71 73 74 74 75 77 74 +10 13 14 15 18 18 +58 62 63 67 64 +74 80 82 84 87 84 84 +67 63 61 60 58 60 59 54 +21 25 28 31 32 35 38 37 +90 88 87 90 87 84 81 77 +19 23 28 31 34 +63 59 59 58 58 +83 82 79 79 78 80 +3 7 13 15 16 18 21 25 +12 12 14 17 18 21 19 +96 96 90 89 84 +51 55 57 59 62 66 68 72 +7 11 14 16 15 17 19 19 +57 52 51 49 48 46 39 38 +85 84 86 88 92 97 +16 12 8 7 6 3 +78 71 68 66 62 61 58 59 +15 21 24 26 29 26 29 30 +17 13 10 9 6 4 3 +17 18 19 21 19 22 22 +18 18 21 18 21 22 23 27 +63 67 72 75 78 80 82 88 +44 40 38 36 36 34 +59 55 52 51 48 45 42 42 +95 94 91 90 89 83 +61 61 66 69 70 72 76 +61 62 60 58 54 52 49 42 +64 64 63 62 61 61 57 +69 72 71 71 70 70 +49 48 49 51 51 +50 44 44 41 37 +76 79 83 86 89 92 95 95 +16 13 11 11 9 8 +92 95 92 90 89 82 +37 33 32 35 34 32 30 +5 9 11 13 15 18 22 +6 10 13 12 14 17 +62 63 65 68 69 68 71 70 +18 14 13 10 9 11 +23 30 37 38 41 44 47 49 +15 18 17 15 13 11 11 8 +25 18 15 11 7 +64 64 67 67 70 72 76 +56 59 57 56 53 52 51 51 +56 52 53 51 49 46 49 +20 16 12 10 10 +44 50 53 54 57 58 61 58 +44 42 40 35 36 +84 80 77 73 76 +60 65 69 71 73 75 78 82 +98 93 91 88 86 88 +74 74 74 77 80 81 81 +69 70 67 68 67 67 +44 44 42 39 38 37 33 +86 80 77 74 73 73 +57 56 53 55 61 +16 13 9 7 9 +3 3 4 7 10 12 12 +49 51 52 52 55 56 62 +5 12 14 15 16 17 17 +40 40 42 41 48 +86 89 87 83 79 +66 64 67 64 68 +78 78 79 81 84 88 +84 84 85 86 93 94 97 99 +24 30 34 35 37 37 +83 89 89 92 94 96 94 +33 33 26 25 22 21 +60 59 56 53 50 44 40 +56 63 64 66 63 65 70 +30 37 39 42 43 42 45 49 +35 40 45 46 52 +6 6 6 8 11 16 +74 70 63 62 57 +52 52 54 60 63 66 66 +57 62 62 63 63 +65 64 67 69 69 71 72 +61 61 59 56 54 51 51 +16 22 25 28 28 32 +15 19 23 26 27 29 31 32 +58 58 60 61 62 67 +43 41 43 46 46 51 +42 41 43 45 50 +48 48 50 53 54 56 59 +72 67 68 67 64 62 58 +63 68 71 76 79 81 78 +26 20 17 14 12 9 12 11 +63 59 54 52 50 47 44 +91 91 93 91 92 95 93 +83 79 76 73 67 65 65 +20 23 26 28 31 33 36 +59 60 62 64 66 68 69 +52 55 58 60 63 64 +68 69 71 72 74 76 79 80 +72 73 75 77 80 82 84 85 +14 11 9 6 5 +10 11 13 16 18 20 22 +32 29 28 27 26 25 24 23 +14 15 16 18 21 +45 42 39 36 33 32 30 29 +19 16 15 12 10 9 +92 93 94 96 98 +25 23 20 17 14 +44 46 49 50 51 53 55 +50 47 46 44 42 39 37 +9 11 14 15 18 20 23 24 +22 20 17 15 14 12 10 9 +59 58 55 52 49 48 46 +35 32 31 30 27 +56 58 61 63 65 67 68 +73 72 71 70 69 67 64 62 +86 85 82 81 80 77 74 71 +42 40 38 36 33 30 +63 61 58 57 54 52 +81 80 77 74 71 70 67 +21 24 25 27 29 30 +16 19 22 25 26 +23 25 26 29 32 35 36 +66 67 69 71 73 76 78 +36 34 32 30 28 27 25 +48 46 45 44 41 38 37 +32 35 36 39 40 +11 14 16 19 20 21 22 23 +24 26 27 30 32 33 34 +23 26 27 30 32 34 +44 45 48 50 53 56 +35 38 39 42 44 +29 26 25 23 21 19 +1 2 4 6 9 12 +8 11 13 14 17 +79 77 76 75 72 71 +92 90 87 84 82 81 +83 85 88 89 90 93 +10 13 14 16 18 20 23 25 +49 52 54 55 57 59 60 63 +27 30 32 35 38 40 42 44 +86 85 83 81 79 77 +21 18 16 15 12 10 +86 84 81 78 77 +56 59 60 61 64 67 +16 13 11 8 7 6 5 4 +46 45 42 41 38 36 33 32 +42 39 38 35 33 32 +43 45 46 48 50 52 53 +65 66 68 70 72 75 +57 55 52 51 50 49 47 +42 39 36 33 30 28 +29 30 31 33 35 +96 93 92 89 86 84 81 80 +7 9 10 12 15 +93 92 90 87 86 84 83 +67 65 62 59 57 56 +95 94 91 90 87 85 +33 32 29 28 27 25 +62 61 59 58 55 53 51 +85 83 80 79 77 75 +47 48 50 51 52 54 +15 17 18 19 21 24 27 28 +83 80 78 77 75 +64 62 59 58 55 53 51 +90 88 87 85 83 +70 71 73 75 78 81 82 +80 77 76 74 71 68 66 +16 17 18 20 23 +50 53 54 56 59 60 62 63 +29 32 34 37 40 42 +58 57 56 54 53 52 +42 43 45 46 49 50 51 52 +47 50 53 56 59 61 63 65 +24 25 28 29 32 33 35 36 +31 28 26 23 20 17 14 +74 77 79 81 83 +56 57 60 61 63 66 67 70 +62 65 68 69 70 73 +19 18 16 15 14 +13 12 11 10 8 6 3 +42 45 48 50 52 55 57 59 +29 30 32 34 35 37 38 40 +19 20 21 22 24 27 29 +76 75 73 72 70 67 64 +52 55 56 57 59 61 64 67 +88 90 91 93 96 97 99 +54 51 48 46 44 41 40 +84 85 88 91 93 95 98 +79 76 74 72 70 +27 25 22 21 19 16 +74 75 77 78 80 82 84 +74 75 76 77 80 81 82 83 +30 33 35 36 39 40 +11 13 16 18 20 23 25 +26 29 31 32 33 +79 77 74 73 70 68 67 +2 5 6 7 9 10 +17 19 22 24 27 28 +47 45 44 43 40 +91 88 87 86 85 +49 50 53 54 55 58 60 63 +12 13 14 16 17 +88 90 93 94 97 +89 91 92 94 95 +8 7 6 5 3 +84 86 87 90 92 94 +84 85 86 87 89 +17 16 14 13 11 +37 36 35 34 32 30 29 27 +89 87 84 81 78 76 75 +80 81 84 87 89 92 +64 62 60 58 57 +62 61 59 56 53 51 +35 34 31 28 25 24 23 +76 79 80 82 83 84 86 89 +94 91 90 89 87 85 83 +82 80 78 77 74 73 71 69 +38 36 34 33 32 31 30 28 +55 57 58 60 62 65 68 +55 56 57 59 60 63 +70 69 66 64 62 61 59 +67 68 71 74 77 79 81 +70 68 65 63 61 +19 16 15 14 11 +24 23 22 21 20 18 +52 49 46 43 40 +79 81 83 86 87 88 90 +18 16 15 14 12 9 8 +38 35 33 30 28 26 23 22 +44 41 40 38 37 +81 82 84 85 86 87 89 91 +85 84 81 79 76 75 +50 51 53 54 55 56 57 60 +13 16 18 21 23 24 26 +13 15 16 19 22 +79 77 75 74 72 69 66 64 +23 26 28 29 30 +94 92 90 88 85 83 80 78 +51 49 47 45 44 42 40 37 +35 33 32 29 26 +81 80 79 77 74 71 +88 87 85 83 82 +20 18 16 14 13 12 9 8 +17 16 13 10 9 6 4 2 +50 47 46 43 42 41 39 +71 74 75 76 79 80 +75 76 79 80 83 86 88 +53 56 58 59 60 63 64 +66 64 61 59 56 55 54 +78 79 82 83 86 87 88 +24 27 28 31 33 35 37 40 +13 14 17 18 19 20 21 22 +73 75 76 77 78 81 84 +61 58 56 55 53 52 +14 16 17 18 19 22 24 27 +71 73 76 78 80 81 84 +6 8 9 10 12 14 15 18 +42 39 37 36 35 33 32 +24 22 21 18 15 14 +76 74 73 71 70 68 67 64 +10 9 8 7 6 5 4 2 +4 6 8 10 12 14 15 16 +16 13 12 11 9 8 5 3 +76 78 81 82 85 88 91 +9 11 12 14 16 18 19 21 +57 58 59 61 62 63 65 67 +31 29 28 27 25 22 20 +65 68 71 73 75 76 77 80 +98 96 93 91 88 87 84 81 +48 51 54 57 58 59 +23 22 19 17 15 14 +99 97 95 93 90 89 88 87 +76 74 72 70 69 +53 56 59 61 62 64 65 +61 60 57 56 53 50 47 +21 23 26 29 31 +63 62 61 59 56 54 51 50 +17 18 21 23 25 27 29 30 +81 80 79 77 76 75 74 +49 47 44 43 40 +42 41 39 37 35 +27 29 32 35 36 37 38 41 +62 65 66 69 71 74 76 79 +5 8 10 13 16 +16 13 11 8 5 4 2 +65 67 69 71 73 +77 78 81 83 84 86 +65 66 68 70 71 73 +44 41 40 39 38 37 35 34 +32 31 29 28 25 22 21 20 +29 26 25 22 21 18 +53 55 57 58 60 62 +43 42 39 37 34 32 +9 10 12 14 16 17 20 21 +5 7 9 10 11 +52 50 48 45 42 41 39 38 +74 77 78 81 83 86 88 +69 70 72 73 76 78 81 82 +82 80 78 77 74 71 +55 58 59 60 63 +76 77 78 80 82 +65 63 62 61 59 57 54 52 +62 64 65 68 69 +74 71 70 68 66 64 +75 76 79 82 83 +57 55 53 52 49 48 46 43 +11 12 15 16 19 21 24 +45 48 50 51 54 +89 88 87 85 83 80 78 77 +76 77 79 80 81 +50 47 44 42 41 +66 69 72 73 76 79 81 +72 70 69 68 65 64 61 60 +28 30 31 32 34 36 39 +24 21 20 18 16 +15 14 11 8 7 +64 62 60 57 56 55 53 +90 93 94 95 98 +34 35 37 40 43 +24 22 19 18 17 16 14 13 +40 39 37 35 34 31 28 +55 54 52 51 48 47 +28 30 32 35 37 +10 12 14 15 18 20 +56 58 61 62 65 +83 85 86 88 91 94 97 +74 71 69 66 63 +64 67 69 71 74 +85 83 82 80 77 75 72 69 +12 13 16 19 22 +92 89 87 86 84 +41 44 47 50 52 53 55 57 +28 31 34 37 39 42 44 +47 44 42 40 39 36 +21 18 16 13 10 9 7 +97 94 92 89 88 86 83 +22 23 25 27 30 31 34 +75 72 71 70 67 66 65 63 +54 52 50 49 47 46 43 +48 46 43 40 37 +54 57 58 61 62 64 +72 71 68 66 64 62 60 +17 19 20 21 24 25 28 +53 54 55 57 60 62 64 65 +20 17 16 15 12 11 10 9 +55 58 61 64 65 +29 32 33 35 36 +62 64 65 67 70 +20 22 23 24 25 +76 79 82 83 85 87 +53 55 56 59 61 64 66 69 +4 5 6 8 9 +69 70 72 74 76 77 79 81 +74 76 79 82 83 86 +87 86 85 82 79 77 75 74 +19 21 22 25 26 29 30 31 +52 55 57 58 60 61 62 +73 71 70 68 67 +41 39 37 34 31 29 27 24 +40 39 38 36 34 33 +57 60 61 63 64 67 69 72 +67 68 71 73 76 77 79 81 +78 75 73 71 68 66 +39 37 35 32 31 +13 16 19 20 22 +40 43 44 47 48 51 +72 69 66 63 60 57 +64 65 66 68 70 73 75 76 +21 20 17 15 14 12 +83 82 80 78 77 74 +15 16 18 19 21 24 27 30 +68 66 65 63 61 60 58 55 +67 65 62 60 58 55 52 49 +95 93 91 89 87 86 84 83 +16 15 14 13 12 +36 39 42 45 48 51 +28 30 32 35 36 37 38 +73 74 76 79 80 83 +18 16 13 11 8 5 +97 94 92 91 89 87 86 +80 82 84 87 90 93 95 96 +34 36 38 39 40 43 +60 57 56 54 51 50 48 46 +38 41 43 45 46 48 50 52 +67 66 64 63 61 +51 48 46 43 41 40 39 37 +81 80 78 76 73 70 67 +56 53 51 50 47 +27 29 31 32 34 37 38 +81 79 77 74 71 +17 16 14 12 9 6 4 1 +94 91 90 87 85 +45 47 50 53 55 57 +22 25 27 28 29 30 31 34 +87 86 85 83 82 81 78 76 +23 26 28 30 33 +96 94 92 91 90 87 +23 26 28 30 32 34 37 38 +35 33 30 27 24 21 20 +83 85 86 88 89 91 93 +57 59 62 65 67 +80 79 78 75 74 71 70 +1 3 4 6 8 9 11 14 +83 82 81 78 77 74 72 +95 94 93 91 89 87 85 82 +36 39 42 45 47 50 +53 55 56 59 60 63 65 +84 82 80 78 77 76 +63 61 60 59 56 54 +88 87 86 84 83 +69 72 74 75 78 81 +82 81 78 77 76 75 73 +34 33 30 28 27 25 22 20 +65 68 70 73 76 79 80 81 +81 78 77 74 72 71 +60 58 55 53 51 +66 64 63 62 61 59 57 55 +7 8 11 13 14 15 16 +55 54 53 51 49 48 46 +1 2 3 4 7 8 +52 54 56 58 61 64 +29 30 31 33 36 37 +50 53 54 57 58 61 64 65 +36 35 33 30 29 26 +67 68 69 70 71 +71 73 76 78 81 +91 88 85 83 81 +68 67 66 63 61 +78 79 80 81 83 85 87 89 +90 88 87 84 83 81 +7 9 10 12 15 18 19 +38 36 33 31 29 26 25 +78 76 74 72 71 70 +35 34 32 30 29 28 26 25 +46 43 42 40 37 34 +55 53 51 49 47 44 42 +49 50 52 54 55 56 59 60 +43 41 39 36 35 32 31 +73 74 75 78 79 82 83 85 +36 39 41 43 44 46 49 +28 25 24 21 18 +81 83 84 86 89 90 91 92 +36 38 39 41 42 45 48 49 +73 72 69 67 65 63 +91 90 88 87 85 82 81 80 +42 43 45 47 49 51 +88 86 83 80 79 77 +59 56 54 52 49 47 +78 80 83 84 87 90 +49 52 54 56 59 62 64 66 +57 58 61 63 65 68 70 71 +31 34 35 37 40 42 43 +43 41 39 38 36 34 31 29 +25 28 31 32 34 +50 49 48 45 44 41 39 37 +48 50 52 54 55 57 +49 52 55 56 58 +21 24 27 29 32 34 +19 21 22 23 26 +71 74 77 78 80 81 82 +67 69 70 71 73 74 77 79 +95 92 89 87 85 84 81 78 +22 25 27 29 31 33 36 38 +70 72 74 76 79 +79 77 75 74 71 +34 31 28 25 22 20 17 16 +1 4 7 8 10 12 14 17 +14 16 18 19 20 22 23 25 +29 28 27 26 24 +66 65 63 60 58 55 +66 65 64 63 60 57 56 +38 40 43 46 47 +32 29 28 25 22 21 +55 57 60 62 65 68 69 +58 59 62 64 66 69 71 74 +32 30 27 26 23 21 18 15 +58 55 52 49 46 43 +89 91 93 94 96 +21 23 24 27 30 +30 29 26 23 22 21 20 +64 62 59 58 56 55 54 +32 31 28 27 25 24 23 21 +47 49 52 55 57 59 61 63 +73 75 77 78 80 82 83 diff --git a/2/inputDemo b/2/inputDemo new file mode 100644 index 0000000..b49c10d --- /dev/null +++ b/2/inputDemo @@ -0,0 +1,6 @@ +7 6 4 2 1 +1 2 7 8 9 +9 7 6 2 1 +1 3 2 4 5 +8 6 4 4 1 +1 3 6 7 9 diff --git a/2/main b/2/main new file mode 100755 index 0000000..4fe93a1 Binary files /dev/null and b/2/main differ diff --git a/2/main.c b/2/main.c new file mode 100644 index 0000000..a82ec2d --- /dev/null +++ b/2/main.c @@ -0,0 +1,45 @@ +#include +#include + +#define LINES 1000 + +int compare(const void *a, const void *b); + +int main() +{ + int new; + int old; + int safe = 0; + FILE *input; + input = fopen("./input", "r"); + // read number. Compare next number (higher, lower, +-1-2) + // if you get to newline, ++ + for (int i = 0; i < LINES; i++) { + int rising = 0; + int first = 1; + fscanf(input, "%d", &old); + char nextChar = 0; + while ((nextChar = fgetc(input)) && nextChar != '\n') { + fscanf(input, "%d", &new); + // if difference isnt 1-3 + if (abs(new - old) > 3 || abs(new - old) < 1) { + while(getc(input) != '\n'); + goto loopEnd; + } + // only for first comparison of row. Set direction. + if (first && ((new - old) < 0)) rising = 0; else if (first) rising = 1; + // for other comparisons, compare current direction to the previous. + if (!first && (rising != !((new - old) < 0))) { + // printf("rising: %d while %d - %d is %d\n", rising, new, old, new - old); + while(getc(input) != '\n'); + goto loopEnd; + } + // get ready for the next comparisons! + first = 0; + old = new; + } + safe++; + loopEnd: + } + printf("%d\n", safe); +} diff --git a/2/mainB.c b/2/mainB.c new file mode 100644 index 0000000..4ccd3f7 --- /dev/null +++ b/2/mainB.c @@ -0,0 +1,110 @@ +#include +#include +#include + +#define LINES 1000 + +// 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; +} +// check if specific report is safe +int check_report(int *row, int len) +{ + // read number. Compare next number (higher, lower, +-1-2) + // if you get to row[i + 1]line, ++ + bool rising = 0; + bool first = 1; + for (int i = 0; i < len - 1; i++) { + // if difference isnt 1-3 + if (abs(row[i + 1] - row[i]) > 3 || abs(row[i + 1] - row[i]) < 1) + return 0; + // only for first comparison of row. Set direction. + if (first && ((row[i + 1] - row[i]) < 0)) + rising = 0; + else if (first) + rising = 1; + // for other comparisons, compare current direction to the previous. + if (!first && (rising != !((row[i + 1] - row[i]) < 0))) { + // printf("rising: %d while %d - %d is %d\n", rising, row[i + 1], row[i], row[i + 1] - row[i]); + return 0; + } + // get ready for the next comparisons! + first = 0; + } + return 1; +} + +int dampener(int *row, int len) +{ + if (check_report(row, len)) + return 1; + + for (int i = 0; i < len; i++) { + int *dampened_row = malloc((len - 1) * sizeof(int)); + // initialize shorter array, but skip element i + bool skipped = 0; + for (int j = 0; j < len - 1; j++) { + if (j != i && !skipped) { + dampened_row[j] = row[j]; + } + else { + dampened_row[j] = row[j + 1]; + skipped = 1; + } + } + if (check_report(dampened_row, len - 1)) { + free(dampened_row); + return 1; + } + free(dampened_row); + } + + return 0; +} + +int main() +{ + int safe = 0; + // read input row into array, count elements + FILE *input; + input = fopen("./input", "r"); + char line[32]; + for (int i = 0; i < LINES; i++) { + // get string (line), count numbers, put into int array (row) + int numbers = 1; + fgets(line, sizeof(line), input); + // count number of numbers, allocate memory + for (int c = 0; line[c]; c++) numbers += (line[c] == ' '); + int *row = (int *)calloc(numbers, sizeof(int)); + // parse numbers into array + parse_numbers(line, row, numbers); + // for (int j = 0; j < numbers; j++) printf("%d ", row[j]); + // printf("\n\n"); + + // send elements and length to check_report, add result to sum + safe += dampener(row, numbers); + free(row); + } + + printf("%d\n", safe); +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..0981bc0 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +plz be nice