Skip to content

Instantly share code, notes, and snippets.

@zerosum
Created February 21, 2013 15:09
Show Gist options
  • Select an option

  • Save zerosum/5005313 to your computer and use it in GitHub Desktop.

Select an option

Save zerosum/5005313 to your computer and use it in GitHub Desktop.
Project Euler: Problem 79
package euler.zerosum
import scala.io.Source
object Euler0079 {
def main(args: Array[String]) {
val f = Source.fromFile("resources/keylog.txt")
val keylogs = f.getLines.toList
f.close()
val passcords = keylogs.mkString.toList.distinct
.permutations
.map(_.mkString)
.toList
val regex = keylogs.map(_.toList.mkString("[0-9]*", "[0-9]*", "[0-9]*"))
println(passcords.filter(p => regex.forall(p.matches(_))).head)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment