• + 0 comments

    C# Solution

    public static string encryption(string s)
    {
        s.Replace(" ", string.Empty);
        string encryptedString = string.Empty;
        int columns = (int)Math.Ceiling(Math.Sqrt(s.Length));
    
        for(int i = 0; i < columns; i++)
        {
            for(int j = i; j < s.Length; j += columns)
                encryptedString += s[j];
    
            encryptedString += " ";
        }
        return encryptedString;
    }