fun main() {
    val inputLineRegex = """\d""".toRegex()

    fun lineToSets(line: String): Pair<Set<Int>, Set<Int>> {
        val (start1, end1, start2, end2) = inputLineRegex.findAll(line).map { it.value.toInt() }.toList()

        return Pair((start1..end1).toSet(), (start2..end2).toSet())
    }

    fun part1(input: List<String>): Int = input
        .map(::lineToSets)
        .count { (a, b) -> a.containsAll(b) || b.containsAll(a) }

    fun part2(input: List<String>): Int = input
        .map(::lineToSets)
        .count { (a, b) -> a.intersect(b).isNotEmpty() }

    test(
        day = 4,
        testTarget1 = 2,
        testTarget2 = 4,
        part1 = ::part1,
        part2 = ::part2,
    )
}

Compiled from "Day04.kt"
public final class Day04Kt {
  public static final void main();
    Code:
       0: new           #8                  // class kotlin/text/Regex
       3: dup
       4: ldc           #10                 // String \\d
       6: invokespecial #14                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
       9: astore_0
      10: iconst_4
      11: iconst_2
      12: invokestatic  #20                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: iconst_4
      16: invokestatic  #20                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      19: new           #22                 // class Day04Kt$main$1
      22: dup
      23: aload_0
      24: invokespecial #25                 // Method Day04Kt$main$1."<init>":(Lkotlin/text/Regex;)V
      27: checkcast     #27                 // class kotlin/jvm/functions/Function1
      30: new           #29                 // class Day04Kt$main$2
      33: dup
      34: aload_0
      35: invokespecial #30                 // Method Day04Kt$main$2."<init>":(Lkotlin/text/Regex;)V
      38: checkcast     #27                 // class kotlin/jvm/functions/Function1
      41: invokestatic  #36                 // Method UtilsKt.test:(ILjava/lang/Object;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V
      44: return

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

  private static final int main$lineToSets$lambda$0(kotlin.text.MatchResult);
    Code:
       0: aload_0
       1: ldc           #47                 // String it
       3: invokestatic  #53                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #59,  1           // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
      12: invokestatic  #63                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      15: ireturn

  private static final kotlin.Pair<java.util.Set<java.lang.Integer>, java.util.Set<java.lang.Integer>> main$lineToSets(kotlin.text.Regex, java.lang.String);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #69                 // class java/lang/CharSequence
       5: iconst_0
       6: iconst_2
       7: aconst_null
       8: invokestatic  #73                 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;
      11: invokedynamic #91,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      16: invokestatic  #97                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      19: invokestatic  #101                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      22: astore_2
      23: aload_2
      24: iconst_0
      25: invokeinterface #107,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      30: checkcast     #109                // class java/lang/Number
      33: invokevirtual #113                // Method java/lang/Number.intValue:()I
      36: istore_3
      37: aload_2
      38: iconst_1
      39: invokeinterface #107,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      44: checkcast     #109                // class java/lang/Number
      47: invokevirtual #113                // Method java/lang/Number.intValue:()I
      50: istore        4
      52: aload_2
      53: iconst_2
      54: invokeinterface #107,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      59: checkcast     #109                // class java/lang/Number
      62: invokevirtual #113                // Method java/lang/Number.intValue:()I
      65: istore        5
      67: aload_2
      68: iconst_3
      69: invokeinterface #107,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      74: checkcast     #109                // class java/lang/Number
      77: invokevirtual #113                // Method java/lang/Number.intValue:()I
      80: istore        6
      82: new           #115                // class kotlin/Pair
      85: dup
      86: new           #117                // class kotlin/ranges/IntRange
      89: dup
      90: iload_3
      91: iload         4
      93: invokespecial #120                // Method kotlin/ranges/IntRange."<init>":(II)V
      96: checkcast     #122                // class java/lang/Iterable
      99: invokestatic  #128                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     102: new           #117                // class kotlin/ranges/IntRange
     105: dup
     106: iload         5
     108: iload         6
     110: invokespecial #120                // Method kotlin/ranges/IntRange."<init>":(II)V
     113: checkcast     #122                // class java/lang/Iterable
     116: invokestatic  #128                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     119: invokespecial #131                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     122: areturn

  private static final int main$part1(kotlin.text.Regex, java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: checkcast     #122                // class java/lang/Iterable
       4: astore_2
       5: nop
       6: iconst_0
       7: istore_3
       8: aload_2
       9: astore        4
      11: new           #143                // class java/util/ArrayList
      14: dup
      15: aload_2
      16: bipush        10
      18: invokestatic  #147                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #150                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #152                // class java/util/Collection
      27: astore        5
      29: iconst_0
      30: istore        6
      32: aload         4
      34: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      39: astore        7
      41: aload         7
      43: invokeinterface #162,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      48: ifeq          92
      51: aload         7
      53: invokeinterface #166,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      58: astore        8
      60: aload         5
      62: aload         8
      64: checkcast     #168                // class java/lang/String
      67: astore        9
      69: astore        11
      71: iconst_0
      72: istore        10
      74: aload_0
      75: aload         9
      77: invokestatic  #170                // Method main$lineToSets:(Lkotlin/text/Regex;Ljava/lang/String;)Lkotlin/Pair;
      80: aload         11
      82: swap
      83: invokeinterface #174,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          41
      92: aload         5
      94: checkcast     #103                // class java/util/List
      97: nop
      98: checkcast     #122                // class java/lang/Iterable
     101: astore_2
     102: nop
     103: iconst_0
     104: istore_3
     105: aload_2
     106: instanceof    #152                // class java/util/Collection
     109: ifeq          128
     112: aload_2
     113: checkcast     #152                // class java/util/Collection
     116: invokeinterface #177,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     121: ifeq          128
     124: iconst_0
     125: goto          242
     128: iconst_0
     129: istore        4
     131: aload_2
     132: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     137: astore        5
     139: aload         5
     141: invokeinterface #162,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     146: ifeq          240
     149: aload         5
     151: invokeinterface #166,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     156: astore        6
     158: aload         6
     160: checkcast     #115                // class kotlin/Pair
     163: astore        7
     165: iconst_0
     166: istore        8
     168: aload         7
     170: invokevirtual #180                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     173: checkcast     #182                // class java/util/Set
     176: astore        9
     178: aload         7
     180: invokevirtual #185                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     183: checkcast     #182                // class java/util/Set
     186: astore        10
     188: aload         9
     190: aload         10
     192: checkcast     #152                // class java/util/Collection
     195: invokeinterface #189,  2          // InterfaceMethod java/util/Set.containsAll:(Ljava/util/Collection;)Z
     200: ifne          218
     203: aload         10
     205: aload         9
     207: checkcast     #152                // class java/util/Collection
     210: invokeinterface #189,  2          // InterfaceMethod java/util/Set.containsAll:(Ljava/util/Collection;)Z
     215: ifeq          222
     218: iconst_1
     219: goto          223
     222: iconst_0
     223: ifeq          139
     226: iinc          4, 1
     229: iload         4
     231: ifge          139
     234: invokestatic  #192                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     237: goto          139
     240: iload         4
     242: ireturn

  private static final int main$part2(kotlin.text.Regex, java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: checkcast     #122                // class java/lang/Iterable
       4: astore_2
       5: nop
       6: iconst_0
       7: istore_3
       8: aload_2
       9: astore        4
      11: new           #143                // class java/util/ArrayList
      14: dup
      15: aload_2
      16: bipush        10
      18: invokestatic  #147                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #150                // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #152                // class java/util/Collection
      27: astore        5
      29: iconst_0
      30: istore        6
      32: aload         4
      34: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      39: astore        7
      41: aload         7
      43: invokeinterface #162,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      48: ifeq          92
      51: aload         7
      53: invokeinterface #166,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      58: astore        8
      60: aload         5
      62: aload         8
      64: checkcast     #168                // class java/lang/String
      67: astore        9
      69: astore        11
      71: iconst_0
      72: istore        10
      74: aload_0
      75: aload         9
      77: invokestatic  #170                // Method main$lineToSets:(Lkotlin/text/Regex;Ljava/lang/String;)Lkotlin/Pair;
      80: aload         11
      82: swap
      83: invokeinterface #174,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      88: pop
      89: goto          41
      92: aload         5
      94: checkcast     #103                // class java/util/List
      97: nop
      98: checkcast     #122                // class java/lang/Iterable
     101: astore_2
     102: nop
     103: iconst_0
     104: istore_3
     105: aload_2
     106: instanceof    #152                // class java/util/Collection
     109: ifeq          128
     112: aload_2
     113: checkcast     #152                // class java/util/Collection
     116: invokeinterface #177,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     121: ifeq          128
     124: iconst_0
     125: goto          237
     128: iconst_0
     129: istore        4
     131: aload_2
     132: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     137: astore        5
     139: aload         5
     141: invokeinterface #162,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     146: ifeq          235
     149: aload         5
     151: invokeinterface #166,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     156: astore        6
     158: aload         6
     160: checkcast     #115                // class kotlin/Pair
     163: astore        7
     165: iconst_0
     166: istore        8
     168: aload         7
     170: invokevirtual #180                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     173: checkcast     #182                // class java/util/Set
     176: astore        9
     178: aload         7
     180: invokevirtual #185                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     183: checkcast     #182                // class java/util/Set
     186: astore        10
     188: aload         9
     190: checkcast     #122                // class java/lang/Iterable
     193: aload         10
     195: checkcast     #122                // class java/lang/Iterable
     198: invokestatic  #218                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     201: checkcast     #152                // class java/util/Collection
     204: invokeinterface #177,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     209: ifne          216
     212: iconst_1
     213: goto          217
     216: iconst_0
     217: nop
     218: ifeq          139
     221: iinc          4, 1
     224: iload         4
     226: ifge          139
     229: invokestatic  #192                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     232: goto          139
     235: iload         4
     237: ireturn

  public static final int access$main$part1(kotlin.text.Regex, java.util.List);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #223                // Method main$part1:(Lkotlin/text/Regex;Ljava/util/List;)I
       5: ireturn

  public static final int access$main$part2(kotlin.text.Regex, java.util.List);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #226                // Method main$part2:(Lkotlin/text/Regex;Ljava/util/List;)I
       5: ireturn
}

Compiled from "Day04.kt"
final class Day04Kt$main$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.util.List<? extends java.lang.String>, java.lang.Integer> {
  final kotlin.text.Regex $inputLineRegex;

  Day04Kt$main$2(kotlin.text.Regex);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #13                 // Field $inputLineRegex:Lkotlin/text/Regex;
       5: aload_0
       6: iconst_1
       7: ldc           #15                 // class kotlin/jvm/internal/Intrinsics$Kotlin
       9: ldc           #17                 // String part2
      11: ldc           #19                 // String main$part2(Lkotlin/text/Regex;Ljava/util/List;)I
      13: iconst_0
      14: invokespecial #22                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      17: return

  public final java.lang.Integer invoke(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #29                 // String p0
       3: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #13                 // Field $inputLineRegex:Lkotlin/text/Regex;
      10: aload_1
      11: invokestatic  #41                 // Method Day04Kt.access$main$part2:(Lkotlin/text/Regex;Ljava/util/List;)I
      14: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      17: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #51                 // class java/util/List
       5: invokevirtual #53                 // Method invoke:(Ljava/util/List;)Ljava/lang/Integer;
       8: areturn
}

Compiled from "Day04.kt"
final class Day04Kt$main$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.util.List<? extends java.lang.String>, java.lang.Integer> {
  final kotlin.text.Regex $inputLineRegex;

  Day04Kt$main$1(kotlin.text.Regex);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #13                 // Field $inputLineRegex:Lkotlin/text/Regex;
       5: aload_0
       6: iconst_1
       7: ldc           #15                 // class kotlin/jvm/internal/Intrinsics$Kotlin
       9: ldc           #17                 // String part1
      11: ldc           #19                 // String main$part1(Lkotlin/text/Regex;Ljava/util/List;)I
      13: iconst_0
      14: invokespecial #22                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      17: return

  public final java.lang.Integer invoke(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #29                 // String p0
       3: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #13                 // Field $inputLineRegex:Lkotlin/text/Regex;
      10: aload_1
      11: invokestatic  #41                 // Method Day04Kt.access$main$part1:(Lkotlin/text/Regex;Ljava/util/List;)I
      14: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      17: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #51                 // class java/util/List
       5: invokevirtual #53                 // Method invoke:(Ljava/util/List;)Ljava/lang/Integer;
       8: areturn
}