Nadvent of Code - 2022 Day 1 - Lemmy.World
lemmy.world
external-link
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

Thanks Chief

Ategon
mod
link
fedilink
3
edit-2
1Y

Note weve also got an advent of code community that got started up into this instance at !advent_of_code@programming.dev

@mykl@lemmy.world
creator
link
fedilink
11Y

Yes, when I did a search, I found I had a choice between two quite small and inactive communities, so I went for the slightly larger one. I’ll crosspost today’s post to that community see if it stirs up any more interest.

I love dart, keep up the good work

@mykl@lemmy.world
creator
link
fedilink
31Y

Yes, I really adopted it due to Flutter, but the dev team really are doing great work to make it a nice language, especially with version 3.

I’m biased because I wrote a backend framework for it, but it’s really good on the backend and even just a general scripting language

@mykl@lemmy.world
creator
link
fedilink
11Y

True. I’m certainly at the point where quick jobs that I would have once done in Python quite often get done in Dart instead, avoiding the “context switch” of having to think in Python for that one task.

Create a post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



  • 1 user online
  • 1 user / day
  • 1 user / week
  • 1 user / month
  • 1 user / 6 months
  • 1 subscriber
  • 1.21K Posts
  • 17.8K Comments
  • Modlog