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
/** | |
* Read file line by line "synchronous" | |
* | |
* require nodejs ~0.11, run with "node --harmony" | |
* | |
* Example: | |
* | |
* var readLineSync = require('./readLineSync'); | |
* | |
* |
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
arrayShuffle = (arr, numOfSwaps = arr.length / 2) -> | |
#copy array | |
newArr = arr.slice(0) | |
for i in [0...numOfSwaps] | |
rnd1 = Math.floor( Math.random() * arr.length ) | |
rnd2 = Math.floor( Math.random() * arr.length ) | |
#swap elements | |
buf = newArr[rnd1] |