diff --git a/solutions/orso/day07/day_7.py b/solutions/orso/day07/day_7.py index 0dfe567..653d8a0 100644 --- a/solutions/orso/day07/day_7.py +++ b/solutions/orso/day07/day_7.py @@ -1,53 +1,204 @@ +#-------------------------------------------------------------------------------------------------------------------------------- +# INCLUDE +#-------------------------------------------------------------------------------------------------------------------------------- + +import logging + +from itertools import product + +import copy + +from typing import Generator, Dict, Tuple, List + +#-------------------------------------------------------------------------------------------------------------------------------- +# RULES +#-------------------------------------------------------------------------------------------------------------------------------- + +""" +Rules: +-You have a result +-You have a list of arguments +-In between arguments you can insert either + or * +-Arguments are evaluated STRICTLY left to right + 81 + 40 * 27 + 81+40 = 121 + 121 * 27 = 3267 +Objective: +-Find the equations that can be made true +-Sum the result of the equations that can be made true +""" + +#-------------------------------------------------------------------------------------------------------------------------------- +# ALGORITHM +#-------------------------------------------------------------------------------------------------------------------------------- + """ ---- Day 7: Bridge Repair --- - -The Historians take you to a familiar rope bridge over a river in the middle of a jungle. -The Chief isn't on this side of the bridge, though; maybe he's on the other side? -When you go to cross the bridge, you notice a group of engineers trying to repair it. -(Apparently, it breaks pretty frequently.) You won't be able to cross until it's fixed. -You ask how long it'll take; the engineers tell you that it only needs final calibrations, -but some young elephants were playing nearby and stole all the operators from their calibration equations! -They could finish the calibrations if only someone could determine which test values could possibly be -produced by placing any combination of operators into their calibration equations (your puzzle input). - -For example: -190: 10 19 -3267: 81 40 27 -83: 17 5 -156: 15 6 -7290: 6 8 6 15 -161011: 16 10 13 -192: 17 8 14 -21037: 9 7 18 13 -292: 11 6 16 20 - -Each line represents a single equation. -The test value appears before the colon on each line; -it is your job to determine whether the remaining numbers can be combined with operators to produce the test value. - -Operators are always evaluated left-to-right, -not according to precedence rules. -Furthermore, numbers in the equations cannot be rearranged. -Glancing into the jungle, you can see elephants holding two different types of operators: -add (+) and multiply (*). - -Only three of the above equations can be made true by inserting operators: - - 190: 10 19 has only one position that accepts an operator: - between 10 and 19. - Choosing + would give 29, - but choosing * would give the test value (10 * 19 = 190). - - 3267: 81 40 27 has two positions for operators. - - Of the four possible configurations of the operators, two cause the right side to match the test value: - 81 + 40 * 27 and 81 * 40 + 27 both equal 3267 (when evaluated left-to-right)! - - 292: 11 6 16 20 can be solved in exactly one way: 11 + 6 * 16 + 20. - -The engineers just need the total calibration result, which is the sum of the test values from just the equations that could possibly be true. -In the above example, the sum of the test values for the three equations listed above is 3749. - -Determine which equations could possibly be true. What is their total calibration result? - -""" \ No newline at end of file +Can I just try all combinations of operators? +Better, I start with MUL. If it overflow, demote to PLUS? +""" + + +#-------------------------------------------------------------------------------------------------------------------------------- +# MAIN +#-------------------------------------------------------------------------------------------------------------------------------- + +class Operator_finder: + class Equation: + n_result : int = 0 + n_num_arg : int = 0 + ln_arguments : List[int] = list() + s_operators : str = str() + + def set( self, in_result: int, iln_argument : List[int] ) -> bool: + self.n_result = in_result + self.ln_arguments = iln_argument + self.n_num_arg = len(iln_argument) + return False #OK + + def generate_operators(self, in_num_operators) -> List[List[str]]: + """ + Knowing the number of arguments + I generate all possible combination of operators + """ + if in_num_operators <= 0: + return list() #FAIL + combinations = list(product("+*", repeat=in_num_operators)) + lln_operators = [''.join(combo) for combo in combinations] + + return lln_operators + + def operation_generator(self, in_num_operators) -> Generator[str, None, None]: + """ + generator that will give a new operator combination every time it is called + """ + + if in_num_operators <= 0: + return list() #FAIL + + combinations = list(product("+*", repeat=in_num_operators)) + for combo in combinations: + yield ''.join(combo) + + return list() #FAIL + + def show(self): + s_str = f"Result: {self.n_result} | Arguments: " + for n_arg in self.ln_arguments: + s_str += f"{n_arg} - " + logging.debug(f"{s_str}") + + def evaluate(self, s_operators : str ) -> int: + """ + the equation will b evaluated using the operators given + + """ + n_len_arg = len(self.ln_arguments) + n_len_op = len(s_operators) + if (n_len_arg != n_len_op +1): + logging.error(f"ERROR: inconsistent length: arguments: {n_len_arg} operators: {n_len_op}") + return -1 + + #initialize accumulator + n_accumulator = self.ln_arguments[0] + for n_index, s_operator in enumerate(s_operators): + if s_operator == "+": + n_accumulator += self.ln_arguments[n_index+1] + elif s_operator == "*": + n_accumulator *= self.ln_arguments[n_index+1] + else: + logging.error("ERROR: invalid operator {s_operator}") + return 0 + return n_accumulator + + def solve(self) -> bool: + """ + ask this equation to solve itself + return True mean FAIL + retunrr False mean found a solution + the solution is in the operator list + """ + + #create an operator generator + + #print(st_equation.generate_operators(st_equation.n_num_arg)) + + if self.n_num_arg <= 1: + return True #FAIL + #Create a generator that will spit out the next combo of opetrators + gen_operators = self.operation_generator(self.n_num_arg -1) + + b_continue = True + while b_continue: + try: + s_operation = next(gen_operators) + n_result = self.evaluate( s_operation ) + logging.debug(f"Operators: {s_operation} -> Result: {n_result} Expected Result: {self.n_result}") + if n_result == self.n_result: + self.s_operators = s_operation + return False #Found solution + except StopIteration: + b_continue = False #solution not found + return True #FAIL + + def __init__(self): + """ + Initialize the Patrol_route class + """ + self.glst_equation : List[self.Equation]= list() + + def load_equations(self, s_filename: str): + """ + Load equations from a file and populate the lst_equation list + """ + with open(s_filename, 'r') as file: + for line in file: + parts = line.split(':') + n_result = int(parts[0].strip()) + ln_arguments = list(map(int, parts[1].split())) + st_equation = self.Equation() + st_equation.set(n_result, ln_arguments) + self.glst_equation.append( st_equation ) + + def show(self): + for st_equation in self.glst_equation: + st_equation.show() + + def solve(self) -> int: + n_accumulator_result = 0 + for st_equation in self.glst_equation: + logging.debug("SOLVE:") + st_equation.show() + b_fail = st_equation.solve() + if (b_fail == False): + n_accumulator_result += st_equation.n_result + logging.debug(f"SOLUTION: {st_equation.s_operators} {st_equation.n_result} -> Accumulator: {n_accumulator_result}") + else: + logging.debug(f"NOT SOLVABLE:") + return n_accumulator_result + +#-------------------------------------------------------------------------------------------------------------------------------- +# MAIN +#-------------------------------------------------------------------------------------------------------------------------------- + +# Example usage +#gs_filename_output = 'day07\day_7_map_output.txt' +gs_filename_example = 'day07\day_7_example.txt' +gs_filename_data = 'day07\day_7_data.txt' +# if interpreter has the intent of executing this file +if __name__ == "__main__": + logging.basicConfig( + filename='day07\day_7.log', + # Specify the log file name + level=logging.DEBUG, + # Set the level of debug to show + format='[%(asctime)s] %(levelname)s %(module)s:%(lineno)d > %(message)s ', + filemode='w' + ) + logging.info("Begin") + + cl_operator_finder = Operator_finder() + #cl_operator_finder.load_equations(gs_filename_example) + cl_operator_finder.load_equations(gs_filename_data) + cl_operator_finder.show() + n_accumulator_result = cl_operator_finder.solve() + print(f"accumulator: {n_accumulator_result}") \ No newline at end of file diff --git a/solutions/orso/day07/day_7_data.txt b/solutions/orso/day07/day_7_data.txt new file mode 100644 index 0000000..eb344f0 --- /dev/null +++ b/solutions/orso/day07/day_7_data.txt @@ -0,0 +1,850 @@ +31084: 8 67 8 735 38 +40541461584: 5 81 9 4 32 43 283 228 +6208: 915 6 2 539 148 29 +306501986: 6 3 630 45 536 64 6 +21276000: 8 5 5 91 6 5 8 6 8 985 2 8 +1432991: 3 403 4 821 591 2 236 +17115994: 69 321 254 764 3 99 +19961295: 5 311 84 6 63 +22953531: 22 95 35 2 8 +18894343830: 90 5 3 2 65 7 159 2 91 1 +4312695565: 158 8 716 615 95 59 +391: 1 326 64 +25202: 8 5 62 1 401 +5324514: 6 8 466 59 169 +658234: 3 83 592 97 57 4 +26804472776473: 7 61 1 447 29 496 71 9 +1503368: 653 23 18 824 625 +24803314445: 5 2 4 4 417 1 987 4 447 +1021069871: 7 3 2 7 9 37 2 2 8 5 58 +1614: 63 645 4 3 31 868 +4258805: 68 532 78 91 5 +4495130022: 583 78 275 37 77 +45111648: 47 98 45 855 998 46 6 +2964501691711: 9 672 76 9 754 7 4 65 +90685578359: 906 855 782 33 126 +13608006: 3 5 7 7 3 602 7 4 7 720 6 +4645623: 66 863 5 615 8 +2569495: 443 74 7 71 5 +134484: 68 55 4 77 9 2 327 4 +1143450000: 24 750 35 264 5 1 +5449: 4 2 907 7 +23061783: 854 9 5 6 1 1 7 3 2 76 5 +2930: 18 6 7 555 5 +2115475: 9 194 8 54 42 5 31 +19449: 6 1 9 4 4 769 8 1 79 905 +4595553: 298 3 4 257 5 3 345 45 +208314087: 7 3 877 815 9 9 3 2 6 51 +2905504: 46 58 514 626 763 +963368: 48 425 484 6 370 +9980664: 1 98 80 5 98 68 +652568: 7 197 871 290 68 +45827: 15 3 665 9 154 +722: 2 21 337 5 357 +27652464029930: 7 829 9 700 7 9 3 7 4 1 8 +6868809: 45 2 9 848 9 +1175: 7 5 98 +2133: 17 2 5 36 5 +528: 55 1 5 8 9 31 +8206806: 1 4 9 4 99 6 24 97 2 5 6 5 +37530658373: 1 2 8 5 8 4 5 7 3 946 373 +65484738025: 47 5 4 43 8 6 43 7 7 26 5 +2157: 8 2 1 93 8 568 +23082508: 7 5 3 3 2 5 8 477 2 3 1 1 +29090880: 45 28 37 8 78 +1262763: 1 1 27 729 93 16 2 75 +1409848204234: 7 87 622 84 820 42 34 +3304: 6 55 4 +1196013120: 8 340 179 35 192 +124278235: 4 4 69 225 78 235 +2735190615: 273 2 3 1 906 1 5 +52192: 104 89 6 45 10 72 +573777850: 680 31 807 8 50 +35694425: 82 38 921 61 871 84 2 +658877085778: 7 86 55 156 10 977 8 +20860682976: 546 3 7 930 7 954 42 6 +224616: 441 46 8 36 73 8 3 45 7 +358087: 7 236 9 45 2 9 3 9 6 4 2 5 +6354432: 55 792 7 153 639 7 +1923524: 177 175 9 3 3 528 21 +117340: 9 82 159 +1234059: 64 357 9 45 6 +2651349895: 8 526 4 7 9 1 6 42 9 89 5 +3884759: 737 251 3 5 7 +633925731: 346 4 3 5 472 9 7 9 4 8 9 +43555: 37 4 60 25 53 77 +4230519: 2 2 12 8 9 9 91 41 2 5 2 3 +5489: 69 8 9 515 6 +82630872: 33 1 2 19 81 9 4 5 6 6 33 +203340489: 181 55 1 4 112 9 +72068: 7 197 4 5 9 +168389664: 1 683 84 5 667 +30367442: 2 657 6 4 384 5 673 49 +2846739576: 4 8 743 9 3 9 829 719 6 +78401: 77 4 9 93 5 +627886555182: 1 61 78 8 65 4 57 94 82 +53361: 85 3 592 1 63 +154268: 48 43 3 892 4 8 3 8 1 +525075263: 656 34 4 8 6 6 +248294606: 6 896 24 1 83 9 4 1 7 75 +9082152: 182 66 9 8 6 7 7 2 195 2 +1657909631: 8 5 76 7 5 95 2 9 22 544 +484430: 2 5 64 7 49 961 83 3 +11192683920: 6 26 7 8 5 8 6 3 8 372 1 1 +52887178: 4 863 61 118 60 +896861: 88 9 7 671 4 187 +721710054179: 135 891 60 541 81 +12403134: 92 6 34 58 6 5 7 9 6 6 +33615296: 312 44 55 9 3 1 572 +183192: 35 8 5 5 612 28 71 3 4 8 +1244794661146: 6 4 9 6 1 6 4 57 7 685 8 6 +362827266: 86 643 395 8 738 813 +1477891785: 86 6 2 8 13 2 91 7 1 8 8 +5983: 3 888 5 291 2 57 6 +73739569: 668 6 687 89 6 69 +902757501: 855 24 627 1 63 26 9 +177442819: 6 9 401 2 4 52 256 4 3 +87403263: 95 920 3 191 7 65 +223398085: 57 3 1 8 11 50 45 8 9 85 +76471: 81 472 2 1 6 +102739: 1 284 1 8 9 1 +98723250300: 79 119 1 1 2 143 5 7 21 +37813543: 28 4 5 813 540 +21449386021: 185 4 9 9 3 6 4 46 7 1 3 8 +355140846: 39 4 6 90 845 +25511824797: 3 7 4 746 48 55 3 15 +11681963: 5 76 9 67 1 35 3 8 50 3 2 +10812636790: 3 778 3 954 790 +144: 90 14 40 +2954988: 6 3 3 16 4 95 2 1 7 3 9 3 +1666626: 282 573 74 39 1 46 +380854191760: 2 7 24 5 54 177 5 5 664 +20485976: 47 155 643 323 3 8 +562264400: 8 1 3 1 5 74 3 67 309 88 +5054: 67 3 55 599 604 +5790: 8 6 4 3 7 43 1 9 8 4 17 6 +1423: 232 6 23 2 6 +2214885600: 1 5 2 1 3 50 183 41 82 3 +586061: 507 69 31 975 3 +68594249: 2 9 373 9 50 340 3 32 6 +380980: 95 4 980 +7510: 5 4 825 4 71 9 +451918: 90 50 18 11 106 +16294: 29 134 8 65 4 1 455 3 +10536237: 6 6 3 9 1 1 4 724 4 5 1 97 +24566372: 1 34 8 3 90 592 85 87 +284990: 5 5 5 91 7 5 88 5 +1108832032: 80 93 29 3 727 88 +215422984: 63 82 417 8 70 1 +37636247: 3 875 3 39 615 6 73 5 2 +511718662: 3 505 3 718 23 42 9 +172674894: 6 76 9 6 7 5 6 6 7 7 22 2 +2494298: 21 8 468 606 6 +1164891: 12 97 891 +1303421387: 8 604 17 5 6 48 95 87 +113169: 242 889 55 7 6 +28083319654: 7 1 6 2 780 4 8 9 9 3 8 7 +689769: 2 479 72 6 +664006: 603 60 997 9 +383810: 312 123 4 7 +278838736: 254 851 15 86 76 +35266920: 4 8 65 481 94 +2342060: 5 55 2 43 99 710 +61499384: 760 4 83 423 2 4 +1337677: 769 562 5 67 3 9 13 +20708670: 1 7 8 1 9 9 6 70 6 1 3 57 +22607703347: 23 6 7 6 7 67 80 39 44 +422584: 1 6 185 2 95 23 1 878 +16961283369: 7 614 720 9 609 1 9 +7743900: 12 80 8 38 33 75 525 +5198: 5 14 5 5 3 +7706: 5 765 6 +60799047884: 9 6 5 331 7 2 2 6 3 3 5 87 +373279812855: 74 65 5 946 16 571 5 +273426612: 519 24 87 2 656 3 958 +449: 250 94 8 9 88 +69949442: 8 92 4 1 15 33 8 3 1 2 2 +2540247614: 578 3 346 73 29 5 5 9 2 +72710790952: 99 4 87 255 85 7 4 +43727113667: 3 1 333 66 106 71 2 4 7 +74125836117: 4 5 52 6 25 35 9 3 521 +527906: 54 9 9 931 29 +139782: 11 33 6 526 918 +19218: 704 402 9 522 284 8 +8668810: 40 8 6 3 6 2 84 2 2 75 7 3 +1487663526: 9 9 517 70 2 6 2 5 94 8 4 +20610: 1 152 3 2 45 +359112: 323 5 47 54 7 6 3 8 4 2 4 +3198: 1 7 8 8 24 7 1 4 41 7 27 +41189: 13 9 3 624 5 +4720776758223: 47 20 776 758 222 +195264: 4 2 339 36 2 +16012371600: 6 9 6 3 6 3 95 3 76 4 185 +3864074: 3 4 426 84 73 +45674415: 42 4 9 7 82 410 5 +1175718380: 6 340 5 911 746 +51156: 3 4 4 540 87 +4831584: 2 43 8 2 55 5 7 5 69 96 +874516400: 874 5 16 368 32 +220190: 7 974 32 38 1 7 4 172 4 +429894584: 1 9 5 7 5 98 94 9 6 9 58 4 +114640: 3 7 31 52 7 6 1 772 299 +10759: 23 1 6 12 7 2 1 4 81 28 7 +360390945715: 2 431 696 27 213 20 5 +3140056: 783 9 5 1 43 9 8 864 +15606936: 96 6 40 639 172 +1134226: 9 824 46 152 2 +640: 5 32 2 2 +46339061240: 7 20 9 987 5 715 618 +35646030: 42 1 885 137 7 +271367519: 7 45 964 127 96 893 +495104: 1 960 8 56 64 +3480: 7 1 12 3 1 40 +2608290: 91 95 46 3 3 30 +55890251: 1 65 7 9 4 81 454 3 582 +541872: 774 7 46 2 27 +309960637: 8 43 4 90 640 +14270: 44 8 875 1 9 6 1 8 3 5 5 +2461824: 1 4 1 9 7 12 61 71 1 4 1 8 +53575: 6 73 9 7 118 3 +3128658: 93 9 2 2 20 8 94 331 7 +223592: 5 43 381 5 9 4 5 884 8 +12112807054: 870 119 7 61 15 274 4 +27775914: 6 1 781 1 9 18 4 3 5 889 +279477744: 33 3 9 411 87 763 +9896932013: 647 3 331 353 343 46 +8127207475: 8 1 2 720 3 4 29 9 4 91 3 +3683665: 981 751 5 5 8 +7203976: 3 51 7 5 629 3 5 9 9 8 5 4 +12182439609: 5 57 9 9 9 7 9 8 4 320 3 3 +6547981: 9 727 2 47 84 +269451007: 9 262 62 4 992 +1760418: 99 34 1 5 99 96 4 27 6 +4881246: 5 3 46 2 4 67 57 8 +104401: 68 69 8 72 1 +57612060: 6 270 53 61 11 +65336211: 92 71 912 169 540 1 +1056886344323: 8 990 3 9 1 6 18 695 64 +431112: 3 19 108 92 69 +1497953467: 1 640 5 8 6 9 38 65 +20122455: 24 76 903 9 +112719469: 32 80 7 13 6 456 4 6 +1178483161: 18 8 6 29 75 754 4 3 4 +119908723232: 48 39 7 5 3 73 8 64 30 +21106565: 350 1 37 4 966 2 1 7 2 2 +70193: 4 53 9 2 7 701 59 746 4 +3034: 21 45 68 816 3 +3005: 2 89 24 92 7 58 +81430304: 124 4 989 2 83 +22260548: 7 15 212 54 7 +494808: 87 6 665 6 8 +6723: 4 81 13 457 13 +463069864051: 995 8 4 91 7 465 10 +913887: 3 6 7 2 752 9 5 1 36 5 2 1 +824408862: 82 43 9 86 8 94 6 5 +3431928092169: 5 3 67 76 755 15 362 6 +502132176: 9 109 624 964 702 +83412526: 1 4 7 2 27 405 3 1 721 8 +407094: 27 7 60 433 7 5 +701412: 2 5 84 648 97 836 8 +25707842242: 311 3 2 3 711 8 8 2 2 42 +505119: 1 44 41 7 40 +295936440: 9 27 963 89 272 4 38 +59813: 595 97 657 457 984 +297534: 348 61 1 1 2 7 296 46 +143500: 618 32 8 31 19 1 82 7 +138312966147: 5 29 5 3 2 2 7 50 4 8 96 2 +311740: 5 76 5 37 1 1 597 3 20 +4908292: 9 785 31 59 5 +6141663: 204 7 25 3 5 1 7 2 9 6 2 2 +746258: 1 3 61 6 48 21 4 11 81 5 +310680: 6 7 59 782 9 45 8 +170615594: 447 3 7 74 35 7 7 6 6 6 2 +160656040: 75 78 105 603 7 +5577322182: 47 49 942 2 24 5 7 1 2 7 +48328: 3 7 4 7 9 149 9 456 7 3 7 +155259452737: 56 746 874 2 8 342 +35341: 5 76 93 1 +22236341: 3 381 88 641 5 1 +44989863673: 96 6 5 6 71 2 3 381 7 3 3 +606: 4 80 50 4 70 +12733: 65 9 2 86 5 +22463298: 24 88 3 5 80 1 4 89 8 +377019478: 6 748 5 1 3 4 1 9 7 2 3 8 +19642752: 696 5 7 544 51 +702511961: 887 792 1 7 961 +6024648: 8 86 75 47 168 +104509650: 5 1 482 62 72 597 7 70 +1135227: 2 218 25 27 45 5 5 +224: 2 4 6 2 86 100 +173902: 99 277 462 89 4 99 +823929: 9 9 8 5 929 +25781529: 60 9 8 4 7 65 9 2 4 213 9 +15984006: 38 6 5 9 727 7 6 4 96 1 5 +911: 7 6 1 868 1 +1319338035: 7 6 1 7 6 438 1 448 5 87 +281978: 561 4 9 5 5 56 1 4 1 9 5 3 +26739745316256: 3 772 8 21 75 45 5 75 5 +804636: 50 6 26 542 927 +4368: 9 87 1 8 42 +1339970241787: 2 6 8 17 4 82 9 29 4 95 2 +27896197888: 8 8 849 619 66 521 +1624907806241: 9 270 3 9 649 18 9 44 1 +804053256: 531 30 7 9 25 91 6 +19887: 394 48 682 27 264 +576579196: 34 7 5 75 6 8 1 5 5 5 91 9 +4075638918: 886 5 23 97 1 5 4 7 48 +1242184922: 7 4 5 7 88 9 393 4 925 +816: 5 2 5 6 45 6 +16640: 34 60 177 +55047199922: 5 674 9 97 58 8 985 7 1 +202: 1 57 3 8 1 4 28 2 +128584480: 34 6 835 650 94 8 +14447: 166 3 28 420 83 +302594: 5 6 2 511 83 +100153: 4 389 35 70 60 43 450 +2185551: 38 3 43 19 3 +6746: 4 6 583 93 784 39 +3486469538: 8 47 3 40 786 7 9 1 19 +2105210: 7 4 8 2 6 9 8 31 7 56 3 2 +47524069: 6 4 610 811 106 4 85 8 +24206: 25 599 13 2 19 +83444222: 309 3 9 96 1 8 38 21 +1157600: 383 930 42 92 800 +135424: 274 494 29 6 33 +41759168088: 63 4 91 3 77 2 33 9 94 +912: 6 1 9 58 1 838 +1483426560: 4 6 1 69 801 406 692 6 +1291767304: 41 475 889 4 88 65 8 +4740630: 941 32 56 2 87 +145255683: 6 928 2 270 96 3 3 +2804256: 2 563 36 41 6 91 8 +3662: 592 6 91 11 8 +2070609492: 9 460 7 1 66 352 9 8 5 +58896: 73 2 5 17 5 15 8 +161664199: 5 9 8 9 746 32 2 1 9 8 +28767133: 6 69 10 43 37 96 +321150750: 6 3 33 7 6 191 1 74 355 +32221373185: 931 4 3 78 56 33 8 +125188150: 1 84 8 299 7 6 3 623 38 +529: 1 2 63 54 350 +371329981: 53 730 8 78 760 4 57 1 +8636010413: 34 6 1 516 8 4 4 82 1 1 1 +16436: 8 8 36 7 70 +2610384: 6 74 93 329 8 42 +2511598: 21 497 80 7 10 12 5 +2051303: 68 6 53 523 6 91 +3583491: 58 3 3 8 852 79 4 5 5 46 +2567: 5 3 32 4 3 +37412197: 63 94 238 46 197 +660996: 61 61 7 43 18 +772595115: 1 7 2 25 4 2 314 72 5 8 6 +1125072: 6 82 64 2 3 7 444 2 3 48 +40030036: 9 68 7 66 646 +26483808: 5 6 9 862 16 33 96 +89503594: 2 91 80 112 72 61 +34849136: 7 14 6 1 9 857 68 88 +1052469452651: 5 94 9 5 5 5 9 870 8 8 3 8 +2333026: 2 9 1 8 36 9 5 5 75 1 7 9 +2142047: 55 2 6 1 60 3 9 40 6 5 +18329059: 1 7 398 2 523 11 1 +1515: 1 5 216 3 1 214 +636751072: 65 7 58 3 967 7 759 9 4 +65121: 3 648 21 +1203384: 855 2 9 12 7 +1231: 567 1 29 21 1 612 +5830477499: 416 2 925 357 7 +39904736: 2 2 987 58 51 2 1 8 +7192: 4 881 3 11 8 +984797352: 86 84 99 3 1 459 +4330380: 444 3 8 3 797 7 6 9 1 5 6 +174675: 8 41 206 75 824 530 +644000: 2 4 89 4 17 7 92 14 1 4 +275310: 6 11 31 58 888 4 2 9 2 +2980025: 29 72 7 96 4 61 +1100140: 3 8 9 91 3 9 466 5 6 8 3 9 +26416153: 5 3 64 9 4 764 7 7 5 4 6 7 +392307: 644 22 589 2 30 +1703108: 23 789 9 532 7 8 +84496967641: 9 8 7 71 696 158 605 9 +4926: 5 47 3 5 2 6 60 +1238: 7 20 5 8 75 +4166368: 4 8 393 74 22 7 +264286: 5 5 2 6 11 26 80 115 8 6 +5390070: 38 5 77 813 35 3 54 8 6 +7109213251: 798 2 5 88 89 50 +11479038526: 245 1 5 7 333 456 3 7 9 +35577532: 71 155 500 25 5 +516: 7 4 6 4 1 70 9 66 1 5 39 2 +12159: 9 6 1 225 9 +593081: 1 92 6 4 343 2 6 8 3 41 +52698: 89 592 7 +36739952992513: 9 4 779 4 627 92 4 8 3 7 +2006: 22 8 90 75 5 8 +83601: 68 30 8 5 1 56 3 1 3 7 +478266: 1 4 8 6 3 724 612 8 286 +297000: 49 50 820 9 90 6 88 +1229910807: 262 102 46 6 600 807 +185356128: 44 5 401 7 82 115 48 +246521: 787 6 4 6 307 +86285202: 25 96 42 856 402 +23586: 70 1 3 52 9 5 +18086584: 46 6 144 8 27 534 7 +33690: 4 69 4 56 89 +46311716: 12 3 41 18 619 6 +214023: 5 793 66 7 53 9 +6755: 270 2 799 12 5 +14223284: 9 9 7 5 7 8 2 111 1 45 4 8 +2291081: 3 2 632 725 81 +284789717303: 605 3 9 3 960 30 47 49 +17262: 105 4 3 1 3 9 3 240 2 7 1 +157051: 9 7 6 181 6 9 3 3 451 81 +1349805670: 59 4 874 26 71 +2361910101: 5 623 7 3 38 6 8 1 3 1 8 2 +45459840: 8 42 71 1 3 8 4 9 8 9 384 +644841302: 7 658 2 70 62 68 2 +196349: 69 6 192 81 2 4 +25233495: 14 6 1 3 34 83 14 +2502364627: 9 73 7 1 76 4 7 95 8 5 27 +891841251: 79 62 560 2 63 6 51 +526: 95 9 4 1 417 +46610701: 46 605 5 697 4 +101160: 5 5 6 5 9 4 873 8 4 3 3 63 +74700: 86 2 765 47 83 +487499: 9 52 6 6 85 502 +12930315: 4 77 3 9 48 9 1 5 +818480: 3 4 8 966 10 3 7 1 4 5 4 1 +8956575: 6 8 827 5 676 864 35 +6467920693: 5 8 5 48 652 1 8 8 1 3 8 5 +877: 71 10 689 32 75 +53325209060: 554 965 941 2 53 +23291024284082: 9 42 193 47 6 9 515 48 +929424926: 3 6 29 42 492 5 +17829266: 6 56 4 53 63 +12276: 2 5 55 3 66 +181712606: 595 74 75 412 6 +8831966: 2 56 30 2 2 39 65 2 9 8 7 +661454663997: 231 3 453 350 8 10 78 +237094: 3 3 311 50 646 12 +5707220457: 71 82 86 966 4 920 55 +152255376595: 76 17 40 820 65 163 +1347305: 9 4 8 65 664 3 4 3 701 9 +70155: 91 2 88 257 706 58 1 +60468016: 640 1 23 5 27 726 812 +408075824: 40 74 6 758 22 +149767280436: 1 221 860 788 436 +1581985302: 83 9 258 3 8 38 72 3 6 +157694208: 94 8 52 3 5 15 56 1 3 8 +3814512: 5 6 4 8 8 5 6 5 5 37 9 +4548610: 66 9 3 3 7 57 50 1 9 +21119484: 38 822 28 29 876 +5946398: 661 589 67 71 91 57 +151648362: 894 75 5 9 93 54 317 +10321152: 99 807 712 2 8 +114489: 6 5 4 8 31 84 37 9 +145909: 75 70 909 +106820010: 722 269 10 2 55 +1480075: 44 2 198 9 3 71 691 6 7 +28827: 19 1 5 7 6 9 78 1 8 849 3 +7566: 7 244 8 141 62 23 5 83 +5508361: 495 4 214 13 1 +4988516: 5 33 55 12 568 66 2 97 +184373: 1 9 7 9 5 1 1 33 9 11 20 +199283931852: 3 5 8 4 158 6 3 539 855 +1666857472580: 77 654 23 180 331 +14487733: 557 891 68 9 9 5 828 +1198391800: 231 965 8 84 2 93 1 4 2 +126143604: 86 2 6 463 88 55 5 3 +153392452209: 6 482 7 3 939 11 5 4 9 7 +12681: 5 7 2 9 4 7 44 2 5 65 4 9 +989: 1 9 99 +93840: 98 38 46 15 +217780: 419 3 516 23 5 +33264: 447 87 973 5 22 +7178025: 995 9 5 2 87 7 527 20 5 +9028: 3 83 7 5 3 +12935: 711 5 6 3 47 +3659499181: 365 925 6 229 9 5 181 +701521: 9 4 3 64 7 61 8 26 67 53 +340704429: 52 78 84 319 7 7 99 +62241150: 7 176 842 8 77 6 +112424: 5 1 8 936 82 8 183 92 +723672: 347 67 1 2 874 +3066: 51 5 8 8 8 898 +1274880: 23 52 542 9 87 +2517506958: 37 68 780 726 9 59 +110283391: 3 52 3 53 8 3 8 6 3 903 1 +4536: 83 5 81 9 747 2 +87466: 19 46 6 3 +605783111392: 404 91 601 37 741 4 +58853775: 4 485 79 4 384 399 +47889063: 516 64 89 984 999 29 +23241016: 7 3 5 5 6 1 3 819 27 9 9 1 +27260572330: 9 9 7 9 28 57 2 3 8 2 5 5 +233756964: 61 958 6 5 1 5 26 8 314 +781268: 376 6 743 4 692 1 +69945120: 7 4 539 5 113 5 6 4 7 73 +267715242: 92 8 663 9 4 3 632 3 1 2 +1896465174: 976 920 1 4 651 72 +2800123: 203 8 17 9 384 23 +206464: 3 7 3 186 1 +127766017: 74 12 9 35 714 1 24 1 +24: 7 5 1 9 3 +10510918116: 59 46 109 181 15 +3621981: 2 248 954 2 1 3 9 78 +7258534: 70 96 523 840 898 +12932425: 928 6 43 57 8 54 1 3 9 7 +40426441: 6 8 7 7 3 8 1 2 1 18 509 9 +258400: 70 120 34 40 +895: 81 303 38 2 51 +80809920: 932 69 727 47 995 +21779938: 9 411 92 64 226 +1613: 4 401 4 7 +43158803498: 36 222 9 7 26 39 6 9 9 1 +4366703135: 57 7 93 7 2 70 982 8 6 +167694750: 9 89 350 76 598 +1913663802: 64 299 63 6 2 10 2 +1444191: 556 9 11 4 6 5 1 41 83 7 +1003880435: 19 82 746 977 863 +4155: 72 810 13 4 575 +96614034: 15 6 361 72 6 2 3 6 59 +1688: 5 9 1 5 3 8 8 +41338714328: 41 338 639 75 328 +9197318140: 2 59 6 1 690 8 1 5 227 4 +46479360: 61 7 4 2 9 7 39 272 6 5 8 +404048233: 951 7 8 576 2 4 235 +11494468882: 3 187 5 9 1 3 24 2 6 7 5 7 +1922: 6 233 457 6 61 +6955: 9 7 8 4 5 7 4 2 4 5 202 5 +31285182: 23 136 506 7 63 52 +8117862: 437 1 6 921 2 381 46 6 +47589: 9 94 374 39 7 +2256037: 60 376 39 +2527024499: 4 3 1 7 8 10 3 1 6 51 91 +37690: 3 720 52 6 1 88 1 +4175256007: 4 8 5 39 20 2 34 2 23 +380247474471: 2 4 2 45 497 88 5 7 2 7 1 +21474: 9 9 9 1 17 4 784 8 4 39 9 +3277745: 18 2 5 4 414 89 271 +20611117618: 3 3 2 4 8 1 4 9 39 76 19 +6706090709: 799 2 3 1 8 9 8 4 7 872 +5792: 618 29 68 8 3 69 +410827821: 4 927 73 453 16 409 +233173828: 3 74 634 6 896 3 4 7 5 6 +187959: 119 32 2 556 23 +486043544: 3 230 57 52 54 74 62 7 +2347696: 4 1 35 40 19 769 8 +4278588041013: 44 7 29 4 7 456 7 4 684 +5637600: 58 9 54 25 8 +4977330: 9 7 6 79 3 9 8 838 3 4 7 6 +22497: 82 79 983 1 1 3 9 102 +35382699154: 77 617 2 14 2 46 554 +16502056: 8 6 58 319 488 5 819 +756793: 88 3 3 944 192 3 1 72 +4214: 6 697 1 5 27 +12450094: 2 2 2 6 3 629 9 857 5 9 4 +1618088: 76 4 6 1 7 7 62 90 5 1 8 +1060491: 3 361 14 906 66 1 +266689086: 3 2 17 83 5 6 8 42 6 5 3 3 +68560832: 3 1 82 6 8 5 3 308 2 1 2 +1326: 423 846 4 1 8 44 +68085: 674 6 78 7 +1840707: 85 9 62 6 804 4 3 +13403416: 2 1 3 5 4 65 7 8 7 3 933 +2093: 56 6 868 26 614 9 8 +12213922: 73 703 14 1 17 +224283: 640 7 4 5 8 4 +97770: 1 214 7 27 1 8 378 +25990: 6 5 5 87 2 7 767 6 92 4 +299184551: 325 2 92 544 7 +63062194: 70 9 605 7 46 123 825 +68322843482: 28 244 28 434 82 +37380255: 80 1 935 87 493 4 5 +305472677: 509 6 7 267 7 +46: 1 45 2 +2250: 29 1 75 6 69 +191773: 19 176 5 8 +91083792: 4 7 236 878 7 5 6 4 3 1 1 +335524376: 8 53 51 68 668 158 +29640281671: 7 8 4 6 3 5 7 44 7 8 8 90 +497340: 9 3 762 7 3 6 3 5 6 +279527: 402 67 149 4 1 3 +279694: 1 935 96 765 97 +224785469: 2 1 9 5 68 10 2 3 9 3 7 23 +10732502: 15 5 477 5 60 +7497250: 8 936 1 9 249 +56971: 4 76 9 79 91 +41393070: 2 53 5 781 70 +12168228431496: 64 3 8 2 161 9 7 831 3 +117142318737: 3 6 6 9 2 60 436 3 9 6 9 3 +158260: 9 45 5 4 78 +2363212870: 2 363 212 4 52 420 +447325: 463 2 795 355 25 +4751: 11 48 9 +841: 81 9 97 2 13 +3346211520: 3 9 858 11 522 +697352492: 67 1 4 4 18 3 455 69 9 5 +7319280640: 61 45 7 709 7 656 80 +27260: 7 9 344 79 5 +10737320581: 7 8 5 5 55 7 8 6 294 70 +17943: 9 839 921 18 6 9 4 +35412: 6 724 1 9 8 580 +6453: 161 1 475 81 9 +840798: 975 287 52 3 647 517 +17854: 3 32 69 42 7 655 +1735468803: 3 86 8 5 9 91 68 3 26 80 +1955340326: 54 8 292 2 54 5 327 +7614444: 86 7 718 824 7 88 7 19 +108369902185: 3 9 115 814 7 9 5 7 1 8 6 +139223: 8 3 53 2 77 38 6 3 2 7 4 +2142640: 49 43 35 566 72 +266228026: 3 80 51 8 597 5 62 24 +68870224: 6 62 870 22 4 +393281: 5 4 109 9 32 77 2 22 9 +22257035: 29 25 685 5 6 3 597 3 5 +1480: 679 67 130 537 9 58 +11720991: 1 8 23 7 364 5 5 5 59 7 +156699: 663 9 301 5 5 +1292069: 17 760 21 42 6 +83229203: 100 1 4 7 1 808 321 9 2 +15899250: 986 375 43 +80808: 40 4 521 212 104 +10465625002: 9 77 71 47 50 1 425 2 +819408192: 31 68 991 7 3 87 +667: 8 8 2 7 +26860: 200 45 23 56 4 +49480468: 43 29 90 127 +5186813940000: 504 967 5 825 5 86 2 3 +19174057: 6 7 652 7 51 7 +72691616664: 991 7 733 662 6 38 +18573243: 343 360 489 9 900 6 +3883810560: 6 88 2 8 4 438 8 980 6 +19738: 5 2 508 38 54 +703764: 13 8 48 495 20 77 23 6 +273920: 7 629 987 89 8 20 +911: 7 5 9 4 592 +33029: 50 644 822 7 +524702: 7 153 24 79 7 3 95 17 +109342: 84 130 3 3 2 2 80 +35742400: 8 1 706 7 51 174 6 6 9 7 +1483641: 2 64 70 737 153 +7397: 364 5 8 4 85 +10622451329: 5 80 3 7 1 4 7 879 3 1 2 +1513454743: 69 31 8 732 963 91 +87816030: 47 1 7 80 3 8 1 6 417 1 +2957777379: 30 265 7 777 379 +279602: 759 1 23 4 4 274 9 7 +2793723: 2 10 66 1 6 24 2 723 +13426560: 36 37 180 8 7 +72281484: 8 25 758 6 17 9 36 +15157818475: 26 124 1 5 7 818 475 +1726473: 857 5 41 9 819 2 +69102877793: 9 997 2 91 7 17 711 7 5 +1182849: 2 249 31 38 4 129 8 +81125766: 7 2 670 17 308 3 789 +20198: 8 6 3 396 2 +130416799: 10 27 483 6 7 9 6 4 +29969: 7 62 38 7 91 5 4 907 +4071: 3 10 4 7 23 +3447616557: 858 111 362 9 54 +31720: 38 59 43 63 4 2 +10386966: 1 3 8 612 2 96 5 7 8 4 6 3 +2515969: 2 768 9 906 8 +2085272: 18 65 114 297 25 +245966149: 96 3 146 5 6 4 2 2 3 731 +936628: 57 38 19 887 90 88 +434515299: 905 64 9 8 56 99 +7751781085279: 8 7 900 819 9 389 11 +6523: 4 61 26 151 28 +507242778: 6 822 69 44 4 459 1 6 7 +4557: 2 48 3 9 169 3 +6172533: 37 9 207 43 7 9 7 7 12 9 +4528512: 7 27 871 689 5 6 63 +35178: 1 682 81 46 80 +40198: 67 4 25 6 +12418780: 54 7 6 8 351 6 164 11 +37440: 24 9 8 12 870 247 32 +7303307255: 35 695 324 6 64 8 52 +42929: 9 124 38 5 516 +101311: 2 99 31 1 3 +3786723: 1 685 92 6 3 3 +757762: 76 997 1 3 38 +728: 567 6 23 42 90 +19126995: 593 1 70 65 59 58 458 +83647: 8 828 47 +1250549: 24 939 1 71 50 +9778: 9 173 39 15 5 3 39 262 +18714: 89 265 5 13 4 43 1 3 +10446534727248: 61 465 74 62 990 8 6 +4136: 12 289 668 +986: 919 65 2 +382284584: 655 1 7 1 144 578 7 1 +2087668: 521 7 75 94 48 4 +13551: 62 69 8 36 9 +54736659: 504 52 8 38 17 261 +46609728: 5 9 6 5 78 8 818 9 3 1 5 6 +8001: 55 7 6 9 7 3 +2164: 20 62 3 7 8 8 76 +34288954: 174 227 512 141 854 +149143039: 568 157 839 4 4 8 745 +858002: 715 600 1 2 2 +355275: 3 550 5 22 6 +1161901609: 9 3 7 1 9 5 8 2 99 9 492 4 +14265505: 7 4 77 237 684 +93906: 1 23 457 4 78 +280258704: 396 16 217 528 81 +2447: 237 9 217 9 88 +21103892: 688 2 139 4 3 64 55 7 +572320: 571 889 7 8 7 +22940: 74 1 31 10 +453933144: 884 1 7 2 8 75 164 94 9 +9387402762: 447 7 134 3 70 3 57 2 +628: 2 96 5 6 10 +58729373: 53 4 53 29 373 +16162243: 2 3 90 75 92 139 927 +1806271: 4 319 283 5 13 718 +1908: 72 26 16 8 9 +87108518916: 8 349 61 129 729 4 +1120226562: 81 8 1 54 7 89 8 5 2 32 +5619463232: 7 860 2 3 9 3 24 29 +28275666: 4 35 65 440 227 +57418552: 8 96 4 18 9 6 4 142 +337848089754: 893 778 54 82 7 9 5 +101244761: 2 8 4 1 222 8 1 631 6 4 5 +31091: 2 94 6 323 9 4 4 53 8 3 +9551142: 2 7 4 4 92 9 87 2 54 +431798: 2 827 32 904 554 96 +368064: 62 5 31 10 568 6 +641856: 80 23 1 2 8 +356332: 848 13 8 38 853 4 +1530148: 107 13 11 13 33 +10595: 4 93 3 71 524 +13825: 37 88 128 73 4 +485809: 9 597 19 6 996 5 +6598799: 541 2 674 617 6 5 3 1 1 +15595884486: 6 36 560 69 8 961 +655845: 5 5 2 512 8 298 7 115 +167578404: 716 3 162 9 916 19 +539849: 3 7 1 594 25 +3430232: 9 15 29 9 2 700 7 56 4 8 +4196: 951 77 9 8 4 4 +24625387: 9 6 8 6 9 37 846 38 3 8 8 +4318272002: 10 7 2 3 80 6 5 2 7 306 2 +49392736: 80 63 4 72 34 2 944 2 +97244751876: 3 45 6 3 7 293 8 5 9 2 3 1 +2827209446: 384 6 35 4 9 6 7 3 441 5 +773376516: 7 73 37 651 5 +466781: 21 76 5 364 782 +314242938: 77 30 223 22 610 218 +654638167: 14 95 6 631 7 169 +11952: 76 23 69 7 50 439 18 +7579925: 860 37 435 47 5 +1618: 80 4 7 711 59 +33287: 1 822 40 354 48 2 3 +126232779: 6 3 841 9 5 4 77 8 34 9 3 +155627: 1 6 99 989 54 95 13 99 +713339897: 9 7 5 8 9 30 430 +131670050047: 231 19 75 12 5 1 4 8 +7727322: 2 795 9 753 513 +349733: 615 8 637 271 4 6 28 +2481710424: 1 58 9 49 1 3 96 5 9 3 8 3 +261963659: 9 7 4 7 2 308 655 650 9 +51571974: 7 5 579 7 848 1 1 3 +20290: 3 85 3 467 36 1 1 6 196 +2626: 2 6 96 545 2 +22878: 2 2 80 275 4 21 3 9 +575535: 54 4 14 18 10 8 73 6 3 +477517: 43 3 4 5 8 46 7 50 +1384703: 4 401 6 7 738 51 +891003337: 86 6 12 4 825 3 3 39 +90028742465: 608 3 1 37 4 3 4 2 4 6 2 1 +231588050: 35 3 1 586 1 2 8 1 3 65 5 +1072: 7 9 995 9 5 +11381395: 73 4 974 2 36 2 435 7 +3841: 847 4 87 358 8 +88734868: 3 6 9 8 9 2 7 5 4 838 725 +280240227: 2 981 23 1 48 94 +343965: 6 35 67 885 23 +14417393: 9 4 7 2 63 6 38 35 90 +227912: 8 183 31 19 3 72 9 8 1 +2511501082: 1 946 88 2 430 3 7 6 2 4 +9770975: 2 207 7 58 9 4 36 33 5 +181098129983: 36 3 6 1 3 399 7 9 8 1 8 6 +5511886: 749 92 63 2 9 4 104 94 +11912: 3 167 581 43 15 +54194003: 24 5 7 50 632 +40135618285: 5 5 5 4 8 7 7 38 182 8 3 5 +8817032: 460 2 2 6 4 4 7 2 57 728 +236071: 566 414 610 196 941 +1699: 874 26 799 +9082: 59 85 7 9 10 +14399715: 7 6 5 84 32 1 9 9 8 756 7 +957922: 5 76 282 265 853 +519850: 854 1 1 608 8 +494598: 8 8 8 9 1 2 4 1 3 4 17 78 +717301: 769 92 138 844 1 +79732051: 8 1 7 80 45 5 221 629 8 +193315: 5 329 577 536 60 +443120: 71 7 62 5 764 4 +799531202: 320 693 332 72 50 2 +25055194: 241 48 900 7 194 +148742749564: 341 93 73 435 240 65 +2975722: 802 811 6 919 2 +69614316: 3 9 65 34 9 9 6 3 1 96 59 +9211672: 92 116 51 20 +1384: 5 687 2 +2227754259: 312 1 75 78 952 +1980: 6 46 5 70 6 +1051: 74 41 921 7 8 +7224: 69 9 6 405 7 +100058717: 58 44 628 7 145 31 9 8 +13325842: 86 4 981 7 534 49 5 9 +135606016: 86 1 1 7 2 4 8 877 96 8 +188416: 4 8 735 32 8 +13081748: 306 58 2 737 +3408461: 654 396 4 34 348 94 9 +19518: 2 1 8 9 1 54 9 25 9 616 2 +31719: 65 6 9 78 597 +246572: 26 98 9 4 393 9 81 2 8 +127805458: 40 71 9 1 5 457 +7811: 198 16 5 7 31 1 4 794 6 +1168319105: 5 2 1 2 4 44 8 93 9 12 8 8 +7211685: 411 5 7 562 8 554 93 5 +4028985022: 77 86 48 505 604 +127755655140: 73 70 5 3 8 31 5 140 +208269903: 3 75 267 990 3 +956027222: 455 20 5 10 4 3 5 7 +332644: 63 1 8 660 4 +739903: 8 744 1 67 3 630 9 1 5 +449841: 8 6 3 1 9 9 4 9 608 73 88 +3162: 88 4 6 9 7 3 53 7 9 17 +123780: 961 528 514 51 9 60 +397: 88 299 1 1 9 +20327221321: 10 40 83 98 1 460 7 6 +22759444: 366 7 6 3 241 6 +1397068088398: 419 2 5 161 5 6 4 414 1 +5172: 6 431 2 +7637: 251 9 85 746 7 +1812: 908 35 789 3 77 +1120: 7 9 1 68 9 2 4 +770138283: 11 6 57 1 3 8 947 9 1 3 3 +163644: 610 32 344 63 156 +6168: 137 5 9 +507: 41 9 2 76 60 +593693: 77 77 16 765 9 +1214074355: 9 4 5 3 9 73 5 7 8 4 855 8 +607244471: 6 3 7 3 1 83 2 510 2 4 6 8 +275: 26 2 9 2 2 +250040507: 24 9 455 585 504 +5137920095731: 44 7 438 78 3 23 573 2 +282926819: 6 4 827 26 812 42 3 32 +80952: 37 2 6 948 2 +8890436: 635 2 7 43 8 +10600: 2 1 8 8 6 6 8 3 91 541 6 5 +23840: 5 86 1 9 4 1 7 511 57 5 +283368: 3 8 8 322 8 +1123947090: 49 3 877 8 1 323 9 342 +25775616: 8 8 6 97 692 +243687944: 650 5 815 32 92 +2855764: 2 1 912 730 1 +2736185924: 835 66 2 53 8 3 31 3 2 2 diff --git a/solutions/orso/day07/day_7_example.txt b/solutions/orso/day07/day_7_example.txt new file mode 100644 index 0000000..87b8b25 --- /dev/null +++ b/solutions/orso/day07/day_7_example.txt @@ -0,0 +1,9 @@ +190: 10 19 +3267: 81 40 27 +83: 17 5 +156: 15 6 +7290: 6 8 6 15 +161011: 16 10 13 +192: 17 8 14 +21037: 9 7 18 13 +292: 11 6 16 20 \ No newline at end of file diff --git a/solutions/orso/day07/day_7_formulation.txt b/solutions/orso/day07/day_7_formulation.txt new file mode 100644 index 0000000..f1be155 --- /dev/null +++ b/solutions/orso/day07/day_7_formulation.txt @@ -0,0 +1,55 @@ +https://adventofcode.com/ + +--- Day 7: Bridge Repair --- + +The Historians take you to a familiar rope bridge over a river in the middle of a jungle. +The Chief isn't on this side of the bridge, though; maybe he's on the other side? +When you go to cross the bridge, you notice a group of engineers trying to repair it. +(Apparently, it breaks pretty frequently.) You won't be able to cross until it's fixed. +You ask how long it'll take; the engineers tell you that it only needs final calibrations, +but some young elephants were playing nearby and stole all the operators from their calibration equations! +They could finish the calibrations if only someone could determine which test values could possibly be +produced by placing any combination of operators into their calibration equations (your puzzle input). + +For example: +190: 10 19 +3267: 81 40 27 +83: 17 5 +156: 15 6 +7290: 6 8 6 15 +161011: 16 10 13 +192: 17 8 14 +21037: 9 7 18 13 +292: 11 6 16 20 + +Each line represents a single equation. +The test value appears before the colon on each line; +it is your job to determine whether the remaining numbers can be combined with operators to produce the test value. + +Operators are always evaluated left-to-right, +not according to precedence rules. +Furthermore, numbers in the equations cannot be rearranged. +Glancing into the jungle, you can see elephants holding two different types of operators: +add (+) and multiply (*). + +Only three of the above equations can be made true by inserting operators: + + 190: 10 19 has only one position that accepts an operator: + between 10 and 19. + Choosing + would give 29, + but choosing * would give the test value (10 * 19 = 190). + + 3267: 81 40 27 has two positions for operators. + + Of the four possible configurations of the operators, two cause the right side to match the test value: + 81 + 40 * 27 and 81 * 40 + 27 both equal 3267 (when evaluated left-to-right)! + + 292: 11 6 16 20 can be solved in exactly one way: 11 + 6 * 16 + 20. + +The engineers just need the total calibration result, which is the sum of the test values from just the equations that could possibly be true. +In the above example, the sum of the test values for the three equations listed above is 3749. + +Determine which equations could possibly be true. What is their total calibration result? + + +