Last active
September 6, 2024 02:32
-
-
Save steveast/dbf843e8b2aeb12e14ae98bbd5d0f258 to your computer and use it in GitHub Desktop.
Расшифруйте эту строку. Строка содержит пробел и буквы латинского алфавита.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Расшифруйте эту строку. Строка содержит пробел и буквы латинского алфавита. | |
let input = '711141019711632119111114107'; // Great work | |
let result = ''; | |
function findFirstChar(n) { | |
let char = String.fromCharCode(n); | |
if (/[a-z|A-Z ']/.test(char)) | |
return char; | |
else | |
return false; | |
} | |
function theRecursion(input, i) { | |
if (!input.length) return; | |
i = i || 1; | |
let char = input.substr(0, i); | |
if (char = findFirstChar(char)) { | |
result += char; | |
theRecursion(input.substr(i)); | |
} else { | |
theRecursion(input, ++i); | |
} | |
} | |
theRecursion(input); | |
console.log(result); // Great work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment