Go: package main

import (
	"fmt"
	"math"
	"strconv"
)

// ColorCode is a string like #rrggbb
type ColorCode string

// ColorName is a name of color
type ColorName string

// Color has colorname and colorcode
type Color struct {
	name ColorName
	code ColorCode
}

// ColorTable has default colors
type ColorTable struct {
	colors []Color
}

var (
	colorTable = ColorTable{
		[]Color{
			Color{"black", "#000000"},
			Color{"blue", "#0000ff"},
			Color{"lime", "#00ff00"},
			Color{"aqua", "#00ffff"},
			Color{"red", "#ff0000"},
			Color{"fuchsia", "#ff00ff"},
			Color{"yellow", "#ffff00"},
			Color{"white", "#ffffff"},
		},
	}
)

func main() {
	var code ColorCode
	fmt.Scanf("%s", &code)
	for {
		if code == "0" {
			break
		}
		name := colorTable.getNearestColor(code)
		fmt.Println(name)
		fmt.Scanf("%s", &code)
	}
}

func (colorstr ColorCode) parseColorValue() (float64, float64, float64) {
	rr, gg, bb := colorstr[1:3], colorstr[3:5], colorstr[5:7]
	rri, err1 := strconv.ParseUint(string(rr), 16, 8)
	ggi, err2 := strconv.ParseUint(string(gg), 16, 8)
	bbi, err3 := strconv.ParseUint(string(bb), 16, 8)
	if err1 != nil || err2 != nil || err3 != nil {
		err := fmt.Errorf(
			"Failed to read color strings, color code:%s, err: %v %v %v",
			colorstr, err1, err2, err3)
		panic(err)
	}
	return float64(rri), float64(ggi), float64(bbi)
}

func (table *ColorTable) getNearestColor(targetcode ColorCode) ColorName {
	var nearestColor ColorName
	var nearestValue = 1e5
	for _, v := range table.colors {
		trr, tgg, tbb := targetcode.parseColorValue()
		prr, pgg, pbb := v.code.parseColorValue()
		// diff := math.Sqrt(
		// 	math.Pow(prr-trr, 2) + math.Pow(pgg-tgg, 2) + math.Pow(pbb-tbb, 2))
		diff := math.Pow(prr-trr, 2) +
			math.Pow(pgg-tgg, 2) +
			math.Pow(pbb-tbb, 2)
		if nearestValue > diff {
			nearestValue = diff
			nearestColor = v.name
		}
	}
	return nearestColor
}

Python: # Aizu Problem 0176: What Color?
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

colors = {"black": "#000000", "blue": "#0000ff", "lime": "#00ff00",
          "aqua": "#00ffff", "red": "#ff0000", "fuchsia": "#ff00ff",
          "yellow": "#ffff00", "white": "#ffffff"}

def distance(cc1, cc2):
    r1 = int(cc1[1:3], 16)
    r2 = int(cc2[1:3], 16)
    g1 = int(cc1[3:5], 16)
    g2 = int(cc2[3:5], 16)
    b1 = int(cc1[5:], 16)
    b2 = int(cc2[5:], 16)
    return math.sqrt((r1 - r2)**2 + (g1 - g2)**2 + (b1 - b2)**2)

    
def get_color(cc):
    min_dist = float('Inf')
    for color in colors:
        dist = distance(cc, colors[color])
        if dist < min_dist:
            min_dist = dist
            best = color
    return best


while True:
    cc = input().strip()
    if cc[0] == '0':
        break
    print(get_color(cc))

Python: # 参考:http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2797666#1

COLOR = {
    "000000": "black",
    "0000ff": "blue",
    "00ff00": "lime",
    "00ffff": "aqua",
    "ff0000": "red",
    "ff00ff": "fuchsia",
    "ffff00": "yellow",
    "ffffff": "white"
}

while True:
    s = input()
    if len(s) == 1:
        break
    color = ""

    for first, second in zip(s[1::2], s[2::2]):
        if int(first + second, 16) <= 127:
            color += "00"
        else:
            color += "ff"
    print(COLOR[color])

Python: color = {
	'black' 	: '#000000',
	'blue' 		: '#0000ff',
	'lime' 		: '#00ff00',
	'aqua' 		: '#00ffff',
	'red' 		: '#ff0000',
	'fuchsia' 	: '#ff00ff',
	'yellow' 	: '#ffff00',
	'white' 	: '#ffffff',
}

def list_chunk(arr, n):
	return [arr[i:i+3] for i in range(0,15,n)]

def code2rgb(code):
	code = code.lstrip('#')
	r, g, b = [code[i:i+2] for i in range(0,len(code),2)]
	return [int(v, 16) for v in [r, g, b]]
def dk2(a, b):
	return sum([(a[i]-b[i])**2 for i in range(0,3)])


while True:
	v = input()
	if(v is '0'): break
	rgb = code2rgb(v)
	dks = [dk2(code2rgb(c), rgb) for c in color.values()]
	k = list(color.keys())
	print(k[dks.index(min(dks))])

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0176

"""
import sys
from sys import stdin
from collections import namedtuple
from math import sqrt
input = stdin.readline


color = namedtuple('color', ['name', 'r', 'g', 'b'])
def main(args):
    references = [color('black',   0x00, 0x00, 0x00), color('blue', 0x00, 0x00, 0xff), color('lime',    0x00, 0xff, 0x00),
                  color('aqua',    0x00, 0xff, 0xff), color('red',  0xff, 0x00, 0x00), color('fuchsia', 0xff, 0x00, 0xff),
                  color('yellow', 0xff, 0xff, 0x00), color('white', 0xff, 0xff, 0xff)]

    while True:
        data = input().strip()
        if data[0] == '0':
            break
        my_r = int(data[1:3], 16)
        my_g = int(data[3:5], 16)
        my_b = int(data[5:7], 16)

        distances = []
        for c in references:
            d = sqrt((c.r - my_r)**2 + (c.g - my_g)**2 + (c.b - my_b)**2)
            distances.append(d)

        closest_distance = min(distances)
        closest_color = distances.index(closest_distance)
        print(references[closest_color].name)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: color = {
    "000000": "black",
    "0000ff": "blue",
    "00ff00": "lime",
    "00ffff": "aqua",
    "ff0000": "red",
    "ff00ff": "fuchsia",
    "ffff00": "yellow",
    "ffffff": "white"
}
 
while True:
    n = input()
    if n == '0': break
    code = ''
    for f, s in zip(n[1::2], n[2::2]):
        if int(f+s, 16) <= 127:
            code += '00'
        else:
            code += 'ff'
    print(color[code])

Python: COLOR = {
    "000000": "black",
    "0000ff": "blue",
    "00ff00": "lime",
    "00ffff": "aqua",
    "ff0000": "red",
    "ff00ff": "fuchsia",
    "ffff00": "yellow",
    "ffffff": "white"
}

while True:

    input_data = input()

    if len(input_data) == 1:
        break

    color_code = ""

    for first, second in zip(input_data[1::2], input_data[2::2]):
        if int(first + second, 16) <= 127:
            color_code += "00"
        else:
            color_code += "ff"

    print(COLOR[color_code])

Python: import math

def solve(line):
	R = int(line[1:3], 16)
	G = int(line[3:5], 16)
	B = int(line[5:7], 16)
	
	sa_black = math.sqrt(R**2 + G**2 + B**2)
	sa_max = sa_black
	ans_color = "black"
	
	sa_blue = math.sqrt(R**2 + G**2 + (B - 255)**2)
	if sa_blue < sa_max:
		sa_max = sa_blue
		ans_color = "blue"
	
	sa_lime = math.sqrt(R**2 + (G - 255)**2 + B**2)
	if sa_lime < sa_max:
		sa_max = sa_lime
		ans_color = "lime"
	
	sa_aqua = math.sqrt(R**2 + (G - 255)**2 + (B - 255)**2)
	if sa_aqua < sa_max:
		sa_max = sa_aqua
		ans_color = "aqua"
	
	sa_red = math.sqrt((R - 255)**2 + G**2 + B**2)
	if sa_red < sa_max:
		sa_max = sa_red
		ans_color = "red"
	
	sa_fuchsia = math.sqrt((R - 255)**2 + G**2 + (B - 255)**2)
	if sa_fuchsia < sa_max:
		sa_max = sa_fuchsia
		ans_color = "fuchsia"
	
	sa_yellow = math.sqrt((R - 255)**2 + (G - 255)**2 + B**2)
	if sa_yellow < sa_max:
		sa_max = sa_yellow
		ans_color = "yellow"
	
	sa_white = math.sqrt((R - 255)**2 + (G - 255)**2 + (B - 255)**2)
	if sa_white < sa_max:
		sa_max = sa_white
		ans_color = "white"

	return ans_color

while True:
	line = input()
	if line == '0': break
	print(solve(line))