My AoC program in D is just as fast as in Python

monkyyy crazymonkyyy at gmail.com
Mon Nov 24 14:54:02 UTC 2025


On Monday, 24 November 2025 at 14:37:22 UTC, Jabba Laci wrote:
> To my surprise, the Python program also ran for 3 seconds. I 
> expected that the D program should be much faster.
>
> What's the rule here?
> `int[Pair]`

aa's are fundmental and useful; but they are a cache miss in 
every language

> Because your neighbors keep defeating you in the holiday house 
> decorating contest year after year, you've decided to deploy 
> one million lights in a 1000x1000 grid.

I would consider `bool[1000][1000]` or 
https://dlang.org/phobos/std_bitmanip.html#BitArray to start

If you need to start playing with sparseness `bool[int][256]` and 
understand this math: `y*w+x`; with the theory that powers of two 
are good and 256 is generally big enough to start getting good 
cache behavior.


More information about the Digitalmars-d-learn mailing list