3 ms·
Quick, hackers: what the algorithm for the maximum amount of money he could earn in 365 days?
by bprater 18y ago
Quick, hackers: what the algorithm for the maximum amount of money he could earn in 365 days?
- jasonlbaptiste 18y agoquick, person who doesn't read articles at all where it states that amount a few times: 66,795
- snprbob86 18y agoHe was asking for the _algorithm_ not the solution. The constant time approximation is (count^2) / 2 365 * 365 / 2 = 66,612.5 I'm sure there is a constant time exact solution as well :-)
- jd 18y agox = 365; ((x + 1) * x) / 2 # 66795 For x > 2 and odd.
- eru 18y agoIn this case the solution is also the algorithm in a technical sense, because algorithms solve classes of problems and we can just define the class to consinst of this sole instance. Then 66795 is the algorithm that works for the whole (singleton) class of instances.
- gaius 18y ago>>> (sum(xrange(1,366))) 66795