Mercurial > public > think_complexity
comparison ch6ex1.py @ 39:49db586c727a
Chapter 6, exercise 1: simple program to play with CA and CADrawer.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 11 Jan 2013 21:18:45 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
38:d876711b88b5 | 39:49db586c727a |
---|---|
1 """Chapter 6, exercise 1 in Allen Downey's Think Complexity book. | |
2 | |
3 "Download thinkcomplex.com/CA.py and thinkcomplex.com/CADrawer.py and confirm | |
4 that they run on your system; you might have to install additional Python | |
5 packages." | |
6 | |
7 """ | |
8 import sys | |
9 | |
10 import CA | |
11 from CADrawer import PyplotDrawer | |
12 | |
13 def main(script, rule, n): | |
14 rule = int(rule) | |
15 n = int(n) | |
16 ca = CA.CA(rule, n) | |
17 ca.start_single() | |
18 ca.loop(n - 1) | |
19 | |
20 drawer = PyplotDrawer() | |
21 drawer.draw(ca) | |
22 drawer.show() | |
23 | |
24 | |
25 if __name__ == '__main__': | |
26 main(*sys.argv) |