from collections import deque

class ColorPicker:
    '''
    A queue of the colors provided to the constructor. Calling next will get
    the immediate next color and put it back on the end of the queue. If
    specific colors are desired, they can be used with the used() function,
    which places the color used at the end of the queue. (Colors that aren't in
    the queue can still be used with used(), but they will not be added to the
    queue.)
    '''

    def __init__(self, colors):
        self._colors = deque(colors)

    @classmethod
    def from_graphviz(cls):
        return cls(GRAPHVIZ_COLORS)

    def use(self, color):
        '''
        Add the used color to the end of the queue and remove the first
        instance of that color from the queue.
        '''
        self._colors.append(color)
        self._colors.remove(color)

    def __next__(self):
        '''
        Get the next color in the queue and put it at the end of the queue.
        '''
        popped = self._colors.popleft()
        self._colors.append(popped)
        return popped

    def __len__(self):
        return len(self._colors)

GRAPHVIZ_COLORS = [
        'limegreen',
        'tan3',
        'brown4',
        'plum3',
        'chartreuse1',
        'deeppink3',
        'paleturquoise4',
        'navy',
        'darkseagreen3',
        'darkslategray',
        'plum1',
        'deepskyblue3',
        'dodgerblue1',
        'slategray2',
        'salmon2',
        'violetred3',
        'azure4',
        'indigo',
        'thistle3',
        'darkorange1',
        'deepskyblue1',
        'lavenderblush3',
        'slategray',
        'purple2',
        'peachpuff',
        'palegreen4',
        'pink3',
        'burlywood3',
        'wheat4',
        'mediumspringgreen',
        'palegreen3',
        'blueviolet',
        'ivory4',
        'cadetblue4',
        'maroon2',
        'orangered',
        'goldenrod3',
        'olivedrab1',
        'slategrey',
        'gold3',
        'goldenrod2',
        'mediumorchid4',
        'mediumseagreen',
        'mistyrose2',
        'magenta2',
        'khaki',
        'cadetblue',
        'firebrick4',
        'palegreen',
        'deepskyblue',
        'cadetblue2',
        'gold1',
        'firebrick1',
        'turquoise1',
        'coral4',
        'purple1',
        'hotpink2',
        'paleturquoise2',
        'brown2',
        'darkolivegreen',
        'orange2',
        'orange1',
        'indianred1',
        'deepskyblue2',
        'royalblue2',
        'bisque4',
        'darkolivegreen4',
        'dodgerblue4',
        'chocolate',
        'darkolivegreen3',
        'gold',
        'thistle1',
        'blue4',
        'salmon3',
        'sienna4',
        'forestgreen',
        'salmon',
        'indianred3',
        'burlywood',
        'rosybrown',
        'darkgoldenrod',
        'skyblue4',
        'indianred',
        'darksalmon',
        'cyan3',
        'deeppink1',
        'ivory1',
        'orangered3',
        'rosybrown1',
        'palevioletred',
        'blanchedalmond',
        'snow3',
        'red1',
        'cyan2',
        'mediumblue',
        'lawngreen',
        'pink4',
        'darkgoldenrod4',
        'lemonchiffon1',
        'pink1',
        'peachpuff2',
        'orangered4',
        'firebrick3',
        'peru',
        'steelblue4',
        'tomato4',
        'oldlace',
        'magenta3',
        'darkorchid3',
        'wheat1',
        'deeppink2',
        'purple3',
        'snow1',
        'mistyrose3',
        'chocolate2',
        'orangered2',
        'pink',
        'darkturquoise',
        'gold2',
        'mistyrose4',
        'snow',
        'slateblue3',
        'firebrick2',
        'darkgreen',
        'turquoise4',
        'indianred2',
        'moccasin',
        'blue2',
        'lemonchiffon3',
        'darkseagreen',
        'springgreen1',
        'mistyrose1',
        'coral1',
        'springgreen',
        'maroon',
        'yellow4',
        'orange3',
        'magenta1',
        'lavenderblush',
        'aquamarine1',
        'brown',
        'blue',
        'turquoise3',
        'cadetblue1',
        'dodgerblue2',
        'khaki1',
        'violetred2',
        'ivory',
        'red4',
        'chartreuse4',
        'tan2',
        'maroon1',
        'royalblue4',
        'springgreen2',
        'darkorange2',
        'steelblue',
        'mediumvioletred',
        'royalblue3',
        'darkseagreen4',
        'olivedrab',
        'blue1',
        'khaki3',
        'cornsilk3',
        'hotpink3',
        'darkslateblue',
        'springgreen4',
        'mintcream',
        'violet',
        'aquamarine3',
        'mediumpurple',
        'purple4',
        'slategray1',
        'black',
        'darkorange',
        'azure2',
        'cyan1',
        'seagreen3',
        'chocolate1',
        'palevioletred3',
        'khaki4',
        'steelblue3',
        'peachpuff1',
        'tan',
        'rosybrown2',
        'seagreen4',
        'steelblue2',
        'thistle2',
        'burlywood4',
        'mediumorchid',
        'skyblue2',
        'violetred',
        'darkorange4',
        'azure',
        'orchid1',
        'maroon3',
        'red',
        'darkgoldenrod3',
        'wheat2',
        'steelblue1',
        'mistyrose',
        'brown1',
        'darkslategray4',
        'mediumpurple1',
        'darkgoldenrod1',
        'bisque',
        'rosybrown3',
        'paleturquoise',
        'sienna1',
        'palegreen1',
        'darkslategray2',
        'slategray4',
        'slategray3',
        'slateblue',
        'cornsilk4',
        'slateblue1',
        'darkolivegreen2',
        'darkolivegreen1',
        'invis',
        'coral2',
        'snow4',
        'springgreen3',
        'darkgoldenrod2',
        'darkseagreen1',
        'lemonchiffon2',
        'red3',
        'ivory3',
        'royalblue',
        'olivedrab3',
        'hotpink',
        'orchid',
        'gainsboro',
        'lemonchiffon4',
        'aliceblue',
        'saddlebrown',
        'plum2',
        'orchid3',
        'cornsilk',
        'midnightblue',
        'darkorchid1',
        'royalblue1',
        'mediumpurple4',
        'deepskyblue4',
        'snow2',
        'aquamarine2',
        'lemonchiffon',
        'rosybrown4',
        'aquamarine4',
        'lavenderblush2',
        'peachpuff4',
        'hotpink4',
        'mediumpurple2',
        'bisque1',
        'tomato',
        'violetred4',
        'firebrick',
        'cyan4',
        'dodgerblue',
        'palevioletred1',
        'linen',
        'wheat3',
        'chartreuse3',
        'yellowgreen',
        'mediumpurple3',
        'darkslategrey',
        'maroon4',
        'cornsilk2',
        'deeppink4',
        'mediumorchid3',
        'paleturquoise3',
        'plum4',
        'khaki2',
        'orchid4',
        'navyblue',
        'paleturquoise1',
        'seagreen1',
        'salmon1',
        'purple',
        'tomato2',
        'chartreuse2',
        'skyblue',
        'ivory2',
        'violetred1',
        'skyblue3',
        'azure3',
        'turquoise2',
        'orangered1',
        'lavender',
        'coral3',
        'darkorchid',
        'gold4',
        'blue3',
        'palevioletred2',
        'goldenrod4',
        'goldenrod',
        'cornsilk1',
        'magenta',
        'olivedrab4',
        'yellow1',
        'slateblue4',
        'mediumorchid2',
        'dimgray',
        'cadetblue3',
        'olivedrab2',
        'plum',
        'deeppink',
        'thistle',
        'peachpuff3',
        'pink2',
        'sienna2',
        'chocolate4',
        'coral',
        'brown3',
        'red2',
        'orchid2',
        'dimgrey',
        'tomato1',
        'darkslategray1',
        'orange4',
        'darkseagreen2',
        'burlywood1',
        'bisque3',
        'crimson',
        'yellow3',
        'hotpink1',
        'darkkhaki',
        'salmon4',
        'mediumaquamarine',
        'seagreen2',
        'bisque2',
        'dodgerblue3',
        'thistle4',
        'powderblue',
        'mediumorchid1',
        'mediumslateblue',
        'tan4',
        'darkslategray3',
        'sandybrown',
        'lavenderblush1',
        'cornflowerblue',
        'aquamarine',
        'tan1',
        'yellow2',
        'goldenrod1',
        'turquoise',
        'darkviolet',
        'tomato3',
        'sienna',
        'wheat',
        'cyan',
        'darkorange3',
        'azure1',
        'sienna3',
        'palevioletred4',
        'darkorchid4',
        'slateblue2',
        'skyblue1',
        'darkorchid2',
        'magenta4',
        'lavenderblush4',
        'seagreen',
        'yellow',
        'palegoldenrod',
        'burlywood2',
        'chartreuse',
        'indianred4',
        'chocolate3',
        'orange',
        'mediumturquoise',
        'palegreen2',
        ]

