You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
831 B
TypeScript
40 lines
831 B
TypeScript
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;
|
|
};
|