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
| var POPULATION_SIZE = 10; | |
| var SAMPLE_SIZE = 5; | |
| var nums = []; | |
| function getRandomInt(min, max) { | |
| min = Math.ceil(min); | |
| max = Math.floor(max); | |
| return Math.floor(Math.random() * (max - min)) + min; | |
| // the maximum is exclusive and the minimum is inclusive |
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
| var count = 0; | |
| var letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i"] | |
| var array = [[[], [], []], | |
| [[], [], []], | |
| [[], [], []]]; | |
| for (var i = 0; i < 3; i++) { | |
| for (var j = 0; j < 3; j++) { | |
| array[i][j] = letters[count]; |
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
| function toDegrees (angle) { | |
| return angle * (180 / Math.PI); | |
| } | |
| function myAtan2(y, x) { | |
| if (x > 0) { | |
| return toDegrees(Math.atan(y/x)); | |
| } | |
| else if (x < 0) { | |
| return (180 + toDegrees(Math.atan(y/x))); |
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
| // calculates the total length of the polyline on Pythagorea, puzzle 7.10 | |
| var polyline = [[4,3], [1,2], [2,1], [1,1], [1,3], | |
| [1,1], [2], [1,2], [2,1], [1,3], | |
| [1,1], [1], [1,1], [2], [1]]; | |
| var grandtotal = 0; | |
| function findc(a, b) { | |
| var a2pb2 = 0; |