Day 1 part 1 complete - slight refactor

This commit is contained in:
anthonycicc 2019-12-02 17:18:10 -05:00
parent da70cebc2d
commit 07594c5d9a

View file

@ -7,10 +7,14 @@ import java.util.stream.Collectors
class Day1 {
fun run(inputFile: Path): Long {
return loadFile(inputFile).parallelStream()
.map { it.toLong().div(3).minus(2) }
.map {calculateCost(it)}
.collect(Collectors.summingLong { it } )
}
private fun calculateCost(x: String): Long {
return x.toLong().div(3).minus(2)
}
private fun loadFile(inputFile: Path): List<String> {
return Files.readAllLines(inputFile)
}