Created
February 21, 2013 15:09
-
-
Save zerosum/5005313 to your computer and use it in GitHub Desktop.
Project Euler: Problem 79
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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