|
Walh Hara posted:That said, if I went to a job interview and somebody asked me the fibonacci question I'd be quite offended so I agree it's a silly interview problem. I once offered the iterative form as a response and was told I was wrong ... good thing I didn't really need it ...
|
# ¿ Apr 17, 2016 14:55 |
|
|
# ¿ May 10, 2024 00:03 |
|
RICHUNCLEPENNYBAGS posted:Isn't the traditional improvement on the recursive version to implement a cache? I think the idea is to memoize or use tail recursion, but at that point you can just load an ssd with a table of them. That is the solution, sequence tables as a service over http. dougdrums fucked around with this message at 03:16 on Apr 18, 2016 |
# ¿ Apr 18, 2016 03:10 |
|
I'm sure that working untold hours a week for years on end didn't harm his sanity whatsoever. hahaha is he like thought deaf or something? did he have that surgery where they separate the halves of your brain maybe?: quote:Consider the possibility that you are completely wrong about everything you believe and try re-evaluating your outlook. Has your approach to life made you independently wealthy yet? Like, even if that's what you're thinking, you're gonna choose to express it like that? dougdrums fucked around with this message at 00:25 on Apr 19, 2016 |
# ¿ Apr 19, 2016 00:18 |
|
Use the built in popcnt r, r/m instruction or _mm_popcnt_u64(), if any language is allowed...
|
# ¿ Jun 19, 2016 12:25 |
|
Centripetal Horse posted:I'm not an optimization expert, but the only obvious improvement I see is to get rid or reduce the iterations of the loop. Depending on the language and compiler, you could rewrite that loop to take advantage of SIMD, either implicitly or explicitly. The fastest way I can think of using SIMD is the same way as usual, but with packed values. (And 1 -> accumulate -> shift -> loop) In software, you'd have to compare each bit I think, at least for the smallest packed value you can use. Centripetal Horse posted:Some people mentioned POPCNT, but I remember reading that POPCNT has (had?) some sort of issue with getting tied up waiting for registers for no good reason, which could make it very slow at times. Yes, but iirc it's still faster and smaller than the alternative. Found what you referenced: http://stackoverflow.com/questions/25078285/replacing-a-32-bit-loop-count-variable-with-64-bit-introduces-crazy-performance dougdrums fucked around with this message at 03:54 on Jun 20, 2016 |
# ¿ Jun 20, 2016 03:38 |