-
Notifications
You must be signed in to change notification settings - Fork 26
/
minigolf.html
67 lines (55 loc) · 2.25 KB
/
minigolf.html
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
<!DOCTYPE html>
<html>
<head>
<title>Puzzle: Mini-Golf</title>
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<p class="subtle"><a href="/">« Boston Python puzzles</a></p>
<h1>Mini-Golf</h1>
<p>This is a 9-hole game of Python mini-golf. The goal is to create a series of
9 functions, each of which takes the output of the previous hole as the input.
This is supposed to be useful for beginners, so it provides a tour of Python's
built-in functions: <a href="http://docs.python.org/2/library/functions.html">http://docs.python.org/2/library/functions.html</a></p>
<pre>
def hole0(your_name):
# your_name should be a string of at least 3 letters
# create a function that divides it into 3 strings of equal size (smallest parts first if not divisible by 3)
# hint: check out the built-in len() function
return your_name_parts
def hole1(your_name_parts):
# this function takes as input the output of the hole0() function
# convert those 3 strings into 3 lists of their letters
# hint: check out the builtin list() function
return letters
def hole2(letters):
# sort each of the 3 lists of letters alphabetically
# hint: check out sorted() function and also the list.sort() method, and learn what "sorting in place" means!
return sorted_letters
def hole3(sorted_letters):
# convert each letter list into list of ASCII codes
# hint: ord()
return ASCII
def hole4(ASCII):
# convert these ASCII integers into strings
# hint: str()
return ASCII_str
def hole5(ASCII_str):
# join each ASCII_str as a single string
# hint: look up the join() method
return joined_number_strings
def hole6(joined_number_strings):
# add a decimal point to the beginning of each of the 3 strings
# hint: check out the builtin string operations (like '+')
return point_stuff
def hole7(point_stuff):
# now convert each into a float
# hint: float()
return float_stuff
def hole8(float_stuff):
# and finally, convert into your Python Name Color
# multiply each of these 3 floats by 255 to form an RGB value
# hint: you will need the int() function
# show me your color to claim your candy!
# bonus points: write code that actually outputs a square of this color
return RGB
</pre>