I’m planning to implement each day with new programming language from the sorted list [25/25]
- [X] 1.12 Assembler
- [X] 2.12 AWK
- [X] 3.12 Bash
- [X] 4.12 C
- [X] 5.12 C#
- [X] 6.12 C++
- [X] 7.12 Clojure
- [X] 8.12 Common Lisp
- [X] 9.12 Erlang
- [X] 10.12 F#
- [X] 11.12 Go
- [X] 12.12 Haskell
- [X] 13.12 Java
- [X] 14.12 JS
- [X] 15.12 Kotlin
- [X] 16.12 Lua
- [X] 17.12 Pascal
- [X] 18.12 Perl
- [X] 19.12 PHP
- [X] 20.12 Python
- [X] 21.12 Ruby
- [X] 22.12 Rust
- [X] 23.12 Scala
- [X] 24.12 Scheme
- [X] 25.12 T-SQL
as --64 day1_1.s -o day1_1.o && ld -melf_x86_64 -s day1_1.o -o day1_1
./day1_1 < day1_input.txt
Part 2: O(n2logn), same algo as part 1 but with outer loop of third term which is skipped in the main algo
as --64 day1_2.s -o day1_2.o && ld -melf_x86_64 -s day1_2.o -o day1_2
./day1_2 < day1_input.txt
awk -f day2_1.awk day2_input.txt
awk -f day2_2.awk day2_input.txt
bash day3_1.sh 3 1 day3_input.txt
bash day3_2.sh day3_input.txt
gcc day4_1.c -o day4_1
./day4_1 < day4_input.txt
gcc day4_2.c -o day4_2
./day4_2 < day4_input.txt
Parse binary, use sequence sum formula to find missing element
cd day5
dotnet run < input.txt
std set with map
gcc day6.cpp -lstdc++ -o day6
./day6 < input.txt
Stupid mashup of bfs and dfs
clj -X day7/part1 < day7_input.txt
clj -X day7/part2 < day7_input.txt
Plain execution with history tracking and brute part2
sbcl --load day8.lisp --eval '(day8)' < day8_input.txt
sbcl --load day8.lisp --eval '(day8-2)' < day8_input.txt
Linear with pre-sorted/pre-summed lists with fifo queues.
erl
> c(day9).
> day9:part1("day9_input.txt", 25).
> day9:part2("day9_input.txt", 69316178).
Calc continious ranges, manual calculated permutations based on range lenght
cd day10
dotnet run
Simple loops
go run day11.go
Tried to optimize on assembly level. Multiple tricks are used.
as --64 day11.s -o day11.o && ld -melf_x86_64 -s day11.o -o day11_as
./day11_as day111_input.txt
This gives the following result looping the both parts 100 times:
enikesha@enikesha-desktop:~/dev/aoc2020$ time ./day11_as day11_input.txt > /dev/null
real 0m5.127s
user 0m5.125s
sys 0m0.000s
enikesha@enikesha-desktop:~/dev/aoc2020$ time ./day11_go > /dev/null
real 0m12.658s
user 0m13.009s
sys 0m0.157s
Ok, haskell’s learning curve is quite steep. Otherwise simple instruction processing
ghci
> :l day12
*Day12> day12
*Day12> day12_1
Chinese reminder theorem implementation.
javac day13.java && java day13
BigInt, reduce and explode masked addresses
paste in FF/Chrome console on advent day page
Unboxed IntArray for perf optimization
kotlinc day15.kt -include-runtime -d day15.jar && java -jar day15.jar
All I could get out of it
as --64 day15.s -o day15.o && ld -melf_x86_64 -s day15.o -o day15
With the following results
enikesha@enikesha-desktop:~/dev/aoc2020$ time java -jar day15.jar
30000000: 689
real 0m0.759s
user 0m0.791s
sys 0m0.100s
enikesha@enikesha-desktop:~/dev/aoc2020$ time ./day15
689
real 0m0.597s
user 0m0.544s
sys 0m0.052s
Good ol’ imperative
lua day16.lua < day16_input.txt
Optimized generic solution. 100 times faster than the prevous one. On simulation iterates through bounding n-orthotope with direct flat array index calculation.
fpc day17.pas && ./day17 < day17_input.txt
Shit-crafted calculator. Char level parse into reverse polish notation with evaluation as a second step.
perl day18.pl day18_input.txt
More shit :) I think it’s kinda general, no any ties to my input or special 8/11 handling.
php day19.php day19_input.txt
I’m not proud of it at all :( But at least it works. It took me more time than any other day by a big margin.
python day20.py < day20_input.txt
Set’s intersections for elimination
ruby day21.rb < day21_input.txt
Direct rules implementation. Quite nice language, but borrow checker needs some time to get used to.
rustc day22.rs && ./day22 < day22_input.txt
Imperative one due to performance. Using Array[Int] as label->next index.
scalac day23.scala && scala day23
Unoptimized hash tables over complex numbers as position
guile day24.scm < day24_input.txt
Plpgsql imperative procedural bruteforce :( But that finishes the whole story)
sudo -u postgres psql -f day25.sql