Blog 9.2.2023

Discovering new ways of creating modern green code at the Advent of Code

Gofore Crew

Four weeks of intensive daily problem solving, also called Advent of Code, happened for the 7th time in late 2022. At Gofore we were thinking how to make this event even more fun and attract new people to join the fun. Yet again, the lessons learned at the event revealed inspiring results.

Setting the scene

On previous years we have had some AoC related random discussions on developer oriented Slack channels, but nothing more. This time new ideas were experimented and proven to be working wonderfully. Few days before the event a dedicated AoC Slack channel was set up, and with some simple scripting (listing 1), scheduled Slack messages were rigged to be sent at key moments to start daily challenge and solution discussion threads. A private leaderboard was created at AoC portal and there was internal advertising on developer oriented Slack channels to get people’s attention.

CHANNEL_ID = "aoc"
CHALLENGE_DAYS = 25
 
def schedule_message_at(trigger_day, trigger_hour, message):
  challenge_day = datetime.date(2022, 11, 30)+datetime.timedelta(days=trigger_day)
  scheduled_time = datetime.time(hour=trigger_hour)
  schedule_timestamp = datetime.datetime.combine(challenge_day, scheduled_time).strftime('%s')
 
  try:
      result = client.chat_scheduleMessage(
          channel=CHANNEL_ID,
          text=message,
          post_at=schedule_timestamp
      )
      logger.info(result)
 
  except SlackApiError as e:
      logger.error("Error scheduling message: {}".format(e))
 
days = range(1, CHALLENGE_DAYS+1)
 
list(map(lambda day:
          schedule_message_at(day, 7, "Day "+str(day)+" challenge discussion"),
          days))
 
list(map(lambda day:
          schedule_message_at(day, 9, "Day "+str(day)+" solution discussion"),
          days))

During the first few challenge days people were actively discussing about how they had configured their programming environments and which programming languages they had chosen. Many saw this event as a possibility to try new programming languages or as an opportunity to experiment on things not possible within their current customer projects. 

Our key discoveries

Days passed and challenges got more demanding and complex. Few key findings were made to make solving difficult problems easier. Visualising data for every algorithm iteration proved to be a handy way to see if the data was processed correctly and to spot mistakes. These animated visualisations were also fun to watch and to impress others.

Another big thing was to improve and optimise the algorithm performance. This led to many fruitful discussions and switched people to competitive mode where they tried to find creative ways to save computation time and lower memory usage. One key tool category for optimisation was different profiling tools that could reveal bottle necks and helped to prove if changes in the code really helped to improve to shorten the program execution time.

Key discovery with the optimisation and profiling effort was that optimisation is really important step in software development. Code optimisation is also one of the key methods for achieving green code goals. We have super computers available all over, from different public cloud providers etc., but if we make super code, with modern system languages like Rust, then we can get results with less computing power and with lower power consumption. Isn’t that one of the key building blocks for reaching the sustainability goals with modern digital services if anything?

With full force towards the 2023 event

All in all, our AoC experience improved a lot with these small and easy to do actions which encouraged new people to start solving the challenges and get excited about the event. On our private leaderboard we got five challenge competitors with full starts and over thirty with some stars, not bad. Now we are eagerly waiting 2023 event and are more prepared to make it even better experience for everyone.

Gofore's Advent of Code leaderboard.

Our communities meet up regularly to share their knowledge.

Otto Salminen

Software Architect

I have been involved in architecting modern web application to public for national job seeking service, mentoring best practices and building large-scale Kubernetes environment for large global technology company, and defining DevOps baseline and guidance for one of the largest national public sector organisation. I like to use various techs at work, such as Azure, .NET Core and React. I also participate in organizing hackathons and various meetups, and I share my expertise at internal and external events.

Back to top