Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let input = document.getElementById("input").value;
- let sum = calculateSum(input);
- let result = document.getElementById('resultOutput');
- function calculateSum(input) {
- return input.split('').map(Number).reduce((a, b) => a + b);
- }
- if (String(sum).length > 1) {
- while (String(sum).length > 1) {
- sum = String(sum).split('').map(Number).reduce((a, b) => a + b);
- }
- }
- result.innerHTML = input.substring(sum, input.length - sum).match(new RegExp('.'.repeat(8), "gim"))
- .map(e => parseInt(e, 2)).map(e => String.fromCharCode(e)).join('').match(/[a-zA-Z ]+/gim).join('');
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement