Skip to content

Commit aa3dd5a

Browse files
committed
add best bits to readme
1 parent 524e704 commit aa3dd5a

File tree

4 files changed

+291
-4
lines changed

4 files changed

+291
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ ifeq ($(shell docker image inspect $(image-name) > /dev/null 2>&1 || echo not_ex
9090
make run
9191
else
9292
ifneq ("$(wildcard vendor)", "")
93-
@$(DOCKER_RUN_PHP_MY_IMAGE) $(image-name) php -dmemory_limit=4G -dopcache.enable_cli=1 -dopcache.jit_buffer_size=100M -dopcache.jit=1255 run.php $(onlyThis)
93+
@$(DOCKER_RUN_PHP_MY_IMAGE) $(image-name) php -dmemory_limit=1G -dopcache.enable_cli=1 -dopcache.jit_buffer_size=100M -dopcache.jit=1255 run.php $(onlyThis)
9494
else
9595
@echo -e "\nFirst run detected! No vendor/ folder found, running composer update...\n"
9696
make composer

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ Each day comprises two parts, both based on the same input. You'll need to use a
1717
rely on good knowledge of algorithms, logic and data structures. The true beauty of Advent of Code is the solutions
1818
can be written in any programming language.
1919

20-
I am most proud of my solution to [Day15](/src/Day15.php), which requires you to remember the numbers said in a list,
21-
appending the next based on when it was previously said. Part 2 requires you to calculate the 30'000'000 (30 millionth)
22-
number spoken, and through lots of tweaking and optimisations, I've got this solution down to 11 seconds using 633mb.
20+
### 🏆 Best bits
21+
**Best algorithm and optimisation: Day15**
22+
[Day15](/src/Day15.php), requires you to remember the numbers said in a list, appending the next based on when it was
23+
previously said.
24+
My first attempt at this (part 1) was pants. I used a single array to keep track of every number spoken and used the
25+
array index to calculate turns. Fine for calculating the 2020th but when it came to the 30 millionth… No chance! 😂
26+
27+
After much playing around and refactoring, I was able to make some big improvements by using some lesser-known PHP
28+
class types like `SplFixedArray`. I've got this solution down to just 11 seconds using a paltry 633mb of RAM on my lappy.
2329
![day 15 part 2](/aoc-2020-jthatch-day15-pt2.png "AOC 2020 PHP Day 15 Part 2 in 11 secs")
2430

2531
### Tech

0 commit comments

Comments
 (0)