Click Here to go back to the homepage.

Encoded Message Solution:


import java.util.Scanner;
public class Kattis {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    StringBuilder sb = new StringBuilder();
    int cases = Integer.parseInt(sc.nextLine());
    for (int i = 0; i < cases; i++) {
      String line = sc.nextLine();
      int rowlen = (int)Math.sqrt(line.length());
      for (int j = rowlen-1; j >=0; j--) {
        for (int k = j; k < line.length(); k+=rowlen) {
          sb.append(line.charAt(k));
        }
      }
      sb.append(System.lineSeparator());
    }
    System.out.println(sb);
  }
}