Advent of Code 2023 day 6
12/06/2024, 5:00 AMMarcin Wisniowski
12/06/2024, 5:32 AMMarcin Wisniowski
12/06/2024, 5:33 AMRenette Ros
12/06/2024, 5:42 AMPawel Matysek
12/06/2024, 5:44 AMMichael de Kaste
12/06/2024, 5:45 AMMarcin Wisniowski
12/06/2024, 5:47 AMMichael de Kaste
12/06/2024, 5:48 AMDan Fingal-Surma
12/06/2024, 6:09 AMMichael de Kaste
12/06/2024, 6:12 AMSolution for Day6:
---------Part 1-----------
time: 1.062500ms
answer: 5461
---------Part 2-----------
time: 1.691950900s
answer: 1836
---------Total-----------
time: 1.693013400s
---------End-----------
This is painful though haha, part2 is a snail 🐌Dan Fingal-Surma
12/06/2024, 6:22 AMDan Fingal-Surma
12/06/2024, 6:31 AMDan Fingal-Surma
12/06/2024, 6:33 AMAnirudh
12/06/2024, 6:38 AMSergei Petunin
12/06/2024, 6:53 AMDirection
class https://github.com/forketyfork/aoc-2022/blob/main/src/main/kotlin/year2024/Day06.ktAnirudh
12/06/2024, 6:53 AMPotatoboy
12/06/2024, 6:54 AMDan Fingal-Surma
12/06/2024, 6:59 AMAnirudh
12/06/2024, 7:06 AMephemient
12/06/2024, 7:18 AMDan Fingal-Surma
12/06/2024, 7:28 AMJakub Gwóźdź
12/06/2024, 7:31 AMDan Fingal-Surma
12/06/2024, 7:37 AMMichael de Kaste
12/06/2024, 7:37 AMDan Fingal-Surma
12/06/2024, 7:38 AMJakub Gwóźdź
12/06/2024, 7:39 AMDan Fingal-Surma
12/06/2024, 7:39 AMDan Fingal-Surma
12/06/2024, 7:39 AMJakub Gwóźdź
12/06/2024, 7:40 AMJakub Gwóźdź
12/06/2024, 7:40 AMDan Fingal-Surma
12/06/2024, 7:40 AMephemient
12/06/2024, 7:40 AM.asFlow().flatMapMerge { flow { ... } }
will parallelize on multiplatform (.parallelStream()
is JVM-only)Dan Fingal-Surma
12/06/2024, 7:40 AMJakub Gwóźdź
12/06/2024, 7:40 AMJakub Gwóźdź
12/06/2024, 7:41 AMDan Fingal-Surma
12/06/2024, 7:41 AMDan Fingal-Surma
12/06/2024, 7:41 AMMichael de Kaste
12/06/2024, 7:41 AMJakub Gwóźdź
12/06/2024, 7:41 AMDan Fingal-Surma
12/06/2024, 7:42 AMDan Fingal-Surma
12/06/2024, 7:43 AMDan Fingal-Surma
12/06/2024, 7:43 AMJakub Gwóźdź
12/06/2024, 7:44 AMJakub Gwóźdź
12/06/2024, 7:52 AMasFlow().flatMapMerge
reduced to 329ms 🙂phldavies
12/06/2024, 7:54 AMDan Fingal-Surma
12/06/2024, 7:57 AMAnirudh
12/06/2024, 8:05 AMbut for part 2 I'm testing only the positions found during part 1.and
I'm testing (and putting into "visited") only the positions where I'm turning
Anirudh
12/06/2024, 8:06 AM....#.....
....+---+#
....|...|.
..#.|...|.
..+-+-+#|.
..|.|.|.|.
.#+-^-+-+.
.+----++#.
#+----++..
......#O..
the two `+`'s near the bottom O
wouldn't trigger loop-check but the following right-turn upwards (on the left side) would trigger the loop-check.Anirudh
12/06/2024, 8:16 AMpart Two Time: 19.456338800s
part Two Optimised Time: 4.388765400s
77.4% time improvement
but I did not memoize turning paths, etc.Anirudh
12/06/2024, 8:27 AM.map(Pair<Point, Direction>::first)
as in, why doesn't just this work?
.map(Pair::first)
Jakub Gwóźdź
12/06/2024, 8:28 AMbj0
12/06/2024, 9:02 AMflatMapMerge
not do anything on the jvm? (parallelStream did speed up my solve)bj0
12/06/2024, 9:20 AMNeil Banman
12/06/2024, 9:36 AMJakub Gwóźdź
12/06/2024, 12:08 PMritesh
12/06/2024, 1:07 PMPaul Woitaschek
12/06/2024, 8:09 PMPaul Woitaschek
12/06/2024, 8:16 PMJakub Gwóźdź
12/06/2024, 8:38 PMJakub Gwóźdź
12/06/2024, 9:25 PMMichael Böiers
12/06/2024, 9:41 PMMichael Böiers
12/06/2024, 10:05 PMphldavies
12/07/2024, 12:22 AMWarming up 1 puzzles over 5s for year 2024 day 6...
Warmup finished after 5.001846250s with 790 iterations
year 2024 day 6 part 1
Fast took 105.876us 👑: 5409
year 2024 day 6 part 2
Fast took 5.656859ms 👑: 2022
or swapping parMap{}.count{}
for simple count{}
year 2024 day 6 part 2
Fast took 35.759518ms 👑: 2022
Neil Banman
12/08/2024, 4:50 AMNiel
12/10/2024, 12:51 PMJakub Gwóźdź
12/10/2024, 1:39 PMvisited
only when the direction is UP .
also, I'm not sure how this com.toldoven.aoc.notebook.AocClient
works, but if it just downloads the url as a string, then at the end of val lines = aoc.input().lines()
you'll get an empty string, which will mess with your Boundaries(Point(0, 0), Point(lines.first().lastIndex, lines.lastIndex))
Niel
12/10/2024, 1:52 PMyou can add to (and test)why is that? A loop can also be closed going in any other direction, can't it? concerning the library: It is great for solving aoc with notebooks: https://github.com/Toldoven/aoc-kotlin-notebook. The downloaded input is sanitized correctlyonly when the direction is UPvisited
Jakub Gwóźdź
12/10/2024, 1:53 PMwhy is that? A loop can also be closed going in any other direction, can't it?Sure, but after max 3 next turns it will be a turn UP 🙂 so you'll sacrifice three more iterations but save 75% cache operations
Niel
12/10/2024, 1:57 PMJakub Gwóźdź
12/10/2024, 1:58 PMNiel
12/10/2024, 1:58 PMNiel
12/10/2024, 2:00 PMJakub Gwóźdź
12/10/2024, 3:02 PMNeil Banman
12/10/2024, 4:01 PMNiel
12/11/2024, 2:39 PMJakub Gwóźdź
12/11/2024, 2:40 PMNiel
12/11/2024, 2:48 PMJakub Gwóźdź
12/11/2024, 2:51 PM