From 07d49a707ba77b008875b93fabbfb36be1afb9fa Mon Sep 17 00:00:00 2001 From: Stefan Harmuth Date: Wed, 16 Dec 2020 06:51:06 +0100 Subject: [PATCH] day16 - raw version --- day16.py | 117 +++++++++++++++++++++ inputs/16 | 269 +++++++++++++++++++++++++++++++++++++++++++++++++ inputs/16_test | 12 +++ 3 files changed, 398 insertions(+) create mode 100644 day16.py create mode 100644 inputs/16 create mode 100644 inputs/16_test diff --git a/day16.py b/day16.py new file mode 100644 index 0000000..3ddcf8a --- /dev/null +++ b/day16.py @@ -0,0 +1,117 @@ +import aoclib + +DAY = 16 +TEST_SOLUTION_PART1 = 71 +TEST_SOLUTION_PART2 = 7 + + +def part1(test_mode=False): + my_input = aoclib.getInputAsArray(day=DAY, test=test_mode) + + restraints = {} + other_tickets = [] + + for i, line in enumerate(my_input): + if not line: + other_tickets = my_input[i+5:] + break + + field, limits = line.split(": ") + limit_low, limit_hi = limits.split(" or ") + min_low, max_low = limit_low.split("-") + min_hi, max_hi = limit_hi.split("-") + restraints[field] = [(int(min_low), int(max_low)), (int(min_hi), int(max_hi))] + + invalid_numbers = [] + for ticket in other_tickets: + for number in ticket.split(","): + valid = False + number = int(number) + for field in restraints: + if restraints[field][0][0] <= number <= restraints[field][0][1] or \ + restraints[field][1][0] <= number <= restraints[field][1][1]: + valid = True + + break + + if not valid: + invalid_numbers.append(number) + + return sum(invalid_numbers) + + +def part2(test_mode=False): + my_input = aoclib.getInputAsArray(day=DAY, test=test_mode) + + restraints = {} + possible_positions = {} + my_ticket = '' + other_tickets = [] + + for i, line in enumerate(my_input): + if not line: + my_ticket = my_input[i+2] + other_tickets = my_input[i+5:] + break + + field, limits = line.split(": ") + limit_low, limit_hi = limits.split(" or ") + min_low, max_low = limit_low.split("-") + min_hi, max_hi = limit_hi.split("-") + restraints[field] = [(int(min_low), int(max_low)), (int(min_hi), int(max_hi))] + + num_fields = len(my_ticket.split(',')) + for field in restraints: + possible_positions[field] = [x for x in range(num_fields)] + + for ticket in other_tickets: + invalid = False + for position, number in enumerate(ticket.split(",")): + valid = False + number = int(number) + for field in restraints: + if restraints[field][0][0] <= number <= restraints[field][0][1] or \ + restraints[field][1][0] <= number <= restraints[field][1][1]: + valid = True + + break + + if not valid: + invalid = True + break + + if invalid: + continue + + for position, number in enumerate(ticket.split(",")): + number = int(number) + for field in restraints: + if not restraints[field][0][0] <= number <= restraints[field][0][1] and \ + not restraints[field][1][0] <= number <= restraints[field][1][1]: + possible_positions[field].remove(position) + + single_possibilities = [] + while 1: + all_done = True + for field, possibilities in possible_positions.items(): + possible_position = possibilities[0] + if len(possibilities) == 1 and possible_position not in single_possibilities: + all_done = False + single_possibilities.append(possible_position) + for check_field in possible_positions: + try: + if len(possible_positions[check_field]) > 1: + possible_positions[check_field].remove(possible_position) + except ValueError: + pass + + if all_done: + break + + answer = 1 + my_ticket = [int(x) for x in my_ticket.split(",")] + for field in restraints: + if field.startswith('departure'): + answer *= my_ticket[possible_positions[field][0]] + + return answer diff --git a/inputs/16 b/inputs/16 new file mode 100644 index 0000000..8045d6c --- /dev/null +++ b/inputs/16 @@ -0,0 +1,269 @@ +departure location: 34-269 or 286-964 +departure station: 27-584 or 609-973 +departure platform: 49-135 or 155-974 +departure track: 36-248 or 255-954 +departure date: 50-373 or 381-974 +departure time: 49-454 or 472-967 +arrival location: 33-900 or 925-968 +arrival station: 46-699 or 706-965 +arrival platform: 42-656 or 666-967 +arrival track: 49-408 or 425-950 +class: 30-626 or 651-957 +duration: 43-109 or 127-964 +price: 33-778 or 795-952 +route: 37-296 or 315-966 +row: 28-318 or 342-965 +seat: 33-189 or 208-959 +train: 49-536 or 552-968 +type: 46-749 or 772-949 +wagon: 29-386 or 401-954 +zone: 34-344 or 368-954 + +your ticket: +109,101,79,127,71,59,67,61,173,157,163,103,83,97,73,167,53,107,89,131 + +nearby tickets: +994,873,258,172,884,554,258,712,264,183,728,255,824,54,740,838,614,850,881,873 +578,886,393,79,104,441,483,870,382,104,853,561,403,863,731,406,839,289,625,890 +821,426,58,846,679,272,570,554,942,290,62,73,267,171,682,135,675,369,51,869 +859,675,305,933,516,772,446,734,157,79,384,294,811,451,691,653,942,315,211,209 +809,239,252,404,567,517,169,72,871,159,670,402,845,87,836,709,937,172,373,524 +568,50,286,817,487,369,393,935,266,438,652,722,499,722,487,161,850,624,529,264 +933,928,896,868,104,224,264,427,179,528,890,244,853,300,708,509,76,610,620,127 +64,875,851,697,515,751,257,286,165,738,104,520,895,63,495,833,71,824,799,291 +233,492,210,816,241,405,54,536,726,729,847,62,676,50,222,188,748,287,769,401 +748,442,64,888,246,928,107,690,403,581,946,530,483,835,699,527,565,946,510,4 +723,512,165,694,571,228,747,937,526,287,938,369,182,497,74,613,827,535,5,238 +402,442,505,697,610,684,862,777,931,509,233,189,946,581,498,181,994,851,532,519 +558,857,581,733,738,128,492,845,344,927,175,232,925,431,490,772,553,475,149,895 +474,92,296,530,518,712,189,294,670,508,586,87,687,579,71,812,433,370,557,130 +574,748,777,651,777,140,161,799,673,801,90,684,857,733,78,722,897,515,236,293 +260,93,941,884,690,81,492,556,377,864,621,690,494,523,676,189,891,803,687,609 +12,653,778,800,848,521,625,94,817,510,128,891,259,799,682,707,453,161,187,707 +625,68,992,561,581,478,255,679,732,228,857,169,288,228,162,865,856,68,684,855 +492,446,844,562,709,830,75,570,561,402,656,406,721,836,810,9,563,682,402,668 +778,942,569,369,289,488,726,565,854,832,946,494,884,576,169,820,280,949,612,559 +371,106,434,866,683,222,895,174,730,60,184,100,866,158,846,820,428,231,438,544 +721,676,516,180,561,401,383,90,224,682,186,744,554,293,69,487,382,240,539,493 +541,50,893,743,616,692,472,220,373,804,445,845,534,851,491,216,806,799,90,840 +155,880,613,524,134,624,222,209,277,808,448,267,498,264,880,942,874,716,840,77 +851,109,488,156,55,371,801,453,569,179,449,894,842,518,301,580,733,685,821,260 +230,672,94,89,890,592,743,384,315,157,127,737,133,895,267,187,614,109,91,575 +440,674,386,876,238,486,296,258,683,814,572,220,134,920,707,449,944,132,842,425 +898,99,472,505,932,941,823,863,855,183,895,679,479,566,942,138,163,425,56,840 +834,740,620,810,688,558,744,614,940,474,64,510,386,537,427,874,234,500,858,234 +227,404,184,560,489,669,481,797,607,742,797,90,621,74,490,526,453,318,384,156 +685,861,741,487,886,701,568,507,552,536,318,236,531,695,170,170,833,97,220,449 +80,809,835,105,873,95,65,230,662,578,520,51,578,373,296,798,369,565,886,797 +833,434,169,612,450,513,514,838,857,694,927,425,535,870,809,293,399,215,401,247 +682,437,667,442,80,427,880,723,308,77,925,228,218,714,862,534,881,187,900,749 +848,776,526,214,580,735,365,69,174,482,553,215,511,480,679,452,885,690,692,100 +445,852,371,707,406,860,830,405,295,928,446,611,501,820,775,313,859,228,257,493 +613,729,839,239,343,832,71,617,687,714,463,443,342,381,61,97,181,613,725,52 +269,554,296,872,509,487,55,510,773,686,93,55,678,406,17,208,569,220,845,225 +517,932,69,871,571,170,201,530,652,72,936,486,261,79,825,214,862,244,130,872 +93,185,475,452,231,451,58,666,134,500,74,101,680,523,530,470,246,696,883,928 +464,839,343,492,699,187,576,132,104,166,248,576,816,100,710,65,531,553,290,699 +933,216,69,168,104,720,544,286,71,879,712,263,521,472,939,800,519,266,804,535 +517,108,7,76,344,535,506,864,836,256,451,428,224,813,674,499,558,745,490,581 +711,526,812,478,831,64,815,218,99,843,623,88,946,860,52,439,945,850,853,136 +741,80,736,93,626,83,875,939,295,51,517,844,832,900,450,85,24,98,248,733 +90,132,513,795,895,310,135,373,480,840,892,678,497,288,217,895,447,695,706,743 +181,230,748,939,553,104,558,61,869,507,746,944,58,155,611,861,309,889,532,243 +504,858,127,676,256,719,868,175,246,842,854,527,304,626,729,224,243,133,839,68 +248,211,562,720,155,365,485,836,218,671,620,245,55,168,871,482,234,674,698,748 +562,438,293,163,474,392,215,943,181,851,929,240,799,221,742,264,815,231,433,101 +809,799,515,744,176,262,188,527,830,695,516,823,617,805,778,213,567,426,224,307 +311,76,834,440,684,525,85,368,707,822,408,169,487,266,77,841,711,820,694,776 +78,438,368,713,540,344,159,79,430,238,316,684,263,502,831,188,681,818,576,172 +872,99,53,109,729,65,612,728,165,442,609,91,64,426,505,184,475,825,22,238 +626,491,527,592,342,158,560,433,583,883,774,440,651,935,64,81,163,580,825,225 +578,617,811,862,428,558,583,217,84,795,343,243,96,24,81,746,210,260,266,682 +731,66,381,132,53,982,673,861,670,162,484,135,745,816,246,109,891,681,806,925 +400,504,831,87,774,884,436,573,172,483,825,290,728,932,736,52,440,179,555,943 +870,159,505,165,365,732,71,76,853,480,873,870,676,683,947,669,678,744,266,78 +815,530,217,138,189,534,733,560,451,666,844,672,682,569,506,830,724,215,777,238 +293,799,926,622,258,623,828,655,858,828,444,218,688,199,476,450,488,938,818,509 +371,802,691,521,897,887,777,900,555,569,991,937,563,943,235,155,614,864,777,219 +202,776,107,865,181,526,816,829,343,517,186,170,130,172,175,931,651,798,103,258 +836,481,260,928,562,521,677,178,652,863,849,258,711,789,697,850,852,847,696,74 +512,472,351,441,527,798,318,811,739,881,932,801,480,733,88,439,55,711,264,94 +451,805,746,498,534,503,574,653,387,226,873,75,837,718,64,858,818,739,558,927 +893,535,199,580,522,801,97,268,402,773,76,679,738,716,486,129,526,244,886,496 +368,989,296,294,440,105,796,804,670,210,714,745,881,407,58,730,183,287,231,236 +834,832,935,296,132,805,127,583,93,408,780,69,776,833,129,897,688,267,948,736 +745,940,316,507,936,376,135,481,623,484,70,673,776,720,161,219,810,655,502,175 +177,447,724,508,882,67,625,775,495,99,359,684,100,454,96,515,59,133,343,936 +811,891,477,526,696,239,652,481,435,434,890,529,344,230,237,682,249,573,932,386 +556,561,438,699,687,723,267,896,315,135,193,164,476,624,185,927,565,726,266,622 +691,300,947,370,896,948,850,856,180,808,748,689,707,451,828,890,873,931,487,473 +255,681,134,540,219,288,163,667,426,218,175,489,618,799,897,734,699,894,845,568 +167,88,66,670,865,724,76,803,776,371,97,825,514,706,690,690,261,68,276,435 +52,479,740,107,693,184,383,109,169,877,84,446,363,96,575,801,100,683,158,226 +481,560,694,841,828,677,296,225,426,682,445,65,556,473,947,664,940,446,214,683 +229,66,821,577,472,833,84,289,371,805,226,523,773,946,616,501,720,286,159,206 +454,470,96,517,228,697,53,672,877,240,557,875,454,383,844,53,406,232,499,172 +452,294,875,720,406,879,554,799,949,671,288,686,194,402,556,529,725,497,99,872 +442,476,93,946,611,795,405,565,672,155,823,728,866,618,262,830,946,54,904,866 +425,184,438,490,797,744,131,104,458,435,885,428,385,478,476,940,431,744,692,163 +613,861,501,830,718,544,479,879,675,167,839,526,739,407,63,795,481,221,574,434 +694,819,667,261,160,670,827,776,540,812,933,652,481,939,318,181,673,713,878,530 +448,808,894,217,926,176,226,574,979,946,927,265,626,515,872,492,667,532,860,686 +613,58,880,358,476,800,173,886,573,430,481,475,899,568,53,565,722,79,850,622 +849,715,614,839,77,491,502,853,23,670,70,729,558,189,248,876,85,721,880,858 +445,655,497,982,860,407,482,738,813,498,947,720,514,226,805,853,428,821,288,171 +59,475,215,881,927,510,454,449,186,799,311,234,486,865,894,943,131,75,618,834 +170,796,485,678,562,428,81,165,856,626,549,508,237,673,819,865,441,105,65,894 +830,926,572,98,213,513,808,102,185,679,804,720,540,221,625,672,820,515,709,85 +734,655,383,287,214,899,138,557,187,406,654,698,403,245,535,827,491,555,57,184 +621,802,926,220,175,851,801,54,61,566,738,490,621,235,149,217,69,531,513,858 +287,514,852,405,693,834,93,479,408,433,806,613,666,150,851,695,722,129,744,819 +58,384,622,342,109,428,747,81,429,513,453,107,172,323,504,928,815,134,343,289 +817,220,155,263,432,863,221,188,189,747,251,618,503,620,621,707,496,801,683,165 +888,802,674,292,132,570,294,222,68,749,55,936,92,532,735,874,106,360,656,865 +515,852,532,489,894,56,225,818,262,134,715,569,209,447,832,856,731,844,182,976 +934,439,539,291,554,858,438,160,435,832,866,735,225,317,838,268,812,899,181,712 +435,487,76,524,828,158,897,185,883,801,815,214,261,77,774,880,826,4,888,83 +935,508,859,370,674,263,623,566,159,263,886,405,883,13,614,886,876,227,293,493 +926,166,837,174,396,869,453,510,449,89,428,484,888,814,510,268,898,224,554,900 +230,79,935,86,946,840,576,611,535,806,798,520,749,131,504,343,540,173,812,450 +942,509,94,378,224,616,925,210,77,796,740,876,65,882,697,91,186,517,840,946 +268,689,772,721,676,609,230,726,775,925,944,216,256,816,866,3,87,841,886,54 +774,521,55,240,210,622,222,318,252,71,106,511,816,257,495,67,229,507,381,437 +990,436,169,246,843,165,294,614,214,692,248,434,735,477,217,56,240,944,706,498 +381,384,92,727,54,75,591,435,505,572,677,91,238,427,887,135,684,687,77,69 +880,384,693,724,696,233,682,612,225,342,720,828,493,642,742,774,874,134,653,614 +821,875,801,710,444,247,797,158,371,556,139,815,839,655,725,478,678,849,528,229 +699,588,70,439,933,525,579,720,726,255,692,480,99,433,841,292,87,926,714,80 +254,185,871,262,871,725,733,239,221,875,86,729,526,815,867,171,563,892,106,778 +942,513,479,408,244,718,709,221,94,500,493,654,217,283,263,747,219,818,67,87 +735,559,256,584,495,561,447,865,815,556,529,89,496,222,384,193,737,492,679,799 +219,371,227,513,475,290,292,172,584,288,233,231,707,820,70,283,899,100,262,289 +58,834,21,863,257,173,472,558,88,869,512,864,85,889,873,431,827,63,731,584 +715,358,811,268,343,865,502,897,296,742,404,54,227,226,494,87,66,94,691,669 +689,743,827,615,734,983,948,133,929,837,518,225,532,845,94,653,619,433,506,80 +376,239,493,714,688,795,486,934,268,494,176,730,851,800,524,316,530,870,428,109 +442,87,672,487,318,796,827,626,101,243,891,558,693,227,83,611,801,80,644,163 +483,893,435,76,838,290,343,696,845,74,237,233,925,851,249,801,681,76,178,733 +63,670,52,735,883,712,474,936,703,511,267,240,499,224,849,161,839,815,74,891 +484,59,620,944,873,106,61,222,477,949,938,318,53,897,618,728,221,86,700,68 +779,174,156,740,687,269,102,946,244,825,514,163,186,810,218,483,228,426,169,521 +56,480,693,874,713,885,572,844,779,623,221,819,245,264,81,691,882,709,242,530 +171,502,509,83,209,157,384,709,809,927,493,747,577,616,381,370,725,717,598,209 +572,197,830,719,133,486,78,178,850,574,687,667,213,502,225,403,446,248,672,223 +497,817,829,900,683,809,881,512,831,53,557,14,672,800,800,739,576,521,431,699 +407,729,222,871,106,294,840,453,55,317,71,476,262,704,212,725,944,436,157,676 +748,869,164,978,494,937,610,618,403,294,180,155,846,401,295,809,519,525,740,894 +281,815,174,830,440,294,248,482,166,680,435,884,651,574,510,517,737,878,610,67 +476,185,773,252,866,774,236,888,746,246,372,746,772,925,71,157,318,820,84,129 +719,572,84,841,626,80,432,692,532,452,584,575,692,614,469,368,161,618,614,709 +853,718,84,842,810,984,844,614,744,263,212,71,91,317,185,691,852,373,372,861 +166,535,810,51,691,495,613,200,425,258,504,937,869,811,225,499,218,937,316,316 +795,430,168,875,490,718,893,775,95,817,677,401,162,679,569,815,205,878,56,949 +371,108,156,560,570,671,509,287,255,72,380,625,60,706,892,671,862,858,177,841 +69,259,522,569,237,776,535,135,430,222,609,50,164,189,404,817,477,196,808,531 +213,484,986,261,694,801,92,698,943,160,445,732,874,860,833,174,162,714,516,837 +687,54,16,440,582,869,372,686,128,59,654,454,96,668,578,99,820,159,79,442 +884,545,155,215,343,475,434,688,50,427,160,698,405,56,742,435,838,220,257,102 +480,777,890,450,209,864,82,669,845,873,490,898,62,465,830,506,721,211,699,231 +880,492,428,814,720,553,183,491,518,873,493,83,563,513,593,680,859,527,447,836 +104,928,72,859,73,569,655,694,898,65,617,260,930,24,180,893,748,693,716,733 +920,621,269,838,737,82,870,109,385,478,576,855,65,489,680,50,131,401,940,105 +710,798,402,55,289,948,212,555,628,89,472,189,57,475,681,535,835,533,181,242 +820,95,710,370,691,486,932,442,315,864,385,86,943,849,543,441,656,446,441,575 +80,88,698,725,867,536,87,570,894,882,798,169,670,4,826,158,863,725,66,624 +713,479,737,276,843,882,255,98,739,773,870,256,820,106,88,499,62,571,223,862 +159,655,214,520,949,623,67,229,939,431,514,155,52,756,747,179,450,536,675,570 +483,731,155,210,860,135,872,625,288,944,24,499,232,523,429,385,567,837,184,584 +796,82,844,879,898,625,669,688,615,799,71,485,267,740,351,520,159,427,445,241 +673,343,678,743,835,660,449,558,60,624,736,777,95,815,232,584,109,386,531,723 +439,226,797,773,238,940,101,622,573,669,88,818,171,70,572,542,76,732,523,898 +108,799,616,109,155,486,681,405,190,96,561,890,575,861,806,731,58,255,435,172 +184,837,408,507,838,206,131,536,449,499,859,845,718,679,574,851,579,316,695,248 +289,882,57,824,937,441,719,708,796,432,432,529,478,23,242,495,174,370,900,489 +832,380,851,834,513,500,506,680,74,926,936,925,168,238,265,825,488,817,383,57 +929,855,85,517,487,439,476,876,476,17,68,259,945,726,674,404,498,870,676,797 +453,182,935,854,99,521,810,131,436,809,316,740,70,511,219,449,454,15,495,66 +827,535,804,434,697,681,157,453,286,191,245,817,673,55,494,721,679,738,292,933 +655,860,865,52,862,822,773,561,93,930,52,170,554,377,404,88,491,316,942,532 +927,832,88,513,623,440,887,556,503,848,675,505,17,861,525,686,218,799,296,233 +832,828,494,316,653,86,519,185,756,555,263,729,288,403,736,88,882,798,531,876 +827,900,892,527,453,264,259,573,115,797,247,888,712,668,777,174,79,533,505,481 +796,523,807,813,406,611,83,292,96,718,106,478,811,699,163,700,408,68,383,74 +529,220,929,508,452,572,834,403,291,453,841,832,93,429,514,609,459,739,778,177 +559,262,182,842,222,699,863,521,620,67,828,131,801,738,173,84,217,289,793,574 +133,558,800,666,10,722,842,690,616,231,491,85,925,317,679,260,101,718,727,240 +881,316,707,213,625,522,577,262,896,694,826,232,864,263,511,441,343,564,431,363 +95,668,536,579,616,744,817,128,576,732,725,473,476,734,395,495,84,472,822,407 +91,169,454,235,101,924,521,561,747,508,213,428,518,583,291,287,510,491,936,368 +242,59,877,440,448,489,868,678,262,445,565,899,724,73,442,588,178,248,720,842 +993,838,609,813,555,867,558,572,743,174,483,855,933,98,240,178,797,738,255,258 +748,947,408,714,797,854,486,82,448,369,57,166,778,697,269,883,569,9,437,238 +673,819,563,775,82,864,310,438,747,617,401,481,583,294,688,268,487,472,239,208 +175,130,557,738,157,683,947,690,491,583,234,406,709,227,940,250,683,892,72,695 +710,723,53,582,195,811,175,621,472,482,848,565,67,264,860,499,186,437,529,518 +493,744,817,847,561,515,53,824,182,246,896,656,178,344,999,838,106,773,940,247 +476,861,866,499,684,843,812,262,15,733,625,129,888,795,176,221,234,895,944,847 +490,900,183,558,237,296,381,938,217,862,257,900,473,694,777,520,316,488,661,186 +427,699,561,879,875,465,536,859,857,532,450,479,877,576,441,492,71,796,870,83 +705,514,856,406,242,176,441,555,293,739,808,220,233,745,370,722,229,233,453,493 +893,610,858,433,930,713,260,525,830,386,565,559,826,431,177,244,720,833,561,251 +224,408,614,91,583,179,404,932,167,727,817,741,821,862,728,241,482,868,309,742 +719,178,866,503,385,77,174,358,626,442,689,535,931,731,514,840,896,406,721,730 +845,390,59,54,129,814,402,372,882,713,488,673,496,74,431,77,669,805,265,71 +690,742,244,127,81,132,562,624,264,402,169,444,425,123,554,812,55,566,885,749 +658,796,493,620,512,262,290,715,229,481,444,451,892,560,932,708,532,845,78,51 +847,937,478,846,795,862,495,298,317,454,473,776,893,179,101,235,810,558,243,827 +690,219,696,695,580,745,473,573,370,932,506,814,687,224,888,862,572,258,376,942 +866,743,225,264,832,791,368,61,866,74,654,50,242,170,655,556,814,442,842,431 +508,64,815,555,893,268,574,859,263,818,562,616,16,488,259,53,826,615,218,212 +562,872,79,557,738,174,692,75,479,315,12,80,866,239,514,613,797,864,624,575 +528,425,234,370,886,102,683,896,496,81,886,576,831,474,527,739,240,489,198,857 +502,556,130,652,218,251,847,217,619,802,876,219,184,895,405,245,286,529,530,213 +841,435,724,811,823,850,868,860,452,559,273,373,581,429,510,609,609,817,227,296 +92,65,900,615,666,859,706,440,882,715,182,744,697,397,616,522,885,692,368,655 +241,431,436,803,96,710,254,180,583,935,239,96,894,211,371,244,678,775,134,807 +384,623,848,745,565,617,858,515,824,488,494,798,553,578,800,222,366,225,569,858 +495,524,102,619,426,899,452,235,558,493,531,61,691,165,735,216,989,946,945,342 +828,246,857,882,526,100,680,584,622,485,370,625,93,887,867,394,242,477,795,552 +884,223,386,405,180,656,706,178,181,453,619,854,890,979,870,94,858,854,220,936 +228,145,516,487,578,946,383,945,171,485,383,939,134,73,258,230,896,898,504,439 +615,505,228,710,287,50,723,693,144,576,772,718,296,62,437,225,158,725,512,553 +498,439,569,428,313,264,492,719,946,449,85,654,774,432,292,815,181,727,574,432 +847,238,741,491,610,439,242,535,798,225,882,884,836,838,261,296,889,722,391,480 +264,262,269,498,21,834,809,743,613,671,867,73,444,489,610,370,494,494,933,656 +676,233,940,742,526,565,210,128,75,495,893,504,873,175,935,794,529,929,106,941 +152,572,899,746,175,524,574,220,821,212,796,243,164,286,58,436,434,818,83,892 +835,892,806,574,928,568,880,497,408,169,554,841,983,712,294,262,73,695,667,100 +524,613,554,894,682,684,0,509,240,573,220,159,493,84,77,725,575,656,433,487 +709,425,531,932,715,130,843,226,491,318,552,434,825,524,163,378,474,574,264,554 +426,707,171,535,431,882,653,984,497,513,866,862,671,290,487,291,224,813,652,845 +229,858,673,196,897,501,494,851,806,654,718,566,498,730,480,268,60,611,258,243 +943,619,62,164,259,869,57,502,128,577,430,739,228,802,207,287,797,570,63,726 +694,699,134,162,452,852,724,876,672,73,890,485,161,250,295,676,949,64,407,560 +54,77,567,163,875,238,747,78,363,173,492,52,889,568,936,572,695,714,289,667 +899,560,889,839,824,82,862,181,217,805,801,609,234,712,129,211,139,949,499,698 +343,555,496,846,535,218,503,941,845,55,710,406,826,884,523,819,938,83,468,224 +229,875,823,458,315,716,620,857,370,823,814,882,474,87,485,926,223,498,693,775 +569,289,535,624,100,577,826,447,478,652,226,408,527,555,828,293,656,740,344,392 +351,574,622,97,290,555,168,490,946,678,796,209,450,716,938,577,258,614,690,617 +99,934,131,559,71,610,883,370,616,480,823,509,318,157,87,348,94,434,434,474 +480,291,740,798,823,871,475,431,211,441,71,494,975,711,269,446,713,435,480,91 +508,882,182,818,568,436,263,559,342,854,511,883,498,95,208,103,380,67,722,155 +441,883,267,941,564,626,86,884,107,825,926,722,726,83,819,558,512,232,359,68 +616,803,262,405,486,156,679,227,822,429,890,226,369,658,241,798,108,78,507,524 +222,407,425,893,552,933,484,216,435,890,244,926,441,715,54,833,940,989,574,295 +854,729,93,434,741,503,61,556,747,515,747,219,798,926,58,383,626,70,249,95 +583,517,890,860,622,60,832,502,510,288,395,318,778,383,381,247,506,429,583,749 +453,575,713,388,938,181,866,940,428,850,439,373,156,77,68,234,61,342,609,159 +869,869,83,819,672,570,530,802,481,668,566,89,56,16,612,104,129,723,68,481 +589,162,536,832,243,504,687,433,707,161,838,679,820,105,778,295,234,530,74,526 +131,692,736,305,523,818,444,269,157,689,563,674,715,532,234,404,454,536,239,774 +446,810,445,81,707,692,552,174,717,94,705,87,186,225,515,214,63,525,161,795 +208,440,158,931,682,810,514,89,407,613,50,710,614,600,718,441,189,498,495,501 +515,829,286,674,238,653,168,109,902,816,318,342,699,224,879,713,262,442,807,513 +928,825,774,846,616,179,224,105,182,316,692,257,844,357,247,174,843,215,584,88 +799,104,772,824,990,868,220,490,693,96,263,576,449,514,810,851,187,666,75,451 +79,70,53,710,552,579,514,179,80,689,584,717,852,949,580,501,606,64,243,566 +846,177,944,58,696,654,51,453,244,740,286,882,96,835,513,439,705,179,777,810 +71,250,796,133,433,317,291,818,268,898,239,478,231,738,215,677,869,655,875,609 diff --git a/inputs/16_test b/inputs/16_test new file mode 100644 index 0000000..2b185dc --- /dev/null +++ b/inputs/16_test @@ -0,0 +1,12 @@ +departure class: 1-3 or 5-7 +departure row: 6-11 or 33-44 +seat: 13-40 or 45-50 + +your ticket: +7,1,14 + +nearby tickets: +7,3,47 +40,4,50 +55,2,20 +38,6,12