@@ -0,0 +1,1812 @@
+package aoc20;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.HashMap;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Queue;%0Aimport java.util.Scanner;%0Aimport java.util.stream.Collectors;%0A%0Apublic class Day15 %7B%0A    public static void main(String%5B%5D args) %7B%0A        Scanner in = new Scanner(System.in);%0A        Scanner lineScanner = new Scanner(in.nextLine());%0A        lineScanner.useDelimiter(%22,%22);%0A        List%3CInteger%3E ints = new ArrayList%3C%3E();%0A        while (lineScanner.hasNextInt()) %7B%0A            ints.add(lineScanner.nextInt());%0A        %7D%0A        Map%3CLong, Long%3E numbersSaid = new HashMap%3C%3E();%0A        long turn = 1;%0A        long last = -1;%0A        boolean wasSeen = false;%0A        long lastTurnSeen = -1;%0A        while (turn %3C= 2020) %7B%0A            long num;%0A            if (!ints.isEmpty()) %7B%0A                num = ints.get(0);%0A                ints = ints.subList(1, ints.size());%0A            %7D else %7B%0A                if (wasSeen) %7B%0A                    num = turn - 1 - lastTurnSeen;%0A                %7D else %7B%0A                    num = 0;%0A                %7D%0A                wasSeen = numbersSaid.containsKey(num);%0A                if (wasSeen) %7B%0A                    lastTurnSeen = numbersSaid.get(num);%0A                %7D%0A            %7D%0A            last = num;%0A            numbersSaid.put(num, turn);%0A            turn++;%0A        %7D%0A        System.out.println(last);%0A    %7D%0A%0A    static class LimitedQueue%3CE%3E extends LinkedList%3CE%3E %7B%0A        private int limit;%0A%0A        public LimitedQueue(int limit) %7B%0A            this.limit = limit;%0A        %7D%0A%0A        @Override%0A        public boolean add(E o) %7B%0A            super.add(o);%0A            while (size() %3E limit) %7B%0A                super.remove();%0A            %7D%0A            return true;%0A        %7D%0A    %7D%0A%7D%0A

day15 1