This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Downloads, re-sizes and centers an image to fit a display area, with padding. Uses jQuery. | |
* | |
* Example markup + CSS: | |
* | |
* <div id="gallery-slide"></div> | |
* | |
* #gallery-slide { | |
* width: 200px; | |
* height: 400px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Adds one to the integer represented by the input array | |
* | |
* @param input | |
* an array representation of an integer > -1, e.g. {1,2,3} | |
* @return | |
* an array representation of the input integer, plus one | |
*/ | |
int[] addOne(int[] input) { | |
for (int i = input.length - 1; i >=0; i--) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Naive -> fib(30) runs 2692537 times | |
var fibNaive = function(num) { | |
if (num === 0) return 0; | |
if (num === 1) return 1; | |
return fibNaive(num - 1) + fibNaive(num - 2); | |
} | |
// Memoized -> fib(30) runs 59 times | |
var memo = {}; | |
var fibMemo = function(num) { |