A few solutions
May 13th, 2021:\n\nJavascript\n\nlet ambiguousCoordinates = s => {\n    let allZeros = s => !_.trim(s, \'0\').length;\n    let okStart = s => {\n        let t =
**May 13<sup>th</sup>, 2021:**\n\n*Javascript*\n```\nlet ambiguousCoordinates = s => {\n    let allZeros = s => !_.trim(s, \'0\').length;\n    let okStart = s => {\n        let t = _.trimStart(s, \'0\');\n        let M = s.length,\n            N = t.length\n        return M == N || (t[0] == \'.\' && M - 1 == N); // no leading 0s or one leading decimal point 0 (ie: 0.xxx) \n    };\n    let okEnd = s => {\n        let t = _.trimEnd(s, \'0\');\n        let M = s.length,\n            N = t.length;\n        return 0 <= t.indexOf(\'.\') ? M == N : true; // no trailing 0s if decimal exists\n    };\n    let ok = s => s.length == 1 || (!allZeros(s) && okStart(s) && okEnd(s));\n    let decimal = (s, i) => i ? `${s.substring(0, i)}.${s.substring(i, s.length)}` : s;\n    let slices = (s, A = []) => {\n        let N = s.length - 1,  // -1 to ignore \')\'\n            i = 1              // +1 to ignore \'(\'\n        while (i + 1 < N) {\n            // i is the pivot for first, second slices: s[1..i], s[i + 1..N - 1]\n            let [ a, b ] = [ s.substring(1, i + 1), s.substring(i + 1, N) ];\n            // add decimal points for each j-th index of first and each k-th index of second\n            for (let j = 0; j < a.length; ++j) {\n                let first = decimal(a, j);\n                for (let k = 0; k < b.length; ++k) {\n                    let second = decimal(b, k);\n                    if (ok(first) && ok(second))\n                        A.push([ first, second ]);\n                }\n            }\n            ++i;\n        }\n        return A; // array of valid slices of s\n    }\n    return slices(s).map(pair => `(${pair.join(\', \')})`);\n};\n```\n\n---\n\n**August 10<sup>th</sup>, 2018:**\n\nCheck all potential substrings a,b of S.  Get potential coordinates for all potential values of a,b and store valid coordinates in vectors cx,cy.  Combine all values from cx,cy into the answer to be returned.\n\n*C++*\n```\nclass Solution {\npublic:\n    vector<string> ambiguousCoordinates(string S) {\n        vector<string> ans;\n        S=S.substr(1,S.size()-2);\n        int N=(int)S.size();\n        for (int i=1; i<N; ++i){\n            string a=S.substr(0,i),b=S.substr(i,N-i);\n            vector<string> cx=getCoords(a),cy=getCoords(b);\n            for (auto& x: cx)\n                for (auto& y: cy)\n                    ans.push_back("("+x+", "+y+")");\n        }\n        return ans;\n    }\nprivate:\n    vector<string> getCoords(const string& s){\n        vector<string> coords;\n        int N=(int)s.size();\n        if (isValid(s)) coords.push_back(s);\n        for (int i=1; i<N; ++i){\n            string a=s.substr(0,i),b=s.substr(i,N-i),c=(a+"."+b);\n            if (isValid(c)) coords.push_back(c);\n        }\n        return coords;\n    }\n    bool isValid(const string& s){\n        if (s.size() < 2) return true;\n        if (s[0]==\'0\' && s[1]!=\'.\') return false;\n        if (s.find(\'.\')!=string::npos && s.back()==\'0\') return false;\n        return true;\n    }\n};\n```
[]