Skip to content

Instantly share code, notes, and snippets.

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) {
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 = {};
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;
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");
}
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)
@marcmartino
marcmartino / colorCalc.js
Created June 30, 2017 07:49
dynamic color blending
//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
// 1..100
// 3 5
const seq = min => max => {
let list = [];
for (let index = min; index <= max; index++) {
list.push(index);
}
return list;
}
//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.
*/
//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.
*/
maximum [x*y | x <- [100..999] , y <- [100..999], x*y == reverseInt (x*y)]