This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object S99_P12 { | |
def decode[T](its: Seq[(Int, T)]): Seq[T] = { | |
its.foldLeft(List[T]()) { (l, e) => l ++ List.fill(e._1)(e._2) } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2021-10-11T09:06:00.478Z","extensionVersion":"v3.4.3"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yq -w 250 -Y -i '[(paths | select(.[-1] | tostring | test("^@")))] as $paths | delpaths($paths)' <<file>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package day9 | |
import java.nio.file.Files | |
import java.nio.file.Path | |
class Day9b(val inputs: Array<IntArray>) { | |
val inner = inputs[0].size - 1 | |
val outer = inputs.size - 1 | |
val used = mutableSetOf<Pair<Int, Int>>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package day10 | |
import java.nio.file.Files | |
import java.nio.file.Path | |
import kotlin.system.measureTimeMillis | |
object Day10b { | |
val mapScore = mapOf( | |
')' to 1L, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package day11 | |
import java.nio.file.Files | |
import java.nio.file.Path | |
class State(private val data: Array<IntArray>) { | |
val inner = data[0].size - 1 | |
val outer = data.size - 1 | |
val flashes by lazy { data.sumOf { row -> row.count { it == 0 } } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Fold(val line: Int) { | |
abstract fun transform(p: Pair<Int, Int>): Pair<Int, Int> | |
} | |
class FoldX(line: Int) : Fold(line) { | |
override fun transform(p: Pair<Int, Int>): Pair<Int, Int> { | |
val x = p.first | |
val d = line - x | |
return if(x > line) Pair(x + d*2, p.second) else p | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package day14 | |
import java.nio.file.Files | |
import java.nio.file.Path | |
class Day14_Part2(val input: Input) { | |
val rules = input.rules.map { it.first to it.second }.toMap() | |
private fun find(s: String) = rules[s] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package day18 | |
import java.nio.file.Files | |
import java.nio.file.Path | |
sealed class Node(var parent: Regular? = null) { | |
abstract fun tryExplode(level: Int = 0): Boolean | |
abstract fun trySplit() : Boolean | |
internal fun reduce() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package day20 | |
import java.nio.file.Files | |
import java.nio.file.Path | |
class Enhancer(val code: String) { | |
private fun getPixel(r: Int, c: Int, data: List<String>) = data.getOrNull(r)?.getOrNull(c) ?: defaultChar | |
private var defaultChar = '.' |
OlderNewer