package leetcode;

/**
 * https://leetcode.com/problems/rotated-digits/
 */
public class Problem788 {
    public int rotatedDigits(int N) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem788 prob = new Problem788();
        System.out.println(prob.rotatedDigits(10)); // 4
        System.out.println(prob.rotatedDigits(11)); // 4
        System.out.println(prob.rotatedDigits(12)); // 5
    }
}

@@ -145,300 +145,906 @@
     
-// TODO%0A        return 0;%0A
+int result = 0;%0A        for (int i = 1; i %3C= N; i++) %7B%0A            boolean found = true;%0A   
     
-%7D%0A%0A
+ 
     
-public static void main(String%5B%5D args) %7B%0A        Problem788 prob = new Problem788();%0A        System.out.println(prob.rotatedDigits(10)); // 4%0A        System.out.println(prob.rotatedDigits(11)); // 4%0A        System.out.println(prob.rotatedDigits(12)); // 5
+boolean rotatedToEachOther = false;%0A            for (char c : (%22%22 + i).toCharArray()) %7B%0A                if (canRotate(c)) %7B%0A                    if (isRotatedToEachOther(c)) %7B%0A                        rotatedToEachOther = true;%0A                    %7D%0A                    found = true;%0A                %7D else %7B%0A                    found = false;%0A                    break;%0A                %7D%0A            %7D%0A            if (found && rotatedToEachOther) %7B%0A                result++;%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A%0A    private static boolean canRotate(char c) %7B%0A        return c == '0' %7C%7C c == '1' %7C%7C c == '2' %7C%7C c == '5' %7C%7C c == '6' %7C%7C c == '8' %7C%7C c == '9';%0A    %7D%0A%0A    private static boolean isRotatedToEachOther(char c) %7B%0A        return c == '2' %7C%7C c == '5' %7C%7C c == '6' %7C%7C c == '9';
 %0A   

Solve problem 788