1
0

Use fold for folds

This commit is contained in:
Hubert Van De Walle 2021-12-13 20:10:52 +01:00
parent e014b32ab4
commit 76e670770e

View File

@ -23,12 +23,7 @@ class Day13 : BaseDay() {
override fun part2(): String {
val (nums, folds) = input()
var all = nums.toSet()
folds.forEach { (axis, value) ->
all = all.fold(axis, value.toInt())
}
val all = folds.fold(nums.toSet()) { all, (axis, value) -> all.fold(axis, value.toInt()) }
val res = StringBuilder()
for (y in 0..all.maxOf { it.y }) {
for (x in 0..all.maxOf { it.x }) {