-
Notifications
You must be signed in to change notification settings - Fork 0
/
ruler.py
28 lines (23 loc) · 890 Bytes
/
ruler.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
#-----------------------------------------------------------------------
# ruler.py
#-----------------------------------------------------------------------
import stdlib.stdio as stdio
# Write to standard output the relative lengths of the subdivisions on
# a ruler. The nth line of output is the relative lengths of the marks
# on a ruler subdivided in intervals of 1/2^n of an inch. For example,
# the fourth line of output gives the relative lengths of the marks
# that indicate intervals of one-sixteenth of an inch on a ruler.
ruler1 = '1'
ruler2 = ruler1 + ' 2 ' + ruler1
ruler3 = ruler2 + ' 3 ' + ruler2
ruler4 = ruler3 + ' 4 ' + ruler3
stdio.writeln(ruler1)
stdio.writeln(ruler2)
stdio.writeln(ruler3)
stdio.writeln(ruler4)
#-----------------------------------------------------------------------
# python ruler.py
# 1
# 1 2 1
# 1 2 1 3 1 2 1
# 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1