3 ms·
I wrote it in C with just one loop: for(i=0; i <= 10000; i+=37) and one condition: if(i > 0 && i%13==0 && i%19==0) and it takes only 0.000003 sec.
by milansuk 4y ago
I wrote it in C with just one loop: for(i=0; i <= 10000; i+=37) and one condition: if(i > 0 && i%13==0 && i%19==0) and it takes only 0.000003 sec.
- klyrs 4y agoI was referring to the beer/meat/bread problem, but yeah. Brute force is ruthlessly effective for small problems.
- shoo 4y agoif all the inputs are constants and don't depend on program input, it'd be interesting to disassemble that to see if the compiler solved the problem at compile time and generated a "load <constant_precomputed_solution>" you may not necessarily be timing what you think you are timing