5 ms·
The best tool for solving these problems is a whiteboard; writing code should be seen as a last resort, and brute-force solutions should be shunned, as they pro
by DonbunEf7 9y ago
The best tool for solving these problems is a whiteboard; writing code should be seen as a last resort, and brute-force solutions should be shunned, as they provide no insight.
- pacuna 9y agogood luck with that
- mathattack 9y agoHis point is correct. There are usually efficient and inefficient ways to attack each problem. It's better to solve the math problem first, before the coding problem.
- tedmiston 9y agoOnly when the scale truly matters is the most efficient algorithm the best choice though. For a lot of problems, especially in early stage startups, the brute force solution is more than sufficient and avoids premature optimization. Having perfect algorithms for everything comes with an opportunity cost in startup land that isn't aligned with whether or not your business succeeds most of the time. (This really only applies when the efficient implementation doesn't already exist in the standard library or a package.)
- sixstringtheory 9y agoSome problems simply will never return the result if you brute force it. I've run a brute-force solver and written the elegant approach while I waited for a result that'd never come. Most of the elegant solutions do exist in libraries out there, but the point is to pass down the underlying knowledge. I don't think it's really fair to liken something like mathematics to the startup world, something that has all sorts of nondeterministic factors involved.
- jacquesm 9y agoSome of the answers are explicitly formulated in such a way that your brute force mechanism will not work even though in a practical setting that brute force answer would be more than accurate enough for use. So project Euler does not always steer you simply to a correct answer, they also want you to achieve that answer in a particular way.
- mathattack 9y agoThe context here is Project Euler though. (Math problems)
- tikhonj 9y agoSome friends and I used to hold a hybrid drinking/Project Euler contest. You would have hated our solutions. I remember winning on the back of nine nested for-loops and, on a separate occasion, doing a primality check using a literal array containing the first 80,000 primes. That's what happens when time-to-solution is what you optimize for. I'm sure it's familiar to startup programmers :).
- torbjorn 9y agoWow, that sounds like an awesome party =)
- SoulMan 9y agoWell in TDD you tend to try to do that :)
- huherto 9y agoI agree that solving them with pen and paper is bad ass. But many problems cannot be solved using brute force. They will give you one problem that can be solved using brute force, then in a later problem they increase some n to the point where it cannot be solved using brute force. So it forces you to find a better solution.