A population of bears consists of black bears, brown bears, and white bears.

The input is an array of two elements. 

Determine whether the offspring of the two bears will return `'black'`, `'brown'`, `'white'`, `'dark brown'`, `'grey'`, `'light brown'`, or `'unknown'`.

Elements in the the array will always be a string.



## Examples:

    bear_fur(['black', 'black'])  returns 'black'

    bear_fur(['brown', 'brown'])  returns 'brown'

    bear_fur(['white', 'white'])  returns 'white'

    bear_fur(['black', 'brown'])  returns 'dark brown'

    bear_fur(['black', 'white'])  returns 'grey'

    bear_fur(['brown', 'white'])  returns 'light brown'

    bear_fur(['yellow', 'magenta'])  returns 'unknown'

Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures
Skill types: Data structures

Starter code:
def bear_fur(bears):
	

Solutions:
DEFAULT = 'unknown'
COLORS = {'black' + 'brown': 'dark brown', 'black' + 'white': 'grey', 'brown' + 'white': 'light brown'}

def bear_fur(bears):
	(b1, b2) = sorted(bears)
	return b1 if b1 == b2 else COLORS.get(b1 + b2, DEFAULT)


def bear_fur(bears):
	return {('black', 'black'): 'black', ('black', 'white'): 'grey', ('black', 'brown'): 'dark brown', ('brown', 'brown'): 'brown', ('brown', 'white'): 'light brown', ('white', 'white'): 'white'}.get(tuple(sorted(bears)), 'unknown')


bin_to_colors = {1: 'black', 2: 'brown', 3: 'dark brown', 4: 'white', 5: 'grey', 6: 'light brown'}
colors_to_bin = {v: k for (k, v) in bin_to_colors.items()}

def bear_fur(bears):
	return bin_to_colors.get(sum((colors_to_bin.get(k, 7) for k in set(bears))), 'unknown')


def bear_fur(bears):
	combos = {('black', 'brown'): 'dark brown', ('black', 'white'): 'grey', ('brown', 'white'): 'light brown'}
	if bears[0] == bears[1]:
		return bears[0]
	else:
		colors = tuple(sorted(bears))
		if colors in combos:
			return combos[colors]
		else:
			return 'unknown'


def bear_fur(bears):
	bears = ''.join(bears)
	dict = {'blackblack': 'black', 'brownbrown': 'brown', 'whitewhite': 'white', 'brownblack': 'dark brown', 'blackbrown': 'dark brown', 'blackwhite': 'grey', 'whiteblack': 'grey', 'brownwhite': 'light brown', 'whitebrown': 'light brown'}
	return dict.get(bears, 'unknown')


def bear_fur(bears):
	if bears[0] == bears[1]:
		return bears[0]
	if 'black' in bears and 'white' in bears:
		return 'grey'
	if 'black' in bears and 'brown' in bears:
		return 'dark brown'
	if 'white' in bears and 'brown' in bears:
		return 'light brown'
	return 'unknown'


bear_fur = lambda bears, furs={('black', 'brown'): 'dark brown', ('black', 'white'): 'grey', ('brown', 'white'): 'light brown', ('white', 'white'): 'white', ('brown', 'brown'): 'brown', ('black', 'black'): 'black'}: furs.get(tuple(sorted(bears)), 'unknown')


def bear_fur(bears):
	s = set(bears)
	if s == {'black'}:
		return 'black'
	if s == {'brown'}:
		return 'brown'
	if s == {'white'}:
		return 'white'
	if s == {'black', 'brown'}:
		return 'dark brown'
	if s == {'black', 'white'}:
		return 'grey'
	if s == {'brown', 'white'}:
		return 'light brown'
	return 'unknown'


def bear_fur(bears):
	look = {('black', 'brown'): 'dark brown', ('black', 'white'): 'grey', ('brown', 'white'): 'light brown'}
	(b1, b2) = bears
	if b1 == b2 and b1 in {'black', 'brown', 'white'}:
		return b1
	return look.get(tuple(sorted([b1, b2])), 'unknown')


def bear_fur(bears):
	for i in range(len(bears) - 1):
		if bears[i] == 'black' and bears[i + 1] == 'black':
			return 'black'
		elif bears[i] == 'white' and bears[i + 1] == 'white':
			return 'white'
		elif bears[i] == 'brown' and bears[i + 1] == 'brown':
			return 'brown'
		elif bears[i] == 'black' and bears[i + 1] == 'white':
			return 'grey'
		elif bears[i] == 'black' and bears[i + 1] == 'brown':
			return 'dark brown'
		elif bears[i] == 'white' and bears[i + 1] == 'black':
			return 'grey'
		elif bears[i] == 'white' and bears[i + 1] == 'brown':
			return 'light brown'
		elif bears[i] == 'brown' and bears[i + 1] == 'black':
			return 'dark brown'
		elif bears[i] == 'brown' and bears[i + 1] == 'white':
			return 'light brown'
		else:
			return 'unknown'