package leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * https://leetcode.com/problems/ambiguous-coordinates/
 */
public class Problem816 {
    public List<String> ambiguousCoordinates(String S) {
        // TODO
        List<String> result = new ArrayList<>();
        for (int i = 2; i < S.length() - 1; i++) {
            String first = S.substring(1, i);
            String second = S.substring(i, S.length() - 1);

            System.out.println(first + " -> " + second);
        }
        return result;
    }

    private static List<String> makeDecimals(String s) {
        return null;
    }

    public static void main(String[] args) {
        Problem816 prob = new Problem816();
//        System.out.println(prob.ambiguousCoordinates("(123)")); // "(1, 23)", "(12, 3)", "(1.2, 3)", "(1, 2.3)"
        System.out.println(prob.ambiguousCoordinates("(00011)")); // "(0.001, 1)", "(0, 0.011)"
//        System.out.println(prob.ambiguousCoordinates("(0123)")); // "(0, 123)", "(0, 12.3)", "(0, 1.23)", "(0.1, 23)", "(0.1, 2.3)", "(0.12, 3)"
//        System.out.println(prob.ambiguousCoordinates("(100)")); // "(10, 0)"
    }
}

@@ -215,24 +215,8 @@
 ) %7B%0A
-        // TODO%0A
     
@@ -421,182 +421,721 @@
 1);%0A
-%0A            System.out.println(first + %22 -%3E %22 + second);%0A        %7D%0A        return result;%0A    %7D%0A%0A    private static List%3CString%3E makeDecimals(String s) %7B%0A        return null
+            List%3CString%3E firstNumbers = makeNumbers(first);%0A            List%3CString%3E secondNumbers = makeNumbers(second);%0A            if (!firstNumbers.isEmpty() && !secondNumbers.isEmpty()) %7B%0A                for (String fn : firstNumbers) %7B%0A                    for (String sn : secondNumbers) %7B%0A                        result.add(%22(%22 + fn + %22, %22 + sn + %22)%22);%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A%0A    private static boolean isFirstValid(String s) %7B%0A        if (s.length() == 1) %7B%0A            return true;%0A        %7D%0A        return s.charAt(0) != '0';%0A    %7D%0A%0A    private static boolean isSecondValid(String s) %7B%0A        return s.charAt(s.length() - 1) != '0'
 ;%0A  
@@ -1148,21 +1148,22 @@
    p
-ublic
+rivate
  static 
 void
@@ -1162,30 +1162,40 @@
 tic 
-void main
+List%3CString%3E makeNumbers
 (String
-%5B%5D arg
+ 
 s) %7B
@@ -1207,54 +1207,57 @@
     
-Problem816 prob = new Problem816
+List%3CString%3E result = new ArrayList%3C%3E
 ();%0A
-//
         
 Syst
@@ -1256,433 +1256,365 @@
     
-System.out.println(prob.ambiguousCoordinates(%22(123)%22)); // %22(1, 23)%22, %22(12, 3)%22, %22(1.2, 3)%22, %22(1, 2.3)%22%0A        System.out.println(prob.ambiguousCoordinates(%22(00011)%22)); // %22(0.001, 1)%22, %22(0, 0.011)%22%0A//        System.out.println(prob.ambiguousCoordinates(%22(0123)%22)); // %22(0, 123)%22, %22(0, 12.3)%22, %22(0, 1.23)%22, %22(0.1, 23)%22, %22(0.1, 2.3)%22, %22(0.12, 3)%22%0A//        System.out.println(prob.ambiguousCoordinates(%22(100)%22)); // %22(10, 0)%22
+if (isFirstValid(s)) %7B%0A            result.add(s);%0A        %7D%0A        for (int i = 1; i %3C s.length(); i++) %7B%0A            String first = s.substring(0, i);%0A            String second = s.substring(i);%0A            if (isFirstValid(first) && isSecondValid(second)) %7B%0A                result.add(first + %22.%22 + second);%0A            %7D%0A        %7D%0A        return result;
 %0A   

Solve problem 816