From 120d53c0ff20574866ce10fa0538fb8b0dd2ef82 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Thu, 23 Jun 2022 19:06:22 +0100 Subject: Reorganize repository structure --- 2021/day19/Cargo.toml | 9 + 2021/day19/resources/input.txt | 1077 ++++++++++++++++++++++++++++++++++++++++ 2021/day19/src/main.rs | 81 +++ 3 files changed, 1167 insertions(+) create mode 100644 2021/day19/Cargo.toml create mode 100644 2021/day19/resources/input.txt create mode 100644 2021/day19/src/main.rs (limited to '2021/day19') diff --git a/2021/day19/Cargo.toml b/2021/day19/Cargo.toml new file mode 100644 index 0000000..99f3973 --- /dev/null +++ b/2021/day19/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "day19" +version = "0.1.0" +authors = ["Federico Igne "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/2021/day19/resources/input.txt b/2021/day19/resources/input.txt new file mode 100644 index 0000000..18c1ef0 --- /dev/null +++ b/2021/day19/resources/input.txt @@ -0,0 +1,1077 @@ +--- scanner 0 --- +399,875,-662 +753,395,664 +680,495,564 +594,-277,-533 +46,112,-74 +-892,420,-821 +-591,-687,785 +477,-314,-569 +-545,-417,-790 +549,-387,-545 +-447,529,711 +-448,685,834 +-503,-360,-660 +-595,-725,719 +-877,498,-821 +-528,-591,-682 +434,-468,486 +557,782,-667 +402,781,-788 +431,-244,463 +747,523,550 +-118,2,-15 +-915,442,-682 +-585,-610,573 +-345,578,816 +502,-391,531 + +--- scanner 1 --- +392,527,824 +657,-410,-602 +688,-924,932 +-429,507,-669 +-649,-751,732 +-741,-490,-576 +542,412,-607 +347,444,932 +-394,460,-639 +-430,691,684 +-498,637,795 +-690,-871,652 +-61,-165,46 +607,492,-714 +681,-507,-443 +603,385,-536 +-931,-417,-550 +694,-610,-584 +-909,-489,-563 +-770,-748,690 +694,-942,693 +323,558,787 +733,-981,887 +-436,500,-469 +-599,614,708 + +--- scanner 2 --- +-686,308,577 +450,-433,645 +578,632,-500 +423,-483,643 +-431,-500,-903 +42,18,-9 +-582,369,568 +319,-580,-380 +-815,-786,335 +-448,-700,-828 +780,606,-474 +-866,731,-607 +-639,388,439 +500,801,720 +563,658,786 +566,-389,584 +-482,-566,-882 +-671,-716,270 +708,603,-616 +-89,-138,-78 +-871,770,-611 +-923,561,-636 +530,769,784 +305,-445,-427 +378,-487,-404 +-626,-770,309 + +--- scanner 3 --- +59,4,-15 +787,497,408 +-690,-696,-463 +593,-839,-744 +-632,260,781 +449,787,-776 +-605,-781,-377 +789,-924,372 +78,-175,115 +843,445,473 +625,-902,-612 +663,749,-802 +779,-975,352 +740,-927,440 +-422,512,-600 +-476,-750,680 +-639,329,630 +-510,298,655 +-718,-728,-375 +819,410,462 +-499,499,-601 +-445,552,-507 +-319,-751,739 +515,-814,-558 +535,714,-848 +-428,-701,603 + +--- scanner 4 --- +-780,-611,458 +-683,655,-491 +399,778,333 +-759,749,-451 +-169,107,81 +402,-271,574 +403,-291,763 +321,-360,684 +294,725,-801 +-463,-445,-509 +-780,-557,570 +484,664,302 +-840,623,-390 +-20,-35,61 +236,-476,-443 +-537,674,538 +273,-445,-455 +437,661,-887 +306,-604,-443 +-447,-492,-570 +-566,-467,-510 +448,757,-817 +-47,86,-112 +-487,439,543 +-728,-642,530 +588,779,318 +-438,523,511 + +--- scanner 5 --- +595,-680,-533 +-771,659,-668 +485,489,528 +650,-693,625 +729,-756,526 +613,361,570 +657,444,-727 +726,576,-711 +525,-681,-723 +471,296,547 +-643,-792,540 +-866,-618,-839 +-761,-684,-819 +-708,600,-776 +-608,296,614 +-553,-707,529 +524,-598,-622 +-690,369,502 +-920,681,-776 +-707,-713,504 +-569,427,580 +-50,-89,104 +664,464,-721 +-701,-670,-845 +706,-723,578 +37,47,-9 + +--- scanner 6 --- +257,748,-351 +522,-494,-391 +488,-564,796 +483,739,-387 +-979,586,795 +-516,482,-644 +-525,-796,-274 +-403,542,-596 +-949,596,730 +-525,566,-518 +438,-428,905 +-604,-663,-283 +-17,32,140 +388,600,705 +-771,-833,527 +431,759,-316 +-866,-836,660 +-684,-796,686 +491,680,634 +-974,453,822 +503,-265,-410 +517,531,690 +477,-296,-344 +-466,-601,-299 +-173,131,33 +439,-487,748 + +--- scanner 7 --- +481,-579,-648 +-700,-485,-521 +19,-96,-73 +552,-668,-566 +419,-773,476 +370,532,-691 +350,-757,608 +-71,45,8 +-911,-718,642 +-464,487,427 +412,-767,496 +-637,-559,-445 +426,579,-661 +-622,602,-423 +-389,470,403 +605,501,328 +-619,744,-351 +-516,-589,-510 +463,524,393 +347,480,-724 +-593,718,-553 +591,482,521 +-924,-739,610 +-503,496,488 +551,-769,-649 +-920,-500,637 + +--- scanner 8 --- +-736,-377,560 +482,-439,692 +-670,-280,518 +-733,948,-468 +506,-680,-519 +357,585,707 +492,779,-394 +-693,906,-638 +-670,-403,465 +493,764,-344 +343,672,898 +289,656,780 +-715,705,399 +-726,881,511 +-835,-423,-684 +-686,913,-438 +-746,-442,-543 +494,-645,740 +-603,775,505 +452,-506,762 +397,-697,-389 +-159,45,-18 +397,829,-276 +-797,-409,-641 +18,158,13 +514,-589,-382 + +--- scanner 9 --- +550,650,-263 +844,-575,-415 +828,433,919 +-308,-812,-772 +598,629,-362 +-397,-511,810 +-607,620,562 +-629,621,459 +516,-789,770 +852,-391,-430 +-470,687,-310 +859,-440,-399 +-236,-845,-707 +-325,-794,-819 +-629,675,-277 +828,425,893 +-582,560,443 +-423,-475,843 +95,-141,64 +-508,-412,885 +472,-860,847 +530,547,-342 +455,-682,894 +-598,687,-240 +841,263,830 + +--- scanner 10 --- +-697,-612,-546 +-685,550,722 +694,-955,-427 +395,609,380 +546,582,479 +690,-874,-455 +1,4,-10 +356,-799,566 +-488,436,-379 +311,-883,605 +-739,662,722 +-639,-522,-409 +-770,590,670 +-678,-600,706 +-399,546,-460 +-161,-67,60 +-580,-549,739 +382,-763,651 +-773,-530,-418 +651,802,-646 +311,577,429 +536,818,-542 +-419,357,-461 +767,-949,-426 +-537,-511,725 +650,787,-457 + +--- scanner 11 --- +763,-861,526 +516,720,-594 +697,-681,541 +-779,-476,-432 +-423,476,623 +-609,-487,485 +439,-614,-500 +-539,505,753 +863,450,608 +-661,-464,452 +-562,-543,515 +-39,5,81 +-559,547,-878 +-397,502,825 +481,-673,-374 +533,-679,-477 +654,800,-641 +-735,-553,-503 +645,739,-537 +-796,-429,-610 +-534,338,-826 +96,-54,-57 +861,339,575 +687,-782,446 +-530,377,-821 +797,307,545 + +--- scanner 12 --- +-26,-46,-90 +606,397,-734 +-568,-538,-731 +671,530,746 +670,552,643 +689,-570,526 +-425,736,362 +-820,732,-910 +-557,-313,340 +-362,651,320 +652,437,-835 +790,-538,369 +565,-389,-762 +640,-377,-618 +729,-664,450 +-696,-393,352 +694,525,-731 +-650,-446,-775 +-570,-296,405 +-744,520,-915 +610,577,762 +-728,-468,-728 +-802,637,-813 +-461,762,395 +652,-338,-812 + +--- scanner 13 --- +-726,-330,-603 +-552,710,550 +363,702,766 +-799,-230,-503 +-480,633,-681 +630,-771,593 +-586,-310,386 +-619,-421,384 +539,775,-594 +-477,409,-704 +402,-520,-333 +33,96,126 +-793,-358,-617 +-548,556,-636 +-80,176,-5 +401,-364,-456 +-556,-278,450 +545,852,-382 +583,-691,731 +466,708,714 +299,-413,-351 +526,-710,602 +489,643,808 +-457,811,560 +549,890,-448 +-537,890,484 + +--- scanner 14 --- +707,-327,788 +-633,622,700 +371,642,677 +-642,396,736 +-436,-264,491 +-427,521,-432 +600,661,696 +902,-386,813 +-376,-377,443 +769,-465,804 +769,784,-733 +-381,-581,-498 +25,43,-59 +-394,622,-345 +622,-515,-447 +-321,-517,-509 +-653,570,771 +402,616,743 +647,-494,-436 +804,631,-790 +635,-294,-432 +-390,429,-387 +-460,-386,569 +892,758,-870 +-436,-524,-529 + +--- scanner 15 --- +787,-485,-707 +-431,-623,-639 +-436,-723,662 +803,424,496 +431,-439,578 +743,-562,-636 +804,-438,-529 +-577,-695,658 +80,-68,-14 +-525,-626,582 +538,368,-318 +-473,-682,-765 +-637,730,-602 +788,434,409 +-71,31,91 +721,409,517 +431,-413,586 +-525,-688,-662 +-508,711,-545 +-670,835,844 +-859,784,815 +-646,791,-498 +542,329,-313 +-751,825,827 +567,538,-261 +418,-502,416 + +--- scanner 16 --- +434,685,-709 +-543,743,458 +-406,550,-387 +284,764,-689 +766,419,655 +-654,797,390 +545,434,668 +389,-574,-796 +-172,-57,71 +674,-826,388 +-606,-645,609 +-451,-875,-773 +433,-409,-774 +-686,-765,650 +-648,-642,730 +-406,-818,-728 +-551,664,-363 +733,-801,583 +-52,34,-29 +-630,720,559 +-645,-836,-734 +312,712,-699 +566,423,643 +-514,633,-432 +595,-817,521 +504,-553,-760 + +--- scanner 17 --- +561,642,711 +24,55,-70 +612,-586,330 +-709,-594,466 +371,616,784 +-466,637,498 +775,-343,-600 +694,520,-558 +-808,-443,439 +581,-382,-612 +-783,525,-581 +-406,-543,-462 +-799,572,-642 +697,392,-646 +725,-394,-687 +798,432,-600 +393,629,712 +-680,547,-582 +532,-624,453 +-759,-359,471 +-466,691,386 +653,-666,450 +-563,-575,-563 +-487,-669,-523 +-518,722,458 + +--- scanner 18 --- +-478,352,553 +465,490,636 +750,333,-516 +-540,-619,458 +-433,-684,538 +-611,-680,431 +-545,-734,-364 +-3,-23,-110 +-508,317,506 +-597,854,-371 +359,560,524 +683,439,-457 +798,-590,-584 +536,-642,450 +530,-493,363 +-571,664,-444 +-584,832,-443 +-678,359,546 +-563,-771,-564 +544,370,-523 +698,-580,-584 +647,-513,-530 +471,384,513 +-704,-758,-461 +579,-460,444 + +--- scanner 19 --- +475,366,-593 +-706,504,-793 +-512,516,-754 +-543,-426,-550 +-845,569,469 +444,731,361 +-805,-365,810 +533,-687,932 +-463,-549,-512 +473,-735,819 +828,-567,-777 +87,-26,24 +-672,-374,731 +557,-609,810 +-842,436,564 +-584,-546,-470 +-805,595,651 +-656,591,-742 +-610,-390,869 +877,-535,-693 +556,427,-467 +587,639,386 +632,467,-561 +778,-562,-542 +577,704,356 + +--- scanner 20 --- +-671,800,635 +429,425,459 +-626,-903,797 +544,-605,-716 +305,532,398 +8,-61,70 +-819,362,-579 +-523,-744,-536 +-600,-701,771 +389,703,-454 +352,354,415 +-501,743,664 +363,-563,585 +545,-688,-615 +-916,344,-484 +474,-606,-526 +-629,-831,655 +-462,748,660 +340,-530,533 +-644,-809,-506 +356,739,-480 +314,802,-565 +419,-593,632 +-707,-733,-432 +-921,420,-696 + +--- scanner 21 --- +-455,460,526 +660,399,-501 +689,456,-331 +506,-379,-372 +-554,837,-649 +424,-358,-387 +-614,-575,926 +796,-448,450 +440,845,522 +-429,496,559 +-459,855,-746 +-666,-659,-567 +484,774,599 +-639,-635,807 +796,-440,476 +-671,779,-751 +439,-271,-397 +119,23,83 +-754,-617,-671 +423,667,475 +-661,-636,910 +809,-278,539 +685,451,-292 +-540,397,484 +-794,-571,-570 + +--- scanner 22 --- +-361,-413,777 +790,-525,-788 +298,925,854 +-534,486,-600 +531,728,-649 +-522,447,-406 +-480,-416,-487 +355,970,809 +-522,-328,-383 +862,-512,-810 +408,690,-569 +-504,-487,858 +-797,819,688 +-886,771,761 +669,-546,815 +337,731,815 +19,171,101 +789,-538,-620 +-568,-288,-484 +772,-405,802 +528,770,-528 +869,-564,778 +-842,699,655 +-74,-7,-16 +-609,498,-456 +-472,-496,788 + +--- scanner 23 --- +-454,701,342 +-634,-749,-710 +-782,-709,-630 +925,-437,-648 +785,-348,642 +-245,560,-580 +874,467,-544 +-528,-802,662 +-656,-684,-563 +508,475,663 +447,601,744 +-276,446,-495 +720,-378,632 +-261,445,-684 +812,-353,775 +944,563,-533 +-20,20,-86 +-486,785,391 +-481,550,441 +548,569,587 +-654,-811,746 +858,499,-390 +907,-437,-649 +126,-129,-94 +826,-420,-828 +-606,-924,686 + +--- scanner 24 --- +-659,-754,752 +-655,-542,-488 +690,-706,-660 +706,-778,702 +444,517,442 +658,525,-417 +-775,-471,-534 +-736,-730,921 +-492,518,-433 +685,-471,-710 +-682,-841,853 +-52,-84,150 +-505,593,957 +-552,623,922 +698,610,-469 +-545,423,915 +770,579,-417 +372,504,420 +-691,-516,-573 +445,530,610 +-403,377,-414 +717,-555,-759 +703,-736,581 +-441,420,-400 +826,-698,661 + +--- scanner 25 --- +-345,-664,-651 +-20,81,120 +709,661,731 +595,-493,-413 +458,-541,871 +549,744,732 +-663,-670,697 +-802,932,659 +109,41,-18 +-562,-575,707 +-589,581,-649 +-765,856,726 +624,-363,-529 +-461,453,-607 +621,-291,-387 +609,681,801 +-424,-601,-552 +-742,-590,773 +569,-508,873 +-603,388,-630 +505,548,-635 +391,463,-661 +-755,735,631 +426,-571,807 +-368,-631,-599 +466,487,-644 + +--- scanner 26 --- +-560,-573,400 +770,530,-498 +804,-795,-393 +-723,-607,492 +363,759,551 +-776,621,689 +454,-616,449 +-709,694,-619 +-9,-79,163 +-891,611,543 +-744,-630,-708 +-703,797,-671 +444,-761,393 +448,-843,498 +412,861,446 +814,-812,-474 +763,-783,-285 +-647,-550,-619 +519,758,428 +-626,-690,430 +690,577,-636 +-111,-11,19 +709,634,-507 +-716,-626,-567 +-644,671,-713 +-853,615,477 + +--- scanner 27 --- +844,492,419 +694,433,-458 +-321,702,-683 +-304,511,387 +-324,582,473 +-375,820,-667 +571,427,-564 +661,-716,-433 +776,-649,606 +-697,-480,232 +749,-578,545 +757,498,568 +-635,-495,409 +763,541,386 +-298,492,619 +85,-54,-108 +701,-546,-391 +-389,629,-754 +-525,-422,-575 +-524,-472,-560 +-695,-503,404 +654,-516,-426 +669,-471,610 +683,321,-634 +-429,-354,-510 + +--- scanner 28 --- +-327,-274,-925 +724,-321,-450 +-462,-227,-911 +879,-578,328 +-478,611,556 +-477,471,698 +-365,796,-807 +-271,737,-664 +-369,-251,-852 +919,873,-730 +776,939,-667 +-592,-464,550 +67,95,-130 +-714,-521,503 +736,867,522 +721,-463,-522 +796,798,585 +636,797,502 +-460,455,596 +-682,-420,444 +840,-569,389 +-315,798,-780 +887,937,-700 +954,-595,304 +750,-347,-652 + +--- scanner 29 --- +-492,-926,634 +471,322,565 +-941,268,570 +-539,-728,679 +358,320,618 +512,-386,-709 +386,408,650 +-695,722,-538 +-839,736,-609 +-558,-957,660 +549,481,-760 +757,-794,595 +433,531,-712 +-674,758,-653 +622,545,-644 +-447,-621,-309 +538,-426,-527 +-56,18,7 +-422,-426,-368 +379,-389,-614 +-796,283,472 +-965,242,436 +-431,-559,-447 +600,-735,596 +648,-658,645 + +--- scanner 30 --- +-340,387,680 +-331,-792,458 +618,-610,718 +547,-626,758 +-272,390,729 +-580,564,-536 +686,-744,-703 +475,586,-778 +844,475,533 +-234,-646,-757 +-503,613,-488 +658,500,455 +700,-676,-514 +-271,-559,-598 +-231,-741,-624 +-350,-634,511 +-639,563,-379 +118,75,-29 +636,-792,-587 +712,412,565 +613,-439,784 +-252,339,719 +477,533,-665 +563,618,-750 +-294,-842,493 + +--- scanner 31 --- +526,-583,906 +-527,672,620 +398,544,-668 +726,566,397 +-450,-864,908 +384,-492,-595 +-622,732,571 +701,554,479 +428,-692,866 +347,-485,-389 +-479,394,-609 +-437,-670,908 +500,581,436 +-499,-499,-492 +64,-103,52 +538,-597,856 +574,555,-780 +-628,481,-603 +-576,-553,-341 +-540,-676,906 +-595,647,746 +453,-426,-456 +-60,39,165 +504,667,-674 +-566,-553,-441 +-446,475,-560 + +--- scanner 32 --- +804,618,-745 +590,-382,762 +108,63,-61 +754,-752,-559 +-292,491,777 +524,-361,813 +-389,586,759 +874,627,-713 +-367,786,-695 +2,-91,45 +-651,-392,-436 +-287,703,701 +793,701,-856 +-746,-653,373 +-666,-474,-457 +724,-436,796 +-537,-628,321 +-707,-657,378 +-471,698,-737 +-468,826,-649 +610,-730,-646 +918,526,684 +739,586,660 +-641,-407,-349 +789,612,756 +649,-675,-519 + +--- scanner 33 --- +-560,-534,561 +817,818,502 +291,-548,280 +-598,692,390 +-446,-718,-479 +537,-423,-361 +315,-567,347 +575,854,-858 +-463,-538,-380 +441,-434,-431 +39,114,-11 +-519,-575,620 +337,-471,298 +-531,-538,570 +449,773,-797 +-125,78,-114 +-404,742,-585 +-463,-539,-398 +-619,801,488 +-642,862,376 +543,697,-757 +800,883,489 +-374,752,-520 +473,-280,-447 +720,871,628 +-379,885,-493 + +--- scanner 34 --- +514,518,798 +-680,390,-794 +402,508,736 +-660,607,596 +-746,410,-689 +742,-747,708 +803,-383,-581 +701,-341,-571 +21,-61,48 +-458,-575,704 +-47,87,-78 +597,561,-699 +-746,-649,-570 +-743,506,597 +-432,-426,668 +-678,-650,-346 +740,-644,602 +619,453,-848 +-732,384,-629 +-703,-677,-456 +-742,696,667 +709,-544,-622 +-486,-530,763 +538,453,-636 +382,502,729 +708,-548,690 + +--- scanner 35 --- +583,509,-553 +645,-350,-879 +-708,366,602 +754,-651,391 +-336,-471,692 +-622,-743,-865 +-43,28,-52 +552,561,-625 +727,723,415 +-418,-456,671 +-381,711,-596 +-351,-481,779 +-483,-812,-799 +637,509,-665 +-451,723,-705 +-708,392,610 +658,-328,-951 +149,-46,11 +-689,-849,-806 +-414,803,-724 +842,-755,433 +702,842,475 +632,-518,-878 +-721,455,772 +882,-654,479 +749,826,414 + +--- scanner 36 --- +-675,-759,-370 +-403,-745,345 +787,823,-753 +-633,545,-651 +500,619,783 +-452,655,710 +772,905,-774 +585,-693,612 +431,758,717 +-528,622,-691 +-519,604,656 +-20,42,14 +394,552,724 +67,190,-100 +-390,-745,539 +-784,-652,-423 +762,890,-861 +-489,567,-564 +475,-703,517 +-752,-663,-335 +-529,504,656 +573,-743,626 +-493,-743,533 +412,-757,-455 +361,-568,-426 +371,-649,-443 + +--- scanner 37 --- +565,-432,540 +501,-492,529 +696,791,-782 +-608,620,764 +-62,-111,-30 +818,-547,-460 +-626,449,-598 +-891,-842,-580 +-521,721,787 +-39,22,116 +588,536,467 +-846,-705,796 +-656,-792,-585 +-820,-620,760 +567,511,478 +788,524,463 +-807,-891,-612 +-891,-666,880 +705,-487,-412 +617,658,-773 +-664,529,-721 +558,-547,560 +-632,789,841 +755,596,-757 +696,-571,-538 +-584,570,-601 + +--- scanner 38 --- +631,-465,425 +-884,434,508 +742,-519,493 +655,-542,594 +734,-598,-328 +-660,-744,-547 +-722,-649,424 +735,505,596 +677,704,577 +-816,530,573 +-767,-664,-612 +-766,529,558 +879,-712,-352 +722,611,451 +-735,700,-406 +631,724,-769 +-758,702,-234 +-23,-32,0 +734,666,-632 +-692,-696,389 +634,598,-681 +771,-629,-397 +-522,-656,431 +-589,-771,-608 +-743,640,-411 diff --git a/2021/day19/src/main.rs b/2021/day19/src/main.rs new file mode 100644 index 0000000..48882d2 --- /dev/null +++ b/2021/day19/src/main.rs @@ -0,0 +1,81 @@ +use std::fs; +use std::path::Path; +use std::collections::HashSet; + +type Point = (i32,i32,i32); +struct Scanner { + beacons: Vec, + diffs: HashSet +} + +fn main() { + let input = Path::new("resources").join("input.txt"); + let content = fs::read_to_string(input).expect("Unable to read from input"); + let scanners: Vec = content.split("\n\n").map(|s| parse_scanner(s)).collect(); + let perms: Vec (i32,i32,i32)>> = vec![ + Box::new(|(x,y,z)| (x,y,z)), + Box::new(|(x,y,z)| (-y,x,z)), + Box::new(|(x,y,z)| (-x,-y,z)), + Box::new(|(x,y,z)| (y,-x,z)), + Box::new(|(x,y,z)| (-x,y,-z)), + Box::new(|(x,y,z)| (y,x,-z)), + Box::new(|(x,y,z)| (x,-y,-z)), + Box::new(|(x,y,z)| (-y,-x,-z)), + Box::new(|(x,y,z)| (-z,y,x)), + Box::new(|(x,y,z)| (-y,-z,x)), + Box::new(|(x,y,z)| (z,-y,x)), + Box::new(|(x,y,z)| (y,z,x)), + Box::new(|(x,y,z)| (z,y,-x)), + Box::new(|(x,y,z)| (y,-z,-x)), + Box::new(|(x,y,z)| (-z,-y,-x)), + Box::new(|(x,y,z)| (-y,z,-x)), + Box::new(|(x,y,z)| (x,-z,y)), + Box::new(|(x,y,z)| (z,x,y)), + Box::new(|(x,y,z)| (-x,z,y)), + Box::new(|(x,y,z)| (-z,-x,y)), + Box::new(|(x,y,z)| (x,z,-y)), + Box::new(|(x,y,z)| (-z,x,-y)), + Box::new(|(x,y,z)| (-x,-z,-y)), + Box::new(|(x,y,z)| (z,-x,-y)) + ]; + for i in 0..scanners.len() { + for j in i+1..scanners.len() { + for perm in perms.iter() { + let permset = &scanners[j].diffs.iter().map(|&p| perm(p)).collect(); + let common: HashSet<_> = scanners[i].diffs.intersection(&permset).collect(); + if common.len() > 11 { + println!("At least 12 points in common for scanners {}-{}", i, j) + } + } + } + } + let mut beacons = HashSet::new(); +} + +fn test(s1: &Scanner, s2: &Scanner, perm: &dyn Fn((i32,i32,i32)) -> (i32,i32,i32)) { + let bs1 = s1.beacons; + let bs2: Vec<_> = s2.beacons.iter().map(|&p| perm(p)).collect(); + //let (p1, p2) = bs1.iter().map(|b1| bs2.iter().map(|b2| (b1,b2))).find(|((x1,y1,z1),(x2,y2,z2))| )<++>; +} + +fn parse_scanner(s: &str) -> Scanner { + let mut lines = s.lines(); + let _idx: u8 = lines.next().unwrap().split_whitespace().nth(2).unwrap().parse().unwrap(); + let beacons: Vec = lines.map(|l| { + let mut coords = l.split(","); + let x = coords.next().unwrap().parse().unwrap(); + let y = coords.next().unwrap().parse().unwrap(); + let z = coords.next().unwrap().parse().unwrap(); + (x,y,z) + }).collect(); + let mut diffs = HashSet::new(); + for i in 1..beacons.len() { + for j in 0..i { + let (x1,y1,z1) = beacons[i]; + let (x2,y2,z2) = beacons[j]; + diffs.insert((x1-x2,y1-y2,z1-z2)); + } + } + Scanner { beacons, diffs } +} + -- cgit v1.2.3