class Anagrams {

    public static List<String> generate(String input) {
        List<String> anagrams = new ArrayList<String>();

        char[] chars = input.toCharArray();
        int inputLength = chars.length;
        int maxAnagrams = calculateTotalAnagramsForWordSize(inputLength);

        for (int a = 0; a < maxAnagrams; a++) {
            int pickPosition = calculatePickPosition(inputLength, a);
            System.out.println("pick at " + pickPosition);
            int dropPosition = calculateDropPosition(inputLength, pickPosition, a);
            System.out.println("drop at " + dropPosition);
            char movingLetter = chars[pickPosition];
//            System.out.println("moving " + movingLetter);
            System.out.println("moving " + movingLetter);
            char[] output = new char[inputLength];
            for (int i = 0; i < inputLength; i++) {
                if (dropPosition == i) {
                    output[dropPosition] = movingLetter;
                    output[pickPosition] = chars[i];
                } else {
                    output[i] = chars[i];
                }
            }
            anagrams.add(String.valueOf(output));
        }
        return anagrams;
    }

}