package net.sinceat.aoc2020.day9

import java.util.LinkedList

fun main() {
    val testInput = parseInput("testinput.txt")
    val testBuffer = RingBuffer.fromSequence(testInput, 5)
    println(lookForFirstInvalidNumber(testBuffer, testInput))

    val input = parseInput("input.txt")
    val invalidNumber = run {
        lookForFirstInvalidNumber(RingBuffer.fromSequence(input, 25), input)
    }
    println(invalidNumber!!)

    for (windowSize in 2 .. Integer.MAX_VALUE) {
        println("sequence length: $windowSize")
        for (window in input.windowed(windowSize, 1)) {
            val sum = window.sum()
            when {
                sum == invalidNumber -> {
                    println("found it: ${window.minOrNull()!! + window.maxOrNull()!!}")
                    return
                }
                sum > invalidNumber -> {
                    break
                }
            }
        }
    }
}

fun lookForFirstInvalidNumber(buffer: RingBuffer, input: Sequence<Long>): Long? {
    for (nr in input.drop(buffer.size)) {
        if (nr !in buffer.allSums()) {
            return nr
        }
        buffer.add(nr)
    }
    return null
}

fun RingBuffer.allSums() = sequence {
    for (i in 0 until size) {
        val first = get(i)
        for (k in i until size) {
            val second = get(k)
            yield(first + second)
        }
    }
}

fun parseInput(fileName: String) = sequence {
    ClassLoader.getSystemResourceAsStream(fileName)!!.bufferedReader().useLines { lines ->
        yieldAll(lines.filter(String::isNotBlank).map(String::toLong))
    }
}

class RingBuffer(private val inner: LinkedList<Long>) : List<Long> by inner {
    fun add(element: Long) {
        inner.removeFirst()
        inner.add(element)
    }

    companion object {
        fun fromSequence(sequence: Sequence<Long>, preambleLength: Int): RingBuffer {
            val preamble = LinkedList(sequence.take(preambleLength).toList())
            return RingBuffer(preamble)
        }
    }
}

Compiled from "App.kt"
public final class net.sinceat.aoc2020.day9.AppKt {
  public static final void main();
    Code:
       0: ldc           #8                  // String testinput.txt
       2: invokestatic  #12                 // Method parseInput:(Ljava/lang/String;)Lkotlin/sequences/Sequence;
       5: astore_0
       6: getstatic     #18                 // Field net/sinceat/aoc2020/day9/RingBuffer.Companion:Lnet/sinceat/aoc2020/day9/RingBuffer$Companion;
       9: aload_0
      10: iconst_5
      11: invokevirtual #24                 // Method net/sinceat/aoc2020/day9/RingBuffer$Companion.fromSequence:(Lkotlin/sequences/Sequence;I)Lnet/sinceat/aoc2020/day9/RingBuffer;
      14: astore_1
      15: aload_1
      16: aload_0
      17: invokestatic  #28                 // Method lookForFirstInvalidNumber:(Lnet/sinceat/aoc2020/day9/RingBuffer;Lkotlin/sequences/Sequence;)Ljava/lang/Long;
      20: getstatic     #34                 // Field java/lang/System.out:Ljava/io/PrintStream;
      23: swap
      24: invokevirtual #40                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      27: ldc           #42                 // String input.txt
      29: invokestatic  #12                 // Method parseInput:(Ljava/lang/String;)Lkotlin/sequences/Sequence;
      32: astore_2
      33: iconst_0
      34: istore        4
      36: getstatic     #18                 // Field net/sinceat/aoc2020/day9/RingBuffer.Companion:Lnet/sinceat/aoc2020/day9/RingBuffer$Companion;
      39: aload_2
      40: bipush        25
      42: invokevirtual #24                 // Method net/sinceat/aoc2020/day9/RingBuffer$Companion.fromSequence:(Lkotlin/sequences/Sequence;I)Lnet/sinceat/aoc2020/day9/RingBuffer;
      45: aload_2
      46: invokestatic  #28                 // Method lookForFirstInvalidNumber:(Lnet/sinceat/aoc2020/day9/RingBuffer;Lkotlin/sequences/Sequence;)Ljava/lang/Long;
      49: nop
      50: astore_3
      51: aload_3
      52: dup
      53: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      56: invokevirtual #53                 // Method java/lang/Long.longValue:()J
      59: lstore        4
      61: getstatic     #34                 // Field java/lang/System.out:Ljava/io/PrintStream;
      64: lload         4
      66: invokevirtual #56                 // Method java/io/PrintStream.println:(J)V
      69: iconst_2
      70: istore        4
      72: new           #58                 // class java/lang/StringBuilder
      75: dup
      76: invokespecial #61                 // Method java/lang/StringBuilder."<init>":()V
      79: ldc           #63                 // String sequence length:
      81: invokevirtual #67                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      84: iload         4
      86: invokevirtual #70                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      89: invokevirtual #74                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      92: getstatic     #34                 // Field java/lang/System.out:Ljava/io/PrintStream;
      95: swap
      96: invokevirtual #40                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      99: aload_2
     100: iload         4
     102: iconst_1
     103: iconst_0
     104: iconst_4
     105: aconst_null
     106: invokestatic  #80                 // Method kotlin/sequences/SequencesKt.windowed$default:(Lkotlin/sequences/Sequence;IIZILjava/lang/Object;)Lkotlin/sequences/Sequence;
     109: invokeinterface #86,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     114: astore        5
     116: aload         5
     118: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     123: ifeq          244
     126: aload         5
     128: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     133: checkcast     #98                 // class java/util/List
     136: astore        6
     138: aload         6
     140: checkcast     #100                // class java/lang/Iterable
     143: invokestatic  #106                // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J
     146: lstore        7
     148: nop
     149: lload         7
     151: aload_3
     152: dup
     153: ifnonnull     161
     156: pop
     157: pop2
     158: goto          231
     161: invokevirtual #53                 // Method java/lang/Long.longValue:()J
     164: lcmp
     165: ifne          231
     168: new           #58                 // class java/lang/StringBuilder
     171: dup
     172: invokespecial #61                 // Method java/lang/StringBuilder."<init>":()V
     175: ldc           #108                // String found it:
     177: invokevirtual #67                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     180: aload         6
     182: checkcast     #100                // class java/lang/Iterable
     185: invokestatic  #112                // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     188: dup
     189: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     192: checkcast     #114                // class java/lang/Number
     195: invokevirtual #115                // Method java/lang/Number.longValue:()J
     198: aload         6
     200: checkcast     #100                // class java/lang/Iterable
     203: invokestatic  #118                // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     206: dup
     207: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     210: checkcast     #114                // class java/lang/Number
     213: invokevirtual #115                // Method java/lang/Number.longValue:()J
     216: ladd
     217: invokevirtual #121                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     220: invokevirtual #74                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     223: getstatic     #34                 // Field java/lang/System.out:Ljava/io/PrintStream;
     226: swap
     227: invokevirtual #40                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     230: return
     231: lload         7
     233: aload_3
     234: invokevirtual #53                 // Method java/lang/Long.longValue:()J
     237: lcmp
     238: ifle          116
     241: goto          244
     244: iload         4
     246: ldc           #122                // int 2147483647
     248: if_icmpeq     257
     251: iinc          4, 1
     254: goto          72
     257: return

  public static final java.lang.Long lookForFirstInvalidNumber(net.sinceat.aoc2020.day9.RingBuffer, kotlin.sequences.Sequence<java.lang.Long>);
    Code:
       0: aload_0
       1: ldc           #141                // String buffer
       3: invokestatic  #145                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #146                // String input
       9: invokestatic  #145                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: aload_0
      14: invokevirtual #150                // Method net/sinceat/aoc2020/day9/RingBuffer.size:()I
      17: invokestatic  #154                // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
      20: invokeinterface #86,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
      25: astore_2
      26: aload_2
      27: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          75
      35: aload_2
      36: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      41: checkcast     #114                // class java/lang/Number
      44: invokevirtual #115                // Method java/lang/Number.longValue:()J
      47: lstore_3
      48: aload_0
      49: invokestatic  #158                // Method allSums:(Lnet/sinceat/aoc2020/day9/RingBuffer;)Lkotlin/sequences/Sequence;
      52: lload_3
      53: invokestatic  #162                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      56: invokestatic  #166                // Method kotlin/sequences/SequencesKt.contains:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)Z
      59: ifne          67
      62: lload_3
      63: invokestatic  #162                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      66: areturn
      67: aload_0
      68: lload_3
      69: invokevirtual #169                // Method net/sinceat/aoc2020/day9/RingBuffer.add:(J)V
      72: goto          26
      75: aconst_null
      76: areturn

  public static final kotlin.sequences.Sequence<java.lang.Long> allSums(net.sinceat.aoc2020.day9.RingBuffer);
    Code:
       0: aload_0
       1: ldc           #173                // String <this>
       3: invokestatic  #145                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #175                // class net/sinceat/aoc2020/day9/AppKt$allSums$1
       9: dup
      10: aload_0
      11: aconst_null
      12: invokespecial #178                // Method net/sinceat/aoc2020/day9/AppKt$allSums$1."<init>":(Lnet/sinceat/aoc2020/day9/RingBuffer;Lkotlin/coroutines/Continuation;)V
      15: checkcast     #180                // class kotlin/jvm/functions/Function2
      18: invokestatic  #184                // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
      21: areturn

  public static final kotlin.sequences.Sequence<java.lang.Long> parseInput(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #188                // String fileName
       3: invokestatic  #145                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #190                // class net/sinceat/aoc2020/day9/AppKt$parseInput$1
       9: dup
      10: aload_0
      11: aconst_null
      12: invokespecial #193                // Method net/sinceat/aoc2020/day9/AppKt$parseInput$1."<init>":(Ljava/lang/String;Lkotlin/coroutines/Continuation;)V
      15: checkcast     #180                // class kotlin/jvm/functions/Function2
      18: invokestatic  #184                // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
      21: areturn

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #197                // Method main:()V
       3: return
}

Compiled from "App.kt"
final class net.sinceat.aoc2020.day9.AppKt$parseInput$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super java.lang.Long>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {
  int label;

  private java.lang.Object L$0;

  final java.lang.String $fileName;

  net.sinceat.aoc2020.day9.AppKt$parseInput$1(java.lang.String, kotlin.coroutines.Continuation<? super net.sinceat.aoc2020.day9.AppKt$parseInput$1>);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #14                 // Field $fileName:Ljava/lang/String;
       5: aload_0
       6: iconst_2
       7: aload_2
       8: invokespecial #17                 // Method kotlin/coroutines/jvm/internal/RestrictedSuspendLambda."<init>":(ILkotlin/coroutines/Continuation;)V
      11: return

  public final java.lang.Object invokeSuspend(java.lang.Object);
    Code:
       0: invokestatic  #42                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
       3: astore        11
       5: aload_0
       6: getfield      #46                 // Field label:I
       9: tableswitch   { // 0 to 1
                     0: 32
                     1: 224
               default: 293
          }
      32: aload_1
      33: invokestatic  #52                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
      36: aload_0
      37: getfield      #56                 // Field L$0:Ljava/lang/Object;
      40: checkcast     #58                 // class kotlin/sequences/SequenceScope
      43: astore_2
      44: aload_0
      45: getfield      #14                 // Field $fileName:Ljava/lang/String;
      48: invokestatic  #64                 // Method java/lang/ClassLoader.getSystemResourceAsStream:(Ljava/lang/String;)Ljava/io/InputStream;
      51: dup
      52: invokestatic  #69                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      55: astore_3
      56: getstatic     #75                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      59: astore        4
      61: new           #77                 // class java/io/InputStreamReader
      64: dup
      65: aload_3
      66: aload         4
      68: invokespecial #80                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      71: checkcast     #82                 // class java/io/Reader
      74: astore        5
      76: sipush        8192
      79: istore        6
      81: aload         5
      83: instanceof    #84                 // class java/io/BufferedReader
      86: ifeq          97
      89: aload         5
      91: checkcast     #84                 // class java/io/BufferedReader
      94: goto          108
      97: new           #84                 // class java/io/BufferedReader
     100: dup
     101: aload         5
     103: iload         6
     105: invokespecial #87                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     108: checkcast     #82                 // class java/io/Reader
     111: astore_3
     112: iconst_0
     113: istore        4
     115: aload_3
     116: astore        5
     118: sipush        8192
     121: istore        6
     123: aload         5
     125: instanceof    #84                 // class java/io/BufferedReader
     128: ifeq          139
     131: aload         5
     133: checkcast     #84                 // class java/io/BufferedReader
     136: goto          150
     139: new           #84                 // class java/io/BufferedReader
     142: dup
     143: aload         5
     145: iload         6
     147: invokespecial #87                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     150: checkcast     #89                 // class java/io/Closeable
     153: astore        5
     155: aconst_null
     156: astore        6
     158: nop
     159: aload         5
     161: checkcast     #84                 // class java/io/BufferedReader
     164: astore        7
     166: iconst_0
     167: istore        8
     169: aload         7
     171: invokestatic  #95                 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     174: astore        9
     176: iconst_0
     177: istore        10
     179: aload_2
     180: aload         9
     182: getstatic     #101                // Field net/sinceat/aoc2020/day9/AppKt$parseInput$1$1$1.INSTANCE:Lnet/sinceat/aoc2020/day9/AppKt$parseInput$1$1$1;
     185: checkcast     #103                // class kotlin/jvm/functions/Function1
     188: invokestatic  #109                // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     191: getstatic     #114                // Field net/sinceat/aoc2020/day9/AppKt$parseInput$1$1$2.INSTANCE:Lnet/sinceat/aoc2020/day9/AppKt$parseInput$1$1$2;
     194: checkcast     #103                // class kotlin/jvm/functions/Function1
     197: invokestatic  #117                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     200: aload_0
     201: aload_0
     202: aload         5
     204: putfield      #56                 // Field L$0:Ljava/lang/Object;
     207: aload_0
     208: iconst_1
     209: putfield      #46                 // Field label:I
     212: invokevirtual #121                // Method kotlin/sequences/SequenceScope.yieldAll:(Lkotlin/sequences/Sequence;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
     215: dup
     216: aload         11
     218: if_acmpne     251
     221: aload         11
     223: areturn
     224: iconst_0
     225: istore        4
     227: iconst_0
     228: istore        8
     230: iconst_0
     231: istore        10
     233: aconst_null
     234: astore        6
     236: aload_0
     237: getfield      #56                 // Field L$0:Ljava/lang/Object;
     240: checkcast     #89                 // class java/io/Closeable
     243: astore        5
     245: nop
     246: aload_1
     247: invokestatic  #52                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     250: aload_1
     251: pop
     252: getstatic     #126                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     255: astore        7
     257: aload         5
     259: aload         6
     261: invokestatic  #132                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     264: goto          288
     267: astore        8
     269: aload         8
     271: astore        6
     273: aload         8
     275: athrow
     276: astore        8
     278: aload         5
     280: aload         6
     282: invokestatic  #132                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     285: aload         8
     287: athrow
     288: nop
     289: getstatic     #126                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     292: areturn
     293: new           #134                // class java/lang/IllegalStateException
     296: dup
     297: ldc           #136                // String call to \'resume\' before \'invoke\' with coroutine
     299: invokespecial #139                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     302: athrow
    Exception table:
       from    to  target type
         158   215   267   Class java/lang/Throwable
         245   257   267   Class java/lang/Throwable
         158   215   276   any
         245   257   276   any
         267   276   276   any
         276   278   276   any

  public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);
    Code:
       0: new           #2                  // class net/sinceat/aoc2020/day9/AppKt$parseInput$1
       3: dup
       4: aload_0
       5: getfield      #14                 // Field $fileName:Ljava/lang/String;
       8: aload_2
       9: invokespecial #162                // Method "<init>":(Ljava/lang/String;Lkotlin/coroutines/Continuation;)V
      12: astore_3
      13: aload_3
      14: aload_1
      15: putfield      #56                 // Field L$0:Ljava/lang/Object;
      18: aload_3
      19: checkcast     #164                // class kotlin/coroutines/Continuation
      22: areturn

  public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super java.lang.Long>, kotlin.coroutines.Continuation<? super kotlin.Unit>);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokevirtual #170                // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
       6: checkcast     #2                  // class net/sinceat/aoc2020/day9/AppKt$parseInput$1
       9: getstatic     #126                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      12: invokevirtual #172                // Method invokeSuspend:(Ljava/lang/Object;)Ljava/lang/Object;
      15: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #58                 // class kotlin/sequences/SequenceScope
       5: aload_2
       6: checkcast     #164                // class kotlin/coroutines/Continuation
       9: invokevirtual #177                // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      12: areturn
}

Compiled from "App.kt"
final class net.sinceat.aoc2020.day9.AppKt$allSums$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super java.lang.Long>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {
  int I$0;

  int I$1;

  int I$2;

  int I$3;

  long J$0;

  int label;

  private java.lang.Object L$0;

  final net.sinceat.aoc2020.day9.RingBuffer $this_allSums;

  net.sinceat.aoc2020.day9.AppKt$allSums$1(net.sinceat.aoc2020.day9.RingBuffer, kotlin.coroutines.Continuation<? super net.sinceat.aoc2020.day9.AppKt$allSums$1>);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #14                 // Field $this_allSums:Lnet/sinceat/aoc2020/day9/RingBuffer;
       5: aload_0
       6: iconst_2
       7: aload_2
       8: invokespecial #17                 // Method kotlin/coroutines/jvm/internal/RestrictedSuspendLambda."<init>":(ILkotlin/coroutines/Continuation;)V
      11: return

  public final java.lang.Object invokeSuspend(java.lang.Object);
    Code:
       0: invokestatic  #53                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
       3: astore        11
       5: aload_0
       6: getfield      #56                 // Field label:I
       9: tableswitch   { // 0 to 1
                     0: 32
                     1: 171
               default: 230
          }
      32: aload_1
      33: invokestatic  #62                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
      36: aload_0
      37: getfield      #65                 // Field L$0:Ljava/lang/Object;
      40: checkcast     #67                 // class kotlin/sequences/SequenceScope
      43: astore_2
      44: iconst_0
      45: istore_3
      46: aload_0
      47: getfield      #14                 // Field $this_allSums:Lnet/sinceat/aoc2020/day9/RingBuffer;
      50: invokevirtual #73                 // Method net/sinceat/aoc2020/day9/RingBuffer.size:()I
      53: istore        4
      55: iload_3
      56: iload         4
      58: if_icmpge     226
      61: aload_0
      62: getfield      #14                 // Field $this_allSums:Lnet/sinceat/aoc2020/day9/RingBuffer;
      65: iload_3
      66: invokevirtual #77                 // Method net/sinceat/aoc2020/day9/RingBuffer.get:(I)Ljava/lang/Long;
      69: invokevirtual #83                 // Method java/lang/Long.longValue:()J
      72: lstore        5
      74: iload_3
      75: istore        7
      77: aload_0
      78: getfield      #14                 // Field $this_allSums:Lnet/sinceat/aoc2020/day9/RingBuffer;
      81: invokevirtual #73                 // Method net/sinceat/aoc2020/day9/RingBuffer.size:()I
      84: istore        8
      86: iload         7
      88: iload         8
      90: if_icmpge     220
      93: aload_0
      94: getfield      #14                 // Field $this_allSums:Lnet/sinceat/aoc2020/day9/RingBuffer;
      97: iload         7
      99: invokevirtual #77                 // Method net/sinceat/aoc2020/day9/RingBuffer.get:(I)Ljava/lang/Long;
     102: invokevirtual #83                 // Method java/lang/Long.longValue:()J
     105: lstore        9
     107: aload_2
     108: lload         5
     110: lload         9
     112: ladd
     113: invokestatic  #89                 // Method kotlin/coroutines/jvm/internal/Boxing.boxLong:(J)Ljava/lang/Long;
     116: aload_0
     117: checkcast     #91                 // class kotlin/coroutines/Continuation
     120: aload_0
     121: aload_2
     122: putfield      #65                 // Field L$0:Ljava/lang/Object;
     125: aload_0
     126: iload_3
     127: putfield      #93                 // Field I$0:I
     130: aload_0
     131: iload         4
     133: putfield      #95                 // Field I$1:I
     136: aload_0
     137: lload         5
     139: putfield      #97                 // Field J$0:J
     142: aload_0
     143: iload         7
     145: putfield      #99                 // Field I$2:I
     148: aload_0
     149: iload         8
     151: putfield      #101                // Field I$3:I
     154: aload_0
     155: iconst_1
     156: putfield      #56                 // Field label:I
     159: invokevirtual #105                // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
     162: dup
     163: aload         11
     165: if_acmpne     213
     168: aload         11
     170: areturn
     171: aload_0
     172: getfield      #101                // Field I$3:I
     175: istore        8
     177: aload_0
     178: getfield      #99                 // Field I$2:I
     181: istore        7
     183: aload_0
     184: getfield      #97                 // Field J$0:J
     187: lstore        5
     189: aload_0
     190: getfield      #95                 // Field I$1:I
     193: istore        4
     195: aload_0
     196: getfield      #93                 // Field I$0:I
     199: istore_3
     200: aload_0
     201: getfield      #65                 // Field L$0:Ljava/lang/Object;
     204: checkcast     #67                 // class kotlin/sequences/SequenceScope
     207: astore_2
     208: aload_1
     209: invokestatic  #62                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     212: aload_1
     213: pop
     214: iinc          7, 1
     217: goto          86
     220: iinc          3, 1
     223: goto          55
     226: getstatic     #111                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     229: areturn
     230: new           #113                // class java/lang/IllegalStateException
     233: dup
     234: ldc           #115                // String call to \'resume\' before \'invoke\' with coroutine
     236: invokespecial #118                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     239: athrow

  public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);
    Code:
       0: new           #2                  // class net/sinceat/aoc2020/day9/AppKt$allSums$1
       3: dup
       4: aload_0
       5: getfield      #14                 // Field $this_allSums:Lnet/sinceat/aoc2020/day9/RingBuffer;
       8: aload_2
       9: invokespecial #128                // Method "<init>":(Lnet/sinceat/aoc2020/day9/RingBuffer;Lkotlin/coroutines/Continuation;)V
      12: astore_3
      13: aload_3
      14: aload_1
      15: putfield      #65                 // Field L$0:Ljava/lang/Object;
      18: aload_3
      19: checkcast     #91                 // class kotlin/coroutines/Continuation
      22: areturn

  public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super java.lang.Long>, kotlin.coroutines.Continuation<? super kotlin.Unit>);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokevirtual #134                // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
       6: checkcast     #2                  // class net/sinceat/aoc2020/day9/AppKt$allSums$1
       9: getstatic     #111                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      12: invokevirtual #136                // Method invokeSuspend:(Ljava/lang/Object;)Ljava/lang/Object;
      15: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #67                 // class kotlin/sequences/SequenceScope
       5: aload_2
       6: checkcast     #91                 // class kotlin/coroutines/Continuation
       9: invokevirtual #141                // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      12: areturn
}

Compiled from "App.kt"
final class net.sinceat.aoc2020.day9.AppKt$parseInput$1$1$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, java.lang.Long> {
  public static final net.sinceat.aoc2020.day9.AppKt$parseInput$1$1$2 INSTANCE;

  net.sinceat.aoc2020.day9.AppKt$parseInput$1$1$2();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class kotlin/text/StringsKt
       4: ldc           #13                 // String toLong
       6: ldc           #15                 // String toLong(Ljava/lang/String;)J
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Long invoke(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #24                 // String p0
       3: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #36                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      10: invokestatic  #40                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      13: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #44                 // class java/lang/String
       5: invokevirtual #46                 // Method invoke:(Ljava/lang/String;)Ljava/lang/Long;
       8: areturn

  static {};
    Code:
       0: new           #2                  // class net/sinceat/aoc2020/day9/AppKt$parseInput$1$1$2
       3: dup
       4: invokespecial #51                 // Method "<init>":()V
       7: putstatic     #54                 // Field INSTANCE:Lnet/sinceat/aoc2020/day9/AppKt$parseInput$1$1$2;
      10: return
}

Compiled from "App.kt"
final class net.sinceat.aoc2020.day9.AppKt$parseInput$1$1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, java.lang.Boolean> {
  public static final net.sinceat.aoc2020.day9.AppKt$parseInput$1$1$1 INSTANCE;

  net.sinceat.aoc2020.day9.AppKt$parseInput$1$1$1();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class kotlin/text/StringsKt
       4: ldc           #13                 // String isNotBlank
       6: ldc           #15                 // String isNotBlank(Ljava/lang/CharSequence;)Z
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Boolean invoke(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #24                 // String p0
       3: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #32                 // class java/lang/CharSequence
      10: invokestatic  #36                 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      13: ifne          20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: invokestatic  #42                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      24: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #46                 // class java/lang/String
       5: invokevirtual #48                 // Method invoke:(Ljava/lang/String;)Ljava/lang/Boolean;
       8: areturn

  static {};
    Code:
       0: new           #2                  // class net/sinceat/aoc2020/day9/AppKt$parseInput$1$1$1
       3: dup
       4: invokespecial #53                 // Method "<init>":()V
       7: putstatic     #56                 // Field INSTANCE:Lnet/sinceat/aoc2020/day9/AppKt$parseInput$1$1$1;
      10: return
}