Skip to content

Instantly share code, notes, and snippets.

@Caaz
Created January 26, 2018 20:55
Show Gist options
  • Save Caaz/4561aa6808668f4e2bd3393876f9af0a to your computer and use it in GitHub Desktop.
Save Caaz/4561aa6808668f4e2bd3393876f9af0a to your computer and use it in GitHub Desktop.
You're all dumbasses
var answers = {
isk(arr) {
let vowels = 0;
for (e of arr) {
if (e.constructor === Array) vowels += answers.isk(e)
else {
let m = e.match(/[aeiou]/gi);
vowels += m === null ? 0 : m.length;
}
}
return vowels;
},
gentryNew(arr) {
var count = 0;
for (var inner = 0; inner < arr.length; inner++){
for (var i = 0; i < arr[inner].length; i++) {
for (var inception = 0; inception < arr[inner][i].length; inception++){
for (var really = 0; really < arr[inner][i][inception].length; really++){
for (var wtf = 0; wtf < arr[inner][i][inception][really].length; wtf++){
switch(arr[inner][i][inception][really][wtf]){
case "e":
case "E":
case "a":
case "A":
case "i":
case "I":
case "o":
case "O":
case "u":
case "U":
count++
}
}
}
}
}
}
return count
},
gentryClean(object) {
var count = 0;
var string = object.join('')
for (i = 0; i < string.length; i ++ ) {
switch(string[i]) {
case 'e':
case 'a':
case 'i':
case 'o':
case 'u':
case 'E':
case 'A':
case 'I':
case 'O':
case 'U':
count++
}
}
return count
},
gentryOriginal(nestedArr) {
var count = 0;
object = {};
nestedArr.forEach(function(string){
object[string] = 1;
})
obj = JSON.stringify(object);
SplitObject(obj);
function SplitObject(object) {
for (i = 0; i < object.length; i ++ ){
split = object[i].split("");
Vowels(split);
}
}
function Vowels(data) {
if (data == "E"){
count++
}
if (data == "e"){
count++
}
if (data == "A"){
count++
}
if (data == "a"){
count++
}
if (data == "I"){
count++
}
if (data == "i"){
count++
}
if (data == "O"){
count++
}
if (data == "o"){
count++
}
if (data == "U"){
count++
}
if (data == "u"){
count++
}
}
return count
},
gentryRecursive(object){
var count = 0;
const type = typeof object
if (type === 'object'){
for (var i = 0; i < object.length; i++){
count += answers.gentryRecursive(object[i])
}
}
else if(type === 'string') {
for (var i = 0; i < object.length; i++){
switch(object[i]){
case "e":
case "E":
case "a":
case "A":
case "i":
case "I":
case "o":
case "O":
case "u":
case "U":
count++
}
}
}
return count
},
caazRecursive(object) {
const type = typeof object
var count = 0
if(type === 'string') for(var i = 0; i < object.length; i++)
switch(object[i]) {
case 'a': case 'e': case 'i': case 'o': case 'u':
case 'A': case 'E': case 'I': case 'O': case 'U':
count++
}
else if(type === 'object')
for(const index in object) count += answers.caazRecursive(object[index])
return count
},
repod(object) {
return object.join().match(/[aeiou]/gi).length
},
ray(arr){
arrCheck = [];
result = 0;
function vowelCount(str) {
var str2 = str.toLowerCase();
var x = str2.match(/[aeiou]/gi);
var count = x ? x.length: 0;
return count;
};
for (var i = 0; i < arr.length; i++) {
if (Array.isArray(arr[i]) === false) {
arrCheck.push(arr[i]);
} else {
for (var j = 0; j < arr[i].length; j++) {
if (Array.isArray(arr[i][j]) === false) {
arrCheck.push(arr[i][j]);
} else {
for (var k = 0; k < arr[i][j].length; k++) {
if (Array.isArray(arr[i][j][k]) === false) {
arrCheck.push(arr[i][j][k]);
} else {
for (var h = 0; h < arr[i][j][k].length; h++) {
if (Array.isArray(arr[i][j][k][h]) === false) {
arrCheck.push(arr[i][j][k][h]);
}
}
}
}
}
}
}
}
for (var y = 0; y < arrCheck.length; y++) {
result += vowelCount(arrCheck[y]);
}
return result;
},
adrian(object) {
return ("|"+object.toString()+"|").split(/[aeiou]/i).length-1;
}
}
var nestedArr = ['Elie', ['Matt', ['Tim']],['Colt',['Whisky',['Janey'], 'Tom']], 'Lorien']
// for(const index in answers) {
// console.time(index)
// answers[index](nestedArr)
// console.timeEnd(index)
// }
check = 'caazRecursive'
console.time(check)
answers[check](nestedArr)
console.timeEnd(check)
console.log(answers[check](nestedArr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment