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 com.amartus.playground.jackson | |
import com.networknt.schema.InputFormat | |
import com.networknt.schema.JsonSchemaFactory | |
import com.networknt.schema.SchemaValidatorsConfig | |
import com.networknt.schema.SpecVersion | |
import com.networknt.schema.ValidationMessage | |
import com.networknt.schema.walk.JsonSchemaWalkListener | |
import com.networknt.schema.walk.WalkEvent | |
import com.networknt.schema.walk.WalkFlow |
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
import kotlinx.coroutines.* | |
import kotlinx.coroutines.flow.* | |
import java.util.concurrent.Executors | |
import kotlin.system.measureTimeMillis | |
@OptIn(FlowPreview::class) | |
fun main() = runBlocking { | |
val urls = (1..1000).map { "https://example.com/todos/$it" } |
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 day21 | |
import java.lang.Long.max | |
typealias Pos = Int | |
typealias Step = Int | |
val scroll3 : Map<Pos, Int> = (1..3).flatMap { f1 -> | |
(1..3).flatMap { f2 -> |
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 day21 | |
interface Dice { | |
fun value(): Int | |
fun values(count: Int): Sequence<Int> | |
fun rollCount(): Int | |
} | |
class DeterministicDice(var value: Int = 1, val max: Int = 100): Dice { | |
private var rollCount = 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
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 = '.' |
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 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
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 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
package day10 | |
import java.nio.file.Files | |
import java.nio.file.Path | |
import kotlin.system.measureTimeMillis | |
object Day10b { | |
val mapScore = mapOf( | |
')' to 1L, |
NewerOlder