Skip to content

Instantly share code, notes, and snippets.

View audreybongalon's full-sized avatar

Audrey Bongalon audreybongalon

View GitHub Profile
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
@audreybongalon
audreybongalon / triple_array_example.js
Last active October 28, 2016 15:38
example, for reference for the super tic-tac-toe game. shows how to fill a triple array with items and reference each one
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];
@audreybongalon
audreybongalon / atan2-function-for-scratch.js
Last active February 14, 2026 03:49
reference for scratch games. scratch doesn't have an atan2 function, which is very useful for calculating directions (in terms of angles). so i made a reference file here. keep in mind that scratch automatically puts things in degrees, so there's no need to have a conversion function in scratch. also, sometimes this will return values 360 degree…
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)));
@audreybongalon
audreybongalon / pythagorea7-10.js
Last active October 28, 2016 15:40
meant to calculate the length of a polyline, to help solve level 7.10 in the Android game Pythagorea
// 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;