Encryption
Implement an encryption scheme: (1) Remove all spaces from the string. (2) Calculate grid dimensions: rows = floor(√L), cols = ceil(√L). If rows × cols < L, increment rows. (3) Fill the grid row by row with the characters. (4) Read the grid column by column, joining each column's characters. (5) Output columns separated by spaces. Example: 'haveaniceday' → length 12 → √12 ≈ 3.46 → rows=3, cols=4 → Grid: h a v e a n i c e d a y Reading columns: 'hae' 'and' 'via' 'ecy' → Output: 'hae and via ecy'
Input
A single string s containing lowercase letters and spaces.
Output
The encrypted string with space-separated column outputs.
Sample
haveaniceday
Expected
hae and via ecy
Loading editor…
No output yet. Run your code to see results.