Skip to content

Instantly share code, notes, and snippets.

@flexbox
Created March 16, 2020 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flexbox/c11f900d5338900b5eed07b5abf4a7ff to your computer and use it in GitHub Desktop.
Save flexbox/c11f900d5338900b5eed07b5abf4a7ff to your computer and use it in GitHub Desktop.
airplane-sorting-algorithm.js
function solution(N, S) {
const occupied = S.split(' ')
let available = 0
console.log("solution -> available", available)
for (let index = 0; index < N; index++) {
if (
occupied[index] === `${index + 1}A` ||
occupied[index] === `${index + 1}B` ||
occupied[index] === `${index + 1}C` ||
occupied[index] === `${index + 1}D` ||
occupied[index] === `${index + 1}E` ||
occupied[index] === `${index + 1}F` ||
occupied[index] === `${index + 1}I` ||
occupied[index] === `${index + 1}J` ||
occupied[index] === `${index + 1}K`
){
available++
}
}
console.log("solution -> available", available)
return available
}
const two = solution(2, '1A 2F 1C')
console.log("available", two)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment