From 248fd7c7be2c0d1304279f15b3b243838dfdd75e Mon Sep 17 00:00:00 2001 From: red Date: Mon, 25 Mar 2024 03:27:25 +0100 Subject: [PATCH] Year 2017: Day 01+02+03+04+05 --- ....code-snippets => advent-rs.code-snippets} | 22 + .vscode/settings.json | 4 + CHANGELOG.md | 11 + Cargo.toml | 5 +- NOTES_2017.md | 23 + README.md | 1 + benches/year_2017.rs | 91 ++ inputs/year_2017/day_01_input | 1 + inputs/year_2017/day_02_input | 16 + inputs/year_2017/day_03_input | 1 + inputs/year_2017/day_04_input | 512 ++++++++ inputs/year_2017/day_05_input | 1078 +++++++++++++++++ src/lib.rs | 2 + src/year_2017.rs | 64 + src/year_2017/day_01.rs | 63 + src/year_2017/day_02.rs | 65 + src/year_2017/day_03.rs | 81 ++ src/year_2017/day_04.rs | 65 + src/year_2017/day_05.rs | 56 + 19 files changed, 2160 insertions(+), 1 deletion(-) rename .vscode/{new_day.code-snippets => advent-rs.code-snippets} (74%) create mode 100644 NOTES_2017.md create mode 100644 benches/year_2017.rs create mode 100644 inputs/year_2017/day_01_input create mode 100644 inputs/year_2017/day_02_input create mode 100644 inputs/year_2017/day_03_input create mode 100644 inputs/year_2017/day_04_input create mode 100644 inputs/year_2017/day_05_input create mode 100644 src/year_2017.rs create mode 100644 src/year_2017/day_01.rs create mode 100644 src/year_2017/day_02.rs create mode 100644 src/year_2017/day_03.rs create mode 100644 src/year_2017/day_04.rs create mode 100644 src/year_2017/day_05.rs diff --git a/.vscode/new_day.code-snippets b/.vscode/advent-rs.code-snippets similarity index 74% rename from .vscode/new_day.code-snippets rename to .vscode/advent-rs.code-snippets index 28debdb..d384361 100644 --- a/.vscode/new_day.code-snippets +++ b/.vscode/advent-rs.code-snippets @@ -15,6 +15,28 @@ // ], // "description": "Log output to console" // } + "New year": { + "scope": "rust", + "prefix": "create_year_", + "body": [ + "//! Year ${1:year_number}", + "//!", + "#![doc = include_str!(\"../NOTES_${1:year_number}.md\")]", + "", + "pub mod day_01;", + "", + "pub fn solve(day: u8, part: u8, input: impl Into) -> Option {", + " if part != 1 && part != 2 {", + " return None;", + " }", + "", + " match day {", + " 1 => Some(day_01::day_01(part, input).to_string()),", + " _ => None,", + " }", + "}", + ] + }, "New day": { "scope": "rust", "prefix": "create_day_", diff --git a/.vscode/settings.json b/.vscode/settings.json index 23119fb..042da5a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,10 @@ "inputs/year_*/day_*_input": true }, "rust-analyzer.linkedProjects": [ + "./Cargo.toml", + "./Cargo.toml", + "./Cargo.toml", + "./Cargo.toml", "./Cargo.toml" ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 85c5869..ba68edf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,17 @@ Of note: - The changelog 2015.5.2 has been rewritten from each commit content. - This file may be amended entirely in the future to adhere to the [GNU Changelog style](https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html#Style-of-Change-Logs) +## [2017.5.1] +### Added +- Solved [exercice for 2017, day 01](src/year_2017/01.rs). +- Solved [exercice for 2017, day 02](src/year_2017/02.rs). +- Solved [exercice for 2017, day 03](src/year_2017/03.rs). +- Solved [exercice for 2017, day 04](src/year_2017/04.rs). +- Solved [exercice for 2017, day 05](src/year_2017/05.rs). +### Changes +- Benchmarks (at least for 2017) now use `assert_eq!` to ensure that changes I do to optimize runtime don't end up breaking tests. +- More tests, more optimisations,... + ## [2016.25.2] ### Changed - Used [rust-clippy](https://github.com/rust-lang/rust-clippy) to lint more. diff --git a/Cargo.toml b/Cargo.toml index 0416fb5..ee7ddf2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "advent-rs" -version = "2016.25.2" +version = "2017.5.1" edition = "2021" authors = ["Arnaud 'red' Rouyer"] readme = "README.md" @@ -46,6 +46,9 @@ harness = false name = "year_2016" harness = false [[bench]] +name = "year_2017" +harness = false +[[bench]] name = "year_2015_day_01" harness = false [[bench]] diff --git a/NOTES_2017.md b/NOTES_2017.md new file mode 100644 index 0000000..530368a --- /dev/null +++ b/NOTES_2017.md @@ -0,0 +1,23 @@ +## Day 01: Inverse Captcha + +Welcome to another year. First day isn't too complicated, and the only play here is to avoid iterating more than once over a string. + +## Day 02: Corruption Checksum + +Nothing too hard either, if you know how iterations work. In that case, it's FASTER to only iterate once and store the `min` and `max` as you go along, rather than iterating, collecting, and iterating again to gain the `min`, then iterating once more to gain the `max`. + +As for part 2, it's better to use `filter_map()` instead of chaining `filter` then `map` since our verification is based on doing a (costy) calculation. + +## Day 03: Spiral Memory + +Now we are getting somewhere! + +Again, half the battle is knowing exactly what to really look for. While part 2 DOES force us to iterate through the field until we get to a result, part one can be solved by understaing you are faced with an [Ulam Spiral](https://en.wikipedia.org/wiki/Ulam_spiral). From there, a little Google can get you [prettY](https://oeis.org/A268038) [eXciting](https://oeis.org/A268038) [results](https://stackoverflow.com/a/61253346). + +## Day 04: High-Entropy Passphrases + +Knowing how to use iterators properly is often the key to winning. + +## Day 05: A Maze of Twisty Trampolines, All Alike + +I was expecting more difficulty here. diff --git a/README.md b/README.md index cbb05d4..e135260 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ As I said, [Consistency is hard](https://github.com/joshleaves/advent-rb), and I I'm also adding notes that may be useful if you're (like me) discovering Rust: - [2015, complete!](NOTES_2015.md) - [2016, complete!](NOTES_2016.md) +- [2017, up to day 05](NOTES_2017.md) # Regarding style rules I'm gonna use a mix of what `cargo fmt` does, with some stuff that feels more natural to me. diff --git a/benches/year_2017.rs b/benches/year_2017.rs new file mode 100644 index 0000000..874a96b --- /dev/null +++ b/benches/year_2017.rs @@ -0,0 +1,91 @@ +use advent_rs::year_2017::day_01; +use advent_rs::year_2017::day_02; +use advent_rs::year_2017::day_03; +use advent_rs::year_2017::day_04; +use advent_rs::year_2017::day_05; +use criterion::{black_box, criterion_group, criterion_main, Criterion}; + +fn year_2017_day_01(c: &mut Criterion) { + let mut g2017_day_01 = c.benchmark_group("year_2017::day_01"); + let input_year_2017_day_01 = include_str!("../inputs/year_2017/day_01_input"); + g2017_day_01.bench_function("year_2017::day_01_v1", |b| { + b.iter(|| assert_eq!(1_069, day_01::day_01_v1(black_box(input_year_2017_day_01)))) + }); + g2017_day_01.bench_function("year_2017::day_01_v2", |b| { + b.iter(|| assert_eq!(1_268, day_01::day_01_v2(black_box(input_year_2017_day_01)))) + }); + g2017_day_01.finish(); +} + +fn year_2017_day_02(c: &mut Criterion) { + let mut g2017_day_02 = c.benchmark_group("year_2017::day_02"); + let input_year_2017_day_02 = include_str!("../inputs/year_2017/day_02_input"); + g2017_day_02.bench_function("year_2017::day_02_v1", |b| { + b.iter(|| assert_eq!(53_978, day_02::day_02_v1(black_box(input_year_2017_day_02)))) + }); + g2017_day_02.bench_function("year_2017::day_02_v2", |b| { + b.iter(|| assert_eq!(314, day_02::day_02_v2(black_box(input_year_2017_day_02)))) + }); + g2017_day_02.finish(); +} + +fn year_2017_day_03(c: &mut Criterion) { + let mut g2017_day_03 = c.benchmark_group("year_2017::day_03"); + let input_year_2017_day_03 = include_str!("../inputs/year_2017/day_03_input"); + g2017_day_03.bench_function("year_2017::day_03_v1", |b| { + b.iter(|| assert_eq!(552, day_03::day_03_v1(black_box(input_year_2017_day_03)))) + }); + g2017_day_03.bench_function("year_2017::day_03_v2", |b| { + b.iter(|| { + assert_eq!( + 330_785, + day_03::day_03_v2(black_box(input_year_2017_day_03)) + ) + }) + }); + g2017_day_03.finish(); +} + +fn year_2017_day_04(c: &mut Criterion) { + let mut g2017_day_04 = c.benchmark_group("year_2017::day_04"); + let input_year_2017_day_04 = include_str!("../inputs/year_2017/day_04_input"); + g2017_day_04.bench_function("year_2017::day_04_v1", |b| { + b.iter(|| assert_eq!(466, day_04::day_04_v1(black_box(input_year_2017_day_04)))) + }); + g2017_day_04.bench_function("year_2017::day_04_v2", |b| { + b.iter(|| assert_eq!(251, day_04::day_04_v2(black_box(input_year_2017_day_04)))) + }); + g2017_day_04.finish(); +} + +fn year_2017_day_05(c: &mut Criterion) { + let mut g2017_day_05 = c.benchmark_group("year_2017::day_05"); + let input_year_2017_day_05 = include_str!("../inputs/year_2017/day_05_input"); + g2017_day_05.bench_function("year_2017::day_05_v1", |b| { + b.iter(|| { + assert_eq!( + 373_160, + day_05::day_05_v1(black_box(input_year_2017_day_05)) + ) + }) + }); + g2017_day_05.bench_function("year_2017::day_05_v2", |b| { + b.iter(|| { + assert_eq!( + 26_395_586, + day_05::day_05_v2(black_box(input_year_2017_day_05)) + ) + }) + }); + g2017_day_05.finish(); +} + +criterion_group!( + benches, + year_2017_day_01, + year_2017_day_02, + year_2017_day_03, + year_2017_day_04, + year_2017_day_05 +); +criterion_main!(benches); diff --git a/inputs/year_2017/day_01_input b/inputs/year_2017/day_01_input new file mode 100644 index 0000000..cee6ad9 --- /dev/null +++ b/inputs/year_2017/day_01_input @@ -0,0 +1 @@ +36743676522426214741687639282183216978128565594112364817283598621384839756628424146779311928318383597235968644687665159591573413233616717112157752469191845757712928347624726438516211153946892241449523148419426259291788938621886334734497823163281389389853675932246734153563861233894952657625868415432316155487242813798425779743561987563734944962846865263722712768674838244444385768568489842989878163655771847362656153372265945464128668412439248966939398765446171855144544285463517258749813731314365947372548811434646381595273172982466142248474238762554858654679415418693478512641864168398722199638775667744977941183772494538685398862344164521446115925528534491788728448668455349588972443295391385389551783289417349823383324748411689198219329996666752251815562522759374542652969147696419669914534586732436912798519697722586795746371697338416716842214313393228587413399534716394984183943123375517819622837972796431166264646432893478557659387795573234889141897313158457637142238315327877493994933514112645586351127139429281675912366669475931711974332271368287413985682374943195886455927839573986464555141679291998645936683639162588375974549467767623463935561847869527383395278248952314792112113126231246742753119748113828843917812547224498319849947517745625844819175973986843636628414965664466582172419197227695368492433353199233558872319529626825788288176275546566474824257336863977574347328469153319428883748696399544974133392589823343773897313173336568883385364166336362398636684459886283964242249228938383219255513996468586953519638111599935229115228837559242752925943653623682985576323929415445443378189472782454958232341986626791182861644112974418239286486722654442144851173538756859647218768134572858331849543266169672745221391659363674921469481143686952478771714585793322926824623482923579986434741714167134346384551362664177865452895348948953472328966995731169672573555621939584872187999325322327893336736611929752613241935211664248961527687778371971259654541239471766714469122213793348414477789271187324629397292446879752673 diff --git a/inputs/year_2017/day_02_input b/inputs/year_2017/day_02_input new file mode 100644 index 0000000..812761e --- /dev/null +++ b/inputs/year_2017/day_02_input @@ -0,0 +1,16 @@ +1919 2959 82 507 3219 239 3494 1440 3107 259 3544 683 207 562 276 2963 +587 878 229 2465 2575 1367 2017 154 152 157 2420 2480 138 2512 2605 876 +744 6916 1853 1044 2831 4797 213 4874 187 6051 6086 7768 5571 6203 247 285 +1210 1207 1130 116 1141 563 1056 155 227 1085 697 735 192 1236 1065 156 +682 883 187 307 269 673 290 693 199 132 505 206 231 200 760 612 +1520 95 1664 1256 685 1446 253 88 92 313 754 1402 734 716 342 107 +146 1169 159 3045 163 3192 1543 312 161 3504 3346 3231 771 3430 3355 3537 +177 2129 3507 3635 2588 3735 3130 980 324 266 1130 3753 175 229 517 3893 +4532 164 191 5169 4960 3349 3784 3130 5348 5036 2110 151 5356 193 1380 3580 +2544 3199 3284 3009 3400 953 3344 3513 102 1532 161 143 2172 2845 136 2092 +194 5189 3610 4019 210 256 5178 4485 5815 5329 5457 248 5204 4863 5880 3754 +3140 4431 4534 4782 3043 209 216 5209 174 161 3313 5046 1160 160 4036 111 +2533 140 4383 1581 139 141 2151 2104 2753 4524 4712 866 3338 2189 116 4677 +1240 45 254 1008 1186 306 633 1232 1457 808 248 1166 775 1418 1175 287 +851 132 939 1563 539 1351 1147 117 1484 100 123 490 152 798 1476 543 +1158 2832 697 113 121 397 1508 118 2181 2122 809 2917 134 2824 3154 2791 diff --git a/inputs/year_2017/day_03_input b/inputs/year_2017/day_03_input new file mode 100644 index 0000000..ce15bc4 --- /dev/null +++ b/inputs/year_2017/day_03_input @@ -0,0 +1 @@ +325489 diff --git a/inputs/year_2017/day_04_input b/inputs/year_2017/day_04_input new file mode 100644 index 0000000..bf3fffb --- /dev/null +++ b/inputs/year_2017/day_04_input @@ -0,0 +1,512 @@ +pphsv ojtou brvhsj cer ntfhlra udeh ccgtyzc zoyzmh jum lugbnk +vxjnf fzqitnj uyfck blnl impo kxoow nngd worcm bdesehw +caibh nfuk kfnu llfdbz uxjty yxjut jcea +qiho qif eupwww avyglnj nxzotsu hio lws +xjty usocjsh pivk qnknunc yjcgh bwya djw zpyr +ycfmfe mgq sjiomg nfzjul bjwkmgu yvsnvgj dcjupu wzz blmn +rdowgbt vpwfdoi blzl laghnk gsa vhnpo cztxzlb rtz hvwonhb eciju pfjtbo +bqs bqs dbutvgf mmzb izpyud rap izpyud xlzeb mnj hjncs +xpu vwp nujcos piu irindir tpmfd umtvlm gznu +sfpuxar qcnbte omouazv cnh uaxspfr sepolf rusafpx +xbmaf iceyqqq sabpt gliexel muubepe qqiyqce fmrcc eazk obkeonl fmccr kgk +apg gbycwe gap pag +gagv saqbk lwtllc wnhzz khxsjc +lgc alen rlmsp anel gcbvg +bujlaz rks rlqf deknmee yrp +scqvl weusbc bgvaz vgg cjwsfno vqy zbq aqy tvf bgzav +hbki vei fxdwljs myjuba elbsib pvy xxjxgi dtgv +linzaeu qbwdke fdg pykw +qvtdd aco aav bpu mvkcuc kjfj japgfki jfdl gem hog bdzsiea +wpbigkb lzhwba jssjkn qvb kmwu qddv +iny osyvqnt tumunzb torq bdeneg wywank poza ipp iggorw +tuko mhdbsf vmjdop jomaqpj rcdsud hmgspr lsas nzmwc +cirkjq nmjuu xtgejv gtexvj vjcmtqq unjmu +xsdmezq xvqjvqp exhygy qahju hvd qadmdh lok +wvvys kax rohrrar rwhnvi lhnmefp lsktouy bxilosp +wayf diobnl zvu obnidl oibnld +cewil ygsf ffzp ruxhu vah lnvwt aef lnnjc kgkb gxtlx feko +uti epphrin pywths cpzzh csjei nczhamy gayxmb bdcytq xkx fgmt +qvzyuwi dwo swkw bwjdrn dasgd ijgw vzabaop yefyhmc wgij +dyg sugrf vid etz weyqg nyntx dwfgwm khon hnzzzn xfyra +ofbh bdrsk rdrjj elaxvk jrjdr +msxau rsocvx zxdda mxz lknl +qktaywx dirpdbf unqnd wbrwkuu fvmqwl emxr big +xwz kvsydc ayokjyy qiah omw neo htltxx fxhwqwj colqvbb sxmo ephfkex +ncjxoaf fwjkc czmhv ylg axcjofn dvj bzqjku opvcr jiwzucg vmhzc +gmmnrt zqar twdwrg qiwwki fcbr lixm hjdwwe moiva +roinlxg cxeezve whannk cxeezve pyoj boweioy cpkgxsz +qkct qso xlb xyy aellfet rzt cbboow devfb nih fhbfxzi +qyc ltxia alixt atilx xtgrv +svruz ufvo rvesnxv dik vzurs jjg idk +xeudhrg hudn cilo ljplosb +kpb oyzvywx vldko qhfkwod bkeutk zqcqug pbriu wqocos +qkngzfy whobyri aze jvipdty ocirbep icqwc +kzxxlab sjr zhymws xkbx +nnxs gkwtld dwhkry snuibq dtdl aicug bhtlfzp qzk jctos +regvro mxcq hqof yraucxi jhkol iuxineo pbtnk rfjwc szgjpr ndqqj vfgm +yqrfox xoqrfy utbryu utubyr +jdubjt wqrl wnk rlqw nwiq pnbn qinw uaff ftdo htfrav +rum mur umr tij ovbahl losao imawwpb wadhww tbteyqc +napxd kzeiqcp ppgqucm xkityt frq hugrp gjgtt gmuqppc zwqme +xyuzs ysch howlzgu dkqppbs nvbiz mks mtxv vivouex uvawq +ffe lfsn nlq mpulheq ikcfo wdtz cnwsbph zkib muu +bqkxav wtecb lxwdhr kqbavx aqxvbk +czwswqx ldkxapd pfwd bdkkj iqohla cwosw ihqpd pcc ckhabbn +foiip hau rbqiyhh htm omeubgh symh evfcqg +lqx xlq rsgf izu esetis +npsrkdj fvulgkw eovw mzr uobcze azb tij ihoer ehori jit wknsqhm +gnrksh xwggt oosi bpnmhx qqaa mpmryu jhzyz +yad gbexqcr gbexqcr gbexqcr +ldca xxhznn twyy ytwy zhxnnx xfmpi +floioot kfyh dhibv ezyznar sfg sfg ezyznar +cinioim iiocmin ypla aypl +mhwcjbz dftuqsy wswop eizbf ptsd +ehx mlh nfxgfkz uuw xftmn ptlkbo vsnyo ttwce +oexvf orcg cncnkfk comvhl +lqewsj lyulrcl efixd qvd fhznqnz yvrkwyi xmhgc vzbp +dmr wrxqh thcm giomp rtvl ssc gwq rbklw hcmt fjvud +teozhb dmzwfv qkq pvcqfqq +hvlebc qqmg repxk zwrjdx ztruwb such tyligs ybg +psa rqznokd lgc jstqres yiqt mbiody xazb xjuk dtb +lea ncm rnh myzqzwm +wjml eums ueflvbr cjpgnl qduunu zfxaai jwlm lprzzg vrn ttetyr sume +uwkgeu uiahd plyewgi vveo nwhsitz mcitc uvk zsxehgs sewl +lnbdrka sgtivn sozzq mgd vhxfnlr twrfpk +gadphmk mbx lmlbrf tsnehnr lawdpm fnima gxgl +umty vrn dpow fsnnpjv fsnvnjp nnsvpjf cioaio +euu uue zeskmtk hob stekkzm +ypqpri qwdju ypriqp iprqyp jnoxqa +lkppi ingfxw wlulvp yhwrli nxwigf oyuhq ggfslx +kdd ypvr pyvr waw vyrp khqq mamxca bapq gobfm +iuq upvdpv zxef bfwns lmq lxswr kpsqo pwde iaaou nsw udy +lgzo nil ovgrmt omgtrv jrqp pqrj lit +uumyu iiakfj gvdtzz qbux yxn ejs dvlts +hcm ghutxq zswi tmyhqef hgxtuq +shkhkdk kad seubeax kdl mzu +cpykgr skx rfhpor xsk moyhlai ogv ophfrr dxipuuh +beyw jvrre opodn zdoajhx fhg ijs drczy drczy hjungq +jrzieja gfg yzdn yxm wshibsn fgg +xtylh vxscmvp rfymq uzhpyea spxcmvv dlni msj yxhlt +eov awql miv miv eov +mmvrfbg fjiyf hvqz zpuqmbf fszyuz ldfgni wemfjl fjjpl rbnpy rfb +ppzpeh nam ntv xnchtyk hja hpepzp foj bibvx nmmdlff bsrkp +qiy qiy umhlnh qiy +tyds oepk wae tdsy sdty +ukawr rkwau ghtjhm axy +wtbjiv btjivw ewaf hwk ttq +kdpun myve sqv rhvpy fnjwt puw ujhf thsp nkdadqr +vyw wkkpdpy xlgz lmmcuve ncuq lmotk +pmsfw vxd jpe qxlyasx ejp gwuv +pmgyndm ezofbvx nicbwrw kwnlj yjvnas fdpkfo mqcsyhn pyjpf fbexvzo vkftm erl +trmwvk rywuzoz hbidea kicohfz heidab deaibh +sogf govd dknpk vxrvk rlm vwhjk +xnxbfmw wguzrhd zbmkz piwppa mkbzz xvwrdgy flusfqb +cgduq hbnwr xfx mrejb ckw zkbaihf cloow cwk wuvthv iwqctx +vugx qbucd gxuv ocb cob +ilmet fbelxxz qratdfn unoj hbc duv srmikz +vnzuw zgpbqgf uzm thysyxd dinfh bgvr olungg ksd dsetwqz hpg +omagsf zpr coa kknx bzithq pewp flvoz xiiq weojqr wpep +aagj gcglqt gqcglt xbfx dhdx lbx +pljq plxuscw ilh wfk lhi hli fouieyw +hvnh zvm aqy dzitirm veq ctux +lglhs aqibdii hjbn cfgc qrg pnbntcx owoks ebz +jozngde lwne mbo omb fnyzvvj gndozje +bbdgc igtdj uhahgp sqduko +uuspedu fgnspm ewc slly jbs chl heanm abqijx kadvgxu +akfsft skna kusjqr rkqujs +erc vrljpu lruvjp lpvjur +iors hcdr fsqtcj vop vmn dtqnz tov oscjlw cdrh ctfjsq lrnts +fxp mczo sjlcxa mzoc jmsq hcxybow dmrr bcoxhyw +aac ewraerq odmxpz aac aac +zzio zebmxa szeej poordr gmi owwnnh xfx rzrab lfey jesze +akc yyoj vqod drtne +joxhvyf ymasnbr omouvq isxdrr +qyi ayrkzu jsk vqvvno jkkuxi zufnnwu mrsszdf +ocqi htfb tzjna cdt wkzhynm eergf +yokzugl usyuqu qvotq uweqyow lygkzuo kpmqmb uglyzok +glvshl imqv jrv xlpnsy gcg psj irtiamg wkl +bjcpc nvyloa dkkan efj okubpc cxlowm eone kmpny +cyxqys nmuaftv gqxj gtvsc +beouh dioxiah kizdy hyi cozrray rave fqxmxmj gdm +frjz amrsat lxvhzj azhevtu vxlzhj +zwmnrk sbk txzrcsj sbk oosgfej cvh zuthibi onvwd sbk nhwpzq +gzamt vraw kuk ugayl lyaug bww rwav ijah +bdjirxg vifjr rhbxpa oao yrhjxoi pbn +navb umesiys yhix phuhu aekkciu nlnsiq wjf idqdwp +cmhw rsu urs ziprlfe +kyhxitv cgty bnwjyq cygt sgjn pdab imarvhg yjbnqw +axaa ejancv yau njpc jvwy bpft kwjvg qzrbvtm diu njpc bpft +ambj upe rmqr yudbiqf krudp pqyf +tnb mobnpv vep ohxoc cyip wxyccfo jrbi rwsws kls zlv oohxc +fjh dmb hlbq bqc jhf kax suz fjjg rkpc +wjnn byfirm goeyh xtjmdka +tgyfxx hefpxln mveobqr yeo ftfn srt vim vlcu hevoi xtaaff +imyql xotcl poql rlueapq bkwykm hlalk bkwykm +gkec zff hbmtq rjxjbcf arerlu pvz cdaqi nijmhv uodwjh +mpctof mopftc ksfbat sbkatf +nvdd jub bvi kyggdbx nwtiok gjt mgsm dbhsn rzibgjm dvdn eqi +ysd iirp dfgzza wiyeoou ysd ispkv bcqg wwzqgq xphse +ntq ivposb gsd ezl tlkztp lez qyurp vxsmg dgs +wijs rydbj onm usiyqzb hwrol giusanb kewukl yziuqbs doojam nom +lfacyy xwwast truqtt tzneimn uxsydc ktu eqyaj ndszak +ffleooc kikif fohgop aucy moubqxu +iaxc pnwexdl ncy vmwm xrqoi wpgftq rofx utyzjuf stdxq twpgfq +ppmlp etsvi cjdx poly ynx vfxpslg mqjo qnpsage flpsxvg jwsxiqt +lbyhnb kflrpeq ssoti webxr embbjd kbnx ubzqco +khhc vwuqzb ebocbko rwmonkz edfqn hzh qhncoq gbwdi wjeg ocwow +ghzhd kcxblp lzwkkr gzhdh umk pblcxk +wyajtw jiff ouylv sni lwhlrg avqjiis igzx wbl lhrwgl +glhh kaxha tqii hwzx rgic kaxha rgyidmt qdgxfl ynjc oibfij +bapj bix rjniw ynbql idlvnmt wynpzbl zlpuoix kvn kakwys +aldpxxu iojxp rif xbyqtr jffdvy qnrq tqwsdiu +ulssco ktbymjw bfj zhkg zgc ctyri +ilrmq wfahcgk mrlqi bguad inj +cjzc rekuy ifr wfkg sple +cvjkp qbmumnp mprg ltmwxxh zpemtyb ozzssfd ksu mgrp +nvc sxp mpkxz bhlctq hguaa yrdkm iwsgfg qjssh gobbies hucdh +jdxrjw qmo qmo vobhnu +dnjib wtjp rfdjqdj skpvrb vkwevb kxxovp +fzi kicta zkuvr rfaawv ehklq cfdjsyb tukahwr zkuvr kicta ouq +aba ytdguk gqmpn hvxabff hvxabff dckj +fna wxyqhxd hvy khsu yypoyy lvvue medheua gim slf drdbeh ikihf +jquz wwo wwo ghlz jrbvb jrbvb +jwzvkl yjw ouwla yjw ouwla +zsvlgyf rzqbtj qygynem ukdgjm lbsyh tmdzp fbcaim eymzr +pvw sbs dvsa plmepl pwv ayxk vpw dwt +inayadn pnti yzhxk azga gxq aznbciu gjnmyqm +isgf ndqmk beyqq ebyqq srtzxo aiiw oqfuwp uoqwfp buejctv pxbk +pzl irv tzvzdb wcy eszm ybwiw ycw riizifd iybww +btpu cua azzqffy owcr +ofwq sqlpzat lozdxlc aevjmpc lcolzxd wbbysn qwfo vcrx gdzgi +dbpfmxu ydsxwl ijn svxtop csep ldqeog ffye zcrl soh aclw +wyiyyhv vyhiywy obgi hiyywvy +ddvaoc lhv spurn rgxyy onjw illvn yryxg xyyrg +vid wdttqq kajr myip +wolqlue phlunpt dcmmkfm sgxk dmmckmf sfng jlbsntq dxp +zmneyho fswj xdgsjc oefwjdi htgxvbd tgqrq xodoa +ynw bygqdnh hhmnkuw cojqrke qszzdjo orskwq mdfae asabn +vvpm vkj pcxghao caoxphg axhblxb vvmp +txox nzy eqn zgir dytsi girz ffa ugjjbzj brob fll +kbz pukqbd fiwmuh umwihf bkz dvz +vgs vejs vejs vejs mbkyjjy +viqmnmu bitkyw nddnk dknnd cldnpp hipub plcdpn fdzzpb mmyomn +ndylnfx gozlrx ngptk rnpteb wtacx xmtcjy xldha +fey doyxis ampmtr ycqh syw cqhlj hnngx +dijf nac tvkq ayo akbj lzmngdm wfxpn bpyvrf cvdqpa +zsofz lhho hgat wqskga mnt +mylwm zxsd omzpa waz hcrr lxmpq jsw sqtwak pzoma +rwhgsgt ysdq ztihici mpwcawv alkqg wsxiwx +snldn bcb anjdv cbb awsscc cqxult hjmjew mcycb fdpdg sesrh +kukrqm fawafz qdim wyobtqx bnvjnqg dcvqxta yptr nnpu ughldqp duo zafwaf +knb yjqb bscpnt nzg sqeu zkahna ttuf nsbtpc ixwit vucwj idix +bfqyx xlnpc ijrxu zkqi kjxtahr fgag orusms adi bfqyx bfqyx +dqddc ncbv bvfk hefikb dqddc hqjl otpx zfiu +ntkv qunrzx eztzure ctt rjo bkdt znvd jwdf gqhf mmhrzgt +zeavm hkbf rawqwuf pis dojlkt vnjhmi uvk cufmn qginezd xyut +hnidzk chlctc yst pepd dxntbxg vqk daxfpmu wshyddl +jgd vesqgo bdyqy igl ahstdm wjtd lrtkjsv tjsj sccxbih esn gkkzj +iisiswh jll rhlaf jqwwgfa wmhyo izva vrg zjkak nlxxfer rvhx +mkrkd jlqtpy ukstro ktuors wsj ynqpbp kpiyxzv nxeiwg xpzvkiy +jbr gnct fwklekg cmfqnm ctn gqobrs kwht +pztmjs yiffc kfhsblx yiffc yiffc +biezil iiezbl bzeiil smocoju +viiigm gmmmk yeiv dxzogro qsmzsur hukzwjn lcle syo mdj uruf rxfseu +extchsd adeff ouikoj fyaclr rwwvqsd dooe tcxheds zrdqqhm fdoxv kbxi tlcj +aycnydq qlxhka zoi shplo qll +bfry lbwckm ltq rbfy gpn vojp ruj dpxcve geq +svtvfwh lca lac qia vhwsftv nookdfz xgjiaf yvcdlt +aspgqym fryuzhx bbydf tbn bwutsc fqgi zij lmxhog qnmse +rbb gsys volnas onvlas lonasv vwjdso lnteapy +got iauk kficn jvfuy yvoe jcxwui hyamqx mke mwh jcxwui hyamqx +avutfi ggmha dkopc kothnnb syoi xsd wjedywy +oziejyz yzeijoz hnthyn knj juuq qujtp kgq bymlnlf yicf +zsejuy dybeap hvowmvn okxb yoi epadby cnzjk xfwprzc +lacg iiix fblhxvf nrkkol lnafzw qspzsn gvdy ipj zub uouseo +evukwkh ycjxxc lptwmf pmd izxdsos zrkavf pgjoy zwokg mpjiej +vqw ijwoy eaw wvq svmcq ccxi nyub ynlq eqornax uprt pygfe +plue okbbm btvm gba kutn jacjx ysqt lvx pcxxu qcf +pyw ffjfudq bvk hsdwdva fjnivhf odbmw krpgrj +hziesm bxa dceiwt tmvivjk snl fkh dahsxyx kqlhak lurtk +xss sswyxrg yqff dbkx kbxd mpzbmnl bzplnmm +uvz pjm ilrol pmj uzct ztcu brhkv +heiz jcn syjt zfvlvaq aflvqvz amcjh rxnitw +cxl nxvrn vjnz aewtr cxtko nnvcp ltptd adpxt zvjn fntklj +aymmm tuirj hzngq zhbh paqs kvpfo aqsp kmo acprw sabrso kdqmp +ndqjspv mmhp pndjsvq rti usm +ije oad mvelyg jadz ekm dao zdcmv +qwww tmwmdbb oxxfoza rgmf eonku brh gcgiuoi ojscn +fjedeek ohlax fiydku rbnxpg wfivg cdgs +axwbni hojye mwfe oyqknxp whdgfy ihku mbhr gagnz hehagxj +hibautd blnayq lnayqb gepml mgpel qunw +ircx oeb kujtip zbu ebo cmmn +upyqvot wbponp hnn vav avv tvrky omm +yzqsnf agbfsw dbxoya sfnqzy hqrxek qsnyzf oagyerm xxhukm +xzvk mvcwz oujr hell hoe xexa dqlpqt xdqz ucola hsvv tcmybhl +skldxr mzyol ybzyzd jnnxb rxncdy nkpwy fwlnsw omylz oiwieu fshv ngvha +jkwqf yxrox hejfoq orxyx +rijken xiwf mawqcfu erinjk jsi yyg mmu mdkfqb +ornjes krp eornjs enjros pyqp nnwwjl +wzd uqqo kyeli tikdle aykdjog uiz rbpnw mjxezf ihiz rlgyg +cjm ajqgvkz kfgyy dmczlc mjc kxcm zctyqgh ymsk jwhqfd czpqgan +vxkzvco owo qogj uyictoj kfr pyoo ejrru npluynx bvv jhhzu kuciwc +eqk pcsly kelu arzgoe trfo fotr cuaax +lagonw qvcssqz sdoklh uvovi sfrkmd hnvafj ltg wfjj +viwbkm hpwe kzzwrbr axjtlq mznin wwpjg unlwur +nuzorgo qfoz ydisca qxdfutv hzg +nqgge tobtt hjocx ntyqyi rxzkynw wrnxzyk ciscy trjt ottbt +yuii srawx gljxe eteogz kcu jlgxe tjik ktsnp agudqok jwol vfnyv +vgicg dhnrmxz sjhozy hlalx rutwq +nyoyoje kco hoyam hoyam tta iflud amh gdxcsj vqr fvsqcgv +xdmbtph ueen cskerl rxjvpdc +nricn addljzg obq rikez igq bxygkmv qmgojou uheubk qor +snzd ztusvr vrstzu mceddga hgu +vvrbfjg mcdhmsf ldtwl otuna gmjurrx jgrurxm rxmurjg yrioq +iotkvo sftfvn vvoit lllju xvlg rdsb ywmdf mzxigu kzq +sgqw gqsw lqfu wgqs xpiwou jurgucd azq wgaqpm +ijntzi chlnfj yjqatz hjflcn vys ofq oqf oadthe jrfw +mmc motjo vcwmod rpaszfk zgkkua bpja vjb htrk +bpfvvka kmger mnvvfl hakudy yfprdoo mvnlfv rgmek evnwg +mykpu juavkn cecdvi aszbi lxm hmps oaqoif +fshizd fsdzhi lvcq hhpb eavwno auqlwz rpv owcdojx amsmf qgnddd +pohmcn hlcxk qsesxh rncr +fgyrsis ldem avxmnh frpodq oefzn +plfpu qdyojz xdrzrjy kpv abkh fge bbnotvp liikmcu czvwl oyh +ovha muitw pzy edfjoo fhsxuh dliyruc dikcd cqem ywfy +exyry jtzqn tscr qbtxno cikk poqgr tnjzq eofe sxea anlikep kick +zcie purpw dmhhms bcdo prwup uprpw wfejgjd +kwtjc cmixp dodfwj hcgmmat pkeyspo ubnl ajxvj ffkh xvw +nvlgq oduus psufiqg lrwpn dleftn xtllqvf usgz +liarf sczsf sczsf wky qtzq qvve qvve +cit vtjsh jrhkyvi txj urmq hppx +rhblmxn rhblmxn lkgow dylurwc beyk gfcewxj ehpl disoe tjbjy lkgow +nbkrm jvk ffux ars agns bebic jzjfm kmnbr gptvtsa ufxf +hrlvup jaz tafyr qcgq wkd fiz bgsrx jmtcvo qkbvj +eontk djf tiafrng mtwat puainel nyjoh meynxbf eqdw +aspvmbx tgzuszm fpj xkl nzpr fjp vnomk byx sbtov tnu utn +ldyww gwmiddv hwyh gcgsdit gtgdisc suufl xsw dlwyw +sye dgbd wyf ixqzthx dgdb esy +nsdgera fqz xwbdgui ngdgbcd bcn qrdxml cwcmxws tncm mqsodj cqgk +estayas cocmbpv cdcf vygtswo aplwa estayas +ndc ndc wntr sfls sfls +gse svv esmi lcdii lnr kemrk gnk ildic blnqy wvn +mwlpm awkr sxsudub yauwww hnktbog fpnqc nmxoq yoparu tqjpkug nbipft +czwnkk hrodtmx yyzpil ooqjb cvxzfh +kwa wak gipak gsgrw +jyy fja jjk kuvoqdy urqx +doyu chgn gvtxi qjdigvy kxr dizwrjc sll zenl yyblj +epxeqih kfi hlog pakk kkiidrh hiufw wuhif baqzxzi bgcd phi jzjdxjp +hllhyad sodc nyrtfe kygof hyyqi txddqg wcwxvnt ewqmj wwv +vxymuoe caat diqwbo vfruxdf sqniefn hetcbl nvtttu ouesb +yvoez pvthzc tdowuci wjijicn fhpmq kfobag yctdwj +xaugkb rprkg tidpx pjk tpwwm pbcfhr wmwpt sfynrl iouaw zbnyu +auakc culuxg bffg rodyhea ixlmtfb jdurl szoa +xgona fjzho buh khbvti ddh mgj ptgaqps +dqldupd udpldqd poku gfgpcg zsvk grvk kntx jih uwvxdvq sivk +mwdnq wmqdn uzto mdqnw +alvfm qxqo thwru xqqo jilnsgs rnonk fwntuby ogbha +gvxlxyf cdpv khvpka kgt gshlaa tenb +mtgvvxh mrjrsd truk rrerzx tujweaz +ozepw gsqkr rtmmc cmrtm +spnthg xhlzuu xwcrxz aqqejhh bpzh +ectdftk rgp mkp vxp pevriz wkgfkaw vfygj peg gep wjn +bksbu ywsszf tsbrps vxicr hfustju ynnlbo +sio urbvf ujezjk vkyc ukjezj bvrfu qwwgqmw uqfekvx bzipxus qfumwh +druru kycweog ycmef rjyy fkgp +rmf ifbip rsztco coju wlr bfbmsug lwr bsufbgm nwmp +jjuxtyd yif rkldsvu binq spepa mfg aszm +ghilaau ncm sgbavz omzeotz azukf bgjw zqzo gjbw pld +gtog iqheik budeu guvljmi +qqlj jqql ttk xcxu +cfq cfq kpagib dxfxufw hhksbjh gpcp +xkeax acnia jjubfc mhot uxlhh gnkj pavta rciondm rkquh xudqian +wqhqzg psqh rnnc uujlgq +hpjpaoa maa rdndl xewqj nmagwx xewqj hxuyvou xziv rdndl fbxmbz hmfwghy +dtwnrca hbfcptw qrmvat sdatx les zwizogq +bodiwzg sgoas fsf wgkrn zgbdowi wfkz +ngcsg grtao wcfxpyl gngcs fxwycpl fkpt +txvngo vxngot tkoap zqjc qzcj oeruix myh ihgdfik qtt +rxeh fcbnoo rxeh lve wvoc pmnxej dlcbrh rztt noibg +zyvq lwxqu oyjv bvidmf wxuql +wzc zcw czw dnhkvrg nzslrf +cfgl uwhxu qnsfmt tgyabes mqnq nkitq hmcvxlt qqmn yzmb uomqp +lwziur hgmdmv zuvipkp vir apr gfaq zeo dunat mqgafzg +prq pqkr xlrw njf ncqni kgpoma cmtklv +jwfuc poz opz fuple +fgleub lcgnifu lkwo kftbc onvwvdx lukpod xgmh rnj +rwqvv ezjmoni llq ekd cdvv kzcci gzsj vuipv fnw +rtnua gbnzg kqtogns iozzwc kjpzz kiiurey yzlvzx cpy xrue +fexcjmw ebwssx ewbcgwd uwolou nfdhic vupiykn jss djoo xftbkgo +idf ipvmez qyevwd wfsjxja dif dig +szpbtsa bssaztp sptzasb qppgz odur cpmn wpmg +pxn zjmq rbnr azwstzm mln upaqyty nxp oge nlm +bfaryqv hag phtvh ypi +epeeog lip zqio wuehlnb bau sbd dsb +xbrrp sej agrqnpa aarpnqg bnwyi jbn +uqmsvd asmuyy czxviw pznnmvc +sddwmek wnaea iwphupk sabo +cingdks ksh mtyip zltgafm dflkcd wbdnqup uokm gmxpyd libz svv akce +qge ewv dkabkmb xcpi nrkmsu mkmb djvamg mhhrwjh +krjt etfhm bxzatw zdkvz ehov seyxbw mkiirs plzoplu sogmwb wodfcle +qwea adibdp emo homrd pjcrhlc eqaw kqsrp rphjlcc +gajzo nwjg qxjra jztcnir ijvjwez avxb afz zyywqz kcszgh elmlkfh +lbz ozia bctf bumoji anhil rta xvit +ejybire ypjl qevak fzalx mlh qxlei zib +xmzas kwojjz ntrnrw nbmxlv mdgxs xjhxg suo zdcrxl qkujisz pxmu +eezyd unrtm wyu vhufvto rpb isfcy ygh hgy +nszvbzv ebtt memrsva ebtt qwcaq bhbas pvzfbov ppjbdy nszvbzv jabvrp +rlo zbmi lugvu yeby +tfcd tvl faaq mnural nyarh xnxk ctdf bodz +vwdrhc gub bgu fpcovx rcvwhd jukwsue +aekrhi lpknnrh bett tkib ioqrap igwnst aekrhi lhha +acg mknhazp pcgjuk tajplv +masq fyjkn agq qhxbbl qga npzj fme xtihic rntisg iqv aqg +ipagh fjth mswztpi iexd cocojy vhqrla joe wrsrmw +njztu tsh auqrxca zpp +jctn webxi haq irrr qox irrr webxi +reaw axmnvd voakf lnz ftbxfh zjyxzl pryfjpv sistgb pov mshs +gsy ctsngl ptmnyx vpjx zpvtori pfu ioycdrq +aobdtlj osdnrth sgqe geqs qegs +oamrlxk ygbb rkamoxl nztl sarbmtj yqupjt plu sbtarmj vpa rxea +yvhgp yznko epwpza gqrsod rilukp cglhomj wnaplu ugvdko qdr +cggztg ajw gggzct ubmiefj kpa +rel lvasbh kobm mdnzla pwnyj ehep gzx nhjdnsg rxa +qaz gook rplqwh vsht +dhe aneq ivrn awekad ckcbt zsqca ehd rvni oulwfuu +oxgzzow wntz tkqaoi oxgzzow lwkdpgy lhd aekjasp tkqaoi dnhaw +alxghco cpanoa onjh hyeyebe whxn zfu zozbll gojn +zdqulsa dlqsazu zqudals sfedw +rydtrsv rrtvysd fvyza drdgh lsfzt blnxr cnxe tslzf iijyds ylcxn +cczea nxx kwol kopaza wuvr cyvoo whlicv +zbmrwdq tlzbevx jwzpsc uvkwpd bmss rbzblj +jogx jgi gji hypmtkg ijg oscjv +flkoqja kwmrqv wzehel fvmcfap mkwqvr ivwxg jqfwdvo hweezl +vgjg nzucho nuohcz ggvj tmxci +fqaqx zeybhtg bxeic lftuqp wzuerz sww qfltxk +keiy myrvp blkxcg lncqmsu diittlg fqrf digrel cpwrk ipan dkxb bymlzo +owm irygdz pyhj mow wmo +noul pbvvt zcv ueqyjl zhetlw lpjfhli +felvwb wdykz kyibdz haq qkouj vuav oztyqh +dyxo njcr hcuk ysrr pucw qbajztc +ooyaz pmt hqwu gjx tmp tpm pwz +lyhzajz dfot avyifo kdwka pwypcep kyyw tirlku zdpjmft +aexle hfxo dacwvcy xsiotyg cifq ibupshj aktt rzvf pgafj +pxubhw ibpm jxtxg iwnssf osbpj +exmtfyx blbfg emrunru zkuhoi lfzn zrj unmcece phuppi +icomb rmy mvsqqkh zwjubz lumq wekx +cmdgs gsr pfhqx pfhqx cmdgs pga +rpyf jejc adaiou dutv imbenyu dqw zhebjhu pryf vtxs yprf +cxj roprjn rqoh qacagru snxd +rczvi hfpl luc yowgj nvavlhw vjudkmv dwu teq +klwc cktzh ksnvswl nsgeu xyohp mhs fxnjhm fwrcg rdeadkx cim +ounvb vzqje ujctzzk iyy vxck ebtvbqr uswsmcr jveqz qejzv jmi pboq +lwffygh mqsh vnnj ufz qhms gqfuxo lurzmu +buf psdluck gapwoo wgll sbfavbc lljfvzx cdgo rpt sfvabcb +svefr kubbri fervs nboi zkvq +jwr vtc zkcpzb kczbzp cdned pzbzkc wigjuak fszgweu odflfek +vwdqm khnnj plokjg vnce venc vecn yzxtgb +tawl yrhoz tawl yrhoz +vvehsl kdhzgme rix rcs btm pxnlsps vlhesv sxpnslp yqjtool +eqpyw kpmkcyw wqhglxg ajfzo hbd qvmhy nhokah iisqvad kxuyd fxek +jsz txhwhah hxt djnvl srylveu pxp dzmmn epek tzs +joyzql jqczueb rtdyw fyc fjirfyn tjcalz joyzql fyc +pjrmiz xwnmwns kcqjuut zfgxhdr octwn kqppg zhfgxrd wmwnnxs +ema yqxqs aljjo ajloj wozb +urgmhiz epqj vhhaxdm ptlsvig qzbmm cumbho lkg gyzmg eaopyzf ncfy mqe +ijvwvo oszkees ugvyk hjdj ftip itfp +ylfw qutzdj mgqp cyjss yzsdqqi iykvs fyor sthyqp mrjtzee hgo zwqbtgk +bkfkns gco bykzc mje dwmkrwt ljegqor yxjxp oaleuu +xeltq ggyqis aud frtyxhx iwz wiz fwoxz fozxw +zdu nwduqsa nced iphaaxo +bqjj oah ezd brhgxrc pmkz kdog exw +ihatt hck iepn egemprp wrz wzcuo xjzeaa wku ivjvihh +cwkuof bmj qmxd qbtms zgdei bsqmt ssndhw eeenku lcsqy bvvodr +tek zsgytci vgoun kwwu +jcxvp ijxc buqgix uil zfoku +ggndshq bmjeo yqaxtik blspz yofh edaroy +ipvtxh ouye elln dllvx iqza nhwf zyfw pvlky +iydcx gvarm gvarm wegmiy +sfjd liiflle mulboe qywzs tzbns trojl pad mnfcrhb sltb +gthqj jvpsof jwlfyeg jwhlfj +qckv umzrge gnzc mnr xde +gvgxmhv txnait taxint ius iboqdj +vsfex kbpvsby qembkb efxvs vhflzvm eaazg dyg bbmekq +wxpfk xwfpk xwkpf cjsyi +knzg eefq feqe seppop ttxz qnqfn atgsy cch mkjlbwt uyhct +quzw jbiw miqehe qvf jyipqh kzcjxyh +teuvzf tdtwoi pcuafa cwgjk ccur lgmqv jpjdkk efrnw uloqn dpkjkj lwloeph +yaffjy xntstsv gygq sxttvsn tvnstxs +cvbmdf pfrfkna wupv van iocb hsiyke obspj ytyfkl hbsqtij hkcw +oeddmnu koso mdodeun ybe mhjbmwy ubejz soko yxvuv +nylhy ylnyh olb vcdik +gsp ilba llnu jjk urbvuma qzypf bkceotg ezxq hyvjngf +tfnegyq rue waeif tfnegyq mvqm +wvgnsk cpd oib wrdfaz kohwgkc kzzig hogkwck gkizz +fecuuyp yfq bvanvxb cjeqwf unw dccr qzh zqu voakj +utoazh bjuq kmhcre izmny mirorsy twnl jyoc +fnnpd dmr ccgu eqgewc zuqivf +kkxiba qdabuen oikaz dnuywmm +aogud adugo uzcglpj lucv dgoua mdsqa mvrg +lymhv sof hvyml mlvhy nit +chu bwxp xpbw ghaix seklnc ola zofnrwt uch +wtt abob vblijtd oabb qjws +uozrpw kgf gxidxm uehdr fta pqakkrq atf fat woaolk +gaee voshd ghlyy emvzlkg cmcgk tuwlsj jwtsul znrta mjieqph glker +qiugxas gkg cbzmoz kahs obzzcm +puz omcokz gjc heuqb +dgndhb wid wdi scwnrjf juaisgo eivaw hgdndb +mgcrd hnqg pkpeb vprxcp +atlcnzp fyp cpkivxi bzj ypf cqpt bysu +pnd jiitmzs csw mxnpck vxutdrs ivipzy cws xiegsy qut +txlk avcvbuu hnq yyriq ajyswd urgiwc +qgiqut gvblizs giqnfrk tty mvoj wpikl giqnfrk bkdpndu xztmxn hsmqxf +llthg zjslki wilj rcyfois bavz hrqxn +ytbw hlkl vip skycogy ejiirhx +ndmtg bthlbw lsoq cvlvo sqol sqlo bppl sdkbls dtpyzrq vgm +psm xpj xjp lqi spm gqirw aglpj +htg fcchvyt xffev szdu lieadft +nbjo qohgzu vofg vvild dbtyi pdolxn plnoao jxze xlpbxj brajzg +urpp jjv lihmvp ivkwdqr sesyp ypbry qok sesyp ivkwdqr was +yinepzv qvnzdtf apv ucxo bdioo juga hjfsyl hmowo avc +dmiv tplae iiuiaxx tpale pyzkc +giwhst mpexd byfyc swuzkc +yydkwp xuu vjya kav ujmcxy qrtp zvlk +lsvdyn tkw qxu omvlc wwmfvov mrgcoov dhpu tfair hupd zbx njzgwtw +zuz rsxc xsrc gdwwf nycsv zzu kcu +unlvzv jerqqgm nozma ykbflj qihqkx +pctffo begf ivrvy ezru mvqt waocq +tubtuk gxkc ikgw bjrird kxjebbh sbjyc yafkd khqajmt aclpmf gqfo yrpf +rdt vrxa fyudo myeosb ursflwk +wbjras edlbwdp ctobtw jbvtvcd xjgoo cmunxm mjtbpi klovx bypmsab unc +xckml uztr htublq vilabvr jdiwus qejxur evfw qqm +tzqq tzqq wkb wkb +dgmg ljzc dgmg mbmco cgze qsap jccvot uors iiq +rwvac woylk dmn teorprx nyuvz hcwwxlj lvej drbjo asjgq +ljen tpfl vixcivr guaf lnje waim jlen +djgaa janhi adudm yzv zkcb xqw fgvrz +kpkjoon ggzx skp rqcsw xgzg zgxg jtf ghc +rtnyxo qixfd nphekk mouzk gny fpzquw qgywx rpr gqydze +gawdlv vrivoof rte iyp gaih sfzplm +csojx wzojode uzy qulr lylmb guvtkwv +ovxj aamms ftxo ebckdqw wqvsdci jwfqxks jafrcrn yyomrot +qnu jqwr ywudxk qpsez rdc kiyfz iiecf dthxjjb bown +typ zxcvjo rip acjhl paaab qhqipg xkguye sbxy pomkvn +ofvaegv hgak oafevgv hkemar rqkha grklnsp msvkkku rekahm bxmjnw +ahoihju sdyn phi uhz lupbx +lavt jef klmq oqyfpf kis nazul ymezxek xpla fxyrfnt +nwnagwy hvpjqfg sgm ungfstr gso owqqxjh +hey hye ipyrt qxmthg jth wpbr hxgmtq cvfkfux qykdzhk movcfnl vxyoc +zsras abnrj fgaczuk ssazr xzf cnxu gns wnqqy dwjh szars +uhb zanlvh lvdotkb xekl kcofo +lhx iccy ibkjw ciykxaj imsx ehamqlz iwzapxc rhaltv +pofit owmpqej vwrobh jvox gdqehss yyxd styu tfkm fiotp +ecz mdpoqsv mdpoqsv yxx rexok hcfll yvury hdhcfu juhkvpt rspnfj hxvgdir +ohed mtigaoe eodh agmiteo +vjvv hfco cppbxtw hawsjxz ovlsq qgs risgwhg auhj +togivgg czrtvw ccz wzvtrc bse lsk +ndc ndc lrfi iyleol nchx jxpv xdcsfmp nnx wtvq pih tgc +hzpf sur zhfp klfmhx lbuidp xiqimnf +qddpdk trfxpip pnsowj hidgvnf prur rsrautp aamykfm fysqjmq xwzjane mbmtxhf oqctt +lfd eops govslp ultbye vrqai hcjkcf snpape +cbok koumkad otpozb pqcs emilpe wpcyvxd bock +spjb xkkak anuvk ejoklh nyerw bsjp zxuq vcwitnd xxtjmjg zfgq xkpf +juo pmiyoh xxk myphio ogfyf dovlmwm moevao qqxidn diff --git a/inputs/year_2017/day_05_input b/inputs/year_2017/day_05_input new file mode 100644 index 0000000..a515642 --- /dev/null +++ b/inputs/year_2017/day_05_input @@ -0,0 +1,1078 @@ +0 +1 +1 +-2 +-2 +-2 +-2 +-4 +2 +0 +-9 +1 +-5 +-12 +-9 +-10 +-7 +-7 +-2 +-10 +-2 +0 +-6 +-14 +-6 +-24 +-10 +0 +-4 +1 +1 +-30 +-31 +-24 +0 +-20 +-24 +-10 +-2 +0 +-28 +-8 +-3 +-23 +-6 +2 +-41 +-36 +-2 +-11 +-39 +-27 +-21 +-48 +-38 +-4 +-29 +-49 +-9 +-57 +-33 +-60 +-42 +-12 +-21 +-19 +-21 +-52 +-65 +-62 +-26 +-64 +-67 +-12 +-22 +-21 +-30 +-31 +-20 +-54 +-57 +-20 +-18 +-46 +-1 +1 +-76 +-25 +-80 +-60 +-80 +-36 +-30 +-85 +-21 +-89 +-62 +-66 +-4 +-39 +-64 +-39 +-88 +-17 +-5 +-69 +-90 +-14 +-2 +-13 +-76 +1 +-10 +-10 +-28 +0 +-96 +-16 +-33 +-90 +-56 +-25 +-9 +-4 +-110 +-54 +-72 +-92 +-127 +-112 +-38 +-17 +-114 +-82 +-35 +-51 +-41 +-3 +-14 +-69 +-102 +-72 +-6 +-118 +-80 +-111 +-96 +-45 +-43 +-19 +-37 +-24 +-75 +-75 +-115 +-54 +-52 +-19 +-123 +-151 +-122 +-96 +-20 +-46 +-67 +-128 +-123 +-9 +-43 +-34 +-160 +-111 +2 +-164 +-158 +-63 +-67 +-2 +-145 +-103 +-80 +-53 +-148 +-103 +-47 +0 +-178 +-147 +-57 +-152 +-46 +-173 +-119 +-184 +-69 +-113 +-112 +-51 +-33 +-187 +-172 +-172 +-122 +-56 +-59 +-24 +-204 +-86 +-65 +-152 +-119 +-201 +-75 +-16 +-106 +-159 +-152 +-77 +-29 +-9 +-39 +-49 +-141 +-211 +-23 +-145 +-96 +-94 +-84 +-99 +-66 +-9 +-135 +-185 +-15 +-184 +-123 +-152 +-94 +-67 +-43 +-127 +-3 +-21 +-11 +-76 +-129 +-139 +-65 +-185 +-15 +-215 +-163 +-232 +-1 +-173 +-81 +-148 +-12 +1 +-251 +-183 +-214 +-162 +-213 +-247 +-165 +-232 +-107 +-75 +-190 +-205 +-138 +-149 +-232 +-99 +-57 +-148 +-231 +-188 +-141 +-193 +-39 +-208 +-245 +-102 +-247 +-1 +-76 +-13 +-20 +-263 +-146 +-158 +-81 +-270 +-162 +-70 +-215 +-286 +-98 +-186 +-184 +-147 +-146 +-160 +-172 +-42 +-48 +-14 +-175 +-299 +-293 +-214 +-198 +-128 +-272 +-108 +-94 +-102 +-108 +-53 +2 +-172 +-41 +-293 +-14 +-256 +-92 +-121 +-140 +-294 +-54 +-121 +-221 +-145 +-260 +-298 +-82 +-284 +-238 +-15 +-159 +-159 +-213 +-31 +-44 +-61 +-203 +-247 +-39 +-157 +-130 +-347 +-272 +-23 +-185 +-162 +-337 +-91 +-72 +-91 +-315 +-144 +-165 +-360 +-173 +-258 +-275 +-99 +-81 +-16 +-72 +-150 +-238 +-45 +-7 +-344 +-364 +-339 +-54 +-61 +-24 +-324 +-321 +-294 +-104 +-87 +-165 +-113 +-4 +-306 +-198 +-147 +-136 +-360 +-217 +-20 +-391 +-169 +-209 +-12 +-95 +-164 +-215 +-239 +-87 +-341 +-241 +-340 +-343 +-372 +-305 +-252 +-398 +-208 +-284 +-28 +-11 +-222 +-360 +-190 +-9 +-233 +-68 +-14 +-220 +-34 +-87 +-392 +-84 +-41 +-187 +-59 +-247 +-258 +-143 +-102 +-208 +-182 +-254 +-67 +-182 +-279 +-339 +-200 +-445 +-43 +-120 +-418 +-273 +-201 +-113 +-394 +-4 +-197 +-313 +-116 +-62 +-323 +-47 +-14 +-24 +-416 +-150 +-28 +-288 +-461 +0 +-388 +-375 +-424 +-302 +-4 +-75 +-54 +-288 +-212 +-436 +-414 +-447 +-362 +-120 +-467 +-135 +-93 +-268 +-8 +-192 +-342 +-466 +-162 +-387 +-348 +-351 +-236 +-123 +-51 +-225 +-259 +-52 +-14 +-26 +-347 +-327 +-206 +-37 +-77 +-316 +-278 +-195 +-348 +-330 +-235 +-125 +-36 +-323 +-10 +-77 +-133 +-353 +-109 +-51 +-134 +-281 +-227 +-483 +-406 +-11 +-356 +-443 +-104 +-264 +-90 +-489 +-39 +-145 +-318 +-399 +-238 +-434 +-145 +-122 +-507 +-196 +-156 +-251 +-370 +-207 +-534 +-171 +-117 +-416 +-226 +-393 +-133 +-391 +-347 +-510 +-121 +-84 +2 +-110 +-427 +-456 +-184 +-295 +-337 +-444 +-143 +-120 +-163 +-351 +-36 +-483 +-315 +-240 +-462 +-367 +-237 +-277 +-102 +-426 +-250 +-240 +-503 +-567 +-324 +-555 +-14 +-197 +-24 +-371 +-484 +-54 +-13 +-432 +-343 +-54 +-450 +-374 +-28 +-154 +-216 +-314 +-122 +-281 +-495 +-351 +-365 +-528 +-545 +-429 +-411 +-93 +-230 +-170 +-188 +-227 +-499 +-562 +-275 +-412 +-597 +-64 +-303 +-374 +-262 +-359 +-549 +-579 +-379 +-143 +-598 +-273 +-618 +-449 +-425 +-441 +-251 +-135 +-150 +-521 +-561 +-460 +-79 +-252 +-336 +-27 +-331 +-335 +-46 +-555 +-121 +-447 +-563 +-617 +-42 +-125 +-92 +-472 +-41 +-164 +-450 +-372 +-584 +-327 +-278 +-307 +-378 +-513 +-52 +-55 +-551 +-81 +-550 +-472 +-347 +-664 +-348 +-150 +-88 +-7 +-559 +-475 +-553 +-342 +-20 +-411 +-574 +-419 +-363 +-176 +-379 +-429 +-548 +-649 +-178 +-449 +-594 +-536 +-386 +-108 +-552 +-179 +-578 +-398 +-281 +-3 +-93 +-706 +-679 +-623 +-140 +-682 +-59 +-710 +-416 +-390 +-217 +-679 +-540 +-85 +-31 +-403 +-28 +-15 +-105 +-388 +-571 +-103 +-136 +-404 +-555 +-667 +-189 +-460 +-433 +-278 +-310 +-300 +-393 +-383 +-203 +-632 +-482 +-371 +-385 +-265 +-197 +-100 +-512 +-668 +-291 +-626 +-384 +-40 +-21 +-411 +-288 +-187 +-56 +-556 +-455 +-114 +-560 +-205 +-22 +-442 +-38 +-260 +-492 +-276 +-621 +-202 +-183 +-5 +-345 +-25 +-500 +-633 +-476 +-47 +-778 +-726 +-628 +-308 +-715 +-705 +-247 +-670 +-699 +-136 +-521 +-311 +-773 +-333 +-721 +-77 +-76 +-197 +-101 +-31 +-6 +-701 +-640 +-678 +-421 +-778 +-627 +-359 +-789 +-463 +-99 +-557 +-796 +-12 +-678 +-591 +-359 +-711 +-175 +-82 +-18 +-347 +-601 +-819 +0 +-40 +-32 +-454 +-680 +-783 +-269 +-744 +-726 +-336 +-563 +-152 +-782 +-651 +-674 +-788 +-311 +-640 +-525 +-54 +-317 +-312 +-328 +-128 +-162 +-133 +-769 +-669 +-611 +-553 +-247 +-174 +-217 +-497 +-202 +-450 +-486 +-102 +-35 +-273 +-436 +-282 +-343 +-544 +-602 +-171 +-444 +-865 +-206 +-486 +-5 +-566 +-444 +-496 +-142 +-502 +-9 +-359 +-330 +-797 +-735 +-726 +-66 +-290 +-716 +-494 +-796 +-373 +-519 +-502 +-78 +-622 +-602 +-408 +-511 +-114 +-330 +-794 +-102 +-795 +-882 +-264 +-771 +-832 +-729 +-527 +-264 +-4 +-12 +-517 +-516 +-85 +-899 +-693 +-759 +-367 +-844 +-377 +-207 +-590 +-551 +-93 +-810 +-449 +-464 +-111 +-161 +-154 +-823 +-60 +-523 +-265 +-219 +-903 +-170 +-601 +-785 +-144 +-439 +-190 +-275 +-72 +-75 +-175 +-137 +-842 +-336 +-169 +-245 +-480 +-751 +-363 +-610 +-505 +-771 +-85 +-337 +-307 +-687 +-731 +-118 +-313 +-541 +-490 +-485 +-647 +-104 +-101 +-324 +-57 +-5 +-610 +-251 +-841 +-97 +-562 +-664 +-765 +-969 +-449 +-172 +-846 +-465 +-212 +-600 +-62 +-399 +-923 +-62 +-400 +-197 +-144 +-699 +-730 +-754 +-748 +-405 +-518 +-633 +-893 +-675 +-717 +-380 +-464 +-193 +-590 +-888 +-64 +-111 +-905 +-774 +-209 +-492 +-64 +-589 +-952 +-59 +-5 +-615 +-208 +-131 +-867 +-594 +-668 +-253 +-75 +-418 +-5 +-394 +-456 +-266 +-669 +-335 +-687 +-661 +-73 +-446 +-828 +-413 +-643 +-410 +-91 +-25 +-84 +-335 +-943 +-355 +-155 +-778 +-1013 +-772 +-976 +-305 +-575 +-1060 +-148 +-931 +-588 +-204 +-56 +-102 +-467 +-937 +-481 +-890 +-503 +-379 +-442 +-774 +-316 +-732 diff --git a/src/lib.rs b/src/lib.rs index 73b15c6..3f92cc6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,7 @@ macro_rules! solvable { mod bfs; pub mod year_2015; pub mod year_2016; +pub mod year_2017; /// Returns the solution for a specified exercise and input. /// @@ -44,6 +45,7 @@ pub fn solve(year: u16, day: u8, part: u8, input: impl Into) -> Option year_2015::solve(day, part, input), 2016 => year_2016::solve(day, part, input), + 2017 => year_2017::solve(day, part, input), _ => None, } } diff --git a/src/year_2017.rs b/src/year_2017.rs new file mode 100644 index 0000000..308ec82 --- /dev/null +++ b/src/year_2017.rs @@ -0,0 +1,64 @@ +//! Year 2017 +//! +#![doc = include_str!("../NOTES_2017.md")] + +pub mod day_01; +pub mod day_02; +pub mod day_03; +pub mod day_04; +pub mod day_05; + +pub fn solve(day: u8, part: u8, input: impl Into) -> Option { + if part != 1 && part != 2 { + return None; + } + + match day { + 1 => Some(day_01::day_01(part, input).to_string()), + 2 => Some(day_02::day_02(part, input).to_string()), + 3 => Some(day_03::day_03(part, input).to_string()), + 4 => Some(day_04::day_04(part, input).to_string()), + 5 => Some(day_05::day_05(part, input).to_string()), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn day_01() { + let input = include_str!("../inputs/year_2017/day_01_input"); + assert_eq!(day_01::day_01_v1(input), 1_069); + assert_eq!(day_01::day_01_v2(input), 1_268); + } + + #[test] + fn day_02() { + let input = include_str!("../inputs/year_2017/day_02_input"); + assert_eq!(day_02::day_02_v1(input), 53_978); + assert_eq!(day_02::day_02_v2(input), 314); + } + + #[test] + fn day_03() { + let input = include_str!("../inputs/year_2017/day_03_input"); + assert_eq!(day_03::day_03_v1(input), 552); + assert_eq!(day_03::day_03_v2(input), 330_785); + } + + #[test] + fn day_04() { + let input = include_str!("../inputs/year_2017/day_04_input"); + assert_eq!(day_04::day_04_v1(input), 466); + assert_eq!(day_04::day_04_v2(input), 251); + } + + #[test] + fn day_05() { + let input = include_str!("../inputs/year_2017/day_05_input"); + assert_eq!(day_05::day_05_v1(input), 373_160); + assert_eq!(day_05::day_05_v2(input), 26_395_586); + } +} diff --git a/src/year_2017/day_01.rs b/src/year_2017/day_01.rs new file mode 100644 index 0000000..9925b50 --- /dev/null +++ b/src/year_2017/day_01.rs @@ -0,0 +1,63 @@ +pub fn day_01_v1(input: impl Into) -> usize { + let mut characters = input + .into() + .trim_end() + .chars() + .map(|c| c as u8) + .collect::>(); + characters.push(characters[0]); + characters + .windows(2) + .filter(|pair| pair[0] == pair[1]) + .map(|pair| (pair[0] - 48) as usize) + .sum() +} + +pub fn day_01_v2(input: impl Into) -> usize { + let characters = input + .into() + .trim_end() + .chars() + .map(|c| c as u8) + .collect::>(); + let length = characters.len(); + characters + .iter() + .enumerate() + .filter(|(idx, chr)| **chr == characters[(idx + length / 2) % length]) + .map(|(_idx, chr)| (*chr - 48) as usize) + .sum() +} + +solvable!(day_01, day_01_v1, day_01_v2, usize); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn works_with_samples_v1() { + let sample_one: [(&str, usize); 4] = [ + ("1122", 3), + ("1111", 4), + ("1234", 0), + ("91212129", 9), + ]; + for (sample, result) in sample_one { + assert_eq!(day_01_v1(sample), result); + } + } + #[test] + fn works_with_samples_v2() { + let sample_two: [(&str, usize); 5] = [ + ("1212", 6), + ("1221", 0), + ("123425", 4), + ("123123", 12), + ("12131415", 4), + ]; + for (sample, result) in sample_two { + assert_eq!(day_01_v2(sample), result); + } + } +} diff --git a/src/year_2017/day_02.rs b/src/year_2017/day_02.rs new file mode 100644 index 0000000..6fbce71 --- /dev/null +++ b/src/year_2017/day_02.rs @@ -0,0 +1,65 @@ +use itertools::Itertools; + +pub fn day_02_v1(input: impl Into) -> usize { + input + .into() + .lines() + .map(|line| { + let mut max = 0; + let mut min = usize::MAX; + line.split_whitespace().for_each(|number| { + let number = number.parse::().unwrap(); + max = std::cmp::max(max, number); + min = std::cmp::min(min, number); + }); + max - min + }) + .sum() +} + +pub fn day_02_v2(input: impl Into) -> usize { + input + .into() + .lines() + .map(|line| { + line + .split_whitespace() + .map(|number| number.parse::().unwrap()) + .combinations(2) + .filter_map(|pair| { + if pair[0] % pair[1] == 0 { + Some(pair[0] / pair[1]) + } else if pair[1] % pair[0] == 0 { + Some(pair[1] / pair[0]) + } else { + None + } + }) + .next() + .unwrap() + }) + .sum() +} + +solvable!(day_02, day_02_v1, day_02_v2, usize); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn works_with_samples_v1() { + let sample_one = "5 1 9 5\n\ + 7 5 3\n\ + 2 4 6 8"; + assert_eq!(day_02_v1(sample_one), 18); + } + + #[test] + fn works_with_samples_v2() { + let sample_one = "5 9 2 8\n\ + 9 4 7 3\n\ + 3 8 6 5"; + assert_eq!(day_02_v2(sample_one), 9); + } +} diff --git a/src/year_2017/day_03.rs b/src/year_2017/day_03.rs new file mode 100644 index 0000000..6e60c38 --- /dev/null +++ b/src/year_2017/day_03.rs @@ -0,0 +1,81 @@ +use std::collections::HashMap; + +// Thanks https://stackoverflow.com/a/61253346 +fn spiral(input: usize) -> (i64, i64) { + let n = input as f64; + let k = ((n.sqrt() - 1f64) / 2f64).ceil(); + let mut t = (2f64 * k) + 1f64; + let mut m = t.powf(2f64); + t -= 1f64; + if n >= (m - t) { + return ((k - (m - n)) as i64, -k as i64); + } else { + m -= t; + } + if n >= (m - t) { + return (-k as i64, (-k + (m - n)) as i64); + } else { + m -= t; + } + if n >= (m - t) { + return ((-k + (m - n)) as i64, k as i64); + } + + (k as i64, (k - (m - n - t)) as i64) +} + +pub fn day_03_v1(input: impl Into) -> usize { + let number = input.into().trim_end().parse::().unwrap(); + let position = spiral(number); + + (position.0.unsigned_abs() + position.1.unsigned_abs()) as usize +} + +#[inline] +fn get_neighbors(values: &HashMap<(i64, i64), usize>, position: (i64, i64)) -> usize { + let mut result: usize = 0; + for position_x in position.0 - 1i64..=position.0 + 1i64 { + for position_y in position.1 - 1i64..=position.1 + 1i64 { + if let Some(position_value) = values.get(&(position_x, position_y)) { + result += *position_value; + } + } + } + result +} + +pub fn day_03_v2(input: impl Into) -> usize { + let target = input.into().trim_end().parse::().unwrap(); + let mut values: HashMap<(i64, i64), usize> = HashMap::new(); + values.insert((0i64, 0i64), 1); + let mut counter = 1; + loop { + counter += 1; + let position = spiral(counter); + let position_value = get_neighbors(&values, position); + if position_value > target { + return position_value; + } + values.insert(position, position_value); + } +} + +solvable!(day_03, day_03_v1, day_03_v2, usize); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn works_with_samples_v1() { + let sample_one: [(&str, usize); 4] = [ + ("1", 0), + ("12", 3), + ("23", 2), + ("1024", 31), + ]; + for (sample, result) in sample_one { + assert_eq!(day_03_v1(sample), result); + } + } +} diff --git a/src/year_2017/day_04.rs b/src/year_2017/day_04.rs new file mode 100644 index 0000000..888ef77 --- /dev/null +++ b/src/year_2017/day_04.rs @@ -0,0 +1,65 @@ +use itertools::Itertools; + +pub fn day_04_v1(input: impl Into) -> usize { + input + .into() + .lines() + .filter(|line| { + !line + .split_whitespace() + .sorted() + .collect::>() + .windows(2) + .any(|pair| pair[0] == pair[1]) + }) + .count() +} + +pub fn day_04_v2(input: impl Into) -> usize { + input + .into() + .lines() + .filter(|line| { + !line + .split_whitespace() + .map(|word| word.chars().sorted().collect::>()) + .sorted() + .collect::>() + .windows(2) + .any(|pair| pair[0] == pair[1]) + }) + .count() +} + +solvable!(day_04, day_04_v1, day_04_v2, usize); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn works_with_samples_v1() { + let sample_one: [(&str, usize); 3] = [ + ("aa bb cc dd ee", 1), + ("aa bb cc dd aa", 0), + ("aa bb cc dd aaa", 1), + ]; + for (sample, result) in sample_one { + assert_eq!(day_04_v1(sample), result); + } + } + + #[test] + fn works_with_samples_v2() { + let sample_two: [(&str, usize); 5] = [ + ("abcde fghij", 1), + ("abcde xyz ecdab", 0), + ("a ab abc abd abf abj", 1), + ("iiii oiii ooii oooi oooo", 1), + ("oiii ioii iioi iiio", 0), + ]; + for (sample, result) in sample_two { + assert_eq!(day_04_v2(sample), result); + } + } +} diff --git a/src/year_2017/day_05.rs b/src/year_2017/day_05.rs new file mode 100644 index 0000000..67413ae --- /dev/null +++ b/src/year_2017/day_05.rs @@ -0,0 +1,56 @@ +pub fn day_05_v1(input: impl Into) -> usize { + let mut instructions: Vec = input + .into() + .lines() + .map(|line| line.parse::().unwrap()) + .collect(); + let mut pc: i16 = 0; + let mut moves: usize = 0; + + while let Some(instruction) = instructions.get_mut(pc as usize) { + pc += *instruction; + *instruction += 1; + moves += 1; + } + moves +} + +pub fn day_05_v2(input: impl Into) -> usize { + let mut instructions: Vec = input + .into() + .lines() + .map(|line| line.parse::().unwrap()) + .collect(); + let mut pc: i16 = 0; + let mut moves: usize = 0; + + while let Some(instruction) = instructions.get_mut(pc as usize) { + pc += *instruction; + *instruction += if *instruction >= 3 { -1 } else { 1 }; + moves += 1; + } + moves +} + +solvable!(day_05, day_05_v1, day_05_v2, usize); + +#[cfg(test)] +mod tests { + use super::*; + + const SAMPLE: &str = "0\n\ + 3\n\ + 0\n\ + 1\n\ + -3"; + + #[test] + fn works_with_samples_v1() { + assert_eq!(day_05_v1(SAMPLE), 5); + } + + #[test] + fn works_with_samples_v2() { + assert_eq!(day_05_v2(SAMPLE), 10); + } +}