@@ -0,0 +1,1296 @@
+class Solution(object):%0D%0A%0D%0A    def romanToInt(self, s):%0D%0A        %22%22%22%0D%0A        :type s: str%0D%0A        :rtype: int%0D%0A        %22%22%22%0D%0A        # metanum = %7B'I': 1, 'IV': 4, 'V': 5, 'IX': 9,%0D%0A        #            'X': 10, 'XL': 40, 'L': 50, 'XC': 90,%0D%0A        #            'C': 100, 'CD': 400, 'D': 500, 'CM': 900,%0D%0A        #            'M': 1000%7D%0D%0A        metanum = %7B'I': 1, 'V': 5, 'X': 10,%0D%0A                   'L': 50, 'C': 100, 'D': 500, 'M': 1000%7D%0D%0A        strlist = %5B%5D%0D%0A        numlist = %5B%5D%0D%0A        for c in s:%0D%0A            strlist.append(c)%0D%0A            numlist.append(metanum%5Bc%5D)%0D%0A%0D%0A        allsum = sum(numlist)%0D%0A        allminus = 0%0D%0A        for i in range(len(numlist) - 1):%0D%0A            if numlist%5Bi%5D %3C numlist%5Bi + 1%5D:%0D%0A                allminus += numlist%5Bi%5D%0D%0A%0D%0A        return allsum - 2 * allminus%0D%0A%0D%0A%0D%0Aif __name__ == '__main__':%0D%0A    s = Solution()%0D%0A    # print(s.romanToInt('MCDXXXVII'))%0D%0A    # print(s.romanToInt('VII'))%0D%0A    # print(s.romanToInt('XCIX'))%0D%0A    # print(s.romanToInt('MDCCCLXXX'))%0D%0A    # print(s.romanToInt('MMMCCCXXXIII'))%0D%0A%0D%0A    assert s.romanToInt('MCDXXXVII') == 1437%0D%0A    assert s.romanToInt('VII') == 7%0D%0A    assert s.romanToInt('XCIX') == 99%0D%0A    assert s.romanToInt('MDCCCLXXX') == 1880%0D%0A    assert s.romanToInt('MMMCCCXXXIII') == 3333%0D%0A%0D%0A    print(%22test finished%22)%0D%0A

Roman to Integer