중복 방지를 위해 정렬 한 뒤에 같은 알파벳은 swap 해주지 않는 것이 관건

import Foundation

let n = Int(readLine()!)!
var words: [[Character]] = []

(0..<n).forEach { _ in
    let word = Array(readLine()!).sorted()
    words.append(word)
}

func combination(word: [Character], depth: Int = 0) {
    if depth == word.count {
        print(String(word))
        return
    }
    var word = word

    for i in depth..<word.count {
        if i != depth && word[i] == word[depth] { continue }
        word.swapAt(depth, i)
        combination(word: word, depth: depth + 1)
    }
}

words.forEach { word in
    combination(word: word)
}

참고 : https://www.acmicpc.net/problem/6443