Skip to content
16 changes: 16 additions & 0 deletions 01-make-change/change-Tyler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function change(n){
// coinValues set to [quarters, dimes, nickels, pennies]
const coinValues = [25,10,5,1];
//amount of [quarters, dimes, nickels, pennies] pushed into array
let coins = [];

for(let i = 0; i < coinValues.length; i++){
if(n >= coinValues[i]){
coins[i] = Math.floor(n / coinValues[i]);
n %= coinValues[i];
} else {
coins[i] = 0;
}
}
return coins;
}
31 changes: 31 additions & 0 deletions 01-make-change/change.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
let coins = [];
function change(n){
coins=[0,0,0,0];
while(n!=0){
if (n>=25){
const di = Math.floor(n/25);
coins[0] = di;
n = n % 25;
}
else if (n>=10){
const di = Math.floor(n/10);
coins[1] = di;
n = n % 10;
}
else if (n>=5){
const di = Math.floor(n/5);
coins[2] = di;
n = n % 5;
}
else if (n>=1){
const di = Math.floor(n/1);
coins[3] = di;
n = n % 1;
}
}
console.log(coins);
}

console.log(change(34));
console.log(change(78));
console.log(change(21));
17 changes: 17 additions & 0 deletions 01-make-change/laurens-change.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//takes two inputs, the amount of money that needs to be made into change
//and an array listing the value of each coin
//will work with different values in case you need to know
//how many silver sickles, bronze knuts, or golden galleons to make change with ;)

function change(change, coins) {
var returnedChange = 0;
var coinCount = [];
coins.forEach(function(coin){
var newChange = change - returnedChange;
var coinAmount = Math.floor(newChange / coin);
coinCount.push(coinAmount);
returnedChange += coinAmount * coin;
});
console.log(coinCount);
return coinCount;
}
9 changes: 9 additions & 0 deletions 02-ace-of-some-base/recursion-es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const isPalindrome = s => s.toString() === s .toString() .split('') .reverse() .join('');
const ariseMyBase = (predicate, base) => num =>
predicate(num.toString(base)) || base >= 36
? base
: ariseMyBase(predicate, ++base, num);

const palindromeBase = ariseMyBase(isPalindrome, 2);

console.log(palindromeBase(11)) // 20
18 changes: 18 additions & 0 deletions 03-lowest-missing-number-in-noncontigous-sequence/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# MissingNo

Given an array of integers, find the first missing positive integer. In other
words, find the lowest positive integer that does not exist in the array. The
array can contain duplicates and negative numbers as well.

## Input
`number` - Array of numbers

## Output
the Lowest missing number

## Example

```
missingNo([3, 4, -1, 1]) // 2
missingNo([1,2,0,-1]) // 3
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// run with node es6-reduce.js

const missingNo = l => l.concat().sort((a,b)=>a-b).reduce((m,v,i) => v===m ? m+1 : m ,1);

console.log(missingNo([4,6,7,8,1,2,2,2,4,-1,-2,8,3])); // 5
console.log(missingNo([4,6,7,8,1,2,2,2,4,-1,-2,8])); // 3