Permalink
Browse files

Problem 24 updated

  • Loading branch information...
1 parent 767e10b commit 580368c59ca4b748ce3b19092ee0b82ef19bc278 @pavelfatin committed Dec 8, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 p24.scala
View
@@ -1,6 +1,6 @@
-def ps(s: String): Seq[String] = if(s.size == 1) Seq(s) else
- s.flatMap(c => ps(s.filterNot(_ == c)).map(c +))
+def ps(s: String): Iterator[String] = if (s.length == 1) Iterator(s)
+ else s.toIterator.flatMap(c => ps(s.filter(c !=)).map(c +))
-val r = ps("0123456789")(999999).toLong
+val r = ps("0123456789").drop(999999).next().toLong
-assert(r == 2783915460L) // 7 s
+assert(r == 2783915460L) // 712 ms

0 comments on commit 580368c

Please sign in to comment.