def search_palette(palette, target):
	best_diff = None
	best_index = None

	def square(x):
		return x * x

	for i in range(len(palette)):
		color = palette[i]

		diff = square(target[0] - color[0])            \
		     + square(target[1] - color[1])            \
		     + square(target[2] - color[2])

		if best_index is None or diff < best_diff:
			best_diff = diff
			best_index = i

	return best_index
Convert a given ElementTree element to a markup stream.
dataset/ETHPy150Open freedoom/freedoom/lumps/colormap/colormap.py/search_palette--crossover with--dataset/ETHPy150Open timonwong/OmniMarkupPreviewer/OmniMarkupLib/Renderers/libs/python2/genshi/input.py/ET