@@ -0,0 +1,2399 @@
+import java.util.HashMap;%0Aimport java.util.Optional;%0Aimport java.util.stream.IntStream;%0A%0Apublic class AoC_2018_02 extends Solution %7B%0A    static int DAY = 2;%0A    static String TITLE = %22Advent of Code 2018 Day 2: Inventory Management System%22;%0A%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(TITLE);%0A        String%5B%5D boxIDs = loadPuzzleInputLines(DAY).toArray(String%5B%5D::new);%0A%0A        int partOneResult = solvePartOne(boxIDs);%0A        assert partOneResult == 9633 : partOneResult;%0A        String partTwoResult = solvePartTwo(boxIDs).orElseThrow();%0A        assert partTwoResult.equals(%22lujnogabetpmsydyfcovzixaw%22) : partTwoResult;%0A%0A        System.out.printf(%22Part one: %25d%5Cn%22, partOneResult);%0A        System.out.printf(%22Part two: %25s%5Cn%22, partTwoResult);%0A    %7D%0A%0A    static int solvePartOne(String%5B%5D boxIDs) %7B%0A        int countTwo = 0;%0A        int countThree = 0;%0A        for (String id : boxIDs) %7B%0A            HashMap%3CString, Integer%3E counter = countLetters(id);%0A            if (counter.values().contains(2)) %7B%0A                countTwo += 1;%0A            %7D%0A            if (counter.values().contains(3)) %7B%0A                countThree += 1;%0A            %7D%0A        %7D%0A        return countTwo * countThree;%0A    %7D%0A%0A    static Optional%3CString%3E solvePartTwo(String%5B%5D boxIDs) %7B%0A        int idLength = boxIDs%5B0%5D.length();%0A        for (String first : boxIDs) %7B%0A            for (String second : boxIDs) %7B%0A                int%5B%5D mismatched = IntStream.range(0, idLength)%0A                        .filter(idx -%3E first.charAt(idx) != second.charAt(idx))%0A                        .toArray();%0A                if (mismatched.length == 1) %7B%0A                    int avoidIdx = mismatched%5B0%5D;%0A                    StringBuilder common = new StringBuilder();%0A                    for (int idx = 0; idx %3C idLength; idx++) %7B%0A                        if (idx != avoidIdx) %7B%0A                            common.append(first.charAt(idx));%0A                        %7D%0A                    %7D%0A                    return Optional.of(common.toString());%0A                %7D%0A            %7D%0A        %7D%0A        return null;%0A    %7D%0A%0A    static HashMap%3CString, Integer%3E countLetters(String candidate) %7B%0A        HashMap%3CString, Integer%3E counter = new HashMap%3C%3E();%0A        for (String character : candidate.split(%22%22)) %7B%0A            counter.put(character, counter.getOrDefault(character, 0) + 1);%0A        %7D%0A        return counter;%0A    %7D%0A%7D%0A

Complete both parts