def parse(lines):
        clazz = Clazz()

        intervals = []
        interval: Interval()

        for index in range(0, len(lines)):
            line = lines[index]
            if (line == '   */\n'):
                interval = Interval()
                interval.start = index + 1
                continue
            if (line.endswith(');\n')):
                interval.end = index + 1
                intervals.append(interval)

        del line

        for interval in intervals:
            content = lines[interval.start:interval.end]

            function = Function.parse(content)

            if clazz.functions is None:
                clazz.functions = []

            clazz.functions.append(function)
            del content

        return clazz
Пример #2
0
from interval import Interval
class Solution:
    def solve(self, n, k, str1, str2):
        # write code here
        # return Interval(3,3)
        count = 0
        for i in range(n):
            if str1[i] == str2[i]:
                count += 1
        if count <= k:
            start = count - (n-k)
            end = count + (n-k)
        else:
            start = count
            end = k + (n-count)

        return Interval(start, end)
a = Interval()
a.start = 0
a.end = 5
return a