Skip to content

Instantly share code, notes, and snippets.

Luciano Borges borgeslt

Block or report user

Report or block borgeslt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@borgeslt
borgeslt / ArrayShuffleExtension.js
Last active Feb 3, 2020
Shuffling an array in Javascript
View ArrayShuffleExtension.js
Array.prototype.shuffle = function () {
return this.map(item => {
return {
index: Math.random(),
value: item
}
})
.sort((item1, item2) => item1.index - item2.index)
.map(item => item.value)
}
@borgeslt
borgeslt / SimpleDemoGA.js
Last active Jan 22, 2020
A Simple Genetic Algorithms in Javascript
View SimpleDemoGA.js
/*
Based on the Vijini Mallawaarachchi's article in Towards Data Science
https://towardsdatascience.com/introduction-to-genetic-algorithms-including-example-code-e396e98d8bf3
*/
"strict mode"
function Individual(numOfGenes) {
const _genes = Array(numOfGenes).fill(0).map(i => Math.floor(Math.random() * 1000 % 2));
let _fitness = 0;
You can’t perform that action at this time.