Not super proud of my solution with this one… spoiler
5 posts - 5 participants
Doesn’t look like I’ll get this one finished tonight, but I’ll create a topic here anyway. Looking forward to seeing everyone’s solutions.
13 posts - 10 participants
I think the problem statement was intentionally difficult to parse this time. Those conditionals are a lot simpler than it makes them sound.
I kept the visited positions in a Hashed_Set
and coming up with a good Hash
function for a pair of Integers was new for me. I ended up making a lot of assumptions (Integer'Size = 32 and Hash_Type'Size = 64
) and just shifted one of the integers left 32 bits. A cursory Google search turned up the Cantor Pairing function, but I wasn’t able to make this work with negative integers in a short amount of time. Clearly I need to do more reading.
Part 2 caught me off guard, I hadn’t anticipated I’d need to deal with more elements.
Note: I’m going to stop using the spoiler blur on the daily posts. If you’ve gotten this far, I assume you know that these posts contain spoilers.
13 posts - 8 participants
I’m having fun building a visualization, so I’ve only finished part 1. It’s not about the leaderboard, right?
6 posts - 6 participants
Spent a huge amount of time to understand why Ada.Integer_Text_IO.Get
is unable to read a value from 0:
string . As always I forgot about deprecated integer format, where #
could b replaced by :
. Isn’t time to get rid of this in 2022?
http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-J-2.html
16 posts - 4 participants
Big-time spoilers that would have helped me finish a lot sooner. Most are available elsewhere; e.g., the subreddit.
11 posts - 4 participants
We’re past halfway!
(The downside is that the problems have suddenly stepped up in difficulty!)
For the second day in a row, writing a program that solves the example wasn’t enough. Twice I ran it and got solutions that were rejected as too large. I had to comb through some of the pairs that my program claimed were legitimate. In both cases, it was the case where I had to compare a number and a list. The instructions are to create a new list that includes the number, then compare the lists, but it seemed equivalent to me simply to compare the number with the first element of the list. This produced false positives. I haven’t quite figured out why, though.
Curiously, in part 2 I was able to make it work simply by spoiler
5 posts - 5 participants
Playing around with visualizing the output…
Test Data part 1: First and Final states:
Animated version:
Part 2:
For the real data it gets very large, so I didn’t output the frames, but only first and final states of part 1:
2 posts - 2 participants
Only 10 days left!
My solution to Part 1 was quite slow, perhaps because I used an OrderedSet
. It might be worth retrying with a HashedSet
at some point.
So I was really worried that Part 2 would be one of those problems whose obvious solution is to apply Part 1, but whoses complexity explodes on you, and as I first began to read it, my heart filled with dread. But then I realized that spoiler It still takes a few moments, but it worked! So I will be interested in seeing if anyone manages to solve it in a fraction of a second, and if so, then how.
I’m also amazed that Part 2 can even be a problem; the fact that he pulled off such a puzzle impresses me. Maybe it won’t impress me if I think about it enough, but even after a couple of glances, I’m still impressed. Maybe I just need some
8 posts - 4 participants
I taught my elephant to change places with me if his room name is bigger than mine and that cut the number of search options in half But this isn’t enough to get the answer fast anyway…
7 posts - 5 participants
Part 1 is pretty straightforward, I think.
Part 2 requires some mathematics, or at least that’s what got me to solve it quite quickly I did one other thing, too.
The solution I uploaded for part 2 will probably not work on the example program, because the example’s sequences aren’t quite as well-behaved as the actual puzzle, which made the problem a little harder. But the same technique really does work!
2 posts - 2 participants
It was nice to get an easy one after the past two days. The only hard thing was that gnatprove was either hanging or crashing, and I guessed that it didn’t like all the nested-nested-nested loops. I rewrote it so I generated an array of all coordinates and looped through that instead of the nested loops and I was able to get gnatprove to finish.
In case anyone needs help with part B:
8 posts - 4 participants
Nope. I’ve been at this for hours.
I wasted hours just trying to get my code to run the example in a reasonable time, and when I gave up I discovered that the input takes not much longer to run than the example.
So there’s a hint that doesn’t require a spoiler: don’t bother trying to get your program to work on the example in seconds; the input isn’t that much harder! Just try to get the program to work on the example, period!
Unfortunately, that’s not enough. The example doesn’t really illuminate the problem. Your code can run correctly on the example and run incorrectly on the problem input. This happens from time to time, but on a problem like today it’s ruinous.
To help me debug my program, I downloaded and ran several people’s solutions posted online (in other languages). I haven’t tried any of the solutions, but there’s a morbid satisfaction in the fact that different “solutions” produce different results on my input.
Some authors admit that they guessed at optimizations and got lucky; the optimizations probably don’t work in general. I’ve tried a few, and nope, they don’t work on my input (unless I’m implementing them wrong).
Some authors used parallelism. I may yet try that, since the problem is parallelizable, and otherwise I have to wait 5-10 minutes per attempt.
In short, I haven’t finished it yet. IMHO the puzzle is terribly flawed, for the reasons given above. And, yeah, sour grapes, too.
8 posts - 3 participants
(edited after remembering another bad idea, whoops)
I had one very good idea, one good idea, and quite a few bad ideas, including one very bad idea that held me up a long time.
8 posts - 4 participants
I really enjoyed today’s puzzle! Observations / hints / spoilers:
7 posts - 4 participants
This was fun. Even the debugging was fun. Even though the example was once again naughty, at least for Part 2, this was fun. (If anyone’s input creates a cube in the same way as the example, I’d like to know!)
Only one hint / comment from me: in part 2, spoiler.
I thought about drawing the paths onto the map, but it’s pretty late where I am, so maybe tomorrow. In lieu of that, here’s an aid I made to help with Part 2.
10 posts - 3 participants