Skip to content

Instantly share code, notes, and snippets.

@crater2150
Created March 12, 2020 14:05
Show Gist options
  • Save crater2150/0523cc929593ebf3aab61e3486bb2646 to your computer and use it in GitHub Desktop.
Save crater2150/0523cc929593ebf3aab61e3486bb2646 to your computer and use it in GitHub Desktop.
find words with same rotation
def normalize(s: String) = (s + s).sliding(s.length).max
val words = scala.io.Source.fromFile("enable1.txt").getLines.toVector
val groupOfFour = words.toList.groupBy(normalize).filter(_._2.length == 4)
println(groupOfFour)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment