mirror of
https://github.com/mx42/adventofcode.git
synced 2026-01-14 13:59:51 +01:00
Adding day 2
This commit is contained in:
16
day2/part2.scala
Normal file
16
day2/part2.scala
Normal file
@@ -0,0 +1,16 @@
|
||||
import scala.io.StdIn._
|
||||
|
||||
|
||||
val items = Iterator
|
||||
.continually(readLine)
|
||||
.takeWhile(_ != null)
|
||||
.toList
|
||||
|
||||
val res = items
|
||||
.combinations(2)
|
||||
.map(x => x(0) zip x(1))
|
||||
.dropWhile(_.count(t => t._1 != t._2) != 1)
|
||||
.map(_.filter(t => t._1 == t._2).map(_._1))
|
||||
.next
|
||||
|
||||
println(res.mkString(""))
|
||||
Reference in New Issue
Block a user