package aoc20;

import java.util.Scanner;

public class Day5 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int maxSeen = 0;
        while (in.hasNextLine()) {
            String line = in.nextLine();
            if (line.isEmpty()) {
                break;
            }
            int id = getSeatId(line);
            maxSeen = Math.max(id, maxSeen);
        }
        System.out.println(maxSeen);
    }

    private static int getSeatId(String line) {
        String rowSection = line.substring(0, 7);
        String rowSectionAsBin = rowSection.replaceAll("F", "0").replaceAll("B", "1");
        int rowNumber = Integer.parseInt(rowSectionAsBin, 2);
        String columnSection = line.substring(7, 10);
        String columnSectionAsBin = columnSection.replaceAll("R", "1").replaceAll("L", "0");
        int columnNumber = Integer.parseInt(columnSectionAsBin, 2);
        return (rowNumber * 8) + columnNumber;
    }
}

@@ -9,16 +9,96 @@
 aoc20;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Comparator;%0Aimport java.util.List;%0A
 import j
@@ -238,23 +238,50 @@
     
-int maxSeen = 0
+List%3CInteger%3E seenNums = new ArrayList%3C%3E()
 ;%0A  
@@ -479,40 +479,267 @@
     
-maxSeen = Math.max(id, maxSeen);
+seenNums.add(id);%0A        %7D%0A        int min = seenNums.stream().min(Comparator.naturalOrder()).get();%0A        int max = seenNums.stream().max(Comparator.naturalOrder()).get();%0A        for (int i = min; i %3C= max; i++) %7B%0A            if (!seenNums.contains(i)) %7B
 %0A   
@@ -735,34 +735,32 @@
 s(i)) %7B%0A        
-%7D%0A
         System.o
@@ -774,17 +774,35 @@
 tln(
-maxSeen);
+i);%0A            %7D%0A        %7D
 %0A   

day 5 2