aoc2023

module
v0.0.0-...-22e6c3c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2024 License: MIT

README

GitHub License GitHub go.mod Go version (subdirectory of monorepo) Go Report Card GitHub top language GitHub repo size GitHub Workflow Status (with event) Go Coverage

Advent of Code 2023

I'm trying to do the Advent of Code in Go this year.

I just started learning Go on Nov 28, 2023. After doing the first 2 days I feel like I'm starting to get the hang of Go.

Day 5

Had some performance issues with my solution for the second problem.

First I added a global backSteps variable to be used by the LocationToSeed method. Which didn't make any noticable difference. I also removed some of the print statements which also made no effect on the speed. Replacing for i := 0; i <= 157211394; i++ with for i := 0; true; i++ for the condition in the loop that does most of the work did nothing either.

No read locks

Since after creation there are no writes to the almanac struct it's safe not to use locks. This shaved 35 seconds from the time.

Ranges

Total rewrite of the second problem to use ranges of numbers instead of indivual numbers made this super fast.

Added an interal library for ranges since they might be useful for future problems.

Version Sample 1 Sample 2 Input 1 Input 2
Initial 432.21µs 318.257µs 1.476169ms 1m25.011957731s
No read locks 471.923µs 507.104µs 1.281487ms 50.185503074s
Ranges 804.622µs 251.19µs 808.556µs 658.571µs

Day 10

Made a visualization of filling the outside spaces and finding the inclosed spaces.

Test Coverage

Go Coverage Chart

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL