-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathchallenge.py
87 lines (78 loc) · 2.23 KB
/
challenge.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# hail mighty travelers, you have reached a quest board. However the board is written in
# the archaic language, something you reckon is called python3.
# the quests have a dictionary, with boss names and how much loot they give you.
# you must find the best boss to kill because you are the best!
#
# hint dictionaries have "keys" that map to "values". If i have a dictionary d, i can access its keys with
# d.keys(). I can get its values with d.values(). If i do d['key in dictionary'], i will get the value
# corresponding to 'key in dictionary'. keys need not be strings. You could just as easily have d[1] as a valid key.
# to get a list containing [(key1, value1), (key2, value2), ... ] do dict.items().
# you can iterate this list by doing
# for key, value in d.items():
# print(key, value)
#
from random import randint
def find_optimal_quest(d):
# write your code here
# it should return the boss with the best loot! Feel free to ask us questions :)
pass
# scroll past this
s = '''Gaston Goshorn
Sandi Stever
Soila Stalling
Rocky Reiling
Renna Rapozo
Laverne Lague
Johnnie Junior
Sherrie Schwenk
Aracely Aberle
Tressie Torrey
Marin Martino
Valda Vallone
Trevor Thome
Reynaldo Raymer
Genoveva Gridley
Tama Tirrell
Janet Jelinek
Jeannetta Jose
Felicitas Fertig
Tambra Toribio
Britt Boose
Orville Oommen
Annmarie Aiello
Margaret Moreman
Nicholle Nedd
Usha Utzinger
Santina Steptoe
Cinderella Chamblee
Tamika Tomer
Thad Tiano
Laurette Lindell
Marcellus Meaney
Sarita Shams
Carlena Countryman
Estell Engleman
Malika Melson
Kieth Knupp
Sebastian Starling
Suzie Schoenfeld
Santos Silverio
Madelaine Minnix
Sixta Scates
Dorris Deforest
An Arruda
Susannah Scanlon
Jada Jessen
Numbers Noonkester
Josephine Jaramillo
Magaly Mcgaugh
Marshall Meany'''
def generate_quest_board():
d = dict()
for name in s.split('\n'):
d[name.strip()] = randint(-1000, 1000)
return d
def validate_answer(d):
return max(list((v, k) for (k, v) in d.items()))[1]
quests = generate_quest_board()
assert validate_answer(quests) == find_optimal_quest(quests)