docs: def rgb_reduce(r, g, b, mode=8):
      '''
      Convert an RGB colour to 8 or 16 colour ANSI graphics.
      '''
      colours = ANSI_COLOURS[:mode]
      matches = [(rgb_distance(c, map(int, [r, g, b])), i)
          for i, c in enumerate(colours)]
      matches.sort()
      return sequence('m')(str(30 + matches[0][1]))