Given:
- a time in string format HH:MM
- a number of minutes
Return:
- The time given those minutes added to the base time
// You're playing a game in which you're given the number of players. | |
// Each turn, the player removes the person next to them. | |
// Play continues until there is only one player left. | |
// EXAMPLE: eenyMeeny(5) => | |
// 1 2 3 4 5 <= round 1: player 1 (remove player 2) | |
// 1 3 4 5 <= round 2: player 3 (remove player 4) | |
// 1 3 5 <= round 3: player 5 (remove player 1) | |
// 3 5 <= round 4: player 3 (remove player 5) | |
// Player 3 is the winner! |
Implement an immutable binary search tree class. The class constructor should accept (at least) a single argument which will represent the value for its root node. Each instance should have two methods: insert
, which takes a numerical value and returns a new binary search tree containing that value, and contains
, which takes a numerical value and returns true
or false
based on whether the tree contains it.
Insert should not mutate the existing binary search tree. That is:
const bstA = new ImmutableBST(5);
const returnsAPromise = (string) => ( | |
new Promise((resolve, reject) => { | |
if (typeof string !== 'string') reject('Not a string!'); | |
resolve(`String is a resolved promise now: ${string}`); | |
}) | |
); | |
const myString = "Kait's string"; | |
let isOurPromiseFinished = false; |
const queryADatabase = function(mysql, query) { | |
return new Promise((resolve, reject) => { | |
mysql.query(query, (err, rows) => { | |
if (err) reject(err); | |
else resolve(rows); | |
}); | |
}) | |
}; | |
/* What we're doing here is creating a promise that resolves or rejects |
/* eslint-disable no-unused-vars */ | |
const rotater = str => { | |
let flip = false; | |
let rotatedStr; | |
return function (steps) { | |
if (steps === str.length) { | |
flip = !flip; | |
} |