3 ms·
In the advent of code, I solved day 23 (the crab and the cups) doing brute force, and even with today's hardware it would have taken many hours, if not days, to
by mikewarot 6y ago
In the advent of code, I solved day 23 (the crab and the cups) doing brute force, and even with today's hardware it would have taken many hours, if not days, to complete. A tweak of the algorithm got it down to 0.248 seconds. That tweak required an 4 megabyte array in RAM.
I back ported the solution to Turbo Pascal 7, it used a "file of longint" in place of the array which you can't do in MS-DOs... it finished in about 10 minutes, because I have an SSD. Otherwise it would have been about 50,000,000 IO operations at 10/second --> 50+ days.
We can and do use the heck out of the hardware, but it's not infinite, and there will always be orders of magnitude performance to be gained by seeking and using better algorithms.
- mark254 6y agoWell, using "himem.sys" you could make use of RAM above 1MB... I used it to write a sort utility that only uses temp files when RAM was exhausted. On my 386 with 4MB total RAM I could use about 3.7 or so, the rest was a shadowed BIOS copy. (Never tried to deactivate that, perhaps it would have been relocated and then made available?)