7419970f4167e6db7919e9fde7b70656c5ff77c6
Advent of Code 2022 - assignment 1
This is the first assignment for Advent of Code 2022. The provided solution uses 3 variables: currentScore, highestCalorieScore, currentElf, highestElf. It is complexity O(n²) since it loops through every line exactly once and the iterates for recalculating highscore.
Solution description
Every iteration the score is added to the currentScore. If an empty line is detected we check if currentscore exceeds one of our highestCalorieScore, if yes we assign currentElf to highestElf.
references
- https://adventofcode.com/2022/day/1
- https://stackoverflow.com/questions/17595361/how-to-read-text-line-by-line-in-a-html-text-area
- https://bobbyhadz.com/blog/javascript-get-value-of-textarea
- https://stackoverflow.com/questions/154059/how-do-i-check-for-an-empty-undefined-null-string-in-javascript
- https://www.geeksforgeeks.org/convert-a-string-to-an-integer-in-javascript/#:~:text=In%20JavaScript%20parseInt()%20function,argument%20of%20parseInt()%20function.
- https://stackoverflow.com/questions/1230233/how-to-find-the-sum-of-an-array-of-numbers
- https://www.w3schools.com/js/js_break.asp
Description
Languages
JavaScript
52.2%
HTML
26.4%
CSS
21.4%