fork(2) download
  1. import scala.collection.mutable.PriorityQueue
  2. import scala.util.Random
  3.  
  4. object Main extends App {
  5.  
  6. val source = Random.shuffle("AABBCC".permutations)
  7. val sorted = ((PriorityQueue.empty[String] /: source ){ _ += _ }).reverse.dequeueAll
  8. sorted foreach println
  9.  
  10. }
Success #stdin #stdout 0.44s 382080KB
stdin
Standard input is empty
stdout
AABBCC
AABCBC
AABCCB
AACBBC
AACBCB
AACCBB
ABABCC
ABACBC
ABACCB
ABBACC
ABBCAC
ABBCCA
ABCABC
ABCACB
ABCBAC
ABCBCA
ABCCAB
ABCCBA
ACABBC
ACABCB
ACACBB
ACBABC
ACBACB
ACBBAC
ACBBCA
ACBCAB
ACBCBA
ACCABB
ACCBAB
ACCBBA
BAABCC
BAACBC
BAACCB
BABACC
BABCAC
BABCCA
BACABC
BACACB
BACBAC
BACBCA
BACCAB
BACCBA
BBAACC
BBACAC
BBACCA
BBCAAC
BBCACA
BBCCAA
BCAABC
BCAACB
BCABAC
BCABCA
BCACAB
BCACBA
BCBAAC
BCBACA
BCBCAA
BCCAAB
BCCABA
BCCBAA
CAABBC
CAABCB
CAACBB
CABABC
CABACB
CABBAC
CABBCA
CABCAB
CABCBA
CACABB
CACBAB
CACBBA
CBAABC
CBAACB
CBABAC
CBABCA
CBACAB
CBACBA
CBBAAC
CBBACA
CBBCAA
CBCAAB
CBCABA
CBCBAA
CCAABB
CCABAB
CCABBA
CCBAAB
CCBABA
CCBBAA