Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.test;
- import java.util.ArrayList;
- public class Main {
- static int c1;
- static int c2;
- static int c3;
- static ArrayList<Integer> permutations = new ArrayList<Integer>();
- static int total;
- public static void main(String[] args) {
- total = 0;
- c1 = 1;
- c2 = 1;
- c3 = 1;
- while (c1 < 7){
- while (c2 < 7){
- while (c3 < 7){
- System.out.println(c1 + " " + c2 + " " + c3); ou g
- ArrayList<Integer> perm = permutate(c1, c2, c3);
- addToList(perm, permutations);
- c3++;
- total++;
- }
- c3 = 1;
- c2++;
- }
- c2 = 1;
- c1++;
- }
- System.out.println(total);
- System.out.println(permutations.size());
- }
- public static ArrayList<Integer> permutate(int i, int j, int k){
- ArrayList<Integer> list = new ArrayList<Integer>();
- int i1 = Integer.parseInt(i + "" + j + "" + k);
- int i2 = Integer.parseInt(i + "" + k + "" + j);
- int i3 = Integer.parseInt(j + "" + i + "" + k);
- int i4 = Integer.parseInt(j + "" + k + "" + i);
- int i5 = Integer.parseInt(k + "" + j + "" + i);
- int i6 = Integer.parseInt(k + "" + i + "" + j);
- list.add(i1);
- list.add(i2);
- list.add(i3);
- list.add(i4);
- list.add(i5);
- list.add(i6);
- return list;
- }
- public static ArrayList<Integer> addToList(ArrayList<Integer> from, ArrayList<Integer> to){
- for (int i = 0; i < from.size(); i++) {
- int value = from.get(i);
- if (to.contains(value) == false){
- to.add(i);
- }
- }
- return to;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement