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

        xy = self.x * self.y
        loc = (self.x0, self.y0)
        locs = set([loc])
        result = [1]
        for (i, d) in enumerate(self.nums):
            nx, ny = loc
            if d == "U":
                nx = max(1, loc[0] - 1)
            if d == "D":
                nx = min(self.x, loc[0] + 1)
            if d == "L":
                ny = max(1, loc[1] - 1)
            if d == "R":
                ny = min(self.y, loc[1] + 1)
            loc = (nx, ny)
            if len(locs) == xy:
                result.append(0)
            elif i == len(self.nums) - 1:
                result.append(xy - len(locs))
            elif loc in locs:
                result.append(0)
            else:
                result.append(1)
            locs.add(loc)

        return " ".join(map(str, result))
 Main calcualtion function of the class 
Main calcualtion function of the class
Main calcualtion function of the class
def calculate(self):
        xy = self.x * self.y
        loc = (self.x0, self.y0)
        locs = set([loc])
        result = [1]
        for (i, d) in enumerate(self.nums):
            nx, ny = loc
            if d == "U":
                nx = max(1, loc[0] - 1)
            if d == "D":
                nx = min(self.x, loc[0] + 1)
            if d == "L":
                ny = max(1, loc[1] - 1)
            if d == "R":
                ny = min(self.y, loc[1] + 1)
            loc = (nx, ny)
            if len(locs) == xy:
                result.append(0)
            elif i == len(self.nums) - 1:
                result.append(xy - len(locs))
            elif loc in locs:
                result.append(0)
            else:
                result.append(1)
            locs.add(loc)
        return " ".join(map(str, result))
def calculate ( self ) : xy = self . x * self . y loc = ( self . x0 , self . y0 ) locs = set ( [ loc ] ) result = [ 1 ] for ( i , d ) in enumerate ( self . nums ) : nx , ny = loc if d == "U" : nx = max ( 1 , loc [ 0 ] - 1 ) if d == "D" : nx = min ( self . x , loc [ 0 ] + 1 ) if d == "L" : ny = max ( 1 , loc [ 1 ] - 1 ) if d == "R" : ny = min ( self . y , loc [ 1 ] + 1 ) loc = ( nx , ny ) if len ( locs ) == xy : result . append ( 0 ) elif i == len ( self . nums ) - 1 : result . append ( xy - len ( locs ) ) elif loc in locs : result . append ( 0 ) else : result . append ( 1 ) locs . add ( loc ) return " " . join ( map ( str , result ) )
Main calcualtion function of the class
Main calcualtion function of the class
""" Main calcualtion function of the class """
self