Skip to content

Instantly share code, notes, and snippets.

@runandrerun
Created November 12, 2018 19:24
Show Gist options
  • Save runandrerun/ae1b01395d72497fe95535b4fcae78aa to your computer and use it in GitHub Desktop.
Save runandrerun/ae1b01395d72497fe95535b4fcae78aa to your computer and use it in GitHub Desktop.
Question
// JavaScript
// Question #1
strangeSequence = (num) => {
let numbers = []
let count = 1
while (numbers.indexOf(num) === -1) {
count++
numbers.push(num)
num = ("" + num).split("").map(num => num * num).reduce((a, b) => a + b)
}
return count
}
strangeSequence(16)
// Question #2
// Unfinished
turnsToUnlock = (currentState, unlocked) => {
let totalTurns = 0
currentState.forEach((i, index) => {
let turns = i - unlocked[index];
// conditionals to check for turns
// return turns
})
return totalTurns;
}
turnsToUnlock([0, 0, 0], [3, 1, 8])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment