nikolayneykov

Untitled

May 26th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve () {
  2.   let input = document.querySelector('#input').value
  3.   let weight = input
  4.  
  5.   while (weight > 9) {
  6.     weight = weight
  7.       .toString()
  8.       .split('')
  9.       .map(Number)
  10.       .reduce((a, b) => a + b, 0)
  11.   }
  12.  
  13.   let result = input
  14.     .slice(weight, input.length - weight)
  15.     .match(/.{1,8}/g)
  16.     .map(segment => String.fromCharCode(Number.parseInt(segment, 2)))
  17.     .filter(x => /[A-Za-z\s]/.test(x))
  18.     .join('')
  19.  
  20.   document.querySelector('#resultOutput').textContent = result
  21. }
Advertisement
Add Comment
Please, Sign In to add comment