Scala
\nimport scala.math.min\nimport scala.util.chaining._\n\nobject Solution {\n  private val Black = \'0\'\n\n  def minimumWhiteTiles(floor: String, numCarpets: In
```\nimport scala.math.min\nimport scala.util.chaining._\n\nobject Solution {\n  private val Black = \'0\'\n\n  def minimumWhiteTiles(floor: String, numCarpets: Int, carpetLen: Int): Int = floor\n    .indices\n    .zip(floor.map(_ - Black).scanRight(0)(_ + _))\n    .toMap\n    .withDefaultValue(0)\n    .pipe { (1 to numCarpets)\n      .foldLeft(_) { case (previousNumWhiteTiles, _) => floor\n        .indices\n        .foldRight(Map[Int, Int]().withDefaultValue(0)) { case (i, currentNumWhiteTiles) =>\n          currentNumWhiteTiles + \n            (i -> min(floor(i) - Black + currentNumWhiteTiles(i + 1), previousNumWhiteTiles(i + carpetLen)))\n        }\n      }\n      .apply(0)\n    }\n}\n```
[]