Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

type Color struct {
	name    string
	R, G, B int64
}

func main() {
	colors := []Color{
		{"black", 0, 0, 0},
		{"blue", 0, 0, 0xff},
		{"lime", 0, 0xff, 0},
		{"aqua", 0, 0xff, 0xff},
		{"red", 0xff, 0, 0},
		{"fuchsia", 0xff, 0, 0xff},
		{"yellow", 0xff, 0xff, 0},
		{"white", 0xff, 0xff, 0xff},
	}
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), "")
		if buf[0] == "0" {
			break
		}
		r, _ := strconv.ParseInt(strings.Join(buf[1:3], ""), 16, 64)
		g, _ := strconv.ParseInt(strings.Join(buf[3:5], ""), 16, 64)
		b, _ := strconv.ParseInt(strings.Join(buf[5:], ""), 16, 64)
		vmin := int64(3*0xff*0xff)
		var ans string
		for _, c := range colors {
			d := (r-c.R)*(r-c.R) + (g-c.G)*(g-c.G) + (b-c.B)*(b-c.B)
			if d < vmin {
				vmin = d
				ans = c.name
			}
		}
		fmt.Println(ans)
	}
}

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))

Python: import math

sample1 = [ [0, 0, 0], [0, 0, 255], [0, 255, 0], [0, 255, 255], [255, 0, 0], [255, 0, 255], [255, 255, 0], [255, 255, 255] ]
sample2 = ['black', 'blue', 'lime', 'aqua', 'red', 'fuchsia', 'yellow', 'white']

while True:
    color = input()
    
    if color=='0':
        break
    
    Color = list(color)
    Color.pop(0)
    for i in range(6):
        if Color[i]=='a':
            Color.pop(i)
            Color.insert(i,10)
        if Color[i]=='b':
            Color.pop(i)
            Color.insert(i,11)
        if Color[i]=='c':
            Color.pop(i)
            Color.insert(i,12)
        if Color[i]=='d':
            Color.pop(i)
            Color.insert(i,13)
        if Color[i]=='e':
            Color.pop(i)
            Color.insert(i,14)
        if Color[i]=='f':
            Color.pop(i)
            Color.insert(i,15)
    
    R = int(Color[0])*16 + int(Color[1])
    G = int(Color[2])*16 + int(Color[3])
    B = int(Color[4])*16 + int(Color[5])
    
    D = []
    for i in range(8):
        d = math.sqrt( (R-sample1[i][0])**2 + (G-sample1[i][1])**2 + (B-sample1[i][2])**2 )
        D.append(d)
    dmin = min(D)
    index = D.index(dmin)
    print(sample2[index])

Python: L = [ [ 0, "black",     0,  0,    0 ],
      [ 1, "blue",      0,  0,  255 ],
      [ 2, "lime",      0, 255,   0 ],
      [ 3, "aqua",      0, 255, 255 ],
      [ 4, "red",     255,   0,   0 ],
      [ 5, "fuchsia", 255,   0, 255 ],
      [ 6, "yellow",  255, 255,   0 ],
      [ 7, "white",   255, 255, 255 ] ]

while True:
    T = []
    s = input()
    if s == "0":
        break
    code = []
    for i in range(3):
        code.append( int(s[1+2*i:3+2*i], 16) )
    for i in range(len(L)):
        m = 0
        for j in range(3):
            m += (L[i][2+j] - code[j])**2
        T.append( [ L[i][0], m] )
    T.sort(key=lambda x: (x[1], x[0]))
    print(L[T[0][0]][1])