package aoc19;

public class Numbers {
    public static void main(String[] args) {
        int lowerBound = 125730;
        int uppperBound = 579381;
        int count = 0;
        for (int i = lowerBound; i <= uppperBound; i++) {
            if (passesTest(i)) {
                count++;
            }

        }
        System.out.println(count);
    }

    private static boolean passesTest(int number) {
        boolean twoAdjSame = false;
        char[] chars = (number + "").toCharArray();
        for (int i = 0; i < (chars.length - 1); i++) {
            if (chars[i] == chars[i + 1]) {
                twoAdjSame = true;
            }
            if (chars[i] > chars[i + 1]) {
                return false;
            }
        }
        if (twoAdjSame) {
            System.out.println(number + " valid");
        }
        return twoAdjSame;
    }
}

@@ -346,24 +346,579 @@
 nt);%0A    %7D%0A%0A
+    private static String runLengthEncoding(String s) %7B%0A        StringBuilder result = new StringBuilder();%0A        char prev = s.charAt(0);%0A        int length = 1;%0A        for (int i = 1; i %3C s.length(); i++) %7B%0A           if (s.charAt(i) == prev) %7B%0A               length++;%0A           %7D else %7B%0A               result.append(length);%0A               result.append(prev);%0A               prev = s.charAt(i);%0A               length = 1;%0A           %7D%0A        %7D%0A        result.append(length);%0A        result.append(prev);%0A        return result.toString();%0A    %7D%0A%0A
     private 
@@ -1005,24 +1005,24 @@
     
-char%5B%5D chars
+String strRep
  = 
-(
 numb
@@ -1028,17 +1028,47 @@
 ber + %22%22
-)
+;%0A        char%5B%5D chars = strRep
 .toCharA
@@ -1155,18 +1155,17 @@
 hars%5Bi%5D 
-==
+%3E
  chars%5Bi
@@ -1193,112 +1193,377 @@
     
-twoAdjSame = true;%0A            %7D%0A            if (chars%5Bi%5D %3E chars%5Bi + 1%5D) %7B%0A                return false
+return false;%0A            %7D%0A        %7D%0A        String runLengthEncoding = runLengthEncoding(strRep);%0A        System.out.println(String.format(%22RLE of %25s is %25s%22, strRep, runLengthEncoding));%0A        for (int ii = 0; ii %3C runLengthEncoding.length(); ii += 2) %7B%0A            if (runLengthEncoding.charAt(ii) == '2') %7B%0A                twoAdjSame = true;%0A                break
 ;%0A  

day 4 2