Adding day 18 p1 and 19 p1 + creating folder 2018

This commit is contained in:
Xavier Morel
2019-01-17 16:40:36 +01:00
parent 5fb50b11af
commit 5723d21ecb
32 changed files with 121 additions and 0 deletions

14
2018/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)