Skip to content

Instantly share code, notes, and snippets.

fun findSubFunctions(input: List<List<String>>, maxFunctionLength: Int, maxSubFunctions: Int): List<List<String>>? {
if (input.isEmpty()) {
return emptyList()
}
if (maxSubFunctions == 0) {
return null
}
for (i in 1..input[0].size) {
val candidate = input[0].subList(0, i)
if (candidate.joinToString(",").length > maxFunctionLength) {
package dk.faberespensen.scratch.adventofcode.year2019.day17
import adventofcode.year2019.intcode.Machine
import dk.faberespensen.scratch.*
import dk.faberespensen.scratch.adventofcode.getInputLongsFromCsv
class Day17 {
val input = getInputLongsFromCsv(2019, 17)
fun part1() {
package dk.faberespensen.scratch.adventofcode.year2019.day20
import dk.faberespensen.scratch.*
import dk.faberespensen.scratch.adventofcode.getInput
class Day20 {
val input = getInput(2019, 20)
fun part1() {
val map = input.toXYMap()
@rasmusfaber
rasmusfaber / gist:04cc691e501f3d227375e2a417064016
Created December 23, 2019 08:34
Puzzle input 2019 day 23
3,62,1001,62,11,10,109,2255,105,1,0,2049,1309,2018,1816,942,1585,571,1218,1554,2189,1276,1154,909,1847,1247,1379,1878,1490,1443,1187,1119,835,1981,1715,973,1946,701,1651,2220,664,1053,600,732,1410,2090,1519,765,1750,1781,866,1086,1014,802,633,2156,1680,1350,2121,1616,1909,0,0,0,0,0,0,0,0,0,0,0,0,3,64,1008,64,-1,62,1006,62,88,1006,61,170,1105,1,73,3,65,20102,1,64,1,20102,1,66,2,21102,105,1,0,1106,0,436,1201,1,-1,64,1007,64,0,62,1005,62,73,7,64,67,62,1006,62,73,1002,64,2,133,1,133,68,133,101,0,0,62,1001,133,1,140,8,0,65,63,2,63,62,62,1005,62,73,1002,64,2,161,1,161,68,161,1102,1,1,0,1001,161,1,169,1002,65,1,0,1102,1,1,61,1102,1,0,63,7,63,67,62,1006,62,203,1002,63,2,194,1,68,194,194,1006,0,73,1001,63,1,63,1105,1,178,21101,210,0,0,106,0,69,1202,1,1,70,1102,1,0,63,7,63,71,62,1006,62,250,1002,63,2,234,1,72,234,234,4,0,101,1,234,240,4,0,4,70,1001,63,1,63,1106,0,218,1105,1,73,109,4,21101,0,0,-3,21101,0,0,-2,20207,-2,67,-1,1206,-1,293,1202,-2,2,283,101,1,283,283,1,68,283,283,22001,0,-3,-3,21201,-2,1,-2,1105,1,263,21202
22, 30, 25, 45, 23, 38, 48, 37, 3, 46, 21, 5, 48, 2, 34, 35, 22, 44, 10, 39, 45, 43, 8, 2, 42, 17, 17, 36, 49, 40, 15, 20, 47, 21, 15, 45, 11, 2, 14, 31, 45, 7, 15, 28, 28, 36, 31, 28, 47, 20, 28, 21, 23, 23, 46, 5, 21, 48, 44, 22, 20, 27, 14, 7, 6, 46, 41, 18, 5, 32, 21, 1, 21, 29, 1, 27, 2, 28, 35, 14, 38, 1, 6, 46, 6, 30, 48, 41, 7, 21, 22, 46, 43, 45, 13, 45, 49, 34, 25, 15, 5, 1, 8, 3, 39, 28, 22, 18, 42, 15, 0, 2, 7, 6, 16, 9, 9, 0, 2, 30, 8, 46, 49, 28, 10, 33, 9, 28, 43, 3, 21, 23, 25, 0, 31, 1, 3, 17, 1, 10, 22, 38, 8, 34, 7, 45, 43, 5, 37, 35, 6, 35, 36, 19, 28, 49, 48, 33, 25, 8, 40, 36, 1, 34, 25, 49, 4, 41, 9, 49, 2, 18, 45, 32, 12, 26, 49, 5, 12, 5, 7, 35, 44, 7, 14, 42, 39, 22, 14, 25, 4, 49, 25, 11, 7, 4, 22, 16, 31, 31, 31, 34, 35, 32, 12, 2, 29, 0, 39, 46, 27, 46, 21, 35, 3, 2, 1, 6, 15, 24, 41, 44, 41, 1, 25, 40, 38, 3, 49, 41, 35, 16, 33, 16, 47, 22, 40, 42, 29, 34, 35, 44, 15, 46, 15, 40, 41, 31, 23, 39, 35, 37, 30, 14, 2, 13, 30, 24, 14, 9, 31, 32, 46, 25, 29, 17, 32, 36, 17, 23, 46, 17,
22: idle
30: idle
30: -> 49 : 57977 10
30: -> 1 : 6689 10
25: idle
45: idle
23: idle
38: idle
48: idle
37: idle
package xyz.faber;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import java.io.IOException;
import java.io.StringWriter;
public class JsonTest {
@rasmusfaber
rasmusfaber / JsonTest.java
Created May 28, 2020 18:14
Rename field using mixin or naming-strategy
package xyz.faber;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.introspect.AnnotatedField;
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod;
import com.fasterxml.jackson.databind.introspect.AnnotatedParameter;
import org.junit.Test;

Keybase proof

I hereby claim:

  • I am rasmusfaber on github.
  • I am rasmusfaber (https://keybase.io/rasmusfaber) on keybase.
  • I have a public key ASBgdRsx3TrYt87H2AojPs-ilOliKB7NhApiwuUIXgKklQo

To claim this, I am signing this object: