I'm posting a daily Dart solution to last year's Advent of Code challenges

Open link in next tab

Nadvent of Code - 2022 Day 1 - Lemmy.World

https://lemmy.world/post/7583249

As 2023 Advent of Code is approaching fast, I thought I’d revisit my 2022 entries, and I realised a good focus would be to post one a day during November. No guarantees as to the quality of the algorithms used, but hopefully people will find the code readable and interesting. If anyone has questions or ideas for improvement, I’d love to hear them. They were all written in Dart, and I will modify each one to allow it to run online in the browser. Some of the code may look a little odd as I had to inline the functionality from some libraries that I used as DartPad doesn’t support them all. Anyway, here’s the core of my response to Day 1. The full code can be read and run by following the link above. int part1(String lines) => totalCalories(lines).first; int part2(String lines) => totalCalories(lines).take(3).sum; Iterable totalCalories(String lines) => lines .split('\n\n') .map((e) => e.split('\n').map(int.parse).sum) .sorted(descending);

Hi all,

As many people here may already know, Advent of Code is an annual programming challenge that runs from 1st to 25th December each year where each day a new puzzle is published for you to solve. The puzzles ramp up in difficulty during the month and can test your familiarity with core computer science principles and algorithms.

As the title says, I'm currently going through my entries (written in Dart) to last year's challenge and rewriting them to run in your browser using DartPad. I'll be posting one a day until 25th November to the Advent of Code community on lemmy.world.

It's fairly quiet there at the moment, but I hope that with enough awareness of the community, it will liven up enough over the coming weeks that I don't have to go back to the other place for interesting discussions and hints next month!

Cheers, Michael