Delete Day1.scala

This commit is contained in:
kamoshi 2019-12-06 22:26:18 +01:00 committed by GitHub
parent 771130fc13
commit 4eeef93071
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,34 +0,0 @@
package day01
import kamlib.{Reader, Wrapper}
class Day1 {
/** Find fuel needed */
def solveP1(input: List[Int]): Int =
input.foldLeft (0) { (acc, i) => acc + (i/3-2)}
/** Find fuel needed and recursive fuel */
def solveP2(input: List[Int]): Int =
{
@scala.annotation.tailrec
def findRecursiveFuel(fuel: Int, acc: Int): Int =
{
if (fuel <= 0) acc
else findRecursiveFuel((fuel/3)-2, fuel+acc)
}
input.foldLeft (0) { (acc, i) => acc + findRecursiveFuel((i/3)-2, 0)}
}
/** MAIN */
def main(args: Array[String]): Unit =
{
val input: List[Int] = Reader.readList("/input1.txt").map(_.toInt)
println("Part 1")
Wrapper(solveP1(input)).print()
println("Part 2")
Wrapper(solveP2(input)).print()
}
}