codeforces/667C_ling.py
def calculate(self):
        """ Main calcualtion function of the class """

        chars = list(self.s)
        slen = len(chars)
        result = set([])
        vis = set([])
        q = deque([(0, "")])
        while q:
            pos, prev = q.popleft()
            if pos in vis:
                continue
            pos2 = pos + 2
            if slen - pos2 > 4:
                new = str(chars[slen-1-pos-1]) + str(chars[slen-1-pos])
                if new != prev:
                    result.add(new)
                    q.append((pos2, new))
            pos3 = pos + 3
            if slen - pos3 > 4:
                new = (str(chars[slen-1-pos-2]) +
                       str(chars[slen-1-pos-1]) + str(chars[slen-1-pos]))
                if new != prev:
                    result.add(new)
                    q.append((pos3, new))

            vis.add(pos)

        return (str(len(result)) + "\n" + "\n".join(sorted(result))
                if result else "0")
 Main calcualtion function of the class 
Main calcualtion function of the class
Main calcualtion function of the class
def calculate(self):
        chars = list(self.s)
        slen = len(chars)
        result = set([])
        vis = set([])
        q = deque([(0, "")])
        while q:
            pos, prev = q.popleft()
            if pos in vis:
                continue
            pos2 = pos + 2
            if slen - pos2 > 4:
                new = str(chars[slen-1-pos-1]) + str(chars[slen-1-pos])
                if new != prev:
                    result.add(new)
                    q.append((pos2, new))
            pos3 = pos + 3
            if slen - pos3 > 4:
                new = (str(chars[slen-1-pos-2]) +
                       str(chars[slen-1-pos-1]) + str(chars[slen-1-pos]))
                if new != prev:
                    result.add(new)
                    q.append((pos3, new))
            vis.add(pos)
        return (str(len(result)) + "\n" + "\n".join(sorted(result))
                if result else "0")
def calculate ( self ) : chars = list ( self . s ) slen = len ( chars ) result = set ( [ ] ) vis = set ( [ ] ) q = deque ( [ ( 0 , "" ) ] ) while q : pos , prev = q . popleft ( ) if pos in vis : continue pos2 = pos + 2 if slen - pos2 > 4 : new = str ( chars [ slen - 1 - pos - 1 ] ) + str ( chars [ slen - 1 - pos ] ) if new != prev : result . add ( new ) q . append ( ( pos2 , new ) ) pos3 = pos + 3 if slen - pos3 > 4 : new = ( str ( chars [ slen - 1 - pos - 2 ] ) + str ( chars [ slen - 1 - pos - 1 ] ) + str ( chars [ slen - 1 - pos ] ) ) if new != prev : result . add ( new ) q . append ( ( pos3 , new ) ) vis . add ( pos ) return ( str ( len ( result ) ) + "\n" + "\n" . join ( sorted ( result ) ) if result else "0" )
Main calcualtion function of the class
Main calcualtion function of the class
""" Main calcualtion function of the class """
self