3 ms·
A long time ago I was working on a data conversion project that involved taking what was essentially a 10 dimensional data set and reordering it. The easiest w
by smithbits 16y ago
A long time ago I was working on a data conversion project that involved taking what was essentially a 10 dimensional data set and reordering it. The easiest way to achieve this was to load everything into a ten dimensional array and read it out in another order, but I was sure this would take too long. So I spent some time trying to get a sparse array implementation working until I finally sat down and worked out that the entire 10 dimension data structure would require 63 megabytes of RAM (not giga, this was a long time ago.) The Sparc server in the next room had 64 megs of RAM. It was a simple algorithm with quick results and I moved on to the next problem. I think that was the last time I really really cared about performance. I'd spent the previous 15 years getting closer and closer to the hardware, caring about every register and every byte. I've spent the 15 years since then on the slow slide to letting the computer worry about everything. I currently live in Python land and love every minute of it. I hear that string concatenation is slow but honestly, it's never been an issue for me. Computers really are fast.
- JoeAltmaier 16y agoAnother: I solved the 8-queens problem for a magazine contest using a BASIC program (!) Instead of modelling the board with an 8X8 array, I used the digits 1-8 representing the height of the queen (row #), and the 8 digits in a string as the heights for each column. I permuted the digits - n! time to execute which was never going to finish. So, prune! as it swapped digits left to right in a Grey-code-like sequence, test the digits to the left for diagonals (|row#A - row#B| == |A-B|) and don't bother to recurse if its already failing. Every few minutes - out popped a solution, and it finished in under 25 minutes. Nowadays, that would take imperceptible time to execute.