def intToRoman(self, num):
        """
        dealing with digits
        notice the 1, 4, 5, 9, 10 repetition

        :param num: integer, Input is guaranteed to be within the range from 1 to 3999
        :return: a string
        """
        string_builder = []
        components = [1, 4, 5, 9, 10, 10, 40, 50, 90, 100, 400, 500, 900, 1000]

        # starting from the largest
        for component in reversed(components):  # reversed
            while num >= component:
                string_builder.append(int2roman[component])
                num -= component

        return "".join(string_builder)
dataset/ETHPy150Open algorhythms/LeetCode/012 Integer to Roman.py/Solution.intToRoman/original