Advent of Code 2021 - Day 5

preview_player
Показать описание
In this video series, I try to challenge myself with the Advent of Code trials. Each solution will be published to Github, and I hope you will learn something from my coding mistakes and perhaps send some code my way on how you have done these challenges. I know by reading code, so this is such an exciting thing for me.

Github repository:

Unlock unlimited opportunities with 50% off your first month of Coursera Plus

Get on the fast track to a career in cybersecurity. In this certificate program, you'll learn in-demand skills, and get AI training from Google experts. Learn at your own pace, no degree or experience required.

Join the channel to get access to more perks:

Or visit my blog at:

Outro music: Sanaas Scylla

#aoc2021 #advent #code
Рекомендации по теме
Комментарии
Автор

I was also happy that we only had to worry about 45 degree lines. Years ago I did write a line plotting program that used the "y=mx+b" formula (back in the 320x200 VGA days). I never did master the much better/faster Bresenham algorithm.

I included support for diagonal lines in my Part A solution, and filtered my input to just horizontal and vertical. I had a pretty good feeling that diagonals would be in Part B. So my solution to Part B was just to remove my filter.

Since we only have to worry about 0, 45, and 90 degree lines, I just start at the first position and with 4 if statements I increment or decrement the x and y on each iteration until I reach the end position.

I'm really enjoying these challenges so far. Famous last words, now that I've said it, I'll get stumped tomorrow... :)

aaronperl
Автор

THE IF-ELSE CONDITIONS WERE SUPERMESSY FOR ME, ANYWAYS AMAZING JOB DAN

robertelies