Skip to content

Commit

Permalink
Hitra in elegantna rešitev v Scali (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
strelec authored Apr 18, 2024
1 parent 62005ee commit cff15e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/scala/CompressionPuzzle05.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
object CompressionPuzzle05 extends App {
val regex = "(.)\\1*".r
def compress(s: String): String =
regex.findAllIn(s).map(x => x.length + x.take(1)).mkString

assert(compress("AAABBAAC") == "3A2B2A1C")
}

0 comments on commit cff15e1

Please sign in to comment.