Skip to content

Instantly share code, notes, and snippets.

@samskivert
Created August 22, 2010 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samskivert/543061 to your computer and use it in GitHub Desktop.
Save samskivert/543061 to your computer and use it in GitHub Desktop.
object Euler062 extends EulerApp {
def search (n :Long, cubes :Map[Long,List[Long]]) :Long = {
val cube = n*n*n
val key = cube.toString.sortWith(_>_).toLong
val perms = cube :: cubes.getOrElse(key, Nil)
if (perms.length == 5) perms.last
else search(n+1, cubes + (key -> perms))
}
def answer = search(1, Map())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment