You are viewing a single comment's thread. Return to all comments →
TypeScript Solution
function encryption(s: string): string { let stepper = Math.ceil(Math.sqrt(s.length)); let substrings: string[] = []; for (let i = 0; i <= s.length; i = i + stepper) { substrings.push(s.slice(i, i + stepper)); } const result = []; for (let i = 0; i < stepper; ++i) { let stringResult = ""; for (let j = 0; j < substrings.length; ++j) { stringResult += substrings?.[j]?.[i] ?? ""; } result.push(stringResult); } return result.join(" "); }
Seems like cookies are disabled on this browser, please enable them to open this website
Encryption
You are viewing a single comment's thread. Return to all comments →
TypeScript Solution