Let's Get Clever (2 Part Series)
We spend a lot of time trying to write good code. I don't know about you, but I get weary of hearing the (apt) admonishment "don't be clever".
Everyone needs a break. So, in celebration of all our diverse skills and knowledge, Let's Get Clever!
Calculate the Nth digit of the Fibonacci sequence.
In the Fibonacci sequence, every element is the sum of the previous two terms.
0, 1, 1, 2, 3, 5, 8...
So, the next value is
5 + 8, or
Your code should be able to find the
No hard coding allowed! You may not write out the sequence manually anywhere in your code. Every element (except the initial
0, 1, 1) must be generated by the code.
0 <= n < (2^16 − 1). In other words, don't worry about negative numbers, and assume
nis less than the maximum possible value of a 8-bit integer. (Yes, it USED to be a 64-bit integer...I updated the spec to be sane.)
These are NOT required, but if you achieve any of these goals, major bragging rights!
🔂 No Loops: Can you avoid use of any explicit loops or recursion?
⏱️ Efficiency: Can you beat
(These will be the same for every Let's Be Clever challenge.)
Your clever code should accomplish the stated goal in whatever way you like. Watch out for edge cases, though.
You may use any language you like. However, I discourage use of deliberately esoteric languages. Cleverness is usually more fun in production languages.
You know all those rules about readability and maintainability? Fuhgeddaboudit. Cleverness is the goal.
Portability, memory safety, security? Bah humbug. Mel is welcome.
Efficiency is not the main goal, but if your cleverness happens to have an efficiency worth bragging about, definitely point it out!
Explain your Cleverness. Don't wait for others to ask you, although you should be prepared to answer questions. The neat side-effect of Clever code is that everyone can learn cool, weird things.
Be open to feedback. Others might be able to spot edge-cases you missed, or have ideas on how to make your Clever approach even more clever.
Preening is permitted, but don't be obnoxious about it, and be equally liberal with your complements of others. Leave false modesty in the drawer. (Imposter Syndrome sucks, so let's use this to give it a good kick in the teeth.)
Upvote Cleverness! If you really like someone's solution, be sure to give it a Like.
Always be polite and constructive. Please don't criticize anyone for not being clever enough, not understanding what you did, or asking a "stupid question". This is Cleverness on display. Be the tour guide!
Don't forget: CODE HACKERY ENCOURAGED! No holds barred.