Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const input = ['135', '357', '791', '357', '913', '579', '135'];
  2. const print = this.print || console.log;
  3. const gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  4.  
  5. const alphaNumbers = [gets(), gets(), gets(), gets(), gets(), gets(), gets()]
  6.   .filter((num) => {
  7.     const a = +num[0];
  8.     const b = +num[1];
  9.     const c = +num[2];
  10.  
  11.     const biggestNonNegativeDifference = Math.max(
  12.       Math.abs(a - b),
  13.       Math.abs(b - c),
  14.       Math.abs(a - c)
  15.     );
  16.  
  17.     const lastDigitOfTheSum = (a + b + c) % 10;
  18.  
  19.     const isAlphaNumber = biggestNonNegativeDifference > lastDigitOfTheSum;
  20.  
  21.     return isAlphaNumber;
  22.   });
  23.  
  24. print(alphaNumbers);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement