Skip to content

Instantly share code, notes, and snippets.

View thomasvaeth's full-sized avatar
🍕

Thomas Vaeth thomasvaeth

🍕
View GitHub Profile
@thomasvaeth
thomasvaeth / cassidoo Challenge 2-11
Last active February 12, 2018 22:12
"Curiosity will conquer fear even more than bravery will." - James Stephens
function productArrayValues(arr1, arr2) {
return quickSort(arr1, 0, arr1.length - 1)[arr1.length - 1] * quickSort(arr2, 0, arr2.length - 1)[0];
}
function quickSort(arr, left, right) {
if (arr.length < 2) return arr;
var pivot, partitionIndex;
if (left < right) {
@thomasvaeth
thomasvaeth / cassidoo Challenge 9-24
Last active February 12, 2018 21:50
"If you have a strong purpose in life, you don't have to be pushed. Your passion will drive you there." - Roy T. Bennett
// First Solution
function duplicate(arr, num) {
var newArr = [];
for (var i = 1; i <= num; i++) {
newArr = newArr.concat(arr);
}
return newArr;
}
@thomasvaeth
thomasvaeth / cassidoo Challenge 9-17
Last active February 12, 2018 21:50
"Opportunities lie in the place where the complaints are." - Jack Ma
function seatsInTheater(numCols, numRows, myCol, myRow) {
var calcCols = myCol > numCols / 2 ? numCols - myCol + 1 : myCol,
unblocked = ((numCols - calcCols) * numRows) + ((myRow - 1) * calcCols);
return numCols * numRows - unblocked - 1;
}
seatsInTheater(16, 11, 5, 3);
@thomasvaeth
thomasvaeth / please-dont-go
Created January 14, 2017 22:22
Snippet for Title/Favicon Change
var PleaseDontGo = (function() {
var s;
return {
settings: {
originalTitle: document.title,
// New title when tab is changed
newTitle: 'Please Don\'t Go',
favicon: document.querySelectorAll('[rel="icon"]')[0],
originalFavicon: document.querySelectorAll('[rel="icon"]')[0].href,