function calculatePivot(word) {
  const splits = [
    0,
    0,
    0, //012
    1,
    1,
    1, //345
    2,
    2,
    2,
    2, //6789
    3,
    3,
    3,
    3,
    3,
    3, //10-15
    4,
    4,
    4,
    4,
    4,
    4,
    4,
    4
  ]
  return typeof splits[word.length] === 'undefined' ? 5 : splits[word.length]
}

export function pivotIdx(word) {
  const table = {
    1: 0,
    2: 0,
    3: 1,
    4: 1,
    5: 2,
    6: 2,
    7: 2,
    8: 3,
    9: 3,
    10: 3
  }
  return typeof table[word.length] === 'undefined' ? 4 : table[word.length]
}

export function pivotize(word, mode) {
  let start = 0
  let end = word.length
  let pivot = calculatePivot(word)
  return [
    word.slice(start, pivot),
    word.slice(pivot, pivot + 1),
    word.slice(pivot + 1, end)
  ]
}
