Monday, 21 September 2020

Scala: Get permutations of a string

 

scala> "Rhine".toSeq.permutations.toArray
val res54: Array[scala.collection.immutable.WrappedString] = Array(Rhine, Rhien, Rhnie, Rhnei, Rhein, Rheni, Rihne, Rihen, Rinhe, Rineh, Riehn, Rienh, Rnhie, Rnhei, Rnihe, Rnieh, Rnehi, Rneih, Rehin, Rehni, Reihn, Reinh, Renhi, Renih, hRine, hRien, hRnie, hRnei, hRein, hReni, hiRne, hiRen, hinRe, hineR, hieRn, hienR, hnRie, hnRei, hniRe, hnieR, hneRi, hneiR, heRin, heRni, heiRn, heinR, henRi, heniR, iRhne, iRhen, iRnhe, iRneh, iRehn, iRenh, ihRne, ihRen, ihnRe, ihneR, iheRn, ihenR, inRhe, inReh, inhRe, inheR, ineRh, inehR, ieRhn, ieRnh, iehRn, iehnR, ienRh, ienhR, nRhie, nRhei, nRihe, nRieh, nRehi, nReih, nhRie, nhRei, nhiRe, nhieR, nheRi, nheiR, niRhe, niReh, nihRe, niheR, nieRh, niehR, neRhi, neRih, nehRi, nehiR, neiRh, neihR, eRhin, eRhni, eRihn, eRinh, eRnh...

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment