-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24ba383
commit 248fd7c
Showing
19 changed files
with
2,160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
36743676522426214741687639282183216978128565594112364817283598621384839756628424146779311928318383597235968644687665159591573413233616717112157752469191845757712928347624726438516211153946892241449523148419426259291788938621886334734497823163281389389853675932246734153563861233894952657625868415432316155487242813798425779743561987563734944962846865263722712768674838244444385768568489842989878163655771847362656153372265945464128668412439248966939398765446171855144544285463517258749813731314365947372548811434646381595273172982466142248474238762554858654679415418693478512641864168398722199638775667744977941183772494538685398862344164521446115925528534491788728448668455349588972443295391385389551783289417349823383324748411689198219329996666752251815562522759374542652969147696419669914534586732436912798519697722586795746371697338416716842214313393228587413399534716394984183943123375517819622837972796431166264646432893478557659387795573234889141897313158457637142238315327877493994933514112645586351127139429281675912366669475931711974332271368287413985682374943195886455927839573986464555141679291998645936683639162588375974549467767623463935561847869527383395278248952314792112113126231246742753119748113828843917812547224498319849947517745625844819175973986843636628414965664466582172419197227695368492433353199233558872319529626825788288176275546566474824257336863977574347328469153319428883748696399544974133392589823343773897313173336568883385364166336362398636684459886283964242249228938383219255513996468586953519638111599935229115228837559242752925943653623682985576323929415445443378189472782454958232341986626791182861644112974418239286486722654442144851173538756859647218768134572858331849543266169672745221391659363674921469481143686952478771714585793322926824623482923579986434741714167134346384551362664177865452895348948953472328966995731169672573555621939584872187999325322327893336736611929752613241935211664248961527687778371971259654541239471766714469122213793348414477789271187324629397292446879752673 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
325489 |
Oops, something went wrong.