This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function genSeqUntil(valFunc, limitPredicate, seq = []) { | |
var nextVal = valFunc(seq.length); | |
if (limitPredicate(seq.length, nextVal)) { | |
seq[seq.length] = nextVal; | |
return genSeqUntil(valFunc, limitPredicate, seq); | |
} | |
return seq; | |
} | |
function sumOfAllMultiplesUnder(multsArr, max) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function genSeqUntil(valFunc, limitPredicate, seq = []) { | |
var nextVal = valFunc(seq.length); | |
if (limitPredicate(seq.length, nextVal)) { | |
seq[seq.length] = nextVal; | |
return genSeqUntil(valFunc, limitPredicate, seq); | |
} | |
return seq; | |
} | |
const memoize = (fn) => (function () { | |
var cache = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findPrimeFact(num, accum = []) { | |
return 1; | |
} | |
function isDivisible(num) { | |
return (divisor) => num % divisor === 0; | |
} | |
function isPrime(num) { | |
return Array.from({length: Math.floor(num/4 - 1)}, | |
(x, i) => i * 2 + 3) | |
.filter(isDivisible(num)).length === 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myAudio = new Audio(audioUri + phrase + audioFormat); | |
myAudio.play(); | |
//anti-pattern: does not work | |
return Rx.Observable.fromEvent(myAudio, 'onended'); | |
myAudio.onended = () { | |
return Rx.Observable.just("success"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var funcNames = { | |
addition: { | |
func: function (paramsArr = []) { | |
return paramsArr.reduce((tot, num) => tot + num, 0) | |
}, | |
textRep: '+' | |
}, | |
subtraction: { | |
func: function ([head, ...tail] = []) { | |
return tail.reduce((tot, num) => tot - num, head) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//jshint esnext:true | |
// curveColors should have a length longer than or equal to 1 | |
// the colors are split evenly- with a curveColors length of 3 | |
// with said curveColors, a score of 75 would respond to halfway between index 1 and 2 | |
const curveColors = [{r: 49, g: 198, b: 84}, | |
{r: 46, g: 48, b: 193}, | |
{r: 193, g: 138, b: 44}, | |
{r: 193, g: 44, b: 44}] | |
// score should be between 0-100 | |
const score = 50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1..100 | |
// 3 5 | |
const seq = min => max => { | |
let list = []; | |
for (let index = min; index <= max; index++) { | |
list.push(index); | |
} | |
return list; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//jshint esnext:true | |
/* | |
Multiples of 3 and 5 | |
Problem 1 | |
If we list all the natural numbers below 10 that are multiples of 3 or 5, | |
we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
Find the sum of all the multiples of 3 or 5 below 1000. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//jshint esnext:true | |
/* | |
Multiples of 3 and 5 - Problem 1 | |
If we list all the natural numbers below 10 that are multiples of 3 or 5, | |
we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
Find the sum of all the multiples of 3 or 5 below 1000. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maximum [x*y | x <- [100..999] , y <- [100..999], x*y == reverseInt (x*y)] |