# All files / algorithms/lib/isDevided11 isDevided11.ts

79.31% Statements 23/29
66.66% Branches 4/6
100% Functions 1/1
79.31% Lines 23/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    401x
    2x
    2x
    2x
    2x

    2x
    8x
    8x

    8x
    8x

    8x

    8x
    2x
    2x
    2x

    8x

    8x
    8x

    8x
    8x

    8x

    2x
    1x
     export function isDevided11(numbers: number[]): number[] {
      const res: number[] = [];
      let L = 1;
      let R = numbers.length - 1
      let M = 0;

      while (L <= numbers.length - 1 || R >= 0) {
        const L_NUM = numbers[L];
        const R_NUM = numbers[R];

        while (M <= numbers.length - 1) {
          const M_NUM = numbers[M];

          if (((L_NUM + R_NUM) - M_NUM) % 11 === 0) {
            res.push(+`${L_NUM}${M_NUM}${R_NUM}`)
            res.push(+`${R_NUM}${M_NUM}${L_NUM}`)
          }

          if (((L_NUM + M_NUM) - R_NUM) % 11 === 0) {
            res.push(+`${L_NUM}${R_NUM}${M_NUM}`)
            res.push(+`${M_NUM}${R_NUM}${L_NUM}`)
          }

          if (((R_NUM + M_NUM) - L_NUM) % 11 === 0) {
            res.push(+`${R_NUM}${L_NUM}${M_NUM}`)
            res.push(+`${M_NUM}${L_NUM}${R_NUM}`)
          }

          M++
        }

        L++
        R--

      }

      return res;
    };