39

Teacher: Write a program to print fibonacci series up to 8 terms
Me: *hardcodes 0,1,1,2,3,5,8,13*
Teacher: *runs the programs*
Me: *relieved*
Teacher: *checks the code*
Me:

Comments
  • 9
    I wonder if we can obfuscate the code so much that it doesn’t look like you’re hardcoding it.
  • 1
    It could be worse. When I was on Programming basics at university, we had a test. I was about reading a string and print it in diagonal. Most of my partners took the code from Yahoo answers. The teacher noticed it and put a zero of everybody’s test except 3 (including me, fortunately).
  • 4
    I once had to do a similar fibonnaci sequence task in a programming olympiad, i had no idea wtf i did or how i did it, but i managed to get it working, i didnt even understand my own code at the time. My IT and maths teacher approached me asking me why im in lower grade maths when i could do that fibonnaci sequence... I still to this day dont understand what i did and probably cant redo it 😂 but i got an awesome gold certificate to put in my portfolio 😎 Keep in mind i had no prior knowledge of what a fibonnaci sequence was nor did they explain, they just gave examples and said replicate the pattern. If i had to look at an explanation of it now i could probably replicate it easily.
  • 4
    The task wasn't phrased well enough: up to n terms would have forced the solution to be calculated instead of hardcoded
  • 1
    Technically you coded exactly what was required. Most programming languages also have a hardcoded PI constant.

    Best is the recursive Haskell implementation though, infinite list of all fib numbers:

    f = 0 : 1 : zipWith (+) f (tail f)
Add Comment