Holiday Coding Fun: Tackle the Advent of Code with Motoko!

Hey devs :santa:,

The cozy month of December is a great time to learn a new programming language or exercise your developer muscles to improve your skills.

So whether you are new to Motoko or already a seasoned Motoko dev, we’d like to invite you to participate in this year’s Advent of Code using Motoko to solve the challenges.

To kickstart your adventure, @rvanasa has thoughtfully prepared a starter project for you.

Curious about the Advent of Code?

Advent of Code is an annual online event that takes place during the Christmas season, starting on December 1st and running through December 25th. It was created by Eric Wastl. Each day, participants receive a two-part programming challenge that they can solve in any programming language. The challenges are a mix of algorithmic puzzles and problems that require coding to solve.

The event is designed to be fun and to help people improve their programming skills. The puzzles range from relatively simple tasks to more complex ones as the event progresses. Participants can join at any time during the event and don’t have to complete every challenge. They earn “stars” for solving each part of the daily challenge, with a maximum of two stars per day.

Join, learn, have fun!

We encourage you to use this thread as your go-to platform to discuss, dissect, and share solutions.

Wishing you a delightful and code-filled holiday season :christmas_tree:!
Let the coding festivities begin! :star2::woman_technologist::man_technologist:

16 Likes

@rvanasa Hi, very cool idea. I have tried the gitPod, but it doesn’t work to me. The start process ended with an unexpected error.
Bildschirmfoto 2023-12-01 um 09.52.27

Hi @rbole,

what browser are you using? I had the same issue on Chrome, but works in Safari.

Hi, I use Chrome Version 119.0.6045.159 on Mac and yes it works with Safari.

Nice. I see people post the solution in different languages on Reddit. It will be good to see how different languages handle the problem.
I quickly made this (doesn’t work intentionally and needs the regex to be changed)
https://jglts-daaaa-aaaai-qnpma-cai.ic0.app/126.e1933b76d93a3fd9018e59fe23fc67f54816708c9cfdee5e139fe065
Blast can also do it in Motoko, but I’ll have to run now. Will be cool to see what the solution in Motoko will look like. I think having different Motoko solutions will be good learning material.

I am assuming you can’t submit the day one challenge on day two, so you can post your solutions here the day after?

2 Likes

Nice solution @infu.
I published my motoko solutions to this repo: GitHub - tomijaga/advent_of_code
Looking forward to seeing other people’s solutions as well.
I coupled this together quickly so it might not be the most readable code.

2 Likes

Nice, I also made a Motoko version. Took the char to number from you.
The first part should be fast, but it’s a bit unreadable;
For the second part, I wanted to use pipes
https://jglts-daaaa-aaaai-qnpma-cai.ic0.app/128.4644d0fce6735c925c2ada035c4116147dd61aaea032b762c85ba685

2 Likes

Pipes make the code much more readable indeed.
I like your method of inserting the number directly into its word representation ( “one” → “o1e”)
Allowing you to reuse the same function to solve parts 1 and 2.

1 Like