Adding day 5

This commit is contained in:
Xavier Morel
2018-12-05 14:50:30 +01:00
parent d76ac78c7f
commit bd5c5f38e1
2 changed files with 35 additions and 0 deletions

14
day5/part1.scala Normal file
View File

@@ -0,0 +1,14 @@
import scala.io.StdIn._
val ASCII_MIN_MAJ_INTERVAL = 32 // 'a' - 'A'
val res = readLine
.foldLeft(""){
case (acc, chr) => chr match {
case _ if acc.isEmpty => chr.toString
case _ if (acc.last - chr).abs == ASCII_MIN_MAJ_INTERVAL => acc.dropRight(1)
case _ => acc + chr
}
}
println(res.size)