Advent of Code 2022

I like that solution the best, indeed. Could be more performant if you did split the full string only once and then clear the dict in each iteration. Might then even beat my way, I guess.

ALSO: How did you markup that Spoiler text? We should all learn to use that.

1 Like

Right. Ricardo’s solution is basically using a Set as well.

Huh, this thread is getting quite long. Maybe we should make one per day :slight_smile:

1 Like

I had to use a Dictionary as there are no Set, yes.

@Thomas_Tempelmann when you reply, there is a gear icon with the “Hide details” option.

1 Like
Hidden text

Ah, got it. Nice!

Also: The classic Dictionary is case-insensitive. We really need a case-sensitive Set as well.

1 Like

My implementation is case-sensitive. To create the Dictionary, I used dict = ParseJSON( "{}" ).

2 Likes

I’d prefer to use a Set for this, instead of hacking a Dictionary :sweat_smile:

My Day 6 solution is the first one that’s not too ugly to post:

Spoiler
'Day06 Parts 1 & 2
dim inTxt As String = tf1.Text 'Read all of the data into string inTxt
dim bufLen As Integer = 14 '(4 for part 1, 14 for part 2)
dim bfr As String = left(inTxt,bufLen)
dim nchr As Integer = 1
dim bTest As Boolean
do
  bfr = mid(inTxt,nchr, bufLen)
  nchr=nchr+1
  bTest=True
  for i as Integer = 1 to bufLen-1
    for j as Integer = i+1 to bufLen
      bTest = bTest and mid(bfr,i,1)<>mid(bfr,j,1) 
    next
  next
loop until bTest or (nchr > len(inTxt)-bufLen)
MsgBox "The answer is: "+str(nchr+bufLen-2)

I haven’t compared mine to the others yet. So maybe it’s the same as someone else’s. It was fast enough to give an instant answer, which is all that’s needed for these puzzles. I have to get out of the mindset that efficiency matters, unless they start coming up with puzzles that really need it.

Thomas, your link isn’t working for me.

Damnit - I had created a new site in Cyberduck and didn’t update the http URL accordingly.

Here’s the correct link for my code: https://files.tempel.org/RB/AdventOfCode.rbp

(and to add to AlbertoD’s comment: I’ve fixed the link in Cyberduck so that it’ll be https in the future, too)

I am using Chrome and it doesn’t like to follow http content from https pages, as the forum is https, when I try to click your http link, it looks like it is not working because nothing happens.

It looks like https works for your file. This link should work: https://files.tempel.org/RB/AdventOfCode.rbp

1 Like

Finally got round to day 2.

I really need to implement a select...case or switch statement in ObjoScript…

2 Likes

Whew!

Spoiler

Okay. Building file system trees and determining the directory sizes is what I’ve written many times before (-> Find Any File). Though I made some stupid mistakes in the second part (stayed up all night again), I am glad I finished first regardless (anything else would’ve been quite embarrassing). Still, I’d not be surprised if someone else later gets a better turnaround time.

And now I’m too restless (agitated?) to go to bed. Good thing there’s beer in the house :slight_smile: Cheers!

2 Likes

I forgot to implement the function that returns a child by name and it still worked. Wild.

(Fixed now.)

2 Likes

I almost gave up on the Day 7 puzzle, but I guess I’m just too stubborn.
I had an elusive circular reference bug in my node tree that kept causing a stack overflow exception. It took forever to figure that out. Then when I finally got it working with the example data, it broke again with the real data. Finally sorted that one out (a node not being added in some cases when it should have been).

By then my brain was so fried that the relatively simple part 2 took me way longer than it should have.

Oh well, it’s done. I’m afraid to think about what’s coming next.

Beer definitely sounds good right now.

3 Likes

Argf, got stuck with the second part because I wasn’t reading it properly.

  • This one was fun
  • I need more coffee
1 Like

BTW, somebody managed to solve Day 7 in 5 minutes… I barely can prepare myself a coffee in 5 minutes :joy:

Captura de Pantalla 2022-12-07 a las 10.35.02

1 Like

We are getting to more complicated or involved puzzles now, and I’m not one of those people who can do them that quickly. I’m still concerned (somewhat) about code quality rather than just solving the puzzle.

What I’m trying to say is, if I look at the puzzle tonight (or upcoming) and decide it will take too long, I’ll put it off. I don’t mind staying up until 1 am (that’s actually rather normal) or even all night if the situation warrants, but these puzzles don’t rise to that level of urgency.

@Thomas_Tempelmann 's competitive streak notwithstanding: :smiley:

4 Likes

The ones that get it done so fast are probaply playing with GPT-3 or ChatGPT. You can find them mentioned on Twitter and Mastodon. It’s a curious thing, but so far there’s no official way to tag them.

1 Like

My day-night schedule also gets f**ked up by this competition. Couldn’t get to ned until 9 in the morning, got up at 4 in the afternoon. I’ll probably stop that. I just wish the leaderboard would record the start time, then it would be much easier for all of us to compete at our own time. I requested with the organizers that but didn’t get any reaction.

Spoiler

Also: I’m amused that almost everyone took an unexpected long time for part 2, just like me. I first had trouble getting the code right to calculate the limit that needs to be found, and only later realized that the recursive size finding function had to be changed from finding the lower values into finding the higher ones. I made the mistake of duplicating the function, rename it and change its compare operators. But I then got the wrong dirs out of it. Took me a while to realize that the recursion still called the old function, not itself. So, duplicating and renaming wasn’t smart here - adding a parameter for lower/higher would’ve been safer because then the compiler would have told me that the recursive call is missing an argument. Sloppy work on my part

I got stuck in part 2 because I was using the values from the example :man_facepalming:

1 Like