Kem, I congratulate on the quick puzzle solving, of course!
Enjoy it while you can
BTW, I realized later that I could perform the intersection check with the built-in Rect class, like this (my ranges
use a Pair for the start (.Left) and end (.Right) values):
dim r1 as new Realbasic.Rect (ranges(0).Left, 0, ranges(0).Right-ranges(0).Left+1, 1)
dim r2 as new Realbasic.Rect (ranges(1).Left, 0, ranges(1).Right-ranges(1).Left+1, 1)
dim score as Integer
if r1.Intersects (r2) or r2.Intersects (r1) then
score = score + 1
end if
1 Like
Clever, I hadn’t considered that.
I only needed to change one simple line of code to change from part 1 to part 2, but I made several stupid blunders.
How are you able to find the times of the participants? I can only see a link to my own stats.
Wouldn’t the first method call imply the second?
1 Like
Perhaps parsing the JSON API? Otherwise, I don’t know either.
Uh, you are correct. This was a leftover from the first part, where two checks were needed
Right. Text explaining the private leaderboards mentions that you can get the entire JSON record for all participant, and in there you find the timestamps for the times of solving part 1 and part 2. Then you can calc the difference. Sadly, they never store the time when you pulled the page with the new challenge for the first time.
Also: Congrats to Kem for the fastest time again. It took me 30 minutes just to get the parsing right. Then the 1st puzzle in another 8, and the second was quicker because that I had already wrongfully used that 2nd algo in the 1st part at first
(And I notice that you’re slowly building a toolbox with helper functions. That’s smart because the parsing is often similar and may also become more complex, as in today.)
And please don’t forget to push your solution. I’m curious how you did the parsing, Kem.
Pushed.
** SPOILER SPOILER SPOILER **
** SPOILER SPOILER SPOILER **
** SPOILER SPOILER SPOILER **
** SPOILER SPOILER SPOILER **
** SPOILER SPOILER SPOILER **
** SPOILER SPOILER SPOILER **
DAY 5 SPOILER
I relied on the fact that it was single digit stacks and just pulled every fourth character starting at the second character. When I hit “1”, I was done.
1 Like
** SPOILERS BELOW **
** SPOILERS BELOW **
Looking at your code…
It surprised me that you used Split in many places, but then regex for the cmds. I simply split it by spaces. And you used a real array for the stacks, where I simply used a string. I guess now that you have made all those helper functions, you also want to make use of them
But overall most of our codes look similar in the way they work, so far. Then looking at other languages, even Swift, and you see totally different ways, often. That shows the limitations of Xojo. Not having closures is one of the biggest losses we have in Xojo, and could have gotten it if Geoff hadn’t let the developer eng go just when he was ready to add them (he even presented his plans at the Xojo conf back then)
OTOH, when I look at Swift solutions like this, I have trouble reading what the code does. I find our Xojo solutions at least more readable
While looking around for other AoC solutions, I even found one done with TeX. I had no idea that’s possible. Or this for day 1 in AWK
Those last ones - the author solves each daily puzzle with a different language (AWK, TeX, C, Java). He knows his tools. Impressive.
At least the input data was in a reasonable format this time.
Kem, why annoying? Did you make a grave mistake? You were still the fastest, after all.
I started late but took about as long as Kem from start (reading) to finishing puzzle 2. I had the best algo already implemented for part 1, so it needed to only adjust some numbers for the second (though, as I didn’t use a constant in the 3 locations I needed the number, I overlooked one at first and had to find what I missed). Babelfish (Matt Combatti, I suppose) did that one the fastest – congrats!
(Reminder: Always use constants when you refer to the same value several times!)
1 Like
Yup, I’ve found today puzzle easier than other days.
I have to confess that I’m a bit afraid of what Eric Wastl may have prepared for the next days. Feels like the calm before the storm.
1 Like
Yes, I misread a requirement, and kept misreading it, leading it to an incorrect test set result.
Ah well, onto Day 7.
2 Likes
Comparing my code to Ken’s, I see that our algos differ this time. While Kem’s looks forward for matches, mine looks backward - and where his is simpler to understand, mine needs an extra “minPos” variable to prevent wrong results. OTOH, mine should be a little faster for that reason. (Indeed: Kem’s: 18ms, mine: 6ms)
BTW, I found out rather by accident that recent Xojo IDEs can again open .rbp files by default, whereas, for years, the Xojo IDE didn’t offer to open the old project file extensions (used by Real Studio) when double clicking them.
2 Likes
I’ve did it a little bit different. Probably not as performant as the other solutions, but it felt instant anyway.
SPOILERS: Day 6 solution
I’ve made a kind of Set, using a dictionary, then I’ve counted the amount of keys and compared it to the expected amount.
For i As Integer = 0 To data.Length - 1
Var set As New Dictionary
Var chars() As String = data.Middle(i, amount).Split("")
For Each char As String In chars
set.Value(char) = True
Next
If set.KeyCount = amount Then Return i + amount
Next
2 Likes
As long as it finishes in a reasonable time, it doesn’t really matter, and I like your approach. I thought about using my new class to do this in a similar way, but ultimately decided against it. If I had, I probably would have finished a lot quicker.
2 Likes
I know you’re joking since I asked you to comment on it, but for others’ benefit, I create a Set class that I’m lobbying for inclusion in the framework. If Xojo ultimately does not agree, I’ll release it on Github.
2 Likes