Post from wezm on 09 Dec 2022

This is a static archive of wezm@decentralised.social

https://mastodon.decentralised.social/@wezm is now my primary account

☜ Back to home page
wezm
Day 8 of #AdventOfCode: part 1 one took me a long time and I almost gave up on #gleam but I slept on it and got it working this morning.

Since Gleam only has a List type that is not optimised for index based access I implemented part 1 in a way that does not index into it and also pre-calculates the max values in each direction to avoid having to make repeated scans in all four directions.

When it came to part 2 I just did the index based scanning thing and it was a lot quicker to write and also still ran in well under half a second so definitely a case of premature optimisation on part 1.

https://github.com/wezm/advent-of-code/blob/master/2022/src/days/day_8.gleam