Jump to content
pmcgee

The Advent of Code 2024.

Recommended Posts

The Advent of Code 2024.
ChatGPT >>
“The Advent of Code is an annual online event and programming challenge that takes place in December. Each day, a new puzzle or coding challenge is released, and participants are encouraged to solve them using their programming skills. The challenges are designed to be fun, creative, and challenging, and often require problem-solving and critical thinking skills. The event has gained popularity among programmers and coding enthusiasts as a way to improve their skills, compete with others, and have fun during the holiday season.”
I’d like to encourage lots of Delphi people to have a crack and maybe compare solutions - online or at a meeting.
Each day is pretty much independent of the others … but the concepts might build upon previous days’ puzzles.
 
Fun starts on 1st December. Link → The Advent of Code 2024
  • Like 6

Share this post


Link to post

Ready for tomorrow start ?

 

Don't forget that IA like ChatGPT and Copilot are not welcome during coding challenges. It's a game for humans coders only. 😉

(if you use them it has no interest except learning how to explain the problem to them)

 

  • Like 1

Share this post


Link to post

I've solved the first few days of puzzles, written as D12 console apps. My answers are on Github. I'm skipping some that I'm either not sure how to tackle or will take too much time away from my daily tasks--like Day 4, not really sure how to search a matrix of characters for patterns in every direction.

Share this post


Link to post

I'll try to start this week-end on Twitch, but will probably prefer coding some things on my games or tools. I'm not really focused on this challenge this year, which is weird. 😉

Share this post


Link to post

I'm lagging a little bit behind ... my solutions are here https://github.com/pmcgee69/Advent-of-Code-2024/

My ultimate aim is to try to use a functional approach ... and to get ideas for better syntax for Delphi into the future.

I'd really like to also solve in Rust and C++, for the learning but also for the ideas on syntax.  I will definitely try to lean on eg Claude.io to work out solutions in those two. There's only so much time available!

Share this post


Link to post
8 minutes ago, Patrick PREMARTIN said:

please, don't forget to add some topics to your repositories to increase cross visibility

Ah yes--I often forget to add those. Thanks for the reminder--done.

Share this post


Link to post

Thanks 🙂

 

I was a SEO guy in an other life. Putting links and hashtags everywhere has become a reflex, I can be quite insistent on that, please excuse me.
As long as we're spreading our codes, we might as well do our utmost to make sure they have a chance of being seen one day.

 

To infinity and beyond, Delphi defeats the TIOBE index!

 

Maybe I'm overdoing it?

  • Like 1

Share this post


Link to post

I do not normally do these types of challenges because I am no professional.

 

But, I did an Excel version of Day-1's puzzle fairly quickly.  It took a few minutes without any programming involved, so I guess it does not count.

 

306141697_im-praxisforum-TheAdventOfCode2024Day1inExcel.png.a9594dff02d739b720ceae6ad7385cd1.png

 

But I did an XE7 (windows) version, today, though it took me many hours to complete.  I don't have those Services listed on the website, so there is nothing to see from me, source code wise, over there.   And, I am proud to say that, "I did it!" for Day-1's puzzle. 
 

  • Like 1

Share this post


Link to post

@JohnLM Great. This is perfectly reasonable .. for at least two reasons. 

 

1) The challenge is about achieving a solution - dissecting the problem in a way that makes it solvable.

 

2) Eg in the day 2 and 3 problems, I put the data in Excel to manipulate it around, get a perspective on the contents, and to provide results to crosscheck against while I am only part way towards constructing my approach. I have kept them in my Github repo.

 

3) Also, some of the challenge is just reading in the data ... which can be sometimes tedious and/or obvious.  I have used Excel and Notepad++ to make the data into a Delphi unit holding the info, when moving text with code was unrewarding.

 

PS : There's a cool video from the guy that creates and runs the challenges from very recently. People solve the problems in many different ways - and not just with code. 

CppNorth - Keynote: Advent of Code, Behind the Scenes - Eric Wastl

  • Like 2
  • Thanks 1

Share this post


Link to post
1 hour ago, pmcgee said:

There's a cool video from the guy that creates and runs the challenges from very recently

That was a very fun and informative video! Thanks for posting!

  • Like 1

Share this post


Link to post

I was hoping to show a screenshot snippet of my XE7 version of Day-1's puzzle as proof.  I mean, I think some of you may like it.  As soon as I figure out something with the image, I will post it here.  I haven't looked at any of the videos posted here because I don't want to know what the puzzles are until I tackle them as I can if I can. 

 

Also, I just read Day-2's puzzle.  It is interesting.  I have some ideas racing through my head already, and once you see my first puzzle you may be able to figure it out, but I work the night shift and I need to get some sleep. 

  • Like 2

Share this post


Link to post

I set the animation (5 frames) to a limit of 5 iterations only, then it stops. 

 

** I removed the gif because it was tacky to see a watermark from a trialware. I will investigate an alternate method to create my own, maybe delphi can do it, just need to figure out how to accept a list of bitmapt/png images, delay and loop and save as .gif file. 

 

Edited by JohnLM
I removed the gif because of the tacky watermark.

Share this post


Link to post

Ahh, I just spotted a typo.  Should be RT, not RF.  Anyway. . . I forgot to explain my resolve of this puzzle.  

 

Column LF and RT are randomly generated, then calculated in the DST (distance) column via the [Generate] which generates random numbers for both LF/RT columns, and then I calculate (I sum each value in DST) the Total Distance (in the DST column) below those columns.  I should have labeled that section. Oh well.. I can't do everything perfectly! 😞 

Share this post


Link to post

I don't think you should be bothered about watermarks.  In my favourite 'podcast with slides' of well over 100 episodes, the 'Activate Windows' logo has become an expected, even demanded, regular character.

Share this post


Link to post

One thing that is part of the challenge, from my perspective ... is when you can deal with Part 2 with only a reasonably small modification of your Part 1 solution.

 

Maybe it's just me, but I find that very satisfying when it happens.  😎

  • Like 1

Share this post


Link to post

Okay, I found a way to create animated GIF files in Delphi XE7 via TGIFImage, thanks to @Anders Melander for his how-to codesnippet in another post here, where I modified the code slightly in order to create the GIF file via images I screenshotted (ctrl+alt+prt sc) to clipboard and to the delphi app. 
 

I set the animation (5 frames) to a limit of 5 iterations only, then it stops. 

 

 

 

Advent of Code 2024 - Day 01 - Historian Hysteria - in Delphi XE7 - completed


LF and RT are random lists of numbers generated

DST is the list of results from the LF and RT lists, and Total Distance is the summation of DST. 

 

AdventOfCodeDay01_ByJohnLM.gif.9611771e5a50e2282f564fd2418a52f3.gif
 

Edited by JohnLM
added explanation of Day 1's solution
  • Like 1

Share this post


Link to post
20 hours ago, pmcgee said:

One thing that is part of the challenge, from my perspective ... is when you can deal with Part 2 with only a reasonably small modification of your Part 1 solution.

Yeah, it trains you to modularize your solution to accommodate changes to the requirements, a real-world occurrence that programmers must continually face.

Share this post


Link to post

Yes, I agree about the solutional changes.  But I sometimes veer past it in my hair-pulling while debugging alternative solutions. 

 

Oh, I just started Day-2, half an hour ago.  I've got up to the point of generating the random values for filling in the levels list and a few other tid-bits. 

 

And, now about to start the real challenge of how to determine what level(s) are safe and unsafe.  Should take me many more hours to solve. . . can't wait!

  • Like 1

Share this post


Link to post
3 hours ago, JohnLM said:

about to start the real challenge of how to determine what level(s) are safe and unsafe

The tricky part is to figure out whether the levels are increasing or decreasing for a particular line--this determination has a real twist in part 2. Have fun!

Share this post


Link to post

@JohnLM ... (Throwing a possible small spanner) ... I'm not sure from the gif ... are you sorting the two lists?

Share this post


Link to post

Re:  Day 2 puzzle 

 

3 hours ago, corneliusdavid said:

The tricky part is to figure out whether the levels are increasing or decreasing for a particular line--this determination has a real twist in part 2. Have fun!

I believe I have that part worked out.  This is not code, it is just my way for me to keep track of the logic for Inc/Dec directions, visually and mentally. 

{

 given the array for levels [1 3 2 4 5 ] 

1 and 3 = low to high is increase (RT) 
3 and 2 = high to low is decrease (LT) 

}

 

But there are twists as you said.  And I believe I am in that twist. . . 3 hours 10 minutes into this.  I keep a timer on when I start/stop/pause work via the Android clock app. 

 

My skills in if/then Logic are poor.  But as long as I meet up with success, I will survive another project. 

 

What is part 2 that you are talking about?  Another puzzle?  I don't look at other puzzles until I have completed the current one I am working on. 

 

Share this post


Link to post
2 hours ago, pmcgee said:

@JohnLM ... (Throwing a possible small spanner) ... I'm not sure from the gif ... are you sorting the two lists?

No, no sorting.  But I did spot another error.  But is not a bug.  I miss-used the Random() function.  I should have set it as Random(1,9) and not Random(9).  Because of that, I am getting 0's included in the randomized lists in the report for Day-1's puzzle.  The 0's were not in the instructions on the website.  A slight oversite on my part. But, it still passes as a success. 

 

Edited by JohnLM

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×