private static int solve(String s) {
        if (s == null || s.length() == 0) {
            return 0;
        }
        String[] a = s.split("\n");
        Map<String, String> rules = new HashMap<>();
        for (int i = 0; i < a.length; i++) {
            rules.put(a[i].split(" => ")[0].trim(), a[i].split("=>")[1].trim());
        }
        // default state of matrix given by problem statement
        List<List<Character>> image = new ArrayList<>();
        image.add(Arrays.asList('.', '#', '.'));
        image.add(Arrays.asList('.', '.', '#'));
        image.add(Arrays.asList('#', '#', '#'));
        for (int i = 0; i < 18; i++) {
            System.out.println(i);
            List<List<Character>> newImage = new ArrayList<>();
            if (image.size() % 2 == 0) {

                for (int j = 0; j < image.size() - 1; j += 2) {//rows

                    newImage.add(new ArrayList<>());
                    newImage.add(new ArrayList<>());
                    newImage.add(new ArrayList<>());

                    List<Character> current = image.get(j);

                    for (int k = 0; k < current.size() - 1; k += 2) {
                        String square = current.get(k) + "" + current.get(k + 1) + "/" + image.get(j + 1).get(k) + "" + image.get(j + 1).get(k + 1);

                        List<List<Character>> match = findMatch(square, rules);

                        for (int l = 0; l < match.size(); l++) {
                            int index = j == 0 ? 0 : j / 2 * 3;
                            newImage.get(index + l).addAll(match.get(l));
                        }
                    }
                }
            } else if (image.size() % 3 == 0) {
                for (int j = 0; j < image.size() - 2; j += 3) {
                    List<Character> current = image.get(j);

                    newImage.add(new ArrayList<>());
                    newImage.add(new ArrayList<>());
                    newImage.add(new ArrayList<>());
                    newImage.add(new ArrayList<>());

                    for (int k = 0; k < current.size() - 2; k += 3) {

                        String square = current.get(k) + "" + current.get(k + 1) + current.get(k + 2) + "/"
                                        + image.get(j + 1).get(k) + "" + image.get(j + 1).get(k + 1) + image.get(j + 1).get(k + 2) + "/"
                                        + image.get(j + 2).get(k) + "" + image.get(j + 2).get(k + 1) + image.get(j + 2).get(k + 2);

                        List<List<Character>> match = findMatch(square, rules);

                        for (int l = 0; l < match.size(); l++) {
                            int index = j == 0 ? 0 : j / 3 * 4;
                            newImage.get(index + l).addAll(match.get(l));
                        }

                    }
                }
            }
            image = newImage;
        }
        int counter = 0;
        for (int i = 0; i < image.size(); i++) {
            for (int j = 0; j < image.get(i).size(); j++) {
                if (image.get(i).get(j) == '#')
                    counter++;
            }
        }
        return counter;
    }
Why Did you create this class? what does it do?
src/adventofcode/FractalArt_21.java