@@ -0,0 +1,1036 @@
+#!/usr/bin/env python%0A# encoding: utf-8%0A%0A%22%22%22%0Aroman-to-integer.py%0A %0ACreated by Shuailong on 2016-03-17.%0A%0Ahttps://leetcode.com/problems/roman-to-integer/.%0A%0A%22%22%22%0A%0Aclass Solution(object):%0A    def __init__(self):%0A        self.d = %7B'I':1, 'V':5, 'X':10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000%7D%0A%0A    def romanToInt(self, s):%0A        %22%22%22%0A        :type s: str%0A        :rtype: int%0A        %22%22%22%0A        res = 0%0A        for i in range(len(s)):%0A            res += self.d%5Bs%5Bi%5D%5D%0A            if s%5Bi%5D == 'I' and i+1 %3C len(s) and (s%5Bi+1%5D == 'V' or s%5Bi+1%5D == 'X'):%0A                res -= 2%0A            elif s%5Bi%5D == 'X' and i+1 %3C len(s) and (s%5Bi+1%5D == 'L' or s%5Bi+1%5D == 'C'):%0A                res -= 20%0A            elif s%5Bi%5D == 'C' and i+1 %3C len(s) and (s%5Bi+1%5D == 'D' or s%5Bi+1%5D == 'M'):%0A                res -= 200%0A%0A        return res%0A%0A        %0A%0Adef main():%0A    solution = Solution()%0A    Ss = %5B'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X'%5D%0A    for s in Ss:%0A        print solution.romanToInt(s)%0A    %0Aif __name__ == '__main__':%0A    main()%0A%0A        

solve 1 problem