We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Implementation
- Encryption
- Discussions
Encryption
Encryption
Sort by
recency
|
1475 Discussions
|
Please Login in order to post a comment
Haskell:
public static String encryption(String s) { StringBuilder result = new StringBuilder(); s = s.replaceAll("\s", ""); int n = s.length(); int row = (int) Math.sqrt(n); int column = (row * row == n) ? row : row + 1; for (int i = 0; i < column; i++) { for (int j = i; j < n; j += column) { result.append(s.charAt(j)); } result.append(" ");
public static String encryption(String s) { int len = s.length(); int row = (int) Math.floor(Math.sqrt(len)); int col = (int) Math.ceil(Math.sqrt(len));
Kotlin proposal
The solution for "chillout" seems to be wrong?? The length = 8, which translates to 2X3, if we need to store all 8 characters, the array can be 2X4 or 3X3. According to the problem the smallest area should be chosen, which is 2X4, but the example shows 3X3??