From 7a9322e5930ee0d7cf818d4e09a51c1e1baa175a Mon Sep 17 00:00:00 2001 From: Paul-Henri Froidmont Date: Fri, 5 Dec 2025 17:58:54 +0100 Subject: [PATCH] Day 5 --- input/day05 | 1178 +++++++++++++++++++++++++++++++++++++++++++++++ src/day05.scala | 43 ++ 2 files changed, 1221 insertions(+) create mode 100644 input/day05 create mode 100644 src/day05.scala diff --git a/input/day05 b/input/day05 new file mode 100644 index 0000000..7cb991b --- /dev/null +++ b/input/day05 @@ -0,0 +1,1178 @@ +213743501161200-213743501161200 +221359789392478-222960432116258 +553905700373062-561794342755365 +388351876706917-388578461376678 +263685821321516-270464997549766 +384957836075964-385057316204755 +86932924454422-88726115602910 +64713316693400-65189382496202 +68179610157787-68454649435444 +143154545648377-145980913110898 +390250299542523-390843409397977 +392162789636707-394167531415509 +467795551515047-469145316638624 +73412860995201-78319783604609 +174577844186025-180222947242739 +34889394659118-37852045203256 +506719917120116-506719917120116 +64999889315593-65189382496202 +62511033442122-62882231057991 +169629548448978-169629548448978 +195991726717561-200347594718591 +80800364897743-82410540424990 +157966143122749-158625789879543 +414893276002289-420734433214551 +468854880571347-470178150823398 +293047529057561-293047529057561 +526293793744803-526800435871324 +154610263545675-155018832807006 +85676500485010-87494001551296 +404052468013478-411059540873663 +529805857574316-530354749652142 +282126028703430-287392631951184 +536612716581558-542001885354658 +224389325429033-225956850054114 +389327354686290-389941649666180 +226458176996215-227998751964573 +466681105242973-468035461798180 +132182495488136-136864510598769 +158625789879543-158943957000511 +222498723695457-223722626496659 +24396986945805-29009989981082 +387070084421471-387699738663307 +463761550427134-465101663712718 +244484473250009-249824444617715 +235682381324440-239428507922589 +356542431952285-357218504633271 +528809160802420-529163494010802 +203275761047276-207893046967514 +65189382496202-65740304733466 +84564501332038-86342507935742 +528809160802420-529739126171581 +430824287436458-430824287436458 +270464997549767-270464997549767 +73412860995201-73412860995201 +203275761047276-207893046967514 +465765531974637-467339424840641 +88308683283200-90314897336701 +506719917120116-509378158464998 +154610263545675-155018832807006 +436351058276905-441549428537929 +390250299542523-390501802123222 +464766089052130-465995972804612 +153723748856595-154247928476913 +524957458539564-525444885761624 +193355047594087-195991726717559 +68057027039766-68454649435444 +114292754379846-114292754379846 +476176387291714-479287347759176 +68727093315072-69054421292865 +374010991378735-378095042001312 +396702787271742-398555495412596 +92985559435331-99083983384255 +524317721420090-524645436296520 +470916081729043-472406223184007 +307193970359996-309957481846034 +83208072709351-85336482970086 +61908006035935-62767933777530 +12440214380075-19413829756369 +158268094987535-158625789879543 +323855611951188-327225842492665 +232121351950005-235682381324439 +104580961113313-109652180451852 +155719620755384-156378640409574 +225242642256272-226838958939168 +126345620041269-129628037616258 +272979306019768-272979306019768 +229571449179868-230955409924473 +15572428843108-19413829756369 +486438625661094-489174884685392 +399063478386186-400626043814074 +61434917885505-61908006035935 +442807002499434-447467590937981 +153470274802250-153891356149723 +548528649335253-552132613556960 +302406550101741-307193970359994 +284836416410676-290905691766532 +134736737710827-138821293926430 +524645436296520-525444885761624 +347299925469182-350731461622425 +333121507005172-333121507005172 +257633973479609-259311991697339 +418350619486212-420734433214551 +523873015780814-524032209716334 +424331863324814-430824287436457 +143154545648377-148152467497972 +156770859353106-157228370844559 +523401105399726-524032209716334 +3672218268426-9069958349825 +41190120499524-48710502110828 +171431709160547-176780839877720 +65740304733466-66283299959280 +3672218268426-9069958349825 +157444284967581-157743465985657 +99083983384256-99083983384256 +114292754379847-118122243442587 +32783805912506-34889394659117 +495774309849622-495774309849622 +385597213338484-386130309524989 +66422129062863-66711994098586 +390501802123222-390843409397977 +227420995218497-229137292369316 +518765954978807-520809013033287 +81872566000969-83813851796454 +272979306019768-280055074059068 +394469512488834-396279958092492 +469546011173175-471346897231698 +442807002499434-451270889383530 +184738598610317-187210601572675 +364359970290004-369109081626630 +327225842492665-327225842492665 +353087698181504-361406479744402 +293047529057561-299710639297794 +486438625661094-489174884685392 +472788183962691-480272823246663 +152000130191943-152486238796869 +386858817856261-387699738663307 +462503261552047-464039809812541 +183175626133351-189172211000972 +163807315460788-169629548448978 +393534536834350-394918686174827 +344389995827602-347299925469181 +159774306485562-160419960771595 +544514849402253-552132613556960 +65400483278322-66283299959280 +63641646788533-63945948546021 +228387323493940-230123402570745 +223334527687062-225118219054282 +398001413033472-399528430973758 +389120143291068-389327354686290 +251886663550811-259311991697339 +69054421292865-69216943568303 +109652180451852-109652180451852 +53011962076696-56344039055008 +400162615237818-402020110303086 +43204303716398-46879070810322 +314744608126757-318669297711175 +432956413748504-436351058276903 +374010991378735-379580541653265 +53011962076696-58576758868523 +151246265148187-151690444980057 +67160465476009-67649438641309 +333121507005173-341135415342898 +456177793236387-461879349449355 +395508284503006-397494347386228 +533093622413503-538889692659981 +561794342755365-561794342755365 +515616143391792-518765954978806 +69696292125615-70040914201079 +68727093315072-69401400390266 +495774309849623-500237151028475 +369109081626631-369109081626631 +529163494010802-529436944344583 +404052468013478-411059540873663 +121847024509459-126345620041267 +522880293422404-523179474172233 +158459878825465-159131956260867 +213743501161201-219471291456959 + +494837294376908 +435660505746994 +99786817997391 +472909760977579 +463484249547475 +273865746097567 +546948282990871 +313905748059736 +389220642255587 +264910144325219 +194634550937143 +452503195637112 +38664030641468 +8643898228674 +408947325836900 +56337977420387 +174507776974605 +140836347671248 +47631986998014 +235031396283281 +343857671631037 +252684431369877 +561260764726582 +13377139290760 +335659611077426 +305254801428350 +23068609919756 +358157740175632 +336124567002906 +499856499644500 +245581152411526 +4607628398578 +113989649477446 +261695855054656 +54145308170978 +23643219088083 +288564055768829 +76218205231423 +383056969666651 +206049039348792 +362866693952230 +447390838499260 +269419273985840 +495173666576593 +475030519522818 +12103270345560 +107629037149479 +393860930903512 +141626771549297 +250924689541736 +5883371952028 +423912703644535 +302546348630570 +436937082048731 +494664825705194 +448188584703582 +254291468010192 +221243211979987 +350545951774103 +393592820188728 +32794726074237 +215351251387887 +18789663384866 +546887929110328 +229634965624793 +26225821034784 +175436974010271 +330555143105279 +540559732802993 +146048634742198 +457763885033022 +255063532513955 +523233693563579 +520111841799148 +554058843495886 +318786207342405 +377363192140595 +99808601402762 +18925946943601 +114133861116596 +466658719803329 +239088721753669 +437089455846288 +368941022635265 +396739332676075 +136405831558024 +56176226086142 +89188104356081 +522069015255255 +321118023164859 +9031526519848 +426715696390470 +525707768388028 +152077432064905 +409969738179310 +413539799236118 +394325762684221 +152819990377936 +394401954863928 +126602621671422 +504598064766126 +458638902263336 +326459124993522 +419281996008737 +490842973818114 +146271762366396 +22503238293943 +537920215050605 +559195645649780 +53366531225879 +147488127813515 +87770751897444 +355793262392237 +29238551733499 +480135691758946 +538362412784828 +450359874870348 +173926045560484 +401263245119900 +469761746266259 +517263368251455 +49071456365129 +137992440004065 +414963191734774 +478773793672052 +323893963358308 +346609563056966 +528752351256778 +296671648977112 +374729839695085 +454860071033636 +467162739020170 +507732258880396 +230301737270720 +289177397090688 +528799065232012 +165854989903172 +406394881004817 +481447401833724 +516889448667819 +554061619704684 +392059778405048 +175159258924467 +463421480856860 +544635640616828 +309477164734560 +231037323484799 +340860687007580 +448875290293314 +127397009585739 +246830806645075 +518431937476941 +3732761639887 +147285882576699 +396422419852454 +27478056069416 +286717356301433 +236893740878667 +290016489594859 +298887079519963 +461497186313441 +235329424183967 +556647097855604 +261197438978660 +118073942807968 +285360172331044 +169445091271339 +418603412598323 +416679342584654 +163804209188500 +167161416515668 +300589656673348 +84155065043548 +298520045126168 +154549118044364 +509513039742643 +406174906841001 +239965534880610 +264241638530762 +326907134654161 +148801284014366 +252845684706962 +538160202161003 +396627759613700 +546079642043457 +75651194219911 +432586855556463 +96802942627830 +25041440445919 +107116271154358 +303702054634544 +398781252434901 +503172397854082 +379315602131933 +236979084549993 +451397490649019 +279868894290565 +524617891089775 +136961187947989 +136429946001689 +76950346304543 +306928041509744 +312915314588031 +298998035287402 +34760223536011 +446404886235072 +197388407848521 +333191332684099 +221740779665886 +309416371878888 +158477659448444 +516680333458799 +44853377628995 +278888606895658 +278420982927684 +175703803052425 +470568172737830 +236084777219214 +397984966672806 +473425480788950 +522025578442624 +427215517454322 +198299794101146 +349413337275427 +125618902680777 +89314589371888 +368825410886351 +330191130666564 +387752207575580 +440138070603836 +227890254261097 +44488299718077 +29751481585745 +25028650437464 +547595768878 +174236076333058 +133712293361829 +540096229159911 +360206980499620 +258011259781602 +549364690524601 +10091206687143 +470374190930049 +179075060473731 +377242979825409 +352690157476711 +278488530349263 +384422855896670 +49811728480863 +267349043407318 +489564767823505 +73008037929843 +124299946430397 +217882757871908 +108999668545307 +20703850023939 +496246608935789 +541069367118771 +305122372020761 +115492357896852 +193492845516396 +417751256829819 +285658063335359 +246744409069648 +351755993275651 +98127769000175 +482372026370776 +457710650905360 +18026862445928 +108534833075078 +169824794939485 +559142599641987 +2085564400281 +309173175821638 +456153160917877 +293414602125014 +547198783459634 +76444012948089 +529290472539497 +355365766193271 +287986193982431 +173227908416238 +551806007985042 +186471826913763 +121801161824669 +97800001698241 +342494173599273 +12505387404524 +306058580091348 +318867143656603 +428585013529288 +256312606382787 +366239026804887 +51539372147365 +66134064995673 +79041166640102 +75784996215689 +287522598289639 +332881462196418 +520053787194950 +297834256156760 +46395714814142 +478528279216500 +283333063204819 +245859459924907 +473660316927145 +307732071267576 +277227366442821 +390581386350646 +376021035764980 +463341164063984 +185816349933763 +241632149492477 +289330190978899 +476909402388343 +458026449622767 +257790586910592 +174516863536188 +285936912577790 +401130002886351 +458803825528219 +478494606977638 +345725593786871 +138388443036459 +282300697387892 +71713317490775 +556366167372211 +456995326804110 +247592812172057 +494021760846937 +371537593769295 +170534224078136 +42472063541628 +8253779665434 +372548475874699 +9789888924117 +405774436581168 +108848101351560 +356331145749819 +102658847092504 +497003148825168 +202359692308749 +378179874893748 +288190427639734 +67215625812110 +93836607837463 +39963768403407 +461513540873237 +54758410728278 +469151923616890 +166921111216013 +172094825320701 +401988768026836 +72359177616839 +73996848337616 +156027952163011 +80550172897080 +272407697592724 +319010392655020 +105513600420820 +162726193523288 +535986651356692 +436612082177264 +212069750441845 +524009300711044 +3906518069903 +511762793424455 +435458211326830 +182645647469308 +386479321392427 +547154129474513 +189861778530296 +538429181270504 +507550826426915 +444356931927172 +358258263704862 +479009393218306 +124637474760302 +48105008177613 +79260117487309 +174911990213797 +500298985584761 +326954412173914 +295336439807937 +395949666733917 +443370872863471 +318697699565865 +427947513844159 +511045858671785 +203280107417109 +6700597080245 +348384357592517 +374376031983939 +260753794641180 +56191981851288 +97355512125554 +60506801192793 +84565744031887 +488814694065249 +161260860939794 +337637633215227 +173783730103701 +142086002223119 +207574240730436 +436871109820151 +461408177154461 +382258137884632 +440730273321561 +159229941436332 +166460057869524 +15683339825778 +68381063771276 +143598887912420 +96653310252281 +234747364980280 +128261783917087 +103021515222116 +477480443511452 +114836796393351 +176449720440695 +275945902507716 +99018309358801 +254514953778996 +471192665544357 +358710048656100 +469155211803836 +203392280667538 +192303210311382 +15133914751416 +263057847298987 +304201025028695 +109141830415556 +62185120729939 +347423458432248 +1593697889240 +4336364389626 +249534740021091 +245022245155666 +378597629224414 +217930033733263 +47800102644184 +138075535369981 +357729021453863 +349551010555520 +414887370914099 +395344795419827 +521156568954976 +272534129891028 +371964108827244 +227896489799466 +249887136596757 +16884793154524 +317821877138354 +81898773447364 +443073486047140 +247847253283552 +315251502366423 +102188123805733 +303075733196562 +557745658198349 +206799637439489 +451334768708210 +97037065675992 +257278920415657 +56437781998953 +44288968074472 +113292234978530 +151922731113530 +391052761602056 +267944508540614 +343200180160422 +288399431199285 +93273619500930 +75721595033881 +550871884021335 +149604081990381 +512742597104092 +455839846395368 +445378642797525 +16014807365216 +30695616425451 +43049956446441 +270535131219725 +4693914659902 +335914961222544 +272323132654404 +528950169623633 +445047908810129 +419646793721765 +213936570355528 +395125528944776 +141671410426457 +453372985670055 +222478883363391 +439875818936907 +303299784024612 +56388748078988 +318257306432227 +215338536256842 +532406515670856 +172904036406734 +25079121055090 +326898571184918 +383895798528344 +416303301754527 +490848856553941 +320988109028453 +223845273980771 +94966656581935 +190179292225210 +419218075147010 +230508834223536 +548901527044748 +297819409510702 +464859798986245 +118169686522273 +207497906150129 +512346201207054 +1158097103310 +459046195527588 +186759288128078 +96944724188350 +392594151513159 +234466454560389 +68623818756541 +246226233532203 +114619533725580 +493869659303676 +313637481743263 +534137643816612 +264642463242404 +377529710233522 +87155833011856 +35770041890308 +516647262550256 +265354534106177 +406005422023368 +272642225302759 +85930020547676 +284783735206766 +436630505082911 +15951172389804 +444797637969258 +97363222190880 +133445802169347 +272305925709773 +548458915170143 +430806456961455 +245507121943314 +160249013035249 +527709486106910 +367001001737708 +518162583986624 +183225672376704 +296993625361143 +231639876629108 +407962526353092 +67393637407153 +85833159363453 +49339824913993 +28400800168478 +15327853771250 +354370364188649 +201574969117946 +552709965745032 +213632623033074 +312504618210213 +327125906582053 +144452289727950 +203987516214332 +479509321715515 +88372152498413 +307473270739765 +245675091013202 +336432122026158 +41324911865648 +458457956208945 +542446938157188 +89589403513696 +24781388955739 +305437870582706 +348288413987487 +431709614168751 +276141784590342 +466981918128601 +372707468387142 +102568457788486 +349718918963076 +104093272014233 +265342553887934 +339579325422624 +516419655842307 +325305930926652 +409419378044930 +290691078464777 +538500176586611 +104911135244051 +460656158588869 +19085848624265 +550573802219161 +22745479349256 +65579588599422 +254111896868958 +43567781834275 +90573006423916 +45561710350423 +149209374428586 +446575143276470 +550306254135662 +181025204938463 +97330974107531 +379402147450993 +241506356892172 +168713148733973 +48466869897953 +528008864607078 +393115054851961 +165787328717415 +287310392177289 +551681935207092 +122167522220188 +132105403007176 +317705294863715 +109910998040619 +446000068071441 +235531799669044 +146356734397746 +47298585536802 +42273110218235 +444603089915716 +241465851395725 +109573813906530 +231274862902914 +537319538622584 +157414189612508 +221642178690563 +245610078329995 +528325158959332 +145325570078081 +12079144762793 +531588757842283 +547678261102872 +127153144140359 +305742973421716 +8011027076203 +477661996505800 +466477744603636 +403328720663418 +507927453967381 +538069184299013 +214768582354766 +137397594359581 +187613809609389 +357880338028129 +433487759782156 +487471717210901 +180006387715886 +326002409470383 +76444888756813 +444254908195532 +148806304277047 +479844016063762 +330052487223106 +240176280384525 +411385336296896 +354792309945488 +305594460678296 +40995915706785 +39394966701507 +89548663321944 +548307369875750 +488506179147436 +121924775887669 +148038179339071 +338537681759411 +468669066514854 +184481225100823 +360687191874324 +489917124737512 +183480059346292 +210032333691837 +415012143178873 +425782508042329 +206536230476631 +69446550967892 +456998663839841 +487684484253300 +132781025275839 +51299076795592 +214996080875736 +395997740442896 +229801883331266 +410891218970154 +44342335653173 +468644958332092 +133694753338744 +15324257575984 +382577259399786 +371176455304440 +273103366140744 +473864877490707 +348672546656929 +346325654887690 +204798752414288 +205451628438977 +2248039977575 +236557577288755 +246505641659146 +441573876295181 +554299527848615 +368147889057080 +337980441560978 +108843538156956 +214211872574501 +222501948465259 +199340300341502 +57751894058447 +387301004745509 +555684169567228 +444161010809973 +44274057183558 +457484483808702 +299118893791597 +278770127821305 +19364490860923 +269877412509975 +362138446785346 +407915043906975 +110542007795632 +351373538617793 +178613301456939 +419145884127302 +337724653316807 +273150978486771 +314964765668119 +471968715772891 +357610841553825 +22133316659832 +208155444980927 +509198516401694 +411253902813469 +227031471430627 +446602597121154 +271273314812585 +415798095859971 +561190340020923 +336975452894927 +143875972527564 +290796527780450 +562533759378622 +116821329895853 +386671228899496 +317327089314224 +183632275635096 +273373429456521 +129515707014799 +110676169506793 +233033183096270 +318333250308412 +112033225565880 +519454679823055 +55656519297819 +377451642372971 +338691010626694 +64777634972758 +436208855797645 +415156993450774 +98020363049302 +42655570576535 +34400406221986 +290610597270086 +537265183350038 +400911093968583 +525318854899855 +248415410979120 +418842405171486 +411566017836771 +425657631898340 +354259572729994 +268446068326870 +296070266615673 +136227729615321 +120047629033730 +406964876482178 +137521850223080 +92611826977927 +331877322852943 +479781531711867 +266206661846269 +347578536598669 +89240023766690 +529174586943339 +84839756252558 +419979950328255 +547500684314327 +280045500991504 +215483226398738 +441596111446605 +302694962708225 +273892147226306 +482132415192397 +102702250742943 +223089452700980 +457807726448257 +384562645765746 +277781338567261 +439822548783525 +183776192242043 +301325514128398 +70021389620076 +336918674037773 +68295253195049 +543695343432503 +111249314175356 +7690585447477 +309542200032252 +103628229231634 +73718547163740 +159803357847773 +430786036978468 +415204380827690 +48045918311352 +517000580666897 +325917367515042 +426507802694299 +526144643790360 +513035119218192 +315794526632610 +285574806997324 +276841825017615 +179635895379213 +325755181311001 +524060550844191 +91712045450912 +77966935288136 +264428541284938 +524847707306416 +111105350913783 +346301400064114 +556613923238451 +472099250670418 +371207522154824 +451823217286595 +357256514424263 +372048331394790 +434691928665739 +560829027337169 +16136507872053 +282364153898411 +154085261680230 +254154288276590 +514028216189442 +545333427544222 +476497025736792 +242355804527146 +561598070577352 +118400176536972 +375682605796962 +399133654154343 +201628057251316 +217572056496332 +533395907107346 +47345345286797 +7408156832896 +522616875123776 +349641074502968 +345818104113036 +438218046900677 +31628293548083 +351605047809133 +359444834536162 +290228149997469 +135905576277424 +84612883197372 +189982680788991 +450138577332891 +136439932241119 +187799240856577 +68578204608926 +134334871260185 +291561127203042 +273974000047959 +174624183735646 +18383048241682 +556252702946152 +387793821456466 +298566510001603 +172815513476927 +33902411018515 +555994633611969 +289184312520430 +436658715830883 +470864228533567 +164090356849964 +98782919658558 +97942176959956 +112901798817150 +35208936896656 +14353996552438 +471473766116537 +480180311744636 +499204584847002 +80611198707461 +544525064031093 +229232247132363 +162849540618442 +492975074294900 +166448581711132 +114764389841759 +63292143206629 +98480857792796 +157851646383721 +253474206387522 +354978928842494 +278747160618146 +4530472691471 +58079854789591 +66267035140727 +311056476691269 +557762351202903 +197758525541161 +437268149565806 +313236543511296 +302427918967126 +400691760604857 +399668277458282 +223494949882340 +46570814488202 +204451824914507 +345698026918708 +497928342405563 +325773432317635 +93545891401889 +5585896974427 +356380459100139 +264230752597112 +426543387431711 +387146966449194 +41228535640790 +509087992955574 +489729610164135 +416479576139310 +28845488051941 +522009267546744 +271000859618955 +283750554123411 +410419160607446 +185499005938127 +471551666427620 +58626479872089 +42972264624877 +524613104175528 +27852888528989 +237204455550497 +288326266418244 +63065149157014 +553756535652764 +282436178910576 +88402747933723 +400823646916103 +223363824772513 +525071673732969 +537259982319875 +276682773539699 +398451590620752 +245054501306549 +464479921104086 +457043633831813 +516586215954486 +64884357708824 +56128129974389 +152412022204482 +222723024889271 +199274377091885 +477985828686667 +461997935560695 +544878475633187 +173350091865783 +28043191569632 +550154791633306 +95957091506410 +148749440627953 +363647261163259 +137891120244035 +292700540347170 +7279385311717 +127148348879474 +470000742634139 +144166016173754 +394128803397657 +361074837077952 +126989419234613 +420362060242891 +404091808985110 +118996430880710 +108513159619332 +245110820984873 +404371687077287 +92684280085493 +109303133175033 diff --git a/src/day05.scala b/src/day05.scala new file mode 100644 index 0000000..0950f6f --- /dev/null +++ b/src/day05.scala @@ -0,0 +1,43 @@ +package aoc +package day05 + +val dayNumber = "05" + +@main def part1: Unit = + println(part1(loadInput(dayNumber))) + +@main def part2: Unit = + println(part2(loadInput(dayNumber))) + +def part1(input: String): String = + val Array(rangesInput, ingredientsInput) = input.split("\n\n") + val ranges = + rangesInput.split('\n').map { case s"$from-$to" => (from = from.toLong, to = to.toLong) } + ingredientsInput + .split('\n').map(_.toLong) + .count(i => ranges.exists(r => i >= r.from && i <= r.to)).toString + +def part2(input: String): String = + + case class Range(from: Long, to: Long): + def contains(i: Long): Boolean = i >= from && i <= to + def contains(other: Range): Boolean = contains(other.from) && contains(other.to) + def size = Math.max(0, (to - from) + 1) + def diff(other: Range): List[Range] = + if contains(other) then List(Range(from, other.from - 1), Range(other.to + 1, to)) + else if other.contains(this) then List() + else if contains(other.from) then List(Range(from, other.from - 1)) + else if contains(other.to) then List(Range(other.to + 1, to)) + else List(this) + + case class MultiRange(ranges: List[Range] = List.empty): + def size = ranges.map(_.size).sum + def add(range: Range): MultiRange = + val remainingRanges = ranges.foldLeft(List(range))((acc, r) => acc.flatMap(_.diff(r))) + MultiRange(remainingRanges ++ ranges) + + input + .split("\n\n").head + .split('\n') + .map { case s"$from-$to" => Range(from.toLong, to.toLong) } + .foldLeft(MultiRange())(_.add(_)).size.toString