A set of Idiomatic prod-grade katas for experienced devs transitioning to Go
https://github.com/MedUnes/go-kata
#HackerNews #IdiomaticGo #katas #forDevs #GoTransition #CodingChallenges #Programming
A set of Idiomatic prod-grade katas for experienced devs transitioning to Go
https://github.com/MedUnes/go-kata
#HackerNews #IdiomaticGo #katas #forDevs #GoTransition #CodingChallenges #Programming
The new LLM world is very exciting, and I try to experiment with the new tools when I can. This includes building agentic applications, one of which is my personal accounting and invoicing tool - that I wrote about previously As part of that effort I started experimenting with RubyLLM to have some view into items in my system. And while I have used a neat pattern for referencing objects in the application from the tool calls - the Rails Global ID system - it turned out to be quite treacherous. So, let’s have a look at where GlobalID may bite you, and examine alternatives and tweaks we can do. What are Rails GIDs? The Rails global IDs (“GIDs”) are string handles to a particular model in a Rails application. Think of it like a model URL. They usually have the form of gid://awesome-app/Post/32. That comprises: The name of your app (roughly what you passed in when doing rails new) The class name of the model The primary key of the model You can grab a model in your application and get a global ID for it: moneymaker(dev):001> Invoice.last.to_global_id Invoice Load (0.3ms) SELECT "invoices".* FROM "invoices" ORDER BY "invoices"."id" DESC LIMIT 1 /*application='Moneymaker'*/ => #<GlobalID:0x00000001415978a0 @uri=#<URI::GID gid://moneymaker/Invoice/161>> Rails uses those GIDs primarily in ActiveJob serialization. When you do DebitFundsJob.perform_later(customer) where the customer is your Customer model object which is stored in the DB, ActiveJob won’t serialize its attributes but instead serialize it as a “handle” - the global ID. When your job gets deserialized from the queue, the global ID is going to get resolved into a SELECT and your perform method will get the resulting Customer model as argument. All very neat. And dangerous, sometimes - once LLMs become involved.
I really didn't like this one. Basically have to do some bounds checking "it obviously always works" or "it obviously will never work" on it to get it to work on the actual input, but it still NEVER FINISHES on the example. I'm slightly bothered that the problem is more or less unsolvable as written, but I'm really bothered by the actual solution for the input not working on the example. That's not a fun puzzle, that feels like I'm being tricked, like the puzzle was a prank on me. Leaves a real sour taste, especially being the last puzzle of this year's AoC.
#AdventOfCode #AdventOfCode2025 #AdventOfCode2025Day12 #Day12 #Rust #RustLang #Programming #CodingChallenges #AoC #AoC2025 #AoC2025Day12
Memoization actually worked for this one. My first instinct was to just crawl the graph with a memo, and it fortunately did the right thing. It was effectively an exhaustive depth-first search. Really not much to discuss.
My code is not nice or clean, but after yesterday's, I can't even be assed to clean it up or properly comment it. I barely gathered the gumption to pass errors up, and when I started writing it, I was just throwing unwrap() everywhere.
#AdventOfCode #AdventOfCode2025 #AdventOfCode2025Day11 #Day11 #Rust #RustLang #Programming #CodingChallenges
Part 1 was a little tricky and fun. Solved it by just testing every combination, and sped that up by turning all the buttons and the goal light configuration into numbers that I could XOR together.
Technically, part 2 is done too, but it will never work on the real input. I threw memoization at this thing knowing that it wasn't going to work, but thought I might get lucky and the input would be constructed in a way that it would be fine. Nope.
I gave up and looked at the solutions thread on Reddit, and it looks like almost everybody is just throwing a solver at it (and the ones that aren't are using things like fraction-free Gaussian Elimination, which I can't hope to understand at this point in the night), and there are only 26 comments after 1.75 hours, so I guess this is a really hard problem this year.
I might come back to it tomorrow, but I doubt I'll find a good solution on my own. I don't want to just throw a solver at it if I don't have to.
#AdventOfCode #AdventOfCode2025 #AdventOfCode2025Day10 #Day10 #Rust #RustLang #Programming #CodingChallenges
This one was really hard for me. Part 1 wasn't bad at all; I could basically use the entirety of what I did yesterday for it.
Part 2 was really hard. At first, I tried actually building a HashSet of all the red and green tiles, and then a HashSet of all the areas for each pair, and checking them against each other. Needless to say, that wouldn't work. Building the tile HashSet alone would have eaten up more memory than I have on my computer, and I should have realized that immediately looking at my answer to part 1 (which was an area of over 4 billion tiles). I thought that checking a line of green tiles through the area wouldn't necessarily work, because a malicious input could make that not work (two immediate right or left turns could make a pair of adjacent green tile lines that would still work), but it turns out that it works fine for my input. Probably all inputs.
It works. I don't feel totally satisfied with the solution, but it works.
I think a more robust solution could be to trace the outline and fill it with square area units, then for each area to test (ordered from largest to smallest), repeatedly cut area out of it with the green tile squares. If all overlapping areas are tested and there are still un-cut squares, the area is invalid; move on to the next. If the area is cut completely to nothing, then it is the best area. I'm not going to implement this, because it sounds like a total fiddly pain, but I would be interested in seeing somebody else's solution along these lines.
#AdventOfCode #AdventOfCode2025 #AdventOfCode2025Day9 #AdventOfCode2025Day09 #Day9 #Day09 #Rust #RustLang #Programming #CodingChallenges
Now that's what I call Advent of Code! I'm happy with the algorithm for the most part. I'm sure it could be improved, but I paired up all boxes and pushed them into a BinaryHeap based on their squared distances, then popped the number based on the number of connections to consider (1000 for the real input). These I pushed into a set of "network" HashSets. This is the part I'm least happy with. I iterate the vector of networks to match each point to a network, and if they're both in a network, I extend the earlier one from the later and remove the later. I considered a lot of ways to improve this, but couldn't come up with one that wouldn't be either buggy or inefficient. I'll probably look at the Reddit solutions thread to see how other people tackled it.
Part 2 was really similar in execution to part 1, but continuing until all points were in a network and there was only one network, and keeping track of the last pair added.
Whew, this one was just the right amount of challenging and fun. Most of the days were pretty easy before today's. Now all we're missing is a nice A* problem.
#AdventOfCode #AdventOfCode2025 #AdventOfCode2025Day8 #AdventOfCode2025Day08 #Day8 #Day08 #Rust #RustLang #Programming #CodingChallenges