From 204f1d2a15e282573d2229166af1b00a58489247 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Tue, 20 Dec 2016 11:05:43 -0600 Subject: [PATCH] Day 20 Complete --- 2016/day20/input | 1029 ++++++++++++++++++++++++++++++++++++++++++++ 2016/day20/main.go | 87 ++++ 2016/day20/problem | 49 +++ helpers.go | 9 + 4 files changed, 1174 insertions(+) create mode 100644 2016/day20/input create mode 100644 2016/day20/main.go create mode 100644 2016/day20/problem diff --git a/2016/day20/input b/2016/day20/input new file mode 100644 index 0000000..222a0d9 --- /dev/null +++ b/2016/day20/input @@ -0,0 +1,1029 @@ +1397985562-1399927095 +3833336583-3842601761 +155087348-169525214 +980790001-1002844256 +1977065361-1995466542 +36411396-50881439 +3640866817-3644930814 +2920060305-2932561292 +2865550534-2890593328 +3904139550-3908601694 +732092457-735186747 +1787486182-1806545011 +1491600386-1521258835 +2566773511-2568507598 +2201927929-2217336001 +948934267-952537088 +2146567862-2152339711 +3301828099-3306223909 +476027067-495966189 +2724939184-2726302873 +2270442513-2292973307 +1889038911-1895488302 +1578483230-1586330750 +2640456298-2651236024 +4254290660-4256486512 +1399927096-1421446962 +3253590561-3255525299 +4165315034-4173427102 +2875463797-2888803426 +3656533491-3659451752 +1995466544-2025204494 +3947779886-3987268039 +1521258837-1538635254 +735486056-744123494 +230221149-237996554 +3652971511-3653104884 +3019667516-3024190047 +969642901-977292032 +3645248112-3645595401 +3107902888-3148345903 +3202431537-3216963208 +1220746925-1223070151 +3267241325-3270573499 +903635659-931632639 +2847235008-2856948110 +4224654922-4236958325 +856464812-859836714 +1804748836-1825290046 +4082899236-4091369419 +953634177-954158487 +185823994-190243500 +1964052811-1976412955 +2420916052-2424566745 +953985134-954947310 +2584348542-2614406629 +2191157950-2198152569 +792721019-802271235 +3791161572-3800845341 +1864843815-1865425121 +1974124152-1989195256 +7825290-22939478 +440787397-441318113 +43830518-44800277 +3060173435-3065634268 +3165692093-3169381847 +1833191664-1858547431 +1931833201-1935239219 +57759373-67515020 +4113876528-4114024438 +1942285042-1951328312 +1604942683-1619936021 +853121890-865841853 +1837742103-1838104083 +3653104885-3680835942 +461163769-461467242 +3154277391-3159331043 +1689521647-1696389379 +4132416435-4154260806 +3575213588-3600527150 +962221692-989154668 +1935239220-1964052809 +853763614-856527667 +1529882226-1553729207 +2908870325-2931754108 +2317225465-2326207645 +550660010-557063544 +2362374340-2370047564 +3154439917-3169895876 +2971931902-2973888167 +3915276202-3919826635 +3443104535-3459421692 +2452320784-2463651682 +2645465344-2652262587 +623576471-624671363 +251678316-253256260 +3892899041-3898838343 +464002012-476960875 +3778510328-3794259788 +1032494594-1042075604 +1726869059-1729493515 +3050865580-3058403387 +4096451268-4105743850 +1794978532-1818366498 +1687963887-1693429657 +1919840326-1931792580 +3890085195-3896657673 +687727514-697989805 +2130251157-2132529361 +3709755147-3710261877 +2103854130-2136933959 +1240822471-1247567713 +2490928812-2517604025 +2792885084-2793563605 +4033319760-4037319553 +643767762-679821627 +2244191155-2263679816 +783204448-826857019 +874202754-876456673 +944792902-949779600 +1014490072-1020320091 +3709667893-3710060580 +3034067373-3060173434 +2380617387-2398492444 +3913418161-3925664598 +1327421559-1355573458 +2029296660-2060654925 +1015438314-1024776747 +758467105-766508249 +3196737715-3203535886 +4113219652-4113918216 +1900161068-1903498607 +737196603-742913680 +2762651281-2782581391 +1241724970-1273412553 +2234377553-2234408980 +3485475801-3485850742 +2823889184-2825719103 +546429220-552909166 +3889312069-3891497364 +1402469948-1411853934 +1612881279-1613899725 +609769932-611526589 +2821381184-2837715581 +2793443367-2793757783 +3865830130-3882113243 +2302840856-2330280758 +1587820493-1589487382 +1925168590-1930014298 +139238032-141721873 +3159767763-3165446614 +3124692923-3128639222 +2270740594-2281991663 +1338789977-1355677780 +1748641567-1751344173 +1416549076-1421417040 +4096185893-4097103352 +2627343873-2650750532 +3948622110-3962424399 +3734105837-3770337993 +557813236-573792261 +551603476-555886358 +1030836305-1032494592 +1839182718-1840151300 +833662859-842106273 +1375985004-1393778055 +1219332117-1221436570 +191846359-198587644 +984829875-987740125 +3262588159-3269982376 +4113255424-4114203177 +3754035901-3768277382 +182356017-189508231 +4235072872-4237128944 +2423845665-2424035634 +2247134633-2249391253 +1857070653-1864762228 +2960971255-2986516950 +3609807449-3629876533 +4232009521-4238664410 +2517604027-2532315540 +2284458125-2290950480 +1864762230-1865525184 +1534410012-1552842249 +1413197933-1418525745 +943004746-952141611 +3692615771-3699711756 +1641152229-1667111341 +3747007580-3765218619 +2379349853-2380702573 +2147254282-2171495074 +1839659452-1840812997 +3895746954-3895831312 +1969771475-1979046124 +3083853152-3107315352 +3503489045-3537546786 +2926162506-2931745365 +1533535067-1553811000 +4201206086-4201731554 +3151335418-3163702483 +3589540929-3593463200 +1469107231-1474901685 +1696389381-1748641566 +3910219915-3918863153 +3431523383-3432952214 +4219640842-4234037045 +2150930801-2173615229 +3364393582-3403187084 +3294593092-3301828098 +690072645-725395887 +1123029535-1135646014 +122125578-124303606 +4157086822-4157139009 +3561413702-3569934827 +3814389694-3815485217 +1931792582-1935186677 +3601713750-3623094300 +2322435284-2327697391 +1362099577-1366674586 +628898939-635522883 +3117359644-3135324932 +1119748429-1139457622 +3998554882-4014887284 +2837930003-2838092963 +2123885505-2126641084 +559576606-579617582 +2712491763-2723761235 +1391544337-1397769783 +3416595318-3422405875 +3403187085-3409221687 +1096346351-1099114997 +2703273295-2705328183 +4113785067-4113908859 +206706372-209083880 +3270160481-3271551430 +3285776930-3292794583 +461234099-461937747 +750957483-775003729 +4184090903-4204400455 +362276042-362676210 +4249953310-4250510076 +3477313433-3479866795 +3421127715-3428203812 +900263617-943004744 +835969757-836263940 +1368935057-1381717988 +149206242-166300349 +2154227228-2154605899 +1906507809-1919840325 +305745049-306370999 +1726861064-1728699678 +1357107426-1362288056 +799761595-801167452 +229374054-231369444 +1529834231-1535566821 +754999390-757160209 +1889190091-1897618002 +2138256423-2146567860 +2295710373-2336599718 +1019914990-1023404843 +969695821-980184547 +1443906340-1473362681 +833198360-836801840 +1598512205-1604942681 +3199387842-3210382637 +3895688557-3895758051 +1377900216-1382117658 +3504189983-3527083803 +3577792742-3598561740 +613575187-632091293 +2551456957-2551799726 +4058092124-4103653807 +3381308208-3381342063 +13984873-15227949 +1727002523-1727443872 +2357289728-2361812594 +3876054666-3879516291 +3278228783-3281894754 +1640252019-1649137061 +2372620720-2374166948 +4109383543-4110464683 +2069304258-2091857479 +4107063052-4115320079 +700724903-704038468 +2443015838-2445045788 +2487239190-2506741363 +2840932452-2854276703 +3023346911-3024737732 +855982891-864879970 +3794259789-3803801069 +500728802-502979928 +2043915271-2045977041 +2883286342-2889401600 +3645471325-3645615199 +2570503460-2572567939 +602978860-611682641 +3014237470-3019165777 +82763197-99917251 +3459591973-3480841023 +3726344670-3753436804 +778825357-781459133 +3501129290-3535003794 +2110603192-2124722020 +783458439-789801399 +3244733157-3257526606 +3107315354-3107902887 +3485245437-3487101327 +2981323037-2986657197 +4250870060-4262722661 +402547398-411983817 +1723037247-1732297154 +2168632715-2175630061 +35807058-48835050 +3967606126-3981776003 +1175337592-1177759663 +531093126-538642617 +3639437354-3641516465 +2313078075-2334991622 +2166324817-2172350995 +4271478996-4279496401 +4224492579-4228356386 +213570433-219586693 +3577738508-3578878626 +2004747361-2023251091 +638907979-651338734 +2042269899-2052960282 +3459421693-3470010193 +1255554697-1256876442 +547623253-554247422 +1091999863-1096115712 +3603876264-3620115458 +3743564125-3764787998 +1727097235-1727512693 +3360184134-3361837705 +2693328393-2699639043 +944625756-949285354 +2867948986-2885571238 +3815862045-3817192748 +85521215-90999860 +3492959364-3496450746 +2370047566-2373514273 +978064227-982934994 +3002922234-3034067371 +3702198906-3708772192 +1762248212-1777087215 +3200048313-3217284316 +310731268-314864040 +4256139187-4257030493 +4225267250-4242760473 +4236421277-4249953308 +456593320-464031864 +4173427103-4219640840 +3415471996-3417373524 +517786225-518353134 +2348225752-2349209975 +988767498-1002507583 +251787031-253294331 +2049843175-2053651832 +3272267359-3280700773 +1880334878-1897812119 +2180116083-2181662625 +1325501561-1332569991 +1977956589-1980243809 +1419475215-1429076341 +1571066989-1593324419 +1908591293-1926977363 +892862026-900263616 +2375708935-2420847226 +4252569311-4259706067 +611682642-636576980 +4069864506-4088316591 +3429899073-3443104533 +2881173909-2904242568 +838248538-839457347 +1040048945-1048427339 +2790325698-2817756908 +259065357-260284546 +4251177319-4254787503 +1727035024-1727220036 +1750189264-1751440819 +1182854783-1199103982 +1565110550-1598512204 +1870272544-1906507807 +2294404836-2313311754 +605934295-611508831 +3164119802-3167924307 +1833545461-1834287253 +2077509652-2090604632 +2880238444-2890262424 +1142031337-1148518669 +4005987455-4006591959 +1570054798-1576009746 +2071505543-2096650688 +3485106835-3485722365 +577813461-602978858 +2776866362-2786901141 +652895584-671838947 +3299449839-3300020065 +1623460193-1638054811 +3340666115-3353087971 +2160043893-2166478186 +1096507969-1101378526 +800088830-803013264 +13565145-17743483 +85024888-98806837 +3823224649-3827480049 +3931062541-3938277752 +1012892921-1030836304 +1565255853-1583189516 +1647708193-1660811906 +657010776-666847464 +1839278378-1840330117 +1008973854-1015912839 +1910283066-1913763928 +837557263-838411350 +1282815406-1288995029 +3980611-5584893 +3148345905-3165692092 +2742421263-2776592447 +229688447-231610502 +2743245719-2776866361 +3878098271-3883221309 +801316931-804135040 +1471664269-1473302685 +1667111343-1669791317 +1610947175-1617629889 +2003085048-2013051153 +3307457133-3360184133 +1195340209-1203343093 +2025204495-2028453665 +32923438-47156091 +3168696227-3170592073 +3235742576-3255614827 +2266729227-2280080556 +775349160-775813901 +1473362682-1482720843 +3572312385-3575213587 +528189743-538093910 +2448613175-2454994921 +2843283603-2855830818 +2890593329-2907911642 +153191907-164713586 +4043150608-4096451267 +605875663-610305444 +3021650-3111593 +2420847228-2420916051 +4105743852-4113419273 +2460397045-2462412256 +567585936-602788586 +1727082530-1727671255 +4033434900-4037286987 +4144511592-4162791978 +3075535768-3080851776 +1639907267-1641352662 +920282814-940069234 +3826936712-3829839713 +1916925688-1925357559 +1845213589-1860279111 +1854550234-1855331759 +3065495280-3066648567 +170353613-171186253 +3212824412-3220097963 +2853141261-2853700351 +3556640-3614471 +1976412956-1988224560 +3296627900-3297163117 +725395889-749479392 +2233996777-2234267091 +1757843247-1759325879 +4279435928-4280514617 +801130429-802441496 +3751681078-3760769957 +2347982977-2366662085 +4235682663-4235983270 +3496282296-3499776408 +3821333501-3824224274 +2723761236-2742421261 +2827790660-2835001032 +1935288812-1941728417 +1726855325-1728050569 +1726544710-1727430469 +3940016790-3941936080 +546101318-552097193 +4184013882-4199809831 +2425846522-2426458497 +3361306788-3362865310 +453108094-456181406 +860613212-892862024 +362299769-362572315 +17407637-23147236 +3504547466-3505717615 +985733821-987978530 +2735458050-2740276231 +270737999-279345075 +1787997707-1795677405 +3680835944-3709667892 +3818408771-3825605323 +16201770-24236234 +1158649495-1176112357 +952141612-961131855 +2690399120-2697050905 +2837757591-2838004534 +3487101328-3501129288 +3888980907-3889308041 +3139002312-3144216973 +1812389934-1832528171 +4062104130-4081249321 +4109985868-4116611691 +261499681-305729049 +414982559-415941657 +2837715582-2837939443 +1612314605-1613532579 +1847293843-1854555869 +2048771211-2052518908 +701565294-713634431 +208666820-210559343 +2827420738-2834300681 +4141218867-4154796647 +1970845509-1978651442 +1552842250-1565110548 +412226938-422230809 +596789633-599083332 +571536075-580257978 +4162791979-4165315032 +2578608882-2600367385 +2953753655-2967704893 +1620638998-1623460191 +3652181866-3653081107 +1226734954-1263413684 +208300600-209821102 +3019452277-3019912348 +1614701447-1620638997 +3941936081-3996282520 +3237157247-3249234449 +2348186235-2349807460 +3562813382-3565898388 +3710261879-3738818624 +2629772693-2635508362 +2443958025-2447376004 +399974274-423562472 +1778846705-1790086524 +2234646109-2266729225 +1668227842-1689521646 +3549361830-3564965209 +1286877599-1288249900 +2117171419-2125943104 +3620689032-3652181864 +3299261942-3299688775 +1490791491-1514099208 +3817192749-3833336581 +3410915712-3429899072 +541342032-546429219 +918411171-924314929 +2182745019-2185607312 +2212606518-2214621946 +1779983196-1804748835 +1936162035-1950945741 +3704618658-3705051939 +1764680564-1778846703 +2698697285-2709059938 +1326793529-1329535111 +3702328552-3704015912 +2008848662-2015608293 +1231732813-1247626190 +1750754899-1752420348 +1093229127-1099058712 +4234037046-4236997947 +3493552026-3497919102 +3235053958-3252106974 +4018470466-4036608102 +701727470-719544055 +574115703-596179511 +3202587506-3210265222 +698102469-706160479 +1832528173-1833853020 +441673267-452453492 +2911169435-2921998083 +2229856423-2234646108 +2196901664-2204841238 +1675352425-1691381949 +4250455374-4250513503 +3237515102-3260318492 +171161905-175877664 +2581539215-2596898898 +4004311193-4012385537 +1324083574-1324546090 +4096883078-4097164771 +780817620-784569858 +208242283-211110211 +1330525084-1336070077 +4008229513-4009226682 +834427868-838848257 +348999024-350410733 +467200453-500728800 +4121379695-4138903168 +2949401565-2976409803 +3917170902-3926057375 +3071781061-3074945017 +3299433864-3300019479 +3894069601-3909653487 +3741129648-3770933677 +1337537272-1347157874 +216818049-245842326 +1626689836-1641152228 +1112292760-1131928222 +1651219196-1654305795 +506374440-513152599 +430626871-453108093 +3297525469-3306042698 +3256944-3556639 +2937659849-2949401563 +3915476081-3917349752 +170273133-170386354 +3896834322-3906255111 +2911101673-2912870470 +2383625542-2388030504 +2202988069-2215864531 +3931566185-3938787313 +3893325063-3903409791 +1677593295-1694860962 +1726429432-1726959531 +550814749-553019695 +328183437-332828273 +2463651684-2490928811 +2532315541-2561777512 +902393943-906380753 +3255012511-3262588157 +464031865-471880579 +987894291-990856994 +2994108099-3016224261 +1464668452-1468573067 +3817599599-3819192240 +4281205900-4284988083 +1610485824-1614835930 +2922504894-2943149643 +1366674588-1391544336 +2716673569-2724196148 +2136933960-2141630673 +952929934-954132488 +102430362-103410808 +1097408788-1102041819 +1411884657-1413275434 +1569519099-1595018443 +3314630119-3351858696 +1159063633-1161383669 +1306210365-1310168207 +65606761-70210379 +969367195-1005028750 +305729050-305810398 +2964351925-2968998528 +2586831864-2598752947 +2717800067-2732550815 +1357733985-1357970980 +3142078167-3146050939 +836110255-836394578 +2855830819-2865550532 +1854118661-1854889002 +3275779087-3291457029 +481061771-497879373 +2572567941-2573814074 +3653825904-3656453968 +1752420350-1764680563 +3381301699-3381332932 +1499205864-1508841960 +2568948534-2571512127 +124303608-171161904 +834540652-842353886 +3296634137-3297348568 +756487393-757398433 +2920277931-2929967348 +775003730-775425950 +4006843235-4009222380 +4173461462-4180792939 +2573814075-2627343871 +3379943605-3385769428 +3613135813-3622915872 +456181408-463675190 +1679128363-1689145745 +1771462652-1775663407 +3896043704-3896601721 +3668521412-3670169542 +3189676166-3211906595 +4178058206-4197742264 +649282356-651528503 +4118830219-4151607552 +3403081369-3405163204 +1295416035-1327421558 +3535003795-3540392660 +2521028658-2521094946 +3378794770-3384471028 +3876141848-3885724936 +3415436447-3434089766 +3236961463-3242080308 +1289735149-1320942247 +20583890-31053879 +2039793197-2062178184 +3361173897-3362649522 +476445996-491796622 +2305715287-2337252117 +1407865145-1413213862 +100343325-122125577 +4259473250-4260027959 +1539624652-1558856769 +3388893007-3406562225 +3815438953-3819219050 +88644450-100343323 +2838092965-2853295826 +2298582785-2308283977 +1911552487-1924425897 +3486137486-3495337804 +3087487707-3105123828 +2449249575-2459990446 +1114195378-1147840884 +3084130783-3090098247 +280604127-291812349 +251655795-252002640 +2065738411-2068050329 +3540392662-3561413701 +4108709270-4110339849 +185357325-191846357 +2988550972-3002922233 +2008583503-2009174592 +367514957-375053863 +3738337-5109287 +2068050330-2103854128 +2185761689-2201113375 +502979929-541342030 +437711847-441825502 +763342493-770307022 +3891568242-3896055908 +2771403009-2783873057 +857296477-865365400 +2372996602-2415318753 +209779549-212434153 +3904992626-3910219913 +2976409804-2983591595 +3614472-4019606 +3429649651-3432451145 +2312224052-2330392688 +3889124925-3889312068 +3368044346-3369236254 +2485542419-2506962662 +3703774963-3704692844 +249324444-259065356 +3038718563-3063082755 +2348008128-2348750596 +4027659985-4040018381 +4020167637-4028011463 +631597603-638907977 +156806924-163856510 +465625162-475575707 +1653345924-1655794173 +644029368-673749955 +1342645425-1348056082 +754961620-757509941 +2185607313-2229856421 +2430693014-2452320783 +2423618253-2423991135 +2578007008-2593849390 +251455290-252167220 +2141431440-2145256393 +461551382-490688234 +1280627802-1282187341 +2447416346-2448485092 +801034819-803950109 +3803801071-3817168598 +2791159575-2797552524 +2444538618-2447695611 +3656900217-3658497760 +362424586-362913246 +2315692184-2318703938 +2658294991-2705851874 +758225777-762221309 +3220097965-3253590560 +3918863154-3937848140 +3842601762-3867989792 +1362989964-1365638761 +2669543622-2698580716 +204441701-216667513 +3337068522-3351226708 +2910214082-2911637865 +2887286425-2894235722 +2556506098-2564781736 +3660974732-3670236178 +3738818625-3765658510 +3926612436-3931754899 +849660339-860613211 +3878152839-3882588354 +1198564716-1203493708 +90563967-91509385 +4113419274-4118830217 +2421569872-2430693012 +1380512818-1382191639 +2171495075-2182745017 +2346496816-2347982976 +2773187116-2776527627 +3264380514-3275779086 +2795335811-2807483836 +1255625643-1259049524 +3039851327-3062062714 +3477125643-3485106833 +368161721-385647773 +557063546-567450813 +2662245837-2698867380 +409471723-415008368 +2692399192-2709671522 +3289361982-3294593090 +2444382077-2446243156 +995864334-1008973852 +1485359185-1511483438 +3170296689-3173219013 +651528504-684359142 +2799805080-2819283989 +2745894337-2761860632 +4021069786-4034189388 +2423235028-2423776100 +1161581883-1172788321 +575303235-584246627 +1323324671-1324380624 +423562473-430626869 +3173219015-3207487851 +256367467-256655264 +2729359684-2736808477 +2979779055-2988550970 +1482720845-1491600385 +1057830454-1067468142 +107593407-117739880 +251911362-252150667 +3569934829-3575123572 +2241251261-2263701349 +2726382705-2727247227 +4037319554-4043150606 +3718405500-3739070428 +2364203325-2366532950 +836023031-836878401 +961131857-995864333 +3961933297-3977917454 +3180447251-3212824411 +3124189059-3126106003 +793312386-802938899 +3873230388-3877536365 +2841402828-2852690950 +2931754109-2946377103 +4097161122-4098833023 +2953494240-2963922968 +1016080923-1023809512 +2305965588-2325470268 +1726429959-1728139098 +1725984972-1746517984 +2280080557-2294404834 +1453817212-1468119920 +3343366097-3354792825 +2726120736-2727168410 +1726047629-1726491275 +2425599810-2428632507 +1127809348-1136655248 +784569859-830872706 +3362865312-3399674855 +467374870-490345878 +2028166733-2029296658 +3793434985-3799550158 +4113324238-4114378130 +2768224805-2776292356 +3076910664-3083853151 +3795367294-3799559727 +983334314-985924731 +2566325429-2567644886 +2079828370-2095628301 +1355677782-1357107425 +3139807-3256943 +2297016509-2339606996 +3937987517-3940016788 +3111594-3180044 +3408799234-3410915710 +2736163676-2737085107 +2927299659-2930923781 +2828368238-2835482134 +2924361649-2933817173 +3278336262-3282205864 +209200196-211114889 +1089312986-1101840140 +2426098602-2426594407 +3761524602-3771101074 +4038400571-4039718550 +4278817904-4281979539 +1971790010-1982080495 +2482451447-2482859303 +696142504-708558552 +832751897-838668629 +522885199-537712867 +3854296653-3860724814 +4250257176-4250870059 +1098058891-1101871591 +2041494246-2044474847 +3379302636-3380200608 +2823631138-2825091086 +3114946479-3141035176 +2564781738-2570503459 +3066648569-3072839529 +2963998950-2966815574 +3996282522-4010140708 +2609189498-2612898027 +1398040334-1399196426 +2705851875-2712491761 +3303896197-3307457131 +3072710194-3078315569 +2650750533-2658294989 +125494120-152726161 +1799712687-1813651344 +4113647358-4114354821 +914689746-931400632 +2334991623-2346496814 +952020939-952231689 +3279484720-3279924084 +826369329-829381680 +306371001-356731744 +2545936899-2562194811 +755902693-769100113 +2423872436-2428440493 +1040252532-1043084518 +2531373947-2564360722 +3758158314-3765326552 +250882458-253102421 +2445299323-2451474922 +2845734926-2859990778 +2571586320-2571725933 +4010140709-4018470464 +1397769785-1398762710 +3812038748-3819957572 +2446738279-2447892957 +3600527152-3609409007 +260284548-271403358 +108405773-115248353 +1910315960-1918268562 +1323436354-1327278720 +2234068374-2234384404 +982370550-984890793 +362487749-363332785 +3703404287-3704710600 +511536791-531472470 +1204860806-1211356557 +1280824569-1283027536 +1864956505-1865664159 +1264539978-1280627800 +838668630-849660337 +1039302291-1048802154 +3820162182-3829891468 +252725400-258978812 +3811611218-3815532558 +5584894-20583889 +2571534738-2571657850 +383938370-391077230 +732225856-735643042 +2968582589-2972324720 +2379822184-2380941432 +775813903-782941501 +836283753-836553990 +2786901143-2790325697 +2907911644-2910586722 +3879031171-3883342655 +2446835992-2450584620 +3604970524-3620689031 +3656986634-3664253237 +108870276-116802953 +50881441-82763196 +830872708-834595234 +948787824-952327285 +3554278607-3558372901 +1411483095-1443906338 +1305613100-1306576996 +1171167570-1175215348 +145365808-166164576 +3344972328-3354937927 +178346121-180017093 +3487950867-3498067707 +3455826248-3468331688 +1357654405-1361499079 +2373804146-2375708934 +1682091088-1685006321 +2532666674-2554100432 +3872534964-3888980905 +684359144-690072644 +31053881-36411395 +749479393-750957481 +1233001829-1257233242 +1109953682-1114195377 +175877666-185357324 +1283027537-1289735147 +3374715947-3381800912 +1283434504-1286474690 +1402640030-1423128613 +1426046568-1440437597 +3021217411-3028438706 +3449839444-3455646128 +2192814747-2207353667 +1039244541-1044508076 +363332786-399974272 +620349463-624462815 +3118427268-3142548507 +1177759665-1219332116 +1223070153-1264539977 +2469319931-2491726485 +1101840141-1109953680 +1048427340-1089312984 +2577948853-2584544199 +43965520-47689181 +1833568506-1857070652 +356731745-362276040 +4262722663-4294967295 +2632338905-2641519671 +0-3021649 +1148518671-1158649494 +3562116150-3562242974 +567450814-585792807 +198587645-249324442 +3756871898-3778510326 +2815453754-2821381182 +3562113904-3562138636 +2567358294-2571273144 +2061605698-2065382934 +1865301101-1870272543 +2565458232-2569021972 +267026988-275785393 +2570888765-2571620263 +179248341-180073497 +267066134-277088479 +2060654926-2062597974 +2065382936-2066893485 +3298704119-3299564801 +2194534845-2218883408 diff --git a/2016/day20/main.go b/2016/day20/main.go new file mode 100644 index 0000000..42e3cce --- /dev/null +++ b/2016/day20/main.go @@ -0,0 +1,87 @@ +package main + +import ( + "fmt" + "math" + "sort" + "strings" + + "../../" +) + +func main() { + part1 := aoc.ArgIsSet("-1") + justSort := aoc.ArgIsSet("-sort") + input := aoc.StdinToStringSlice() + var blacklists []Blacklist + for i := range input { + pts := strings.Split(input[i], "-") + st := aoc.Atoi(pts[0]) + end := aoc.Atoi(pts[1]) + blacklists = append(blacklists, *CreateBlacklist(st, end)) + } + sort.Sort(ByStart(blacklists)) + + // Just output the sorted blacklists + if justSort { + for i := range blacklists { + fmt.Print(blacklists[i].start, "-", blacklists[i].end, "\n") + } + return + } + + // Find the lowest non-blacklisted IP + if part1 { + fmt.Println(findLowest(blacklists)) + return + } + + // Count how many IPs are allowed + var numIps, blIdx, ip int + highestIp := int(math.Pow(2, 32)) + for ip <= highestIp { + if blIdx >= len(blacklists) { + break + } + if ip >= blacklists[blIdx].start { + if ip <= blacklists[blIdx].end { + ip = blacklists[blIdx].end + 1 + continue + } + blIdx++ + } else { + numIps++ + ip++ + } + } + + fmt.Println(numIps) +} + +func findLowest(blacklists []Blacklist) int { + var lowestIp int + for i := range blacklists { + if blacklists[i].hasIp(lowestIp) { + lowestIp = blacklists[i].end + 1 + } + } + return lowestIp +} + +type Blacklist struct { + start, end int +} + +func CreateBlacklist(st, end int) *Blacklist { + return &Blacklist{st, end} +} + +func (b *Blacklist) hasIp(inp int) bool { + return inp >= b.start && inp <= b.end +} + +type ByStart []Blacklist + +func (b ByStart) Len() int { return len(b) } +func (b ByStart) Swap(i, j int) { b[i], b[j] = b[j], b[i] } +func (b ByStart) Less(i, j int) bool { return b[i].start < b[j].start } diff --git a/2016/day20/problem b/2016/day20/problem new file mode 100644 index 0000000..b46f68c --- /dev/null +++ b/2016/day20/problem @@ -0,0 +1,49 @@ +Advent of Code + +--- Day 20: Firewall Rules --- + + You'd like to set up a small hidden computer here so you can use it to get back into the network later. However, the corporate firewall only allows communication with certain external + IP addresses. + + You've retrieved the list of blocked IPs from the firewall, but the list seems to be messy and poorly maintained, and it's not clear which IPs are allowed. Also, rather than being + written in dot-decimal notation, they are written as plain 32-bit integers, which can have any value from 0 through 4294967295, inclusive. + + For example, suppose only the values 0 through 9 were valid, and that you retrieved the following blacklist: + + 5-8 + 0-2 + 4-7 + + The blacklist specifies ranges of IPs (inclusive of both the start and end value) that are not allowed. Then, the only IPs that this firewall allows are 3 and 9, since those are the + only numbers not in any range. + + Given the list of blocked IPs you retrieved from the firewall (your puzzle input), what is the lowest-valued IP that is not blocked? + + Your puzzle answer was _______________. + +--- Part Two --- + + How many IPs are allowed by the blacklist? + + Your puzzle answer was _______________. + +References + + Visible links + . http://adventofcode.com/ + . http://adventofcode.com/2016/about + . http://adventofcode.com/2016/support + . http://adventofcode.com/2016/events + . http://adventofcode.com/2016/settings + . http://adventofcode.com/2016/auth/logout + . http://adventofcode.com/2016 + . http://adventofcode.com/2016 + . http://adventofcode.com/2016/leaderboard + . http://adventofcode.com/2016/stats + . http://adventofcode.com/2016/sponsors + . http://adventofcode.com/2016/sponsors + . https://en.wikipedia.org/wiki/IPv4#Addressing + . https://en.wikipedia.org/wiki/Dot-decimal_notation + . https://en.wikipedia.org/wiki/32-bit + . http://adventofcode.com/2016 + . http://adventofcode.com/2016/day/20/input diff --git a/helpers.go b/helpers.go index fcf236c..5e74900 100644 --- a/helpers.go +++ b/helpers.go @@ -75,6 +75,15 @@ func FileToBytes(fn string) []byte { return c } +func PrintProgress(curr, total int) { + pct := int(float64(curr)/float64(total)) * 100 + for i := 0; i < 100; i += 10 { + if pct > i { + fmt.Print(FillChar) + } + } +} + // Some character code stuff for prettier output const ( BorderNS = "\u2502"