5 ms·
The Six Most Common Species Of Code
- Justsignedup 13y agoThat is preposterous! At a hackathon they would probably just return 10 or something. int fib(int val) { return 10; } // todo: implement me
- mcpherrinm 13y agoCertainly the version they gave is too much typing! Maybe something more like fn f(i: int)->int{[1,1,2,3,5,8,13,21][i]}; Need more values? copypaste from the online encyclopedia of integer sequences.
- tomphoolery 13y agomy code is the cat code
- shoyer 13y agoEverybody (except the Math PhD) writes the naive O(2^n) solution? Fat chance...
- himal 13y agoPrevious discussion: https://news.ycombinator.com/item?id=6711192 https://news.ycombinator.com/item?id=6711192
- kozikow 13y agoFalse. Math phd would probably write O(log n) based on either multiplying [[1,0], [1,1]] matrix or compute it directly for smaller numbers and return the rounded power of golden ratio for higher numbers. Notice that for big enough numbers psi becomes insignificant enough, so that we can only use phi.