Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Coding

Keno Clayton dons20

💭
Coding
View GitHub Profile
@dons20
dons20 / table.js
Last active Nov 2, 2020
Prints out the multiplication table up to 12x12
View table.js
// Create array of 12 items from 1-12
let values = Array.from({length: 12}, (_, i) => i + 1);
// Iterate through array (new console log for each line)
values.forEach(value => console.log(Array.from({length: 12}, (_, i) => (i+1) * value).join(" ")));
// Alternative if one console log is to be displayed.
let table = [];
table = values.map(value => Array.from({length: 12}, (_, i) => (i+1) * value).join("\t\t"));
console.log(table.join("\n"));
View Sprinkle.py
sampleInput1 = ("5 1\n"
"0 2 3\n"
"1 3 0\n"
"2 3 0\n"
"3 2 1\n"
"4 6 5\n"
)
def assign(orders):
@dons20
dons20 / SampleFlatten.js
Last active Dec 6, 2018
This code will flatten an array of arbitrarily nested arrays of integers into a flat array of integers
View SampleFlatten.js
//e.g. [[1,2,[3]],4] -> [1,2,3,4]
let complexArray = [[1,2,[3]],4];
//Legacy Approach
function flatten(arr) {
return arr.reduce(function (flat, toFlatten) {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
@dons20
dons20 / 0_reuse_code.js
Created Dec 8, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console