-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolution.py
27 lines (22 loc) · 995 Bytes
/
solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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'
def bear_fur(bears):
return {
('black', 'black'): 'black',
('brown', 'brown'): 'brown',
('white', 'white'): 'white',
('black', 'brown'): 'dark brown',
('black', 'white'): 'grey',
('brown', 'white'): 'light brown',
}.get(tuple(sorted((bears))), 'unknown')