Advertisement
Guest User

Untitled

a guest
May 20th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.44 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.LinkedList;
  3. import java.util.List;
  4. import java.util.Scanner;
  5.  
  6. public class Main2 {
  7.     Scanner sc = new Scanner(System.in);
  8.     ArrayList<List<Integer>> permutations = new ArrayList<>();
  9.  
  10.     void run(){
  11.         int cases = sc.nextInt();
  12.         for (int i = 0; i < cases; i++){
  13.  
  14.             ArrayList<Integer> initial = new ArrayList<>();
  15.             for (int j = 0; j < 4; j++){
  16.                 initial.add(sc.nextInt());
  17.             }
  18.             permute(new ArrayList<Integer>(), initial);
  19.  
  20.  
  21.  
  22.         }
  23.  
  24.  
  25.     }
  26.  
  27.     void permute(List<Integer> out, List<Integer> in){
  28.         if (in.size() == 0){
  29.             permutations.add(out);
  30.             System.out.println(out.toString());
  31.         } else {
  32.             for (int i = 0; i < in.size(); i++){
  33.                 int n = in.get(i);
  34.                 ArrayList<Integer> newIn = new ArrayList<>(in);
  35.                 ArrayList<Integer> newOut = new ArrayList<>(out);
  36.                 newIn.remove(i);
  37.                 newOut.add(n);
  38.                 permute(newOut, newIn);
  39.             }
  40.         }
  41.     }
  42.  
  43.     void check24(){
  44.         boolean check = false;
  45.         for (List l ; permutations){
  46.         check = checkGroup1(l);
  47.         if(check == true) {
  48.             return;
  49.         }
  50.         }
  51.     }
  52.     boolean checkGroup1(List l , ){
  53.  
  54.  
  55.     }
  56.  
  57.  
  58.     public static void main(String[] args) {
  59.         new Main2().run();
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement