Pacific-Design.com

    
Home Index

1. Algorithms

2. Permutation Hex

+ ArrayList

+ HashSet

Algorithms / Permutation Hex /

Permute 3 digit of Hexadecimal String

public class Permute {

    /*----------------------------------------------------------------------*/
    private static int hexPermutation() {

        String str = "0123456789abcdef";
        int permutedSteps = 0;

        char[] c = str.toCharArray();

        for (int i = 0; i < c.length; i++) {
            for (int j = 0; j < c.length; j++) {
                for (int k = 0; k < c.length; k++) {
                    System.out.println(c[i] + " " + c[j] + " " + c[k]);
                    permutedSteps++;
                }
            }
        }

        return permutedSteps;
    }
    /*----------------------------------------------------------------------*/
    public static void main(String[] args) {

        System.out.println("Number of Permutations: " + hexPermutation());
    }
    /*----------------------------------------------------------------------*/
}

/*
Output

0 0 0
0 0 1
0 0 2
0 0 3
0 0 4
0 0 5
0 0 6
0 0 7
0 0 8
0 0 9
0 0 a
0 0 b
0 0 c
0 0 d
0 0 e
0 0 f
0 1 0
0 1 1
0 1 2
0 1 3
0 1 4
0 1 5
0 1 6
0 1 7
0 1 8
*/