C# annoying validation 😒
Intuition\n Describe your first thoughts on how to solve this problem. \nBrute force with validation of generated numbers.\n\n# Approach\n Describe your approac
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBrute force with validation of generated numbers.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Split input into 2 parts (left & right) process each in seperation.\n- Combine results in nested loop.\n- Call function to validate if generated number looks reasonable.\n\n# Complexity\n- Time complexity:\nSeems like a $$O(n^3)$$ in the worst case.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nSeems like a $$O(n^2)$$ in the worst case.\n\n# Code\n```\npublic class Solution {\n\n    bool reasonable(string s)\n    {\n// use a hack to simplofy\n         if (s.IndexOf(\'.\') < 0)\n         {\n             return $"{int.Parse(s)}" == s;\n         }\n                \n// only cases with floating point left here - can\'t end with a 0\n        if (s.Last() == \'0\')                        \n            return false;        \n\n// floating point that starts with a 0, means must have a . as 2nd\n        if (s[0] == \'0\')\n        {\n            if (s.Length < 3)\n                return false;\n\n            if (s[1] != \'.\')\n            {\n                return false;\n            }\n        }\n    \n        return true;\n    }\n// generate possible cases out of supplied digits\n    IList<string> generate(string s)\n    {\n        var a = new List<string>();\n        a.Add(s);\n        for (int i = 1; i < s.Length; i++)\n        {\n            a.Add($"{s.Substring(0,i)}.{s.Substring(i, s.Length-i)}");\n        }\n        return a;\n    }\n\n    public IList<string> AmbiguousCoordinates(string s) {\n\n        var st = s.Substring(1, s.Length-2);\n        var answer = new List<string>();\n   // slide possible position of ,     \n        for (int i = 1; i < st.Length; i++)\n        {\n            var ls = st.Substring(0, i);\n            var rs = st.Substring(i, st.Length-i);\n\n            foreach(var lc in generate(ls))\n            {\n                if (!reasonable(lc))\n                    continue;\n\n                foreach(var rc in generate(rs))\n                {\n                    if (reasonable(rc))\n                        answer.Add($"({lc}, {rc})");\n                }\n            }\n        }    \n        return answer;\n    }\n}\n```
['C#']