Skip to content

Instantly share code, notes, and snippets.

@stepanmas
Last active September 23, 2020 09:19
Show Gist options
  • Save stepanmas/dbf843e8b2aeb12e14ae98bbd5d0f258 to your computer and use it in GitHub Desktop.
Save stepanmas/dbf843e8b2aeb12e14ae98bbd5d0f258 to your computer and use it in GitHub Desktop.
Расшифруйте эту строку. Строка содержит пробел и буквы латинского алфавита.
// Расшифруйте эту строку. Строка содержит пробел и буквы латинского алфавита.
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