You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My Advent of Code 2024 solutions in hand-crafted WebAssembly. No processing in
JavaScript‒input is copied to WebAssembly and the answer is computed entirely in
there.
🎯 Goals
Have fun.
Learn about WebAssembly features (SIMD, threads, etc.)
Small WASM file.
Low memory usage.
Fast execution time.
🧩 How to use
node index.js <DAY> <PART>
For help info, try node index.js.
When running with the input, the data reported includes:
Average runtime in nanoseconds (one billionth of a second) and microseconds
(one millionth of a second)
The table below lists non-trivial data structures and algorithms used in each
solution.
Day
Part
Data structures
Algorithms
1
1
Array
Insertion sort
1
2
Array
2
1
3
1
Finite state automaton
3
2
Finite state automaton
4
1
Array
Transposition
4
2
📔 Diary
Day 1
WebAssembly uses little-endianess. If the input is processed at a less nuanced
level than byte-by-byte, then we will have to be careful how the input is
written to WebAssembly memory.
Switching to SIMD didn't improve performance by much. I'm surprised to have
got it working on first try though.
Took me a while to learn i8x16.shuffle syntax. It takes 2 v128s (on the
stack) and 16 0-based indices, which indexes into bytes stored in the two
vectors. The returned vector is formed from the bytes pointed to by the
indices.
About
Hand-written WebAssembly solutions to Advent of Code 2024.