This file contains hidden or 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
# Fast nCk with memoization. | |
memo_b = {} | |
def binomial(n, k): | |
""" | |
A fast way to calculate binomial coefficients by Andrew Dalke. | |
See http://stackoverflow.com/questions/3025162/statistics-combinations-in-python | |
""" | |
if (n, k) not in memo_b: | |
if 0 <= k <= n: | |
ntok = 1 |
This file contains hidden or 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
/* | |
* Load an object from a JSON file on client's computer. | |
*/ | |
const loadJSON = callback => { | |
if (callback) | |
return loadJSONCallback(callback) | |
return loadJSONPromise() | |
} | |
const loadJSONCallback = callback => { |
This file contains hidden or 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
{ | |
"general": { | |
"numberOfIterations": 20 | |
}, | |
"paths": { | |
"vertices": [ | |
{ | |
"id": 0, | |
"position": { | |
"x": 124.24723822180408, |
This file contains hidden or 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
// let à la place de var pour un scope de bloc et non de fonction. | |
// Ecritures équivalentes d'une fonction : | |
// | |
// function doubler(x){return 2*x} | |
// doubler = function(x){return 2*x} | |
// | |
// Mieux : | |
// let doubler = function(x){return 2*x} | |
// |