• + 0 comments

    typesciprt

    function encryption(s: string): string {
        const cleanS = s.split("").join("")
        const srtL = Math.ceil(Math.sqrt(cleanS.length))
        
        return [...cleanS].reduce((cypfer, character, index) => {
            cypfer[index % srtL] += character
            return cypfer
        }, 
        Array(srtL).fill("")).join(" ")
    }