home.social

#adventofcode2023 — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #adventofcode2023, aggregated by home.social.

  1. Finished my last #AdventOfCode2023 solution writeup! Finally using this neat line-labels feature.

    I'll have to call it here before starting with the ones from 2024, or else I won't be on time for #AdventOfCode this year! I just gotta figure out how to make it auto-update...

    #programming #blog #Python

  2. CW: mild spoilers for Advent of Code 2023 Day 24

    Still writing my #AdventOfCode explainer #blog . To make it easier to explain the #algebra of one puzzle, I'm using #SymPy in as succinct and limited a way I can.

    #AdventOfCode2023 #programming #Python #code

  3. A few weeks ago I decided to start doing the #AdventOfCode2023 exercises in #CommonLisp. Despite barely knowing anything about Lisp I managed the first star without too much trouble beyond having to look a lot of things up. Then for the second star I almost immediately figured out how to do it but spent several days finding out how to express that solution in Lisp without making it too confusing.

  4. I'm super stuck with part 2 of Day 10 of #AdventOfCode2023 but at least I created this cool visualisation of the pipes loop/labyrinth I got in Part 1

  5. I've almost completed all of Advent of Code 2015 (only 9 years too late!). Day 21 was super fun, but Day 22 is possibly going to be oof.

    #aoc #AdventOfCode #AdventOfCode2023

  6. Crazy how much difference the right data structure / #algorithm for a task makes.

    This week I learned about #Deterministic #Finite #Automata and #Nondeterministic Finite Automata just to redo my clunky #AdventOfCode2023 day 12 challenge, written in #Rust #RustLang

    Runtime for part 1 dropped from 1-2secs to milliseconds. Part 2 also milliseconds 😮

    Are there any good Rust crates for DFAs/NFAs?

    Many people solved that problem with #Dynamic #Programming - something else for the learn list 😉

  7. Crazy how much difference the right data structure / #algorithm for a task makes.

    This week I learned about #Deterministic #Finite #Automata and #Nondeterministic Finite Automata just to redo my clunky #AdventOfCode2023 day 12 challenge, written in #Rust #RustLang

    Runtime for part 1 dropped from 1-2secs to milliseconds. Part 2 also milliseconds 😮

    Are there any good Rust crates for DFAs/NFAs?

    Many people solved that problem with #Dynamic #Programming - something else for the learn list 😉

  8. Crazy how much difference the right data structure / #algorithm for a task makes.

    This week I learned about #Deterministic #Finite #Automata and #Nondeterministic Finite Automata just to redo my clunky #AdventOfCode2023 day 12 challenge, written in #Rust #RustLang

    Runtime for part 1 dropped from 1-2secs to milliseconds. Part 2 also milliseconds 😮

    Are there any good Rust crates for DFAs/NFAs?

    Many people solved that problem with #Dynamic #Programming - something else for the learn list 😉

  9. Crazy how much difference the right data structure / #algorithm for a task makes.

    This week I learned about #Deterministic #Finite #Automata and #Nondeterministic Finite Automata just to redo my clunky #AdventOfCode2023 day 12 challenge, written in #Rust #RustLang

    Runtime for part 1 dropped from 1-2secs to milliseconds. Part 2 also milliseconds 😮

    Are there any good Rust crates for DFAs/NFAs?

    Many people solved that problem with #Dynamic #Programming - something else for the learn list 😉

  10. Crazy how much difference the right data structure / #algorithm for a task makes.

    This week I learned about #Deterministic #Finite #Automata and #Nondeterministic Finite Automata just to redo my clunky #AdventOfCode2023 day 12 challenge, written in #Rust #RustLang

    Runtime for part 1 dropped from 1-2secs to milliseconds. Part 2 also milliseconds 😮

    Are there any good Rust crates for DFAs/NFAs?

    Many people solved that problem with #Dynamic #Programming - something else for the learn list 😉

  11. Trying to do #AdventOfCode2023 Day 25 to be close to wrapping it up.

    Apparently the "Stoer–Wagner algorithm" finds the minimum cut to split a graph.

    Except the Wikipedia example code is apparently broken, and all of the other examples I've found are REALLY shit with their naming.

    It's easier to teach a mathematician to code than it is to teach a programmer maths. But that doesn't mean the mathematician can be trusted to write readable code with sensible variables 😐

  12. On to Day 24 of #AdventOfCode2023 and… UGH! Is there any way to make this not horribly maths-y? I've yet to find anyone online giving a clear approach (and I took maths through to A Level… 20 years ago!)

    None of this is made easier by Google being "helpful" and putting lots of "intersection of sets/arrays" content at the top when searching for intersection of vectors in a given programming language 🧐

  13. Hey, look! It's another #AdventOfCode2023 where the sample is correct, everything seems to make sense, and yet my answer is too high. But the full input is so complex and there's no ground truth and so I have no way of finding out which corner case I'm apparently not handling 😐

  14. I think I've worked out where my limit is with #AdventOfCode2023.

    Got to optimise an implementation and use the right data structures? Fine.

    Got to plot things out to find patterns and mathematical shortcuts (especially if it's a shortcut that you've got to know rather than find)? Screw that and leave the boredom for the mathematicians!

  15. Time to wrap up last year's #AdventOfCode. It was a lot of fun, I learned a lot of new thing and finished with 36/50 stars.

    I solved puzzles with #Python, writing explanations and educational tidbits along the way while discussing them and reading solutions from a wide variety of people using different programming languages.

    This retrospective includes a couple of spoilers but is mostly conversational and not about the solutions directly.

    hamatti.org/posts/advent-of-co

    #blogging #AdventOfCode2023

  16. Day 19 of #AdventOfCode2023 wasn't too bad. I even found a generalised way to turn "<" and ">" into operations and call them in Ruby!

    But I'm just glazing over on Day 20. As much as I hate being defeated by coding challenges, and as much as I enjoyed doing Seven Languages in Seven Weeks, I think I need to call it quits with this.

    It has gone from "interesting distraction and challenge" to "you're being so obscure that I just can't bring myself to care".

  17. Trying to catch up on #AdventOfCode2023. Working on Day 18. Almost had it, but the inside count was missing some conditions. Restructured it so it worked with Day 10s "inside the loop" area finding algorithm. Success!

    Then got to part 2. Parsing is trivial. The sample took impossibly long, so the full input is right out.

    Read up online. Shoelaces and Pick's theorem? WTF? I'm a programmer, not a bloody mathematician 😐

    There's "interesting challenge" and there's "teaches you nothing useful".

  18. After regularly switching between #Clojure, #Ocaml, #Rust, #Elixir, and #Scala to solve #adventofcode2023 puzzles, my head is mush about syntax. Could it have been more worse if I had used more languages, e.g., #Zig, #Crystal, #Nim? 🤷‍♂️

  19. @jasonekratz Heh, yeah, I know. I did a ton of COBOL in the late 80s and early 90s, and for some unknown reason, I've gotten a little nostalgic for it. I've been playing with GNU COBOL the last few days, and actually rewrote Day 1, Part 1 of #AdventOfCode2023 in it. 🤣

  20. Me: I was too distracted and busy before Christmas. I'll get back to the #AdventOfCode2023

    Me: I've got an idea for better pruning on the route finding for day 17. I'm sure it'll work.

    *implements*
    *runs*

    Me: That's nice and fast. And the sample still gives the right answer.

    Advent of Code: Nope, still too high.

    Me: 😑

  21. CW: Still catching up with some later AoC puzzles

    So I’ve just solved day 24 part 2… by writing out 9 equations for the first 3 hailstones in #wxMaxima and letting it solve them for me.

    Now I just need to figure out how to write a solver for this kind of equations system myself in #RustLang

    #Maxima #AoC2023 #AdventOfCode2023 #Aoc #AdventOfCode

  22. CW: Still catching up with some later AoC puzzles

    So I’ve just solved day 24 part 2… by writing out 9 equations for the first 3 hailstones in and letting it solve them for me.

    Now I just need to figure out how to write a solver for this kind of equations system myself in

  23. So the follow up on #adventofcode2023

    I did finish but with about 20ish stars with of “cheating”. Why? From an earlier post, I was using C and that is a huge disadvantage by the time you get your day 15.

    So I went to c++ to gain maps and other libs to get it done. But at some point with the holiday upon me, I started slacking off and found my checking using a great python programmers repo (@johnathanpaulson on GitHub) I learned a few more libraries to solve things. Particularly day 24, where z3 solver was introduced once I could bloody get it installed. Geeze.

    As I am coding less day to day and driving vision for my team, this was a nice reminder of how to break down problems into something solvable. It’s an important skill even if you are a shit programmer.

    Also the language you use matters. Python clearly is powerful in expediency and clarity. It would take 50-100lines for me to just take in the input file!

    Side note, some of the days I simply could not understand the sample or the goal but a vast majority of the days the story and explanations were great.

    Like many programmers, I’m shy about sharing code until it’s ready. But it will be under @rebelbot on GitHub AdventofCod2023 repo… just need to switch to public. But aren’t we all hear to learn?

  24. CW: Advent of Code spoilers

    I didn't even get to solving #AdventOfCode2023 Day 25 until after Christmas, but luckily it wasn't too bad.

    However, I did have to install networkx first. Most people seem to have used that.

    #AdventOfCode #programming #puzzle

  25. CW: Advent of Code spoilers

    Plenty of folks used external libraries to solve this, like sympy, z3, and numpy. I decided to use sympy myself for the sake of convenience.

    However, some other folks rolled out their own equation solvers to use for this problem! I think that takes dedication.

    #AdventOfCode #AdventOfCode2023

  26. CW: Advent of Code spoilers

    #AdventOfCode2023 Day 24 is the first day where I actually used an external library.

    For Part 1, I wrote my own code to get the hailstones' crossing points. But for Part 2, I used sympy to solve a series of equations that ensure the rock and hailstones collide.

    #AdventOfCode #programming #puzzle

  27. Feeling Advent of Code burnout. I’ve 5 stars missing (parts 2 of days 21, 23, 24, and the whole 25th day) and can’t get around to doing any of that.

    (Also honestly I’ve never done any graph algorithms so not even sure how to approach 25th)

    #AdventOfCode #AdventOfCode2023 #AoC #AoC2023

  28. CW: I cheesed AoC day 23 part 1

    I wrote Dijkstra distance-like function, but choosing nodes with longest distances first; and the order of considered candidates with equal distance depends on the internal state of the HashMap (which in #RustLang is randomized). So it’s not guaranteed to actually always find the longest path, but sometimes it does. I ran it ~10 times and chose the largest result. Seems I got lucky (or the input is simple enough).

    #AoC #AoC2023 #AdventOfCode #AdventOfCode2023

  29. CW: AoC days 20–21

    I failed to solve 2nd parts of those two puzzles myself. I looked at other people’s code/write-ups and I know how to approach them now (and I’ll try to finish them today).

    But I don’t like those puzzles since it’s basically “let’s look at the input and try to get the answer for it specifically” rather than doing a “proper” general solution to the problem as outlined in the puzzle’s description.

    #AdventOfCode #AoC #AdventOfCode2023 #AoC2023

  30. #AdventOfCode 2023 Day 19: Aplenty

    adventofcode.com/2023/day/19

    That was fun. I had a small mistake in part 2. In order to debug it, I was looking for a tool to visualize the decision graph. I found that #networkx in combination with #cytoscape works fantastic. Attached are the graphs from the test input and my real input.

    Code is here:
    github.com/nharrer/AdventOfCod

    NetworkX: networkx.org/
    Cytoscape: cytoscape.org/

    #AdventOfCode2023 #AoC #Python

  31. CW: Advent of Code Day 12 Spoilers

    2023 Day 12

    Oh my god, I had too much trouble with this. Haven't done in years, so I completely spaced it until my solution was taking forever.

    Memoization gave at a considerable speed boost. It's not the best solution, and it's far from readable, but it gets the job done and still takes under a second on my machine.

    codeberg.org/Taywee/AdventOfCo

  32. #AdventOfCode #AoC

    I completed #Day09 of #AdventOfCode2023.

    Part 1:
    - Difficulty: 1/10
    - Workout: 1/10

    Part 2:
    - Difficulty: 0/10
    - Workout: 1/10

    This one was too easy, done in half a hour! 2-dimension array to hold all difference sequences (including the original sequence, at index 0). No need to get to the all-zeros level, the one just above (all values are equal) is enough. Attention to index fiddling. That's it.

    Since I still got time, I refactored the program to make it presentable. It's in the next post in this thread. Done in almost one hour.

  33. #AdventOfCode #AoC

    I completed #Day08 of #AdventOfCode2023.

    Part 1:
    - Difficulty: 3/10
    - Workout: 2/10

    Part 2:
    - Difficulty: 3/10
    - Workout: 5/10

    Part 1 was a straight simulation: instructions given, parse and table moves, loop for following instructions. Barely a half-hour of work.

    Part 2 extends from one start point to several; it just means a list of places mapping to a list of places, instead of place mapping to place.

    Brute force, like in part 1, turned out to be not viable: 1.8e9 iterations, and nothing. I tried to find repeatable sequences of places, starting with each place and instruction position, but the volume of data generated was getting too big.

    I had to resort to r/AdventOfCode for tips. At once, I found: closed cycles and LCM. It was enough. I quickly found --Z to --Z cycles, and their periods; all multiples of the same number. A quick implementation of GCD, then LCM(a, b) = a * b / GCD(a, b), reduce list of periods by LCM, and done.

    Total time, programming and wasting CPU: about 7 hours.

  34. CW: Advent of Code

    I just completed Day 7 of #AdventOfCode2023 in #Elixir
    adventofcode.com/2023/day/7

    This was not particularly difficult, but rather verbose to code. All in all, one of those days I am truly happy I am a #FunctionalPrograming #fangirl, since pattern-matching makes my implementation almost a specification!

    gitlab.com/lauramcastro/advent

    #AdventOfCode
    #myElixirStatus
    #weBEAMTogether

  35. #AdventOfCode #AoC

    I completed #Day07 of #AdventOfCode2023.

    Part 1:
    - Difficulty: 2/10
    - Workout: 4/10

    Part 2:
    - Difficulty: 3/10
    - Workout: 4/10

    Took me almost 4 hours to solve this one, mainly because of the tricky implementation for jokers in part 2. Turned out that my method was too clever by half, and introduced itself a subtle bug.

  36. #AdventOfCode #AoC

    I completed #Day06 of #AdventOfCode2023.

    Part 1:
    - Difficulty: 1/10
    - Workout: 1/10

    Part 2:
    - Difficulty: 1/10
    - Workout: 1/10

    Completed in just over 1 hour. The implementation of part 1 was straightforward: easy parsing, map, filter, length. Part 2 would work, too, but after a few seconds running, I did the smart thing: skip the loops entirely. Immediate solution.

    Big hint: solve the equation

    a * (t - a) > d

    For integer a.

  37. #AdventOfCode #AoC

    I completed #Day06 of #AdventOfCode2023.

    Part 1:
    - Difficulty: 1/10
    - Workout: 1/10

    Part 2:
    - Difficulty: 1/10
    - Workout: 1/10

    Completed in just over 1 hour. The implementation of part 1 was straightforward: easy parsing, map, filter, length. Part 2 would work, too, but after a few seconds running, I did the smart thing: skip the loops entirely. Immediate solution.

    Big hint: solve the equation

    a * (t - a) > d

    For integer a.

  38. CW: Advent of Code Day 6 Spoilers

    Day 6

    Very easy day. Used my whiteboard to suss out that this was a (yes, I had to use my whiteboard to do this, and I'm not ashamed of being an embarrassment). Naturally, my solution uses the to find the answers.

    codeberg.org/Taywee/AdventOfCo

  39. #AdventOfCode #AoC

    I (finally!) completed #Day05 of #AdventOfCode2023.

    Part 1:
    - Difficulty: 4/10
    - Workout: 3/10

    Part 2:
    - Difficulty: 5/10
    - Workout: 7/10

    Part 1 was completed in 1 hour. Early in the game, I noticed that the mappings, with billions of elements, were too big to fit explicitly in memory. So, I created a function to pass one seed through the mapping, only checking the intervals' end points.

    Then part 2 came, with billions of seeds to check. Brute forcing was a lost cause: tried it, lost 2 hours, expected another 6 to be done.

    I had to resort to clever set operations (intersection and difference) over intervals: several folks had this idea. Split seed intervals over each mapping: common intervals are mapped to destination intervals, seeds not in common intervals make their own intervals and pass unchanged. The result is a list of intervals, to pass as input "seeds" to the next mapping.

    Now part 2 was almost immediate, the seeds having been pulverized into just a few hundred intervals.

    Total elapsed time: about 8 hours. Whew!

  40. CW: Advent of Code recap, 1/3. CW for length.

    #AdventOfCode #AoC

    #Recap, days 01 to 04.

    I'm doing #AdventOfCode2023, and while I wait for the next day, I use my limited free time (a luxury these days) to exercise on #AdventOfCode2015 older problems.

    I'm caught up with day 04 in 2023, and solved days 01 to 06 of 2015.

    I'm using JavaScript to solve the problems, because it's the language I better know currently. I *could* use one of several languages I learned something of in the past - Python, Ruby, PHP, Java, Visual Basic, PL/SQL... - but then, I would be still stuck in day 1! I'm here for the workout, not for (re)learning a language.

    Apropos of languages, there's a new kid on the block: Uiua (uiua.org/) #uiua. It's a child of #APL and #Forth, and beautifully #queer af! Just go to the site and see the live examples: #rainbow-colored syntax, and started to make sense to me in less than 15 minutes, even with the 1-#Unicode-char function names. And, for the #art folks, it generates images and sounds out-of-the-box.