Why the downvotes? Clean code - Python/Java
Intuition\n\nThis question definitely doesn\'t deserve so many downvotes. The edge cases may seem bad initially, but in code it\'s only a couple if elif conditi
> # Intuition\n\nThis question definitely doesn\'t deserve so many downvotes. The edge cases may seem bad initially, but in code it\'s only a couple `if elif` conditionals to make this pass.\n\nMy initial thoughts with this question were [Leetcode 22](https://leetcode.com/problems/generate-parentheses/description/). But we don\'t actually need recursion at all to solve this problem, and the key to it is realising we can `exhaust the comma separations` by just using loops. See comments in-line:\n\n---\n> # Solutions\n\n```python []\nclass Solution:\n    def ambiguousCoordinates(self, s: str) -> List[str]:\n        #trim parantheses and create res array\n        string,res = s[1:-1],[]\n\n        #exhaust all possible left and right partitions of s\n        for i in range(1,len(string)):\n            #exhaust all possible spaces we can place the decimal for each partition\n            leftPartition = self._makeDecimals(string[:i])\n            rightPartition = self._makeDecimals(string[i:])\n\n            if leftPartition and rightPartition:\n                #go through every combination we found\n                for lPartition in leftPartition:\n                    for rPartition in rightPartition:\n                        #and add the result\n                        res.append(f"({lPartition}, {rPartition})")\n        return res\n\n    def _makeDecimals(self,currentPartition):\n        #holds the original number\n        partitions = [currentPartition]\n\n        #if it\'s a length of 1 it\'s value is irrelevant, whether it\'s just\n        #a 0, or another integer, we always want it\n        if len(currentPartition) == 1:\n            return partitions\n        \n        #if it begins with a 0\n        elif currentPartition[0] == "0":\n            #and ends with a 0\n            if currentPartition[-1] == "0":\n                #we can\'t have 0.4430, 0.10 etc, so return []\n                return []\n            #otherwise we know it\'ll be 0. something, so return the rest of curr partition\n            return [f"0.{currentPartition[1:]}"]\n        #say we have a case where (10,0) and (1.0,0)\n        elif currentPartition[-1] == "0":\n            #we\'d want to keep the 10, and discard the 1.0 since 1.0 is invalid\n            #so we can perform a final check to see if we end in 0, after passing the previous conditionals\n            #if we do, we know it\'ll be something akin to 2.3330 3.0 4.560 etc.\n            return partitions\n        \n        #if we\'ve made it this far we\'re valid\n        for i in range(1,len(currentPartition)):\n            #so compute all decimal combinations\n            partitions.append(currentPartition[:i]+"."+currentPartition[i:])\n        return partitions\n```\n```Java []\nclass Solution{\n    public Solution(){};\n\n    public List<String> ambiguousCoordinates(String s){\n        String string = s.substring(1, s.length()-1);\n        List<String> res = new ArrayList<>();\n\n        for (int i = 1; i < string.length();i++){\n            List<String> leftPartition = makeDecimals(string.substring(0, i));\n            List<String> rightPartition = makeDecimals(string.substring(i, string.length()));\n            \n            if (!leftPartition.isEmpty() && !rightPartition.isEmpty()){\n                for (String lPartition: leftPartition){\n                    for (String rPartition : rightPartition){\n                        res.add("(" + lPartition + ", " + rPartition + ")");\n                    }\n                }\n            }\n        }\n        return res;\n    }\n\n    private List<String> makeDecimals(String currentPartition){\n        List<String> partitions = new ArrayList<>();\n        partitions.add(currentPartition);\n        \n        if (currentPartition.length()==1){\n            return partitions;\n        }else if (currentPartition.charAt(0) == \'0\'){\n            if (currentPartition.charAt(currentPartition.length()-1)==\'0\'){\n                return new ArrayList<>();\n            }\n            List<String> curr = new ArrayList<>();\n            curr.add("0."+currentPartition.substring(1, currentPartition.length()));\n            return curr;\n        }else if (currentPartition.charAt(currentPartition.length()-1)==\'0\'){\n            return partitions;\n        }\n        for (int i = 1; i < currentPartition.length();i++){\n            partitions.add(currentPartition.substring(0,i)+"."+currentPartition.substring(i, currentPartition.length()));\n        }\n        return partitions;\n    }\n}\n```
['String', 'Python', 'Java', 'Python3']