January 2020
Intermediate to advanced
470 pages
11h 13m
English
4.1. Minimalistic function: It works because fib(0)=0 and fib(1)=1, so it's true that for n<2, fib(n)=n.
4.2. A cheap way: Basically, this algorithm works the same way as you'd calculate a Fibonacci number by hand. You'd start by writing down fib(0)=0 and fib(1)=1, adding them to get fib(2)=1, adding the last two to get fib(3)=2, and so on. In this version of the algorithm, a and b stand for two consecutive Fibonacci numbers. This implementation is quite efficient!
4.3. A shuffle test: Before shuffling the array, sort a copy of it, JSON.stringify() it, and save the result. After shuffling, sort a copy of the shuffled array and JSON.stringify() it as well. Finally, two JSON strings should be produced, ...
Read now
Unlock full access