Skip to content

Instantly share code, notes, and snippets.

@harryh
Created November 10, 2012 01:31
Show Gist options
  • Save harryh/4049422 to your computer and use it in GitHub Desktop.
Save harryh/4049422 to your computer and use it in GitHub Desktop.
Letterpress Solver
val letterSupply = args.reduce(_ + _)
.groupBy(_.toLower)
.mapValues(_.length)
scala.io.Source.fromFile("letterpress.words")
.getLines
.filter(word => word.forall(c => letterSupply.get(c).exists(_ >= word.count(_ == c))))
.toList
.sortBy(_.length)
.foreach(System.out.println(_))
@harryh
Copy link
Author

harryh commented Nov 10, 2012

scala Letterpress.scala abcde fghij klmno pqrst uvwxy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment