fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int[][] input = new int[][]{
  13. new int[]{1, 5, 3, 5, 8},
  14. new int[]{5, 3, 5, 3, 5},
  15. new int[]{3, 9, 7, 1, 3}
  16. };
  17. int[] counts = new int[10];
  18. for (int r = 0 ; r != 3 ; r++)
  19. for (int c = 0 ; c != 5 ; c++)
  20. counts[input[r][c]]++;
  21. List<List<Integer>> splitResults = new ArrayList<>();
  22. for (int num = 0 ; num != 10 ; num++) {
  23. if (counts[num] < 5) {
  24. continue;
  25. }
  26. System.out.println("Processing "+num);
  27. List<Integer> toAdd = new ArrayList<>();
  28. for (int c = 0 ; c != 5 ; c++) {
  29. for (int r = 0 ; r != 3 ; r++) {
  30. if (input[r][c] == num) {
  31. toAdd.add(r);
  32. System.out.print(r+" ");
  33. break;
  34. }
  35. }
  36. }
  37. System.out.println();
  38. splitResults.add(toAdd);
  39. }
  40.  
  41.  
  42. }
  43. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
Processing 3
2 1 0 1 2 
Processing 5
1 0 1 0 1