diff --git a/.gitignore b/.gitignore index f24cd99..d81016d 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ pip-log.txt #Mr Developer .mr.developer.cfg +.DS_Store diff --git a/README.md b/README.md index 3052b3f..49967b0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,70 @@ -ThinkPython -=========== +============== +Pense Python 2 +============== -LaTeX source, code examples, and exercise solutions for Think Python, 2nd edition, by Allen Downey. +Mutirão para tradução da 2ª edição de Think Python, de Allen Downey. + +Este repositório contém o código fonte do texto integral, exemplos e exercícios. + +------------------- +Objetivo do projeto +------------------- + +Vamos traduzir o Think Python 2ed para PT-BR com dois objetivos: + +* Produzir versões eletrônicas livres em HTML, PDF e ePUB para que o maior número de pessoas possam aprender com este livro maravilhoso. + +* Produzir uma versão impressa a ser publicada por uma editora de verdade, com ISBN, para que o MEC possa aceitar o *Pense Python* como livro-texto de introdução à programação no ensino superior em todo o Brasil! + + +-------------- +Como colaborar +-------------- + +Entre no grupo ``pensepython`` no Google Groups, se apresente e pergunte o que há para ser feito: + +https://groups.google.com/forum/?hl=en#!forum/pensepython + +-------------------- +Histórico do projeto +-------------------- + +No início de 1999 o prof. Allen Downey iria ministrar uma terceira turma de programação introdutória com Java, depois de duas tentativas pouco satisfatórias. Então ele resolveu escrever um livro muito menor e mais simples que os livros de Java que conhecia. Assim nasceu "How to Think Like a Computer Scientist" ("Como pensar como um cientista da computação"), publicado por Downey como GNU Free Documentation. + +No ano seguinte, o prof. Jeff Elkner converteu o livro para Python, e em 2001 Downey, Elkner e Chris Meyers publicaram "How to Think Like a Computer Scientist: Learning with Python", também uma publicação livre pela GNU-FDL. + +Primeira tradução brasileira +---------------------------- + +Por volta de 2003 eu (LR) trabalhava com o prof. Imre Simon do IME/USP na Incubadora Virtual Fapesp, e resolvemos iniciar um mutirão para traduzir o "How to Think Like a Computer Scientist: Learning with Python". Reunimos mais um pessoal online, fizemos um encontro presencial no FISL, e traduzimos o livro nos meses seguintes. O prof. Imre traduziu pessoalmente o capítulo sobre árvores. O que faltou daquela vez foi alguém (eu) assumir a responsabilidade de revisar o livro de ponta a ponta, uniformizando a terminologia e traduzindo alguns pequenos trechos que restaram em inglês por causa de dificuldades na tradução. A incubadora Fapesp saiu do ar, mas o trabalho realizado então está neste repositório: + +https://github.com/PensePython/aprendacompy + +Segunda tradução brasileira +--------------------------- + +Alguns anos depois, os professores do IME/USP Carlos Hitoshi Morimoto, Jose Coelho de Pina Jr. e José Antonio (não sei o nome completo, perdão), traduziram uma versão interativa de "How to Think Like a Computer Scientist: Learning with Python" e publicaram aqui: + +https://panda.ime.usp.br/pensepy/static/pensepy/index.html + +O código-fonte desta tradução pode ser visto aqui: + +https://github.com/PensePython/pensepython (mas o repositório principal é outro, fora do Github) + +Think Python 2ed e a terceira tradução +-------------------------------------- + +Enquanto isso, Allen Downey foi trabalhar no Olin College onde passou a usar Python como linguagem para ensinar programação e foi aperfeiçoando seu material até lançar o Think Python (O'Reilly, 2012) e agora o Think Python 2ed (O'Reilly, 2015), dessa vez usando uma licença Creative Commons Attribution-NonCommercial 3.0 Unported. + +Fiz um clone do repositório do Think Python 2ed, converti o código-fonte de LaTeX para ReStructuredText (mesmo formato usado nas duas traduções brasileiras anteriores), separei os capítulos e criei um glossário consolidado. O repositório é este: + +https://github.com/PensePython/PensePython2 + +O glossário consolidado em HTML pode ser visto aqui: + +https://pensepython.github.io/C-glossary.html + +E é aqui que a gente se encontra! + +[ ]s +Luciano diff --git a/attic/latex/Makefile b/attic/latex/Makefile new file mode 100644 index 0000000..e3a1074 --- /dev/null +++ b/attic/latex/Makefile @@ -0,0 +1,96 @@ +LATEX = latex + +DVIPS = dvips + +PDFFLAGS = -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress \ + -dCompressPages=true -dUseFlateCompression=true \ + -dEmbedAllFonts=true -dSubsetFonts=true -dMaxSubsetPct=100 + + +%.dvi: %.tex + $(LATEX) $< + +%.ps: %.dvi + $(DVIPS) -o $@ $< + +%.pdf: %.ps + ps2pdf $(PDFFLAGS) $< + +all: book.tex + makeindex book.idx + pdflatex book + mv book.pdf thinkpython2.pdf + evince thinkpython2.pdf + +hevea: book.tex header.html footer.html + # replace the pdfs with eps + sed s/.pdf/.eps/g book.tex > thinkpython2.tex + latex thinkpython2 + rm -rf html + mkdir html + hevea -fix -O -e latexonly htmlonly thinkpython2 +# the following greps are a kludge to prevent imagen from seeing +# the definitions in latexonly, and to avoid headers on the images + grep -v latexonly thinkpython2.image.tex > a; mv a thinkpython2.image.tex + grep -v fancyhdr thinkpython2.image.tex > a; mv a thinkpython2.image.tex + imagen -png thinkpython2 + hacha thinkpython2.html + cp up.png next.png back.png html + mv index.html thinkpython2.css thinkpython2*.html thinkpython2*.png *motif.gif html + +DEST = /home/downey/public_html/greent/thinkpython2 + +epub: + cd html; ebook-convert index.html thinkpython2.epub + +distrib: + rm -rf dist + mkdir dist dist/tex dist/tex/figs + rsync -a thinkpython2.pdf html dist + rsync -a Makefile book.tex latexonly htmlonly dist/tex + rsync -a figs/*.fig figs/*.pdf dist/tex/figs + cd dist; zip -r thinkpython2.tex.zip tex + cd dist; zip -r thinkpython2.html.zip html + rsync -a dist/* $(DEST) + chmod -R o+r $(DEST)/* + cd $(DEST)/..; sh back + +# UPDATE THE PATHS BELOW BEFORE RUNNING PLASTEX + +plastex: + # Before running plastex, we need the current directory in PYTHONPATH + # export PYTHONPATH=$PYTHONPATH:. + python Filist.py book.tex > book.plastex + rm -rf /home/downey/thinkpython2/trunk/book + plastex --renderer=DocBook --theme=book --image-resolution=300 --filename=book.xml book.plastex + rm -rf /home/downey/thinkpython2/trunk/book/.svn + +plastest: + # Before running plastex, we need the current directory in PYTHONPATH + # export PYTHONPATH=$PYTHONPATH:. + python Filist.py test.tex > test.plastex + rm -rf /home/downey/thinkpython2/trunk/test + plastex --renderer=DocBook --theme=test --filename=test.xml test.plastex + rm -rf /home/downey/thinkpython2/trunk/test/.svn + +xxe: + xmlcopyeditor ~/ThinkDSP/book/book/book.xml & + +lint: + xmllint -noout book/book.xml + +OREILLY = atlas + +oreilly: + rsync -a book.tex $(OREILLY) + rsync -a book/ $(OREILLY) + rsync -a figs/* $(OREILLY)/figs + cd $(OREILLY); git add . + cd $(OREILLY); git commit -m "Automated check in." + cd $(OREILLY); git push + +clean: + rm -f *~ *.aux *.log *.dvi *.idx *.ilg *.ind *.toc + + + diff --git a/book/back.png b/attic/latex/back.png similarity index 100% rename from book/back.png rename to attic/latex/back.png diff --git a/attic/latex/book.rst b/attic/latex/book.rst new file mode 100644 index 0000000..e1e8a01 --- /dev/null +++ b/attic/latex/book.rst @@ -0,0 +1,13666 @@ +[chapter] + +| 3 Think Python +| How to Think Like a Computer Scientist + +2nd Edition, Version 2.2.14 + +| 3 Think Python +| How to Think Like a Computer Scientist + +2nd Edition, Version 2.2.14 + +Allen Downey + +Green Tea Press + +Needham, Massachusetts + +Copyright © 2015 Allen Downey. + +| Green Tea Press +| 9 Washburn Ave +| Needham MA 02492 + +Permission is granted to copy, distribute, and/or modify this document +under the terms of the Creative Commons Attribution-NonCommercial 3.0 +Unported License, which is available at +http://creativecommons.org/licenses/by-nc/3.0/. + +The original form of this book is LaTeX source code. Compiling this +LaTeX source has the effect of generating a device-independent +representation of a textbook, which can be converted to other formats +and printed. + +The LaTeX source for this book is available from +http://www.thinkpython2.com + +Think Python: How to Think Like a Computer Scientist + +Allen B. Downey + +2nd Edition, Version 2.2.14 + +Preface +======= + +The strange history of this book +-------------------------------- + +In January 1999 I was preparing to teach an introductory programming +class in Java. I had taught it three times and I was getting frustrated. +The failure rate in the class was too high and, even for students who +succeeded, the overall level of achievement was too low. + +One of the problems I saw was the books. They were too big, with too +much unnecessary detail about Java, and not enough high-level guidance +about how to program. And they all suffered from the trap door effect: +they would start out easy, proceed gradually, and then somewhere around +Chapter 5 the bottom would fall out. The students would get too much new +material, too fast, and I would spend the rest of the semester picking +up the pieces. + +Two weeks before the first day of classes, I decided to write my own +book. My goals were: + +- Keep it short. It is better for students to read 10 pages than not + read 50 pages. + +- Be careful with vocabulary. I tried to minimize jargon and define + each term at first use. + +- Build gradually. To avoid trap doors, I took the most difficult + topics and split them into a series of small steps. + +- Focus on programming, not the programming language. I included the + minimum useful subset of Java and left out the rest. + +I needed a title, so on a whim I chose *How to Think Like a Computer +Scientist*. + +My first version was rough, but it worked. Students did the reading, and +they understood enough that I could spend class time on the hard topics, +the interesting topics and (most important) letting the students +practice. + +I released the book under the GNU Free Documentation License, which +allows users to copy, modify, and distribute the book. + +What happened next is the cool part. Jeff Elkner, a high school teacher +in Virginia, adopted my book and translated it into Python. He sent me a +copy of his translation, and I had the unusual experience of learning +Python by reading my own book. As Green Tea Press, I published the first +Python version in 2001. + +In 2003 I started teaching at Olin College and I got to teach Python for +the first time. The contrast with Java was striking. Students struggled +less, learned more, worked on more interesting projects, and generally +had a lot more fun. + +Since then I’ve continued to develop the book, correcting errors, +improving some of the examples and adding material, especially +exercises. + +The result is this book, now with the less grandiose title *Think +Python*. Some of the changes are: + +- I added a section about debugging at the end of each chapter. These + sections present general techniques for finding and avoiding bugs, + and warnings about Python pitfalls. + +- I added more exercises, ranging from short tests of understanding to + a few substantial projects. Most exercises include a link to my + solution. + +- I added a series of case studies—longer examples with exercises, + solutions, and discussion. + +- I expanded the discussion of program development plans and basic + design patterns. + +- I added appendices about debugging and analysis of algorithms. + +The second edition of *Think Python* has these new features: + +- The book and all supporting code have been updated to Python 3. + +- I added a few sections, and more details on the web, to help + beginners get started running Python in a browser, so you don’t have + to deal with installing Python until you want to. + +- For Chapter [turtle] I switched from my own turtle graphics package, + called Swampy, to a more standard Python module, turtle, which is + easier to install and more powerful. + +- I added a new chapter called “The Goodies”, which introduces some + additional Python features that are not strictly necessary, but + sometimes handy. + +I hope you enjoy working with this book, and that it helps you learn to +program and think like a computer scientist, at least a little bit. + +| Allen B. Downey +| Olin College + +Acknowledgments +--------------- + +Many thanks to Jeff Elkner, who translated my Java book into Python, +which got this project started and introduced me to what has turned out +to be my favorite language. + +Thanks also to Chris Meyers, who contributed several sections to *How to +Think Like a Computer Scientist*. + +Thanks to the Free Software Foundation for developing the GNU Free +Documentation License, which helped make my collaboration with Jeff and +Chris possible, and Creative Commons for the license I am using now. + +Thanks to the editors at Lulu who worked on *How to Think Like a +Computer Scientist*. + +Thanks to the editors at O’Reilly Media who worked on *Think Python*. + +Thanks to all the students who worked with earlier versions of this book +and all the contributors (listed below) who sent in corrections and +suggestions. + +Contributor List +---------------- + +More than 100 sharp-eyed and thoughtful readers have sent in suggestions +and corrections over the past few years. Their contributions, and +enthusiasm for this project, have been a huge help. + +If you have a suggestion or correction, please send email to +feedback@thinkpython.com. If I make a change based on your feedback, I +will add you to the contributor list (unless you ask to be omitted). + +If you include at least part of the sentence the error appears in, that +makes it easy for me to search. Page and section numbers are fine, too, +but not quite as easy to work with. Thanks! + +- Lloyd Hugh Allen sent in a correction to Section 8.4. + +- Yvon Boulianne sent in a correction of a semantic error in Chapter 5. + +- Fred Bremmer submitted a correction in Section 2.1. + +- Jonah Cohen wrote the Perl scripts to convert the LaTeX source for + this book into beautiful HTML. + +- Michael Conlon sent in a grammar correction in Chapter 2 and an + improvement in style in Chapter 1, and he initiated discussion on the + technical aspects of interpreters. + +- Benoit Girard sent in a correction to a humorous mistake in Section + 5.6. + +- Courtney Gleason and Katherine Smith wrote horsebet.py, which was + used as a case study in an earlier version of the book. Their program + can now be found on the website. + +- Lee Harr submitted more corrections than we have room to list here, + and indeed he should be listed as one of the principal editors of the + text. + +- James Kaylin is a student using the text. He has submitted numerous + corrections. + +- David Kershaw fixed the broken catTwice function in Section 3.10. + +- Eddie Lam has sent in numerous corrections to Chapters 1, 2, and 3. + He also fixed the Makefile so that it creates an index the first time + it is run and helped us set up a versioning scheme. + +- Man-Yong Lee sent in a correction to the example code in Section 2.4. + +- David Mayo pointed out that the word \`\`unconsciously“ in Chapter 1 + needed to be changed to \`\`subconsciously”. + +- Chris McAloon sent in several corrections to Sections 3.9 and 3.10. + +- Matthew J. Moelter has been a long-time contributor who sent in + numerous corrections and suggestions to the book. + +- Simon Dicon Montford reported a missing function definition and + several typos in Chapter 3. He also found errors in the increment + function in Chapter 13. + +- John Ouzts corrected the definition of \`\`return value" in Chapter + 3. + +- Kevin Parks sent in valuable comments and suggestions as to how to + improve the distribution of the book. + +- David Pool sent in a typo in the glossary of Chapter 1, as well as + kind words of encouragement. + +- Michael Schmitt sent in a correction to the chapter on files and + exceptions. + +- Robin Shaw pointed out an error in Section 13.1, where the printTime + function was used in an example without being defined. + +- Paul Sleigh found an error in Chapter 7 and a bug in Jonah Cohen’s + Perl script that generates HTML from LaTeX. + +- Craig T. Snydal is testing the text in a course at Drew University. + He has contributed several valuable suggestions and corrections. + +- Ian Thomas and his students are using the text in a programming + course. They are the first ones to test the chapters in the latter + half of the book, and they have made numerous corrections and + suggestions. + +- Keith Verheyden sent in a correction in Chapter 3. + +- Peter Winstanley let us know about a longstanding error in our Latin + in Chapter 3. + +- Chris Wrobel made corrections to the code in the chapter on file I/O + and exceptions. + +- Moshe Zadka has made invaluable contributions to this project. In + addition to writing the first draft of the chapter on Dictionaries, + he provided continual guidance in the early stages of the book. + +- Christoph Zwerschke sent several corrections and pedagogic + suggestions, and explained the difference between *gleich* and + *selbe*. + +- James Mayer sent us a whole slew of spelling and typographical + errors, including two in the contributor list. + +- Hayden McAfee caught a potentially confusing inconsistency between + two examples. + +- Angel Arnal is part of an international team of translators working + on the Spanish version of the text. He has also found several errors + in the English version. + +- Tauhidul Hoque and Lex Berezhny created the illustrations in Chapter + 1 and improved many of the other illustrations. + +- Dr. Michele Alzetta caught an error in Chapter 8 and sent some + interesting pedagogic comments and suggestions about Fibonacci and + Old Maid. + +- Andy Mitchell caught a typo in Chapter 1 and a broken example in + Chapter 2. + +- Kalin Harvey suggested a clarification in Chapter 7 and caught some + typos. + +- Christopher P. Smith caught several typos and helped us update the + book for Python 2.2. + +- David Hutchins caught a typo in the Foreword. + +- Gregor Lingl is teaching Python at a high school in Vienna, Austria. + He is working on a German translation of the book, and he caught a + couple of bad errors in Chapter 5. + +- Julie Peters caught a typo in the Preface. + +- Florin Oprina sent in an improvement in makeTime, a correction in + printTime, and a nice typo. + +- D. J. Webre suggested a clarification in Chapter 3. + +- Ken found a fistful of errors in Chapters 8, 9 and 11. + +- Ivo Wever caught a typo in Chapter 5 and suggested a clarification in + Chapter 3. + +- Curtis Yanko suggested a clarification in Chapter 2. + +- Ben Logan sent in a number of typos and problems with translating the + book into HTML. + +- Jason Armstrong saw the missing word in Chapter 2. + +- Louis Cordier noticed a spot in Chapter 16 where the code didn’t + match the text. + +- Brian Cain suggested several clarifications in Chapters 2 and 3. + +- Rob Black sent in a passel of corrections, including some changes for + Python 2.2. + +- Jean-Philippe Rey at Ecole Centrale Paris sent a number of patches, + including some updates for Python 2.2 and other thoughtful + improvements. + +- Jason Mader at George Washington University made a number of useful + suggestions and corrections. + +- Jan Gundtofte-Bruun reminded us that “a error” is an error. + +- Abel David and Alexis Dinno reminded us that the plural of “matrix” + is “matrices”, not “matrixes”. This error was in the book for years, + but two readers with the same initials reported it on the same day. + Weird. + +- Charles Thayer encouraged us to get rid of the semi-colons we had put + at the ends of some statements and to clean up our use of “argument” + and “parameter”. + +- Roger Sperberg pointed out a twisted piece of logic in Chapter 3. + +- Sam Bull pointed out a confusing paragraph in Chapter 2. + +- Andrew Cheung pointed out two instances of “use before def”. + +- C. Corey Capel spotted the missing word in the Third Theorem of + Debugging and a typo in Chapter 4. + +- Alessandra helped clear up some Turtle confusion. + +- Wim Champagne found a brain-o in a dictionary example. + +- Douglas Wright pointed out a problem with floor division in arc. + +- Jared Spindor found some jetsam at the end of a sentence. + +- Lin Peiheng sent a number of very helpful suggestions. + +- Ray Hagtvedt sent in two errors and a not-quite-error. + +- Torsten Hübsch pointed out an inconsistency in Swampy. + +- Inga Petuhhov corrected an example in Chapter 14. + +- Arne Babenhauserheide sent several helpful corrections. + +- Mark E. Casida is is good at spotting repeated words. + +- Scott Tyler filled in a that was missing. And then sent in a heap of + corrections. + +- Gordon Shephard sent in several corrections, all in separate emails. + +- Andrew Turner spotted an error in Chapter 8. + +- Adam Hobart fixed a problem with floor division in arc. + +- Daryl Hammond and Sarah Zimmerman pointed out that I served up + math.pi too early. And Zim spotted a typo. + +- George Sass found a bug in a Debugging section. + +- Brian Bingham suggested Exercise [exrotatepairs]. + +- Leah Engelbert-Fenton pointed out that I used tuple as a variable + name, contrary to my own advice. And then found a bunch of typos and + a “use before def”. + +- Joe Funke spotted a typo. + +- Chao-chao Chen found an inconsistency in the Fibonacci example. + +- Jeff Paine knows the difference between space and spam. + +- Lubos Pintes sent in a typo. + +- Gregg Lind and Abigail Heithoff suggested Exercise [checksum]. + +- Max Hailperin has sent in a number of corrections and suggestions. + Max is one of the authors of the extraordinary *Concrete + Abstractions*, which you might want to read when you are done with + this book. + +- Chotipat Pornavalai found an error in an error message. + +- Stanislaw Antol sent a list of very helpful suggestions. + +- Eric Pashman sent a number of corrections for Chapters 4–11. + +- Miguel Azevedo found some typos. + +- Jianhua Liu sent in a long list of corrections. + +- Nick King found a missing word. + +- Martin Zuther sent a long list of suggestions. + +- Adam Zimmerman found an inconsistency in my instance of an “instance” + and several other errors. + +- Ratnakar Tiwari suggested a footnote explaining degenerate triangles. + +- Anurag Goel suggested another solution for ``is_abecedarian`` and + sent some additional corrections. And he knows how to spell Jane + Austen. + +- Kelli Kratzer spotted one of the typos. + +- Mark Griffiths pointed out a confusing example in Chapter 3. + +- Roydan Ongie found an error in my Newton’s method. + +- Patryk Wolowiec helped me with a problem in the HTML version. + +- Mark Chonofsky told me about a new keyword in Python 3. + +- Russell Coleman helped me with my geometry. + +- Wei Huang spotted several typographical errors. + +- Karen Barber spotted the the oldest typo in the book. + +- Nam Nguyen found a typo and pointed out that I used the Decorator + pattern but didn’t mention it by name. + +- Stéphane Morin sent in several corrections and suggestions. + +- Paul Stoop corrected a typo in ``uses_only``. + +- Eric Bronner pointed out a confusion in the discussion of the order + of operations. + +- Alexandros Gezerlis set a new standard for the number and quality of + suggestions he submitted. We are deeply grateful! + +- Gray Thomas knows his right from his left. + +- Giovanni Escobar Sosa sent a long list of corrections and + suggestions. + +- Alix Etienne fixed one of the URLs. + +- Kuang He found a typo. + +- Daniel Neilson corrected an error about the order of operations. + +- Will McGinnis pointed out that polyline was defined differently in + two places. + +- Swarup Sahoo spotted a missing semi-colon. + +- Frank Hecker pointed out an exercise that was under-specified, and + some broken links. + +- Animesh B helped me clean up a confusing example. + +- Martin Caspersen found two round-off errors. + +- Gregor Ulm sent several corrections and suggestions. + +- Dimitrios Tsirigkas suggested I clarify an exercise. + +- Carlos Tafur sent a page of corrections and suggestions. + +- Martin Nordsletten found a bug in an exercise solution. + +- Lars O.D. Christensen found a broken reference. + +- Victor Simeone found a typo. + +- Sven Hoexter pointed out that a variable named input shadows a + build-in function. + +- Viet Le found a typo. + +- Stephen Gregory pointed out the problem with cmp in Python 3. + +- Matthew Shultz let me know about a broken link. + +- Lokesh Kumar Makani let me know about some broken links and some + changes in error messages. + +- Ishwar Bhat corrected my statement of Fermat’s last theorem. + +- Brian McGhie suggested a clarification. + +- Andrea Zanella translated the book into Italian, and sent a number of + corrections along the way. + +- Many, many thanks to Melissa Lewis and Luciano Ramalho for excellent + comments and suggestions on the second edition. + +- Thanks to Harry Percival from PythonAnywhere for his help getting + people started running Python in a browser. + +- Xavier Van Aubel made several useful corrections in the second + edition. + +The way of the program +====================== + +The goal of this book is to teach you to think like a computer +scientist. This way of thinking combines some of the best features of +mathematics, engineering, and natural science. Like mathematicians, +computer scientists use formal languages to denote ideas (specifically +computations). Like engineers, they design things, assembling components +into systems and evaluating tradeoffs among alternatives. Like +scientists, they observe the behavior of complex systems, form +hypotheses, and test predictions. + +The single most important skill for a computer scientist is **problem +solving**. Problem solving means the ability to formulate problems, +think creatively about solutions, and express a solution clearly and +accurately. As it turns out, the process of learning to program is an +excellent opportunity to practice problem-solving skills. That’s why +this chapter is called, “The way of the program”. + +On one level, you will be learning to program, a useful skill by itself. +On another level, you will use programming as a means to an end. As we +go along, that end will become clearer. + +What is a program? +------------------ + +A **program** is a sequence of instructions that specifies how to +perform a computation. The computation might be something mathematical, +such as solving a system of equations or finding the roots of a +polynomial, but it can also be a symbolic computation, such as searching +and replacing text in a document or something graphical, like processing +an image or playing a video. + +The details look different in different languages, but a few basic +instructions appear in just about every language: + +input: + Get data from the keyboard, a file, the network, or some other + device. + +output: + Display data on the screen, save it in a file, send it over the + network, etc. + +math: + Perform basic mathematical operations like addition and + multiplication. + +conditional execution: + Check for certain conditions and run the appropriate code. + +repetition: + Perform some action repeatedly, usually with some variation. + +Believe it or not, that’s pretty much all there is to it. Every program +you’ve ever used, no matter how complicated, is made up of instructions +that look pretty much like these. So you can think of programming as the +process of breaking a large, complex task into smaller and smaller +subtasks until the subtasks are simple enough to be performed with one +of these basic instructions. + +Running Python +-------------- + +One of the challenges of getting started with Python is that you might +have to install Python and related software on your computer. If you are +familiar with your operating system, and especially if you are +comfortable with the command-line interface, you will have no trouble +installing Python. But for beginners, it can be painful to learn about +system administration and programming at the same time. + +To avoid that problem, I recommend that you start out running Python in +a browser. Later, when you are comfortable with Python, I’ll make +suggestions for installing Python on your computer. + +There are a number of web pages you can use to run Python. If you +already have a favorite, go ahead and use it. Otherwise I recommend +PythonAnywhere. I provide detailed instructions for getting started at +http://tinyurl.com/thinkpython2e. + +There are two versions of Python, called Python 2 and Python 3. They are +very similar, so if you learn one, it is easy to switch to the other. In +fact, there are only a few differences you will encounter as a beginner. +This book is written for Python 3, but I include some notes about Python +2. + +The Python **interpreter** is a program that reads and executes Python +code. Depending on your environment, you might start the interpreter by +clicking on an icon, or by typing python on a command line. When it +starts, you should see output like this: + +:: + + Python 3.4.0 (default, Jun 19 2015, 14:20:21) + [GCC 4.8.2] on linux + Type "help", "copyright", "credits" or "license" for more information. + >>> + +The first three lines contain information about the interpreter and the +operating system it’s running on, so it might be different for you. But +you should check that the version number, which is 3.4.0 in this +example, begins with 3, which indicates that you are running Python 3. +If it begins with 2, you are running (you guessed it) Python 2. + +The last line is a **prompt** that indicates that the interpreter is +ready for you to enter code. If you type a line of code and hit Enter, +the interpreter displays the result: + +:: + + >>> 1 + 1 + 2 + +Now you’re ready to get started. From here on, I assume that you know +how to start the Python interpreter and run code. + +The first program +----------------- + +Traditionally, the first program you write in a new language is called +“Hello, World!” because all it does is display the words “Hello, +World!”. In Python, it looks like this: + +:: + + >>> print('Hello, World!') + +This is an example of a **print statement**, although it doesn’t +actually print anything on paper. It displays a result on the screen. In +this case, the result is the words + +:: + + Hello, World! + +The quotation marks in the program mark the beginning and end of the +text to be displayed; they don’t appear in the result. + +The parentheses indicate that print is a function. We’ll get to +functions in Chapter [funcchap]. + +In Python 2, the print statement is slightly different; it is not a +function, so it doesn’t use parentheses. + +:: + + >>> print 'Hello, World!' + +This distinction will make more sense soon, but that’s enough to get +started. + +Arithmetic operators +-------------------- + +After “Hello, World”, the next step is arithmetic. Python provides +**operators**, which are special symbols that represent computations +like addition and multiplication. + +The operators +, -, and perform addition, subtraction, and +multiplication, as in the following examples: + +:: + + >>> 40 + 2 + 42 + >>> 43 - 1 + 42 + >>> 6 * 7 + 42 + +The operator / performs division: + +:: + + >>> 84 / 2 + 42.0 + +You might wonder why the result is 42.0 instead of 42. I’ll explain in +the next section. + +Finally, the operator \* performs exponentiation; that is, it raises a +number to a power: + +:: + + >>> 6**2 + 6 + 42 + +In some other languages, ``^`` is used for exponentiation, but in Python +it is a bitwise operator called XOR. If you are not familiar with +bitwise operators, the result will surprise you: + +:: + + >>> 6 ^ 2 + 4 + +I won’t cover bitwise operators in this book, but you can read about +them at http://wiki.python.org/moin/BitwiseOperators. + +Values and types +---------------- + +A **value** is one of the basic things a program works with, like a +letter or a number. Some values we have seen so far are 2, 42.0, and +``'Hello, World!'``. + +These values belong to different **types**: 2 is an **integer**, 42.0 is +a **floating-point number**, and ``'Hello, World!'`` is a **string**, +so-called because the letters it contains are strung together. + +If you are not sure what type a value has, the interpreter can tell you: + +:: + + >>> type(2) + + >>> type(42.0) + + >>> type('Hello, World!') + + +In these results, the word “class” is used in the sense of a category; a +type is a category of values. + +Not surprisingly, integers belong to the type int, strings belong to str +and floating-point numbers belong to float. + +What about values like ``'2'`` and ``'42.0'``? They look like numbers, +but they are in quotation marks like strings. + +:: + + >>> type('2') + + >>> type('42.0') + + +They’re strings. + +When you type a large integer, you might be tempted to use commas +between groups of digits, as in 1,000,000. This is not a legal *integer* +in Python, but it is legal: + +:: + + >>> 1,000,000 + (1, 0, 0) + +That’s not what we expected at all! Python interprets 1,000,000 as a +comma-separated sequence of integers. We’ll learn more about this kind +of sequence later. + +Formal and natural languages +---------------------------- + +**Natural languages** are the languages people speak, such as English, +Spanish, and French. They were not designed by people (although people +try to impose some order on them); they evolved naturally. + +**Formal languages** are languages that are designed by people for +specific applications. For example, the notation that mathematicians use +is a formal language that is particularly good at denoting relationships +among numbers and symbols. Chemists use a formal language to represent +the chemical structure of molecules. And most importantly: + + **Programming languages are formal languages that have been designed + to express computations.** + +Formal languages tend to have strict **syntax** rules that govern the +structure of statements. For example, in mathematics the statement +:math:`3 + 3 = 6` has correct syntax, but :math:`3 + = 3 \$ 6` does not. +In chemistry :math:`H_2O` is a syntactically correct formula, but +:math:`_2Zz` is not. + +Syntax rules come in two flavors, pertaining to **tokens** and +structure. Tokens are the basic elements of the language, such as words, +numbers, and chemical elements. One of the problems with +:math:`3 += 3 \$ 6` is that :math:` \$ ` is not a legal token in +mathematics (at least as far as I know). Similarly, :math:`_2Zz` is not +legal because there is no element with the abbreviation :math:`Zz`. + +The second type of syntax rule pertains to the way tokens are combined. +The equation :math:`3 += 3` is illegal because even though :math:`+` and +:math:`=` are legal tokens, you can’t have one right after the other. +Similarly, in a chemical formula the subscript comes after the element +name, not before. + +This is @ well-structured Engli$h sentence with invalid t\*kens in it. +This sentence all valid tokens has, but invalid structure with. + +When you read a sentence in English or a statement in a formal language, +you have to figure out the structure (although in a natural language you +do this subconsciously). This process is called **parsing**. + +Although formal and natural languages have many features in +common—tokens, structure, and syntax—there are some differences: + +ambiguity: + Natural languages are full of ambiguity, which people deal with by + using contextual clues and other information. Formal languages are + designed to be nearly or completely unambiguous, which means that + any statement has exactly one meaning, regardless of context. + +redundancy: + In order to make up for ambiguity and reduce misunderstandings, + natural languages employ lots of redundancy. As a result, they are + often verbose. Formal languages are less redundant and more concise. + +literalness: + Natural languages are full of idiom and metaphor. If I say, “The + penny dropped”, there is probably no penny and nothing dropping + (this idiom means that someone understood something after a period + of confusion). Formal languages mean exactly what they say. + +Because we all grow up speaking natural languages, it is sometimes hard +to adjust to formal languages. The difference between formal and natural +language is like the difference between poetry and prose, but more so: + +Poetry: + Words are used for their sounds as well as for their meaning, and + the whole poem together creates an effect or emotional response. + Ambiguity is not only common but often deliberate. + +Prose: + The literal meaning of words is more important, and the structure + contributes more meaning. Prose is more amenable to analysis than + poetry but still often ambiguous. + +Programs: + The meaning of a computer program is unambiguous and literal, and + can be understood entirely by analysis of the tokens and structure. + +Formal languages are more dense than natural languages, so it takes +longer to read them. Also, the structure is important, so it is not +always best to read from top to bottom, left to right. Instead, learn to +parse the program in your head, identifying the tokens and interpreting +the structure. Finally, the details matter. Small errors in spelling and +punctuation, which you can get away with in natural languages, can make +a big difference in a formal language. + +Debugging +--------- + +Programmers make mistakes. For whimsical reasons, programming errors are +called **bugs** and the process of tracking them down is called +**debugging**. + +Programming, and especially debugging, sometimes brings out strong +emotions. If you are struggling with a difficult bug, you might feel +angry, despondent, or embarrassed. + +There is evidence that people naturally respond to computers as if they +were people. When they work well, we think of them as teammates, and +when they are obstinate or rude, we respond to them the same way we +respond to rude, obstinate people (Reeves and Nass, *The Media Equation: +How People Treat Computers, Television, and New Media Like Real People +and Places*). + +Preparing for these reactions might help you deal with them. One +approach is to think of the computer as an employee with certain +strengths, like speed and precision, and particular weaknesses, like +lack of empathy and inability to grasp the big picture. + +Your job is to be a good manager: find ways to take advantage of the +strengths and mitigate the weaknesses. And find ways to use your +emotions to engage with the problem, without letting your reactions +interfere with your ability to work effectively. + +Learning to debug can be frustrating, but it is a valuable skill that is +useful for many activities beyond programming. At the end of each +chapter there is a section, like this one, with my suggestions for +debugging. I hope they help! + +Glossary +-------- + +problem solving: + The process of formulating a problem, finding a solution, and + expressing it. + +high-level language: + A programming language like Python that is designed to be easy for + humans to read and write. + +low-level language: + A programming language that is designed to be easy for a computer to + run; also called “machine language” or “assembly language”. + +portability: + A property of a program that can run on more than one kind of + computer. + +interpreter: + A program that reads another program and executes it + +prompt: + Characters displayed by the interpreter to indicate that it is ready + to take input from the user. + +program: + A set of instructions that specifies a computation. + +print statement: + An instruction that causes the Python interpreter to display a value + on the screen. + +operator: + A special symbol that represents a simple computation like addition, + multiplication, or string concatenation. + +value: + One of the basic units of data, like a number or string, that a + program manipulates. + +type: + A category of values. The types we have seen so far are integers + (type int), floating-point numbers (type float), and strings (type + str). + +integer: + A type that represents whole numbers. + +floating-point: + A type that represents numbers with fractional parts. + +string: + A type that represents sequences of characters. + +natural language: + Any one of the languages that people speak that evolved naturally. + +formal language: + Any one of the languages that people have designed for specific + purposes, such as representing mathematical ideas or computer + programs; all programming languages are formal languages. + +token: + One of the basic elements of the syntactic structure of a program, + analogous to a word in a natural language. + +syntax: + The rules that govern the structure of a program. + +parse: + To examine a program and analyze the syntactic structure. + +bug: + An error in a program. + +debugging: + The process of finding and correcting bugs. + +Exercises +--------- + +It is a good idea to read this book in front of a computer so you can +try out the examples as you go. + +Whenever you are experimenting with a new feature, you should try to +make mistakes. For example, in the “Hello, world!” program, what happens +if you leave out one of the quotation marks? What if you leave out both? +What if you spell print wrong? + +This kind of experiment helps you remember what you read; it also helps +when you are programming, because you get to know what the error +messages mean. It is better to make mistakes now and on purpose than +later and accidentally. + +#. In a print statement, what happens if you leave out one of the + parentheses, or both? + +#. If you are trying to print a string, what happens if you leave out + one of the quotation marks, or both? + +#. You can use a minus sign to make a negative number like -2. What + happens if you put a plus sign before a number? What about 2++2? + +#. In math notation, leading zeros are ok, as in 02. What happens if you + try this in Python? + +#. What happens if you have two values with no operator between them? + +Start the Python interpreter and use it as a calculator. + +#. How many seconds are there in 42 minutes 42 seconds? + +#. How many miles are there in 10 kilometers? Hint: there are 1.61 + kilometers in a mile. + +#. If you run a 10 kilometer race in 42 minutes 42 seconds, what is your + average pace (time per mile in minutes and seconds)? What is your + average speed in miles per hour? + +Variables, expressions and statements +===================================== + +One of the most powerful features of a programming language is the +ability to manipulate **variables**. A variable is a name that refers to +a value. + +Assignment statements +--------------------- + +An **assignment statement** creates a new variable and gives it a value: + +:: + + >>> message = 'And now for something completely different' + >>> n = 17 + >>> pi = 3.141592653589793 + +This example makes three assignments. The first assigns a string to a +new variable named message; the second gives the integer 17 to n; the +third assigns the (approximate) value of :math:`\pi` to pi. + +A common way to represent variables on paper is to write the name with +an arrow pointing to its value. This kind of figure is called a **state +diagram** because it shows what state each of the variables is in (think +of it as the variable’s state of mind). Figure [fig.state2] shows the +result of the previous example. + +.. figure:: figs/state2.pdf + :alt: State diagram. + + State diagram. + +Variable names +-------------- + +Programmers generally choose names for their variables that are +meaningful—they document what the variable is used for. + +Variable names can be as long as you like. They can contain both letters +and numbers, but they can’t begin with a number. It is legal to use +uppercase letters, but it is conventional to use only lower case for +variables names. + +The underscore character, ``_``, can appear in a name. It is often used +in names with multiple words, such as ``your_name`` or +``airspeed_of_unladen_swallow``. + +If you give a variable an illegal name, you get a syntax error: + +:: + + >>> 76trombones = 'big parade' + SyntaxError: invalid syntax + >>> more@ = 1000000 + SyntaxError: invalid syntax + >>> class = 'Advanced Theoretical Zymurgy' + SyntaxError: invalid syntax + +76trombones is illegal because it begins with a number. more@ is illegal +because it contains an illegal character, @. But what’s wrong with +class? + +It turns out that class is one of Python’s **keywords**. The interpreter +uses keywords to recognize the structure of the program, and they cannot +be used as variable names. + +Python 3 has these keywords: + +:: + + False class finally is return + None continue for lambda try + True def from nonlocal while + and del global not with + as elif if or yield + assert else import pass + break except in raise + +You don’t have to memorize this list. In most development environments, +keywords are displayed in a different color; if you try to use one as a +variable name, you’ll know. + +Expressions and statements +-------------------------- + +An **expression** is a combination of values, variables, and operators. +A value all by itself is considered an expression, and so is a variable, +so the following are all legal expressions: + +:: + + >>> 42 + 42 + >>> n + 17 + >>> n + 25 + 42 + +When you type an expression at the prompt, the interpreter **evaluates** +it, which means that it finds the value of the expression. In this +example, n has the value 17 and n + 25 has the value 42. + +A **statement** is a unit of code that has an effect, like creating a +variable or displaying a value. + +:: + + >>> n = 17 + >>> print(n) + +The first line is an assignment statement that gives a value to n. The +second line is a print statement that displays the value of n. + +When you type a statement, the interpreter **executes** it, which means +that it does whatever the statement says. In general, statements don’t +have values. + +Script mode +----------- + +So far we have run Python in **interactive mode**, which means that you +interact directly with the interpreter. Interactive mode is a good way +to get started, but if you are working with more than a few lines of +code, it can be clumsy. + +The alternative is to save code in a file called a **script** and then +run the interpreter in **script mode** to execute the script. By +convention, Python scripts have names that end with .py. + +If you know how to create and run a script on your computer, you are +ready to go. Otherwise I recommend using PythonAnywhere again. I have +posted instructions for running in script mode at +http://tinyurl.com/thinkpython2e. + +Because Python provides both modes, you can test bits of code in +interactive mode before you put them in a script. But there are +differences between interactive mode and script mode that can be +confusing. + +For example, if you are using Python as a calculator, you might type + +:: + + >>> miles = 26.2 + >>> miles * 1.61 + 42.182 + +The first line assigns a value to miles, but it has no visible effect. +The second line is an expression, so the interpreter evaluates it and +displays the result. It turns out that a marathon is about 42 +kilometers. + +But if you type the same code into a script and run it, you get no +output at all. In script mode an expression, all by itself, has no +visible effect. Python actually evaluates the expression, but it doesn’t +display the value unless you tell it to: + +:: + + miles = 26.2 + print(miles * 1.61) + +This behavior can be confusing at first. + +A script usually contains a sequence of statements. If there is more +than one statement, the results appear one at a time as the statements +execute. + +For example, the script + +:: + + print(1) + x = 2 + print(x) + +produces the output + +:: + + 1 + 2 + +The assignment statement produces no output. + +To check your understanding, type the following statements in the Python +interpreter and see what they do: + +:: + + 5 + x = 5 + x + 1 + +Now put the same statements in a script and run it. What is the output? +Modify the script by transforming each expression into a print statement +and then run it again. + +Order of operations +------------------- + +When an expression contains more than one operator, the order of +evaluation depends on the **order of operations**. For mathematical +operators, Python follows mathematical convention. The acronym +**PEMDAS** is a useful way to remember the rules: + +- **P**\ arentheses have the highest precedence and can be used to + force an expression to evaluate in the order you want. Since + expressions in parentheses are evaluated first, 2 \* (3-1) is 4, and + (1+1)\*\*(5-2) is 8. You can also use parentheses to make an + expression easier to read, as in (minute \* 100) / 60, even if it + doesn’t change the result. + +- **E**\ xponentiation has the next highest precedence, so 1 + 2\*\*3 + is 9, not 27, and 2 \* 3\*\*2 is 18, not 36. + +- **M**\ ultiplication and **D**\ ivision have higher precedence than + **A**\ ddition and **S**\ ubtraction. So 2\*3-1 is 5, not 4, and + 6+4/2 is 8, not 5. + +- Operators with the same precedence are evaluated from left to right + (except exponentiation). So in the expression degrees / 2 \* pi, the + division happens first and the result is multiplied by pi. To divide + by :math:`2 \pi`, you can use parentheses or write degrees / 2 / pi. + +I don’t work very hard to remember the precedence of operators. If I +can’t tell by looking at the expression, I use parentheses to make it +obvious. + +String operations +----------------- + +In general, you can’t perform mathematical operations on strings, even +if the strings look like numbers, so the following are illegal: + +:: + + '2'-'1' 'eggs'/'easy' 'third'*'a charm' + +But there are two exceptions, + and . + +The + operator performs **string concatenation**, which means it joins +the strings by linking them end-to-end. For example: + +:: + + >>> first = 'throat' + >>> second = 'warbler' + >>> first + second + throatwarbler + +The operator also works on strings; it performs repetition. For example, +``'Spam'*3`` is ``'SpamSpamSpam'``. If one of the values is a string, +the other has to be an integer. + +This use of + and makes sense by analogy with addition and +multiplication. Just as 4\*3 is equivalent to 4+4+4, we expect +``'Spam'*3`` to be the same as ``'Spam'+'Spam'+'Spam'``, and it is. On +the other hand, there is a significant way in which string concatenation +and repetition are different from integer addition and multiplication. +Can you think of a property that addition has that string concatenation +does not? + +Comments +-------- + +As programs get bigger and more complicated, they get more difficult to +read. Formal languages are dense, and it is often difficult to look at a +piece of code and figure out what it is doing, or why. + +For this reason, it is a good idea to add notes to your programs to +explain in natural language what the program is doing. These notes are +called **comments**, and they start with the ``#`` symbol: + +:: + + # compute the percentage of the hour that has elapsed + percentage = (minute * 100) / 60 + +In this case, the comment appears on a line by itself. You can also put +comments at the end of a line: + +:: + + percentage = (minute * 100) / 60 # percentage of an hour + +Everything from the # to the end of the line is ignored—it has no effect +on the execution of the program. + +Comments are most useful when they document non-obvious features of the +code. It is reasonable to assume that the reader can figure out *what* +the code does; it is more useful to explain *why*. + +This comment is redundant with the code and useless: + +:: + + v = 5 # assign 5 to v + +This comment contains useful information that is not in the code: + +:: + + v = 5 # velocity in meters/second. + +Good variable names can reduce the need for comments, but long names can +make complex expressions hard to read, so there is a tradeoff. + +Debugging +--------- + +Three kinds of errors can occur in a program: syntax errors, runtime +errors, and semantic errors. It is useful to distinguish between them in +order to track them down more quickly. + +Syntax error: + “Syntax” refers to the structure of a program and the rules about + that structure. For example, parentheses have to come in matching + pairs, so (1 + 2) is legal, but 8) is a **syntax error**. + + If there is a syntax error anywhere in your program, Python displays + an error message and quits, and you will not be able to run the + program. During the first few weeks of your programming career, you + might spend a lot of time tracking down syntax errors. As you gain + experience, you will make fewer errors and find them faster. + +Runtime error: + The second type of error is a runtime error, so called because the + error does not appear until after the program has started running. + These errors are also called **exceptions** because they usually + indicate that something exceptional (and bad) has happened. + + Runtime errors are rare in the simple programs you will see in the + first few chapters, so it might be a while before you encounter one. + +Semantic error: + The third type of error is “semantic”, which means related to + meaning. If there is a semantic error in your program, it will run + without generating error messages, but it will not do the right + thing. It will do something else. Specifically, it will do what you + told it to do. + + Identifying semantic errors can be tricky because it requires you to + work backward by looking at the output of the program and trying to + figure out what it is doing. + +Glossary +-------- + +variable: + A name that refers to a value. + +assignment: + A statement that assigns a value to a variable. + +state diagram: + A graphical representation of a set of variables and the values they + refer to. + +keyword: + A reserved word that is used to parse a program; you cannot use + keywords like if, def, and while as variable names. + +operand: + One of the values on which an operator operates. + +expression: + A combination of variables, operators, and values that represents a + single result. + +evaluate: + To simplify an expression by performing the operations in order to + yield a single value. + +statement: + A section of code that represents a command or action. So far, the + statements we have seen are assignments and print statements. + +execute: + To run a statement and do what it says. + +interactive mode: + A way of using the Python interpreter by typing code at the prompt. + +script mode: + A way of using the Python interpreter to read code from a script and + run it. + +script: + A program stored in a file. + +order of operations: + Rules governing the order in which expressions involving multiple + operators and operands are evaluated. + +concatenate: + To join two operands end-to-end. + +comment: + Information in a program that is meant for other programmers (or + anyone reading the source code) and has no effect on the execution + of the program. + +syntax error: + An error in a program that makes it impossible to parse (and + therefore impossible to interpret). + +exception: + An error that is detected while the program is running. + +semantics: + The meaning of a program. + +semantic error: + An error in a program that makes it do something other than what the + programmer intended. + +Exercises +--------- + +Repeating my advice from the previous chapter, whenever you learn a new +feature, you should try it out in interactive mode and make errors on +purpose to see what goes wrong. + +- We’ve seen that n = 42 is legal. What about 42 = n? + +- How about x = y = 1? + +- In some languages every statement ends with a semi-colon, ;. What + happens if you put a semi-colon at the end of a Python statement? + +- What if you put a period at the end of a statement? + +- In math notation you can multiply :math:`x` and :math:`y` like this: + :math:`x y`. What happens if you try that in Python? + +Practice using the Python interpreter as a calculator: + +#. The volume of a sphere with radius :math:`r` is + :math:`\frac{4}{3} \pi r^3`. What is the volume of a sphere with + radius 5? + +#. Suppose the cover price of a book is $24.95, but bookstores get a 40% + discount. Shipping costs $3 for the first copy and 75 cents for each + additional copy. What is the total wholesale cost for 60 copies? + +#. If I leave my house at 6:52 am and run 1 mile at an easy pace (8:15 + per mile), then 3 miles at tempo (7:12 per mile) and 1 mile at easy + pace again, what time do I get home for breakfast? + +Functions +========= + +In the context of programming, a **function** is a named sequence of +statements that performs a computation. When you define a function, you +specify the name and the sequence of statements. Later, you can “call” +the function by name. + +Function calls +-------------- + +We have already seen one example of a **function call**: + +:: + + >>> type(42) + + +The name of the function is type. The expression in parentheses is +called the **argument** of the function. The result, for this function, +is the type of the argument. + +It is common to say that a function “takes” an argument and “returns” a +result. The result is also called the **return value**. + +Python provides functions that convert values from one type to another. +The int function takes any value and converts it to an integer, if it +can, or complains otherwise: + +:: + + >>> int('32') + 32 + >>> int('Hello') + ValueError: invalid literal for int(): Hello + +int can convert floating-point values to integers, but it doesn’t round +off; it chops off the fraction part: + +:: + + >>> int(3.99999) + 3 + >>> int(-2.3) + -2 + +float converts integers and strings to floating-point numbers: + +:: + + >>> float(32) + 32.0 + >>> float('3.14159') + 3.14159 + +Finally, str converts its argument to a string: + +:: + + >>> str(32) + '32' + >>> str(3.14159) + '3.14159' + +Math functions +-------------- + +Python has a math module that provides most of the familiar mathematical +functions. A **module** is a file that contains a collection of related +functions. + +Before we can use the functions in a module, we have to import it with +an **import statement**: + +:: + + >>> import math + +This statement creates a **module object** named math. If you display +the module object, you get some information about it: + +:: + + >>> math + + +The module object contains the functions and variables defined in the +module. To access one of the functions, you have to specify the name of +the module and the name of the function, separated by a dot (also known +as a period). This format is called **dot notation**. + +:: + + >>> ratio = signal_power / noise_power + >>> decibels = 10 * math.log10(ratio) + + >>> radians = 0.7 + >>> height = math.sin(radians) + +The first example uses ``math.log10`` to compute a signal-to-noise ratio +in decibels (assuming that ``signal_power`` and ``noise_power`` are +defined). The math module also provides log, which computes logarithms +base e. + +The second example finds the sine of radians. The name of the variable +is a hint that sin and the other trigonometric functions (cos, tan, +etc.) take arguments in radians. To convert from degrees to radians, +divide by 180 and multiply by :math:`\pi`: + +:: + + >>> degrees = 45 + >>> radians = degrees / 180.0 * math.pi + >>> math.sin(radians) + 0.707106781187 + +The expression math.pi gets the variable pi from the math module. Its +value is a floating-point approximation of :math:`\pi`, accurate to +about 15 digits. + +If you know trigonometry, you can check the previous result by comparing +it to the square root of two divided by two: + +:: + + >>> math.sqrt(2) / 2.0 + 0.707106781187 + +Composition +----------- + +So far, we have looked at the elements of a program—variables, +expressions, and statements—in isolation, without talking about how to +combine them. + +One of the most useful features of programming languages is their +ability to take small building blocks and **compose** them. For example, +the argument of a function can be any kind of expression, including +arithmetic operators: + +:: + + x = math.sin(degrees / 360.0 * 2 * math.pi) + +And even function calls: + +:: + + x = math.exp(math.log(x+1)) + +Almost anywhere you can put a value, you can put an arbitrary +expression, with one exception: the left side of an assignment statement +has to be a variable name. Any other expression on the left side is a +syntax error (we will see exceptions to this rule later). + +:: + + >>> minutes = hours * 60 # right + >>> hours * 60 = minutes # wrong! + SyntaxError: can't assign to operator + +Adding new functions +-------------------- + +So far, we have only been using the functions that come with Python, but +it is also possible to add new functions. A **function definition** +specifies the name of a new function and the sequence of statements that +run when the function is called. + +Here is an example: + +:: + + def print_lyrics(): + print("I'm a lumberjack, and I'm okay.") + print("I sleep all night and I work all day.") + +def is a keyword that indicates that this is a function definition. The +name of the function is ``print_lyrics``. The rules for function names +are the same as for variable names: letters, numbers and underscore are +legal, but the first character can’t be a number. You can’t use a +keyword as the name of a function, and you should avoid having a +variable and a function with the same name. + +The empty parentheses after the name indicate that this function doesn’t +take any arguments. + +The first line of the function definition is called the **header**; the +rest is called the **body**. The header has to end with a colon and the +body has to be indented. By convention, indentation is always four +spaces. The body can contain any number of statements. + +The strings in the print statements are enclosed in double quotes. +Single quotes and double quotes do the same thing; most people use +single quotes except in cases like this where a single quote (which is +also an apostrophe) appears in the string. + +All quotation marks (single and double) must be “straight quotes”, +usually located next to Enter on the keyboard. “Curly quotes”, like the +ones in this sentence, are not legal in Python. + +If you type a function definition in interactive mode, the interpreter +prints dots (...) to let you know that the definition isn’t complete: + +:: + + >>> def print_lyrics(): + ... print("I'm a lumberjack, and I'm okay.") + ... print("I sleep all night and I work all day.") + ... + +To end the function, you have to enter an empty line. + +Defining a function creates a **function object**, which has type +``function``: + +:: + + >>> print(print_lyrics) + + >>> type(print_lyrics) + + +The syntax for calling the new function is the same as for built-in +functions: + +:: + + >>> print_lyrics() + I'm a lumberjack, and I'm okay. + I sleep all night and I work all day. + +Once you have defined a function, you can use it inside another +function. For example, to repeat the previous refrain, we could write a +function called ``repeat_lyrics``: + +:: + + def repeat_lyrics(): + print_lyrics() + print_lyrics() + +And then call ``repeat_lyrics``: + +:: + + >>> repeat_lyrics() + I'm a lumberjack, and I'm okay. + I sleep all night and I work all day. + I'm a lumberjack, and I'm okay. + I sleep all night and I work all day. + +But that’s not really how the song goes. + +Definitions and uses +-------------------- + +Pulling together the code fragments from the previous section, the whole +program looks like this: + +:: + + def print_lyrics(): + print("I'm a lumberjack, and I'm okay.") + print("I sleep all night and I work all day.") + + def repeat_lyrics(): + print_lyrics() + print_lyrics() + + repeat_lyrics() + +This program contains two function definitions: ``print_lyrics`` and +``repeat_lyrics``. Function definitions get executed just like other +statements, but the effect is to create function objects. The statements +inside the function do not run until the function is called, and the +function definition generates no output. + +As you might expect, you have to create a function before you can run +it. In other words, the function definition has to run before the +function gets called. + +As an exercise, move the last line of this program to the top, so the +function call appears before the definitions. Run the program and see +what error message you get. + +Now move the function call back to the bottom and move the definition of +``print_lyrics`` after the definition of ``repeat_lyrics``. What happens +when you run this program? + +Flow of execution +----------------- + +To ensure that a function is defined before its first use, you have to +know the order statements run in, which is called the **flow of +execution**. + +Execution always begins at the first statement of the program. +Statements are run one at a time, in order from top to bottom. + +Function definitions do not alter the flow of execution of the program, +but remember that statements inside the function don’t run until the +function is called. + +A function call is like a detour in the flow of execution. Instead of +going to the next statement, the flow jumps to the body of the function, +runs the statements there, and then comes back to pick up where it left +off. + +That sounds simple enough, until you remember that one function can call +another. While in the middle of one function, the program might have to +run the statements in another function. Then, while running that new +function, the program might have to run yet another function! + +Fortunately, Python is good at keeping track of where it is, so each +time a function completes, the program picks up where it left off in the +function that called it. When it gets to the end of the program, it +terminates. + +In summary, when you read a program, you don’t always want to read from +top to bottom. Sometimes it makes more sense if you follow the flow of +execution. + +Parameters and arguments +------------------------ + +Some of the functions we have seen require arguments. For example, when +you call math.sin you pass a number as an argument. Some functions take +more than one argument: math.pow takes two, the base and the exponent. + +Inside the function, the arguments are assigned to variables called +**parameters**. Here is a definition for a function that takes an +argument: + +:: + + def print_twice(bruce): + print(bruce) + print(bruce) + +This function assigns the argument to a parameter named bruce. When the +function is called, it prints the value of the parameter (whatever it +is) twice. + +This function works with any value that can be printed. + +:: + + >>> print_twice('Spam') + Spam + Spam + >>> print_twice(42) + 42 + 42 + >>> print_twice(math.pi) + 3.14159265359 + 3.14159265359 + +The same rules of composition that apply to built-in functions also +apply to programmer-defined functions, so we can use any kind of +expression as an argument for ``print_twice``: + +:: + + >>> print_twice('Spam '*4) + Spam Spam Spam Spam + Spam Spam Spam Spam + >>> print_twice(math.cos(math.pi)) + -1.0 + -1.0 + +The argument is evaluated before the function is called, so in the +examples the expressions ``'Spam '*4`` and math.cos(math.pi) are only +evaluated once. + +You can also use a variable as an argument: + +:: + + >>> michael = 'Eric, the half a bee.' + >>> print_twice(michael) + Eric, the half a bee. + Eric, the half a bee. + +The name of the variable we pass as an argument (michael) has nothing to +do with the name of the parameter (bruce). It doesn’t matter what the +value was called back home (in the caller); here in ``print_twice``, we +call everybody bruce. + +Variables and parameters are local +---------------------------------- + +When you create a variable inside a function, it is **local**, which +means that it only exists inside the function. For example: + +:: + + def cat_twice(part1, part2): + cat = part1 + part2 + print_twice(cat) + +This function takes two arguments, concatenates them, and prints the +result twice. Here is an example that uses it: + +:: + + >>> line1 = 'Bing tiddle ' + >>> line2 = 'tiddle bang.' + >>> cat_twice(line1, line2) + Bing tiddle tiddle bang. + Bing tiddle tiddle bang. + +When ``cat_twice`` terminates, the variable cat is destroyed. If we try +to print it, we get an exception: + +:: + + >>> print(cat) + NameError: name 'cat' is not defined + +Parameters are also local. For example, outside ``print_twice``, there +is no such thing as bruce. + +Stack diagrams +-------------- + +To keep track of which variables can be used where, it is sometimes +useful to draw a **stack diagram**. Like state diagrams, stack diagrams +show the value of each variable, but they also show the function each +variable belongs to. + +Each function is represented by a **frame**. A frame is a box with the +name of a function beside it and the parameters and variables of the +function inside it. The stack diagram for the previous example is shown +in Figure [fig.stack]. + +.. figure:: figs/stack.pdf + :alt: Stack diagram. + + Stack diagram. + +The frames are arranged in a stack that indicates which function called +which, and so on. In this example, ``print_twice`` was called by +``cat_twice``, and ``cat_twice`` was called by ``__main__``, which is a +special name for the topmost frame. When you create a variable outside +of any function, it belongs to ``__main__``. + +Each parameter refers to the same value as its corresponding argument. +So, part1 has the same value as line1, part2 has the same value as +line2, and bruce has the same value as cat. + +If an error occurs during a function call, Python prints the name of the +function, the name of the function that called it, and the name of the +function that called *that*, all the way back to ``__main__``. + +For example, if you try to access cat from within ``print_twice``, you +get a NameError: + +:: + + Traceback (innermost last): + File "test.py", line 13, in __main__ + cat_twice(line1, line2) + File "test.py", line 5, in cat_twice + print_twice(cat) + File "test.py", line 9, in print_twice + print(cat) + NameError: name 'cat' is not defined + +This list of functions is called a **traceback**. It tells you what +program file the error occurred in, and what line, and what functions +were executing at the time. It also shows the line of code that caused +the error. + +The order of the functions in the traceback is the same as the order of +the frames in the stack diagram. The function that is currently running +is at the bottom. + +Fruitful functions and void functions +------------------------------------- + +Some of the functions we have used, such as the math functions, return +results; for lack of a better name, I call them **fruitful functions**. +Other functions, like ``print_twice``, perform an action but don’t +return a value. They are called **void functions**. + +When you call a fruitful function, you almost always want to do +something with the result; for example, you might assign it to a +variable or use it as part of an expression: + +:: + + x = math.cos(radians) + golden = (math.sqrt(5) + 1) / 2 + +When you call a function in interactive mode, Python displays the +result: + +:: + + >>> math.sqrt(5) + 2.2360679774997898 + +But in a script, if you call a fruitful function all by itself, the +return value is lost forever! + +:: + + math.sqrt(5) + +This script computes the square root of 5, but since it doesn’t store or +display the result, it is not very useful. + +Void functions might display something on the screen or have some other +effect, but they don’t have a return value. If you assign the result to +a variable, you get a special value called None. + +:: + + >>> result = print_twice('Bing') + Bing + Bing + >>> print(result) + None + +The value None is not the same as the string ``'None'``. It is a special +value that has its own type: + +:: + + >>> print(type(None)) + + +The functions we have written so far are all void. We will start writing +fruitful functions in a few chapters. + +Why functions? +-------------- + +It may not be clear why it is worth the trouble to divide a program into +functions. There are several reasons: + +- Creating a new function gives you an opportunity to name a group of + statements, which makes your program easier to read and debug. + +- Functions can make a program smaller by eliminating repetitive code. + Later, if you make a change, you only have to make it in one place. + +- Dividing a long program into functions allows you to debug the parts + one at a time and then assemble them into a working whole. + +- Well-designed functions are often useful for many programs. Once you + write and debug one, you can reuse it. + +Debugging +--------- + +One of the most important skills you will acquire is debugging. Although +it can be frustrating, debugging is one of the most intellectually rich, +challenging, and interesting parts of programming. + +In some ways debugging is like detective work. You are confronted with +clues and you have to infer the processes and events that led to the +results you see. + +Debugging is also like an experimental science. Once you have an idea +about what is going wrong, you modify your program and try again. If +your hypothesis was correct, you can predict the result of the +modification, and you take a step closer to a working program. If your +hypothesis was wrong, you have to come up with a new one. As Sherlock +Holmes pointed out, “When you have eliminated the impossible, whatever +remains, however improbable, must be the truth.” (A. Conan Doyle, *The +Sign of Four*) + +For some people, programming and debugging are the same thing. That is, +programming is the process of gradually debugging a program until it +does what you want. The idea is that you should start with a working +program and make small modifications, debugging them as you go. + +For example, Linux is an operating system that contains millions of +lines of code, but it started out as a simple program Linus Torvalds +used to explore the Intel 80386 chip. According to Larry Greenfield, +“One of Linus’s earlier projects was a program that would switch between +printing AAAA and BBBB. This later evolved to Linux.” (*The Linux Users’ +Guide* Beta Version 1). + +Glossary +-------- + +function: + A named sequence of statements that performs some useful operation. + Functions may or may not take arguments and may or may not produce a + result. + +function definition: + A statement that creates a new function, specifying its name, + parameters, and the statements it contains. + +function object: + A value created by a function definition. The name of the function + is a variable that refers to a function object. + +header: + The first line of a function definition. + +body: + The sequence of statements inside a function definition. + +parameter: + A name used inside a function to refer to the value passed as an + argument. + +function call: + A statement that runs a function. It consists of the function name + followed by an argument list in parentheses. + +argument: + A value provided to a function when the function is called. This + value is assigned to the corresponding parameter in the function. + +local variable: + A variable defined inside a function. A local variable can only be + used inside its function. + +return value: + The result of a function. If a function call is used as an + expression, the return value is the value of the expression. + +fruitful function: + A function that returns a value. + +void function: + A function that always returns None. + +None: + A special value returned by void functions. + +module: + A file that contains a collection of related functions and other + definitions. + +import statement: + A statement that reads a module file and creates a module object. + +module object: + A value created by an import statement that provides access to the + values defined in a module. + +dot notation: + The syntax for calling a function in another module by specifying + the module name followed by a dot (period) and the function name. + +composition: + Using an expression as part of a larger expression, or a statement + as part of a larger statement. + +flow of execution: + The order statements run in. + +stack diagram: + A graphical representation of a stack of functions, their variables, + and the values they refer to. + +frame: + A box in a stack diagram that represents a function call. It + contains the local variables and parameters of the function. + +traceback: + A list of the functions that are executing, printed when an + exception occurs. + +Exercises +--------- + +Write a function named ``right_justify`` that takes a string named s as +a parameter and prints the string with enough leading spaces so that the +last letter of the string is in column 70 of the display. + +:: + + >>> right_justify('monty') + monty + +Hint: Use string concatenation and repetition. Also, Python provides a +built-in function called len that returns the length of a string, so the +value of ``len('monty')`` is 5. + +A function object is a value you can assign to a variable or pass as an +argument. For example, ``do_twice`` is a function that takes a function +object as an argument and calls it twice: + +:: + + def do_twice(f): + f() + f() + +Here’s an example that uses ``do_twice`` to call a function named +``print_spam`` twice. + +:: + + def print_spam(): + print('spam') + + do_twice(print_spam) + +#. Type this example into a script and test it. + +#. Modify ``do_twice`` so that it takes two arguments, a function object + and a value, and calls the function twice, passing the value as an + argument. + +#. Copy the definition of ``print_twice`` from earlier in this chapter + to your script. + +#. Use the modified version of ``do_twice`` to call ``print_twice`` + twice, passing ``'spam'`` as an argument. + +#. Define a new function called ``do_four`` that takes a function object + and a value and calls the function four times, passing the value as a + parameter. There should be only two statements in the body of this + function, not four. + +Solution: http://thinkpython2.com/code/do_four.py. + +Note: This exercise should be done using only the statements and other +features we have learned so far. + +#. Write a function that draws a grid like the following: + + :: + + + - - - - + - - - - + + | | | + | | | + | | | + | | | + + - - - - + - - - - + + | | | + | | | + | | | + | | | + + - - - - + - - - - + + + Hint: to print more than one value on a line, you can print a + comma-separated sequence of values: + + :: + + print('+', '-') + + By default, print advances to the next line, but you can override + that behavior and put a space at the end, like this: + + :: + + print('+', end=' ') + print('-') + + The output of these statements is ``'+ -'``. + + A print statement with no argument ends the current line and goes to + the next line. + +#. Write a function that draws a similar grid with four rows and four + columns. + +Solution: http://thinkpython2.com/code/grid.py. Credit: This exercise is +based on an exercise in Oualline, *Practical C Programming, Third +Edition*, O’Reilly Media, 1997. + +Case study: interface design +============================ + +This chapter presents a case study that demonstrates a process for +designing functions that work together. + +It introduces the turtle module, which allows you to create images using +turtle graphics. The turtle module is included in most Python +installations, but if you are running Python using PythonAnywhere, you +won’t be able to run the turtle examples (at least you couldn’t when I +wrote this). + +If you have already installed Python on your computer, you should be +able to run the examples. Otherwise, now is a good time to install. I +have posted instructions at http://tinyurl.com/thinkpython2e. + +Code examples from this chapter are available from +http://thinkpython2.com/code/polygon.py. + +The turtle module +----------------- + +To check whether you have the turtle module, open the Python interpreter +and type + +:: + + >>> import turtle + >>> bob = turtle.Turtle() + +When you run this code, it should create a new window with small arrow +that represents the turtle. Close the window. + +Create a file named mypolygon.py and type in the following code: + +:: + + import turtle + bob = turtle.Turtle() + print(bob) + turtle.mainloop() + +The turtle module (with a lowercase ’t’) provides a function called +Turtle (with an uppercase ’T’) that creates a Turtle object, which we +assign to a variable named bob. Printing bob displays something like: + +:: + + + +This means that bob refers to an object with type Turtle as defined in +module turtle. + +``mainloop`` tells the window to wait for the user to do something, +although in this case there’s not much for the user to do except close +the window. + +Once you create a Turtle, you can call a **method** to move it around +the window. A method is similar to a function, but it uses slightly +different syntax. For example, to move the turtle forward: + +:: + + bob.fd(100) + +The method, fd, is associated with the turtle object we’re calling bob. +Calling a method is like making a request: you are asking bob to move +forward. + +The argument of fd is a distance in pixels, so the actual size depends +on your display. + +Other methods you can call on a Turtle are bk to move backward, lt for +left turn, and rt right turn. The argument for lt and rt is an angle in +degrees. + +Also, each Turtle is holding a pen, which is either down or up; if the +pen is down, the Turtle leaves a trail when it moves. The methods pu and +pd stand for “pen up” and “pen down”. + +To draw a right angle, add these lines to the program (after creating +bob and before calling ``mainloop``): + +:: + + bob.fd(100) + bob.lt(90) + bob.fd(100) + +When you run this program, you should see bob move east and then north, +leaving two line segments behind. + +Now modify the program to draw a square. Don’t go on until you’ve got it +working! + +Simple repetition +----------------- + +Chances are you wrote something like this: + +:: + + bob.fd(100) + bob.lt(90) + + bob.fd(100) + bob.lt(90) + + bob.fd(100) + bob.lt(90) + + bob.fd(100) + +We can do the same thing more concisely with a for statement. Add this +example to mypolygon.py and run it again: + +:: + + for i in range(4): + print('Hello!') + +You should see something like this: + +:: + + Hello! + Hello! + Hello! + Hello! + +This is the simplest use of the for statement; we will see more later. +But that should be enough to let you rewrite your square-drawing +program. Don’t go on until you do. + +Here is a for statement that draws a square: + +:: + + for i in range(4): + bob.fd(100) + bob.lt(90) + +The syntax of a for statement is similar to a function definition. It +has a header that ends with a colon and an indented body. The body can +contain any number of statements. + +A for statement is also called a **loop** because the flow of execution +runs through the body and then loops back to the top. In this case, it +runs the body four times. + +This version is actually a little different from the previous +square-drawing code because it makes another turn after drawing the last +side of the square. The extra turn takes more time, but it simplifies +the code if we do the same thing every time through the loop. This +version also has the effect of leaving the turtle back in the starting +position, facing in the starting direction. + +Exercises +--------- + +The following is a series of exercises using TurtleWorld. They are meant +to be fun, but they have a point, too. While you are working on them, +think about what the point is. + +The following sections have solutions to the exercises, so don’t look +until you have finished (or at least tried). + +#. Write a function called square that takes a parameter named t, which + is a turtle. It should use the turtle to draw a square. + + Write a function call that passes bob as an argument to square, and + then run the program again. + +#. Add another parameter, named length, to square. Modify the body so + length of the sides is length, and then modify the function call to + provide a second argument. Run the program again. Test your program + with a range of values for length. + +#. Make a copy of square and change the name to polygon. Add another + parameter named n and modify the body so it draws an n-sided regular + polygon. Hint: The exterior angles of an n-sided regular polygon are + :math:`360/n` degrees. + +#. Write a function called circle that takes a turtle, t, and radius, r, + as parameters and that draws an approximate circle by calling polygon + with an appropriate length and number of sides. Test your function + with a range of values of r. + + Hint: figure out the circumference of the circle and make sure that + length \* n = circumference. + +#. Make a more general version of circle called arc that takes an + additional parameter angle, which determines what fraction of a + circle to draw. angle is in units of degrees, so when angle=360, arc + should draw a complete circle. + +Encapsulation +------------- + +The first exercise asks you to put your square-drawing code into a +function definition and then call the function, passing the turtle as a +parameter. Here is a solution: + +:: + + def square(t): + for i in range(4): + t.fd(100) + t.lt(90) + + square(bob) + +The innermost statements, fd and lt are indented twice to show that they +are inside the for loop, which is inside the function definition. The +next line, square(bob), is flush with the left margin, which indicates +the end of both the for loop and the function definition. + +Inside the function, t refers to the same turtle bob, so t.lt(90) has +the same effect as bob.lt(90). In that case, why not call the parameter +bob? The idea is that t can be any turtle, not just bob, so you could +create a second turtle and pass it as an argument to square: + +:: + + alice = Turtle() + square(alice) + +Wrapping a piece of code up in a function is called **encapsulation**. +One of the benefits of encapsulation is that it attaches a name to the +code, which serves as a kind of documentation. Another advantage is that +if you re-use the code, it is more concise to call a function twice than +to copy and paste the body! + +Generalization +-------------- + +The next step is to add a length parameter to square. Here is a +solution: + +:: + + def square(t, length): + for i in range(4): + t.fd(length) + t.lt(90) + + square(bob, 100) + +Adding a parameter to a function is called **generalization** because it +makes the function more general: in the previous version, the square is +always the same size; in this version it can be any size. + +The next step is also a generalization. Instead of drawing squares, +polygon draws regular polygons with any number of sides. Here is a +solution: + +:: + + def polygon(t, n, length): + angle = 360 / n + for i in range(n): + t.fd(length) + t.lt(angle) + + polygon(bob, 7, 70) + +This example draws a 7-sided polygon with side length 70. + +If you are using Python 2, the value of angle might be off because of +integer division. A simple solution is to compute angle = 360.0 / n. +Because the numerator is a floating-point number, the result is floating +point. + +When a function has more than a few numeric arguments, it is easy to +forget what they are, or what order they should be in. In that case it +is often a good idea to include the names of the parameters in the +argument list: + +:: + + polygon(bob, n=7, length=70) + +These are called **keyword arguments** because they include the +parameter names as “keywords” (not to be confused with Python keywords +like while and def). + +This syntax makes the program more readable. It is also a reminder about +how arguments and parameters work: when you call a function, the +arguments are assigned to the parameters. + +Interface design +---------------- + +The next step is to write circle, which takes a radius, r, as a +parameter. Here is a simple solution that uses polygon to draw a +50-sided polygon: + +:: + + import math + + def circle(t, r): + circumference = 2 * math.pi * r + n = 50 + length = circumference / n + polygon(t, n, length) + +The first line computes the circumference of a circle with radius r +using the formula :math:`2 \pi r`. Since we use math.pi, we have to +import math. By convention, import statements are usually at the +beginning of the script. + +n is the number of line segments in our approximation of a circle, so +length is the length of each segment. Thus, polygon draws a 50-sides +polygon that approximates a circle with radius r. + +One limitation of this solution is that n is a constant, which means +that for very big circles, the line segments are too long, and for small +circles, we waste time drawing very small segments. One solution would +be to generalize the function by taking n as a parameter. This would +give the user (whoever calls circle) more control, but the interface +would be less clean. + +The **interface** of a function is a summary of how it is used: what are +the parameters? What does the function do? And what is the return value? +An interface is “clean” if it allows the caller to do what they want +without dealing with unnecessary details. + +In this example, r belongs in the interface because it specifies the +circle to be drawn. n is less appropriate because it pertains to the +details of *how* the circle should be rendered. + +Rather than clutter up the interface, it is better to choose an +appropriate value of n depending on circumference: + +:: + + def circle(t, r): + circumference = 2 * math.pi * r + n = int(circumference / 3) + 1 + length = circumference / n + polygon(t, n, length) + +Now the number of segments is an integer near circumference/3, so the +length of each segment is approximately 3, which is small enough that +the circles look good, but big enough to be efficient, and acceptable +for any size circle. + +Refactoring +----------- + +When I wrote circle, I was able to re-use polygon because a many-sided +polygon is a good approximation of a circle. But arc is not as +cooperative; we can’t use polygon or circle to draw an arc. + +One alternative is to start with a copy of polygon and transform it into +arc. The result might look like this: + +:: + + def arc(t, r, angle): + arc_length = 2 * math.pi * r * angle / 360 + n = int(arc_length / 3) + 1 + step_length = arc_length / n + step_angle = angle / n + + for i in range(n): + t.fd(step_length) + t.lt(step_angle) + +The second half of this function looks like polygon, but we can’t re-use +polygon without changing the interface. We could generalize polygon to +take an angle as a third argument, but then polygon would no longer be +an appropriate name! Instead, let’s call the more general function +polyline: + +:: + + def polyline(t, n, length, angle): + for i in range(n): + t.fd(length) + t.lt(angle) + +Now we can rewrite polygon and arc to use polyline: + +:: + + def polygon(t, n, length): + angle = 360.0 / n + polyline(t, n, length, angle) + + def arc(t, r, angle): + arc_length = 2 * math.pi * r * angle / 360 + n = int(arc_length / 3) + 1 + step_length = arc_length / n + step_angle = float(angle) / n + polyline(t, n, step_length, step_angle) + +Finally, we can rewrite circle to use arc: + +:: + + def circle(t, r): + arc(t, r, 360) + +This process—rearranging a program to improve interfaces and facilitate +code re-use—is called **refactoring**. In this case, we noticed that +there was similar code in arc and polygon, so we “factored it out” into +polyline. + +If we had planned ahead, we might have written polyline first and +avoided refactoring, but often you don’t know enough at the beginning of +a project to design all the interfaces. Once you start coding, you +understand the problem better. Sometimes refactoring is a sign that you +have learned something. + +A development plan +------------------ + +A **development plan** is a process for writing programs. The process we +used in this case study is “encapsulation and generalization”. The steps +of this process are: + +#. Start by writing a small program with no function definitions. + +#. Once you get the program working, identify a coherent piece of it, + encapsulate the piece in a function and give it a name. + +#. Generalize the function by adding appropriate parameters. + +#. Repeat steps 1–3 until you have a set of working functions. Copy and + paste working code to avoid retyping (and re-debugging). + +#. Look for opportunities to improve the program by refactoring. For + example, if you have similar code in several places, consider + factoring it into an appropriately general function. + +This process has some drawbacks—we will see alternatives later—but it +can be useful if you don’t know ahead of time how to divide the program +into functions. This approach lets you design as you go along. + +docstring +--------- + +A **docstring** is a string at the beginning of a function that explains +the interface (“doc” is short for “documentation”). Here is an example: + +:: + + def polyline(t, n, length, angle): + """Draws n line segments with the given length and + angle (in degrees) between them. t is a turtle. + """ + for i in range(n): + t.fd(length) + t.lt(angle) + +By convention, all docstrings are triple-quoted strings, also known as +multiline strings because the triple quotes allow the string to span +more than one line. + +It is terse, but it contains the essential information someone would +need to use this function. It explains concisely what the function does +(without getting into the details of how it does it). It explains what +effect each parameter has on the behavior of the function and what type +each parameter should be (if it is not obvious). + +Writing this kind of documentation is an important part of interface +design. A well-designed interface should be simple to explain; if you +have a hard time explaining one of your functions, maybe the interface +could be improved. + +Debugging +--------- + +An interface is like a contract between a function and a caller. The +caller agrees to provide certain parameters and the function agrees to +do certain work. + +For example, polyline requires four arguments: t has to be a Turtle; n +has to be an integer; length should be a positive number; and angle has +to be a number, which is understood to be in degrees. + +These requirements are called **preconditions** because they are +supposed to be true before the function starts executing. Conversely, +conditions at the end of the function are **postconditions**. +Postconditions include the intended effect of the function (like drawing +line segments) and any side effects (like moving the Turtle or making +other changes). + +Preconditions are the responsibility of the caller. If the caller +violates a (properly documented!) precondition and the function doesn’t +work correctly, the bug is in the caller, not the function. + +If the preconditions are satisfied and the postconditions are not, the +bug is in the function. If your pre- and postconditions are clear, they +can help with debugging. + +Glossary +-------- + +method: + A function that is associated with an object and called using dot + notation. + +loop: + A part of a program that can run repeatedly. + +encapsulation: + The process of transforming a sequence of statements into a function + definition. + +generalization: + The process of replacing something unnecessarily specific (like a + number) with something appropriately general (like a variable or + parameter). + +keyword argument: + An argument that includes the name of the parameter as a “keyword”. + +interface: + A description of how to use a function, including the name and + descriptions of the arguments and return value. + +refactoring: + The process of modifying a working program to improve function + interfaces and other qualities of the code. + +development plan: + A process for writing programs. + +docstring: + A string that appears at the top of a function definition to + document the function’s interface. + +precondition: + A requirement that should be satisfied by the caller before a + function starts. + +postcondition: + A requirement that should be satisfied by the function before it + ends. + +Exercises +--------- + +Download the code in this chapter from +http://thinkpython2.com/code/polygon.py. + +#. Draw a stack diagram that shows the state of the program while + executing circle(bob, radius). You can do the arithmetic by hand or + add print statements to the code. + +#. The version of arc in Section [refactoring] is not very accurate + because the linear approximation of the circle is always outside the + true circle. As a result, the Turtle ends up a few pixels away from + the correct destination. My solution shows a way to reduce the effect + of this error. Read the code and see if it makes sense to you. If you + draw a diagram, you might see how it works. + +.. figure:: figs/flowers.pdf + :alt: Turtle flowers. + + Turtle flowers. + +Write an appropriately general set of functions that can draw flowers as +in Figure [fig.flowers]. + +Solution: http://thinkpython2.com/code/flower.py, also requires +http://thinkpython2.com/code/polygon.py. + +.. figure:: figs/pies.pdf + :alt: Turtle pies. + + Turtle pies. + +Write an appropriately general set of functions that can draw shapes as +in Figure [fig.pies]. + +Solution: http://thinkpython2.com/code/pie.py. + +The letters of the alphabet can be constructed from a moderate number of +basic elements, like vertical and horizontal lines and a few curves. +Design an alphabet that can be drawn with a minimal number of basic +elements and then write functions that draw the letters. + +You should write one function for each letter, with names ``draw_a``, +``draw_b``, etc., and put your functions in a file named letters.py. You +can download a “turtle typewriter” from +http://thinkpython2.com/code/typewriter.py to help you test your code. + +You can get a solution from http://thinkpython2.com/code/letters.py; it +also requires http://thinkpython2.com/code/polygon.py. + +Read about spirals at http://en.wikipedia.org/wiki/Spiral; then write a +program that draws an Archimedian spiral (or one of the other kinds). +Solution: http://thinkpython2.com/code/spiral.py. + +Conditionals and recursion +========================== + +The main topic of this chapter is the if statement, which executes +different code depending on the state of the program. But first I want +to introduce two new operators: floor division and modulus. + +Floor division and modulus +-------------------------- + +The **floor division** operator, ``//``, divides two numbers and rounds +down to an integer. For example, suppose the run time of a movie is 105 +minutes. You might want to know how long that is in hours. Conventional +division returns a floating-point number: + +:: + + >>> minutes = 105 + >>> minutes / 60 + 1.75 + +But we don’t normally write hours with decimal points. Floor division +returns the integer number of hours, dropping the fraction part: + +:: + + >>> minutes = 105 + >>> hours = minutes // 60 + >>> hours + 1 + +To get the remainder, you could subtract off one hour in minutes: + +:: + + >>> remainder = minutes - hours * 60 + >>> remainder + 45 + +An alternative is to use the **modulus operator**, ``%``, which divides +two numbers and returns the remainder. + +:: + + >>> remainder = minutes % 60 + >>> remainder + 45 + +The modulus operator is more useful than it seems. For example, you can +check whether one number is divisible by another—if x % y is zero, then +x is divisible by y. + +Also, you can extract the right-most digit or digits from a number. For +example, x % 10 yields the right-most digit of x (in base 10). Similarly +x % 100 yields the last two digits. + +If you are using Python 2, division works differently. The division +operator, ``/``, performs floor division if both operands are integers, +and floating-point division if either operand is a float. + +Boolean expressions +------------------- + +A **boolean expression** is an expression that is either true or false. +The following examples use the operator ==, which compares two operands +and produces True if they are equal and False otherwise: + +:: + + >>> 5 == 5 + True + >>> 5 == 6 + False + +True and False are special values that belong to the type bool; they are +not strings: + +:: + + >>> type(True) + + >>> type(False) + + +The == operator is one of the **relational operators**; the others are: + +:: + + x != y # x is not equal to y + x > y # x is greater than y + x < y # x is less than y + x >= y # x is greater than or equal to y + x <= y # x is less than or equal to y + +Although these operations are probably familiar to you, the Python +symbols are different from the mathematical symbols. A common error is +to use a single equal sign (=) instead of a double equal sign (==). +Remember that = is an assignment operator and == is a relational +operator. There is no such thing as =< or =>. + +Logical operators +----------------- + +There are three **logical operators**: and, or, and not. The semantics +(meaning) of these operators is similar to their meaning in English. For +example, x > 0 and x < 10 is true only if x is greater than 0 *and* less +than 10. + +n%2 == 0 or n%3 == 0 is true if *either or both* of the conditions is +true, that is, if the number is divisible by 2 *or* 3. + +Finally, the not operator negates a boolean expression, so not (x > y) +is true if x > y is false, that is, if x is less than or equal to y. + +Strictly speaking, the operands of the logical operators should be +boolean expressions, but Python is not very strict. Any nonzero number +is interpreted as True: + +:: + + >>> 42 and True + True + +This flexibility can be useful, but there are some subtleties to it that +might be confusing. You might want to avoid it (unless you know what you +are doing). + +Conditional execution +--------------------- + +In order to write useful programs, we almost always need the ability to +check conditions and change the behavior of the program accordingly. +**Conditional statements** give us this ability. The simplest form is +the if statement: + +:: + + if x > 0: + print('x is positive') + +The boolean expression after if is called the **condition**. If it is +true, the indented statement runs. If not, nothing happens. + +if statements have the same structure as function definitions: a header +followed by an indented body. Statements like this are called **compound +statements**. + +There is no limit on the number of statements that can appear in the +body, but there has to be at least one. Occasionally, it is useful to +have a body with no statements (usually as a place keeper for code you +haven’t written yet). In that case, you can use the pass statement, +which does nothing. + +:: + + if x < 0: + pass # TODO: need to handle negative values! + +Alternative execution +--------------------- + +A second form of the if statement is “alternative execution”, in which +there are two possibilities and the condition determines which one runs. +The syntax looks like this: + +:: + + if x % 2 == 0: + print('x is even') + else: + print('x is odd') + +If the remainder when x is divided by 2 is 0, then we know that x is +even, and the program displays an appropriate message. If the condition +is false, the second set of statements runs. Since the condition must be +true or false, exactly one of the alternatives will run. The +alternatives are called **branches**, because they are branches in the +flow of execution. + +Chained conditionals +-------------------- + +Sometimes there are more than two possibilities and we need more than +two branches. One way to express a computation like that is a **chained +conditional**: + +:: + + if x < y: + print('x is less than y') + elif x > y: + print('x is greater than y') + else: + print('x and y are equal') + +elif is an abbreviation of “else if”. Again, exactly one branch will +run. There is no limit on the number of elif statements. If there is an +else clause, it has to be at the end, but there doesn’t have to be one. + +:: + + if choice == 'a': + draw_a() + elif choice == 'b': + draw_b() + elif choice == 'c': + draw_c() + +Each condition is checked in order. If the first is false, the next is +checked, and so on. If one of them is true, the corresponding branch +runs and the statement ends. Even if more than one condition is true, +only the first true branch runs. + +Nested conditionals +------------------- + +One conditional can also be nested within another. We could have written +the example in the previous section like this: + +:: + + if x == y: + print('x and y are equal') + else: + if x < y: + print('x is less than y') + else: + print('x is greater than y') + +The outer conditional contains two branches. The first branch contains a +simple statement. The second branch contains another if statement, which +has two branches of its own. Those two branches are both simple +statements, although they could have been conditional statements as +well. + +Although the indentation of the statements makes the structure apparent, +**nested conditionals** become difficult to read very quickly. It is a +good idea to avoid them when you can. + +Logical operators often provide a way to simplify nested conditional +statements. For example, we can rewrite the following code using a +single conditional: + +:: + + if 0 < x: + if x < 10: + print('x is a positive single-digit number.') + +The print statement runs only if we make it past both conditionals, so +we can get the same effect with the and operator: + +:: + + if 0 < x and x < 10: + print('x is a positive single-digit number.') + +For this kind of condition, Python provides a more concise option: + +:: + + if 0 < x < 10: + print('x is a positive single-digit number.') + +Recursion +--------- + +It is legal for one function to call another; it is also legal for a +function to call itself. It may not be obvious why that is a good thing, +but it turns out to be one of the most magical things a program can do. +For example, look at the following function: + +:: + + def countdown(n): + if n <= 0: + print('Blastoff!') + else: + print(n) + countdown(n-1) + +If n is 0 or negative, it outputs the word, “Blastoff!” Otherwise, it +outputs n and then calls a function named countdown—itself—passing n-1 +as an argument. + +What happens if we call this function like this? + +:: + + >>> countdown(3) + +The execution of countdown begins with n=3, and since n is greater than +0, it outputs the value 3, and then calls itself... + + The execution of countdown begins with n=2, and since n is greater + than 0, it outputs the value 2, and then calls itself... + + The execution of countdown begins with n=1, and since n is + greater than 0, it outputs the value 1, and then calls itself... + + The execution of countdown begins with n=0, and since n is + not greater than 0, it outputs the word, “Blastoff!” and + then returns. + + The countdown that got n=1 returns. + + The countdown that got n=2 returns. + +The countdown that got n=3 returns. + +And then you’re back in ``__main__``. So, the total output looks like +this: + +:: + + 3 + 2 + 1 + Blastoff! + +A function that calls itself is **recursive**; the process of executing +it is called **recursion**. + +As another example, we can write a function that prints a string n +times. + +:: + + def print_n(s, n): + if n <= 0: + return + print(s) + print_n(s, n-1) + +If n <= 0 the **return statement** exits the function. The flow of +execution immediately returns to the caller, and the remaining lines of +the function don’t run. + +The rest of the function is similar to countdown: it displays s and then +calls itself to display s :math:`n-1` additional times. So the number of +lines of output is 1 + (n - 1), which adds up to n. + +For simple examples like this, it is probably easier to use a for loop. +But we will see examples later that are hard to write with a for loop +and easy to write with recursion, so it is good to start early. + +Stack diagrams for recursive functions +-------------------------------------- + +In Section [stackdiagram], we used a stack diagram to represent the +state of a program during a function call. The same kind of diagram can +help interpret a recursive function. + +Every time a function gets called, Python creates a frame to contain the +function’s local variables and parameters. For a recursive function, +there might be more than one frame on the stack at the same time. + +Figure [fig.stack2] shows a stack diagram for countdown called with n = +3. + +.. figure:: figs/stack2.pdf + :alt: Stack diagram. + + Stack diagram. + +As usual, the top of the stack is the frame for ``__main__``. It is +empty because we did not create any variables in ``__main__`` or pass +any arguments to it. + +The four countdown frames have different values for the parameter n. The +bottom of the stack, where n=0, is called the **base case**. It does not +make a recursive call, so there are no more frames. + +As an exercise, draw a stack diagram for ``print_n`` called with +``s = 'Hello'`` and n=2. Then write a function called ``do_n`` that +takes a function object and a number, n, as arguments, and that calls +the given function n times. + +Infinite recursion +------------------ + +If a recursion never reaches a base case, it goes on making recursive +calls forever, and the program never terminates. This is known as +**infinite recursion**, and it is generally not a good idea. Here is a +minimal program with an infinite recursion: + +:: + + def recurse(): + recurse() + +In most programming environments, a program with infinite recursion does +not really run forever. Python reports an error message when the maximum +recursion depth is reached: + +:: + + File "", line 2, in recurse + File "", line 2, in recurse + File "", line 2, in recurse + . + . + . + File "", line 2, in recurse + RuntimeError: Maximum recursion depth exceeded + +This traceback is a little bigger than the one we saw in the previous +chapter. When the error occurs, there are 1000 recurse frames on the +stack! + +If you write encounter an infinite recursion by accident, review your +function to confirm that there is a base case that does not make a +recursive call. And if there is a base case, check whether you are +guaranteed to reach it. + +Keyboard input +-------------- + +The programs we have written so far accept no input from the user. They +just do the same thing every time. + +Python provides a built-in function called input that stops the program +and waits for the user to type something. When the user presses Return +or Enter, the program resumes and ``input`` returns what the user typed +as a string. In Python 2, the same function is called ``raw_input``. + +:: + + >>> text = input() + What are you waiting for? + >>> text + What are you waiting for? + +Before getting input from the user, it is a good idea to print a prompt +telling the user what to type. ``input`` can take a prompt as an +argument: + +:: + + >>> name = input('What...is your name?\n') + What...is your name? + Arthur, King of the Britons! + >>> name + Arthur, King of the Britons! + +The sequence ``\n`` at the end of the prompt represents a **newline**, +which is a special character that causes a line break. That’s why the +user’s input appears below the prompt. + +If you expect the user to type an integer, you can try to convert the +return value to int: + +:: + + >>> prompt = 'What...is the airspeed velocity of an unladen swallow?\n' + >>> speed = input(prompt) + What...is the airspeed velocity of an unladen swallow? + 42 + >>> int(speed) + 42 + +But if the user types something other than a string of digits, you get +an error: + +:: + + >>> speed = input(prompt) + What...is the airspeed velocity of an unladen swallow? + What do you mean, an African or a European swallow? + >>> int(speed) + ValueError: invalid literal for int() with base 10 + +We will see how to handle this kind of error later. + +Debugging +--------- + +When a syntax or runtime error occurs, the error message contains a lot +of information, but it can be overwhelming. The most useful parts are +usually: + +- What kind of error it was, and + +- Where it occurred. + +Syntax errors are usually easy to find, but there are a few gotchas. +Whitespace errors can be tricky because spaces and tabs are invisible +and we are used to ignoring them. + +:: + + >>> x = 5 + >>> y = 6 + File "", line 1 + y = 6 + ^ + IndentationError: unexpected indent + +In this example, the problem is that the second line is indented by one +space. But the error message points to y, which is misleading. In +general, error messages indicate where the problem was discovered, but +the actual error might be earlier in the code, sometimes on a previous +line. + +The same is true of runtime errors. Suppose you are trying to compute a +signal-to-noise ratio in decibels. The formula is +:math:`SNR_{db} = 10 \log_{10} (P_{signal} / P_{noise})`. In Python, you +might write something like this: + +:: + + import math + signal_power = 9 + noise_power = 10 + ratio = signal_power // noise_power + decibels = 10 * math.log10(ratio) + print(decibels) + +When you run this program, you get an exception: + +:: + + Traceback (most recent call last): + File "snr.py", line 5, in ? + decibels = 10 * math.log10(ratio) + ValueError: math domain error + +The error message indicates line 5, but there is nothing wrong with that +line. To find the real error, it might be useful to print the value of +ratio, which turns out to be 0. The problem is in line 4, which uses +floor division instead of floating-point division. + +You should take the time to read error messages carefully, but don’t +assume that everything they say is correct. + +Glossary +-------- + +floor division: + An operator, denoted //, that divides two numbers and rounds down + (toward zero) to an integer. + +modulus operator: + An operator, denoted with a percent sign (%), that works on integers + and returns the remainder when one number is divided by another. + +boolean expression: + An expression whose value is either True or False. + +relational operator: + One of the operators that compares its operands: ==, !=, >, <, >=, + and <=. + +logical operator: + One of the operators that combines boolean expressions: and, or, and + not. + +conditional statement: + A statement that controls the flow of execution depending on some + condition. + +condition: + The boolean expression in a conditional statement that determines + which branch runs. + +compound statement: + A statement that consists of a header and a body. The header ends + with a colon (:). The body is indented relative to the header. + +branch: + One of the alternative sequences of statements in a conditional + statement. + +chained conditional: + A conditional statement with a series of alternative branches. + +nested conditional: + A conditional statement that appears in one of the branches of + another conditional statement. + +return statement: + A statement that causes a function to end immediately and return to + the caller. + +recursion: + The process of calling the function that is currently executing. + +base case: + A conditional branch in a recursive function that does not make a + recursive call. + +infinite recursion: + A recursion that doesn’t have a base case, or never reaches it. + Eventually, an infinite recursion causes a runtime error. + +Exercises +--------- + +The time module provides a function, also named time, that returns the +current Greenwich Mean Time in “the epoch”, which is an arbitrary time +used as a reference point. On UNIX systems, the epoch is 1 January 1970. + +:: + + >>> import time + >>> time.time() + 1437746094.5735958 + +Write a script that reads the current time and converts it to a time of +day in hours, minutes, and seconds, plus the number of days since the +epoch. + +Fermat’s Last Theorem says that there are no positive integers +:math:`a`, :math:`b`, and :math:`c` such that + +.. math:: a^n + b^n = c^n + +for any values of :math:`n` greater than 2. + +#. Write a function named ``check_fermat`` that takes four parameters—a, + b, c and n—and checks to see if Fermat’s theorem holds. If :math:`n` + is greater than 2 and + + .. math:: a^n + b^n = c^n + + the program should print, “Holy smokes, Fermat was wrong!” Otherwise + the program should print, “No, that doesn’t work.” + +#. Write a function that prompts the user to input values for a, b, c + and n, converts them to integers, and uses ``check_fermat`` to check + whether they violate Fermat’s theorem. + +If you are given three sticks, you may or may not be able to arrange +them in a triangle. For example, if one of the sticks is 12 inches long +and the other two are one inch long, you will not be able to get the +short sticks to meet in the middle. For any three lengths, there is a +simple test to see if it is possible to form a triangle: + + If any of the three lengths is greater than the sum of the other + two, then you cannot form a triangle. Otherwise, you can. (If the + sum of two lengths equals the third, they form what is called a + “degenerate” triangle.) + +#. Write a function named ``is_triangle`` that takes three integers as + arguments, and that prints either “Yes” or “No”, depending on whether + you can or cannot form a triangle from sticks with the given lengths. + +#. Write a function that prompts the user to input three stick lengths, + converts them to integers, and uses ``is_triangle`` to check whether + sticks with the given lengths can form a triangle. + +What is the output of the following program? Draw a stack diagram that +shows the state of the program when it prints the result. + +:: + + def recurse(n, s): + if n == 0: + print(s) + else: + recurse(n-1, n+s) + + recurse(3, 0) + +#. What would happen if you called this function like this: recurse(-1, + 0)? + +#. Write a docstring that explains everything someone would need to know + in order to use this function (and nothing else). + +The following exercises use the turtle module, described in +Chapter [turtlechap]: + +Read the following function and see if you can figure out what it does. +Then run it (see the examples in Chapter [turtlechap]). + +:: + + def draw(t, length, n): + if n == 0: + return + angle = 50 + t.fd(length*n) + t.lt(angle) + draw(t, length, n-1) + t.rt(2*angle) + draw(t, length, n-1) + t.lt(angle) + t.bk(length*n) + +.. figure:: figs/koch.pdf + :alt: A Koch curve. + + A Koch curve. + +The Koch curve is a fractal that looks something like Figure [fig.koch]. +To draw a Koch curve with length :math:`x`, all you have to do is + +#. Draw a Koch curve with length :math:`x/3`. + +#. Turn left 60 degrees. + +#. Draw a Koch curve with length :math:`x/3`. + +#. Turn right 120 degrees. + +#. Draw a Koch curve with length :math:`x/3`. + +#. Turn left 60 degrees. + +#. Draw a Koch curve with length :math:`x/3`. + +The exception is if :math:`x` is less than 3: in that case, you can just +draw a straight line with length :math:`x`. + +#. Write a function called koch that takes a turtle and a length as + parameters, and that uses the turtle to draw a Koch curve with the + given length. + +#. Write a function called snowflake that draws three Koch curves to + make the outline of a snowflake. + + Solution: http://thinkpython2.com/code/koch.py. + +#. The Koch curve can be generalized in several ways. See + http://en.wikipedia.org/wiki/Koch_snowflake for examples and + implement your favorite. + +Fruitful functions +================== + +Many of the Python functions we have used, such as the math functions, +produce return values. But the functions we’ve written are all void: +they have an effect, like printing a value or moving a turtle, but they +don’t have a return value. In this chapter you will learn to write +fruitful functions. + +Return values +------------- + +Calling the function generates a return value, which we usually assign +to a variable or use as part of an expression. + +:: + + e = math.exp(1.0) + height = radius * math.sin(radians) + +The functions we have written so far are void. Speaking casually, they +have no return value; more precisely, their return value is None. + +In this chapter, we are (finally) going to write fruitful functions. The +first example is area, which returns the area of a circle with the given +radius: + +:: + + def area(radius): + a = math.pi * radius**2 + return a + +We have seen the return statement before, but in a fruitful function the +return statement includes an expression. This statement means: “Return +immediately from this function and use the following expression as a +return value.” The expression can be arbitrarily complicated, so we +could have written this function more concisely: + +:: + + def area(radius): + return math.pi * radius**2 + +On the other hand, **temporary variables** like a can make debugging +easier. + +Sometimes it is useful to have multiple return statements, one in each +branch of a conditional: + +:: + + def absolute_value(x): + if x < 0: + return -x + else: + return x + +Since these return statements are in an alternative conditional, only +one runs. + +As soon as a return statement runs, the function terminates without +executing any subsequent statements. Code that appears after a return +statement, or any other place the flow of execution can never reach, is +called **dead code**. + +In a fruitful function, it is a good idea to ensure that every possible +path through the program hits a return statement. For example: + +:: + + def absolute_value(x): + if x < 0: + return -x + if x > 0: + return x + +This function is incorrect because if x happens to be 0, neither +condition is true, and the function ends without hitting a return +statement. If the flow of execution gets to the end of a function, the +return value is None, which is not the absolute value of 0. + +:: + + >>> absolute_value(0) + None + +By the way, Python provides a built-in function called abs that computes +absolute values. + +As an exercise, write a compare function takes two values, x and y, and +returns 1 if x > y, 0 if x == y, and -1 if x < y. + +Incremental development +----------------------- + +As you write larger functions, you might find yourself spending more +time debugging. + +To deal with increasingly complex programs, you might want to try a +process called **incremental development**. The goal of incremental +development is to avoid long debugging sessions by adding and testing +only a small amount of code at a time. + +As an example, suppose you want to find the distance between two points, +given by the coordinates :math:`(x_1, y_1)` and :math:`(x_2, y_2)`. By +the Pythagorean theorem, the distance is: + +.. math:: \mathrm{distance} = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2} + +The first step is to consider what a distance function should look like +in Python. In other words, what are the inputs (parameters) and what is +the output (return value)? + +In this case, the inputs are two points, which you can represent using +four numbers. The return value is the distance represented by a +floating-point value. + +Immediately you can write an outline of the function: + +:: + + def distance(x1, y1, x2, y2): + return 0.0 + +Obviously, this version doesn’t compute distances; it always returns +zero. But it is syntactically correct, and it runs, which means that you +can test it before you make it more complicated. + +To test the new function, call it with sample arguments: + +:: + + >>> distance(1, 2, 4, 6) + 0.0 + +I chose these values so that the horizontal distance is 3 and the +vertical distance is 4; that way, the result is 5, the hypotenuse of a +3-4-5 triangle. When testing a function, it is useful to know the right +answer. + +At this point we have confirmed that the function is syntactically +correct, and we can start adding code to the body. A reasonable next +step is to find the differences :math:`x_2 - x_1` and :math:`y_2 - y_1`. +The next version stores those values in temporary variables and prints +them. + +:: + + def distance(x1, y1, x2, y2): + dx = x2 - x1 + dy = y2 - y1 + print('dx is', dx) + print('dy is', dy) + return 0.0 + +If the function is working, it should display ``dx is 3`` and +``dy is 4``. If so, we know that the function is getting the right +arguments and performing the first computation correctly. If not, there +are only a few lines to check. + +Next we compute the sum of squares of dx and dy: + +:: + + def distance(x1, y1, x2, y2): + dx = x2 - x1 + dy = y2 - y1 + dsquared = dx**2 + dy**2 + print('dsquared is: ', dsquared) + return 0.0 + +Again, you would run the program at this stage and check the output +(which should be 25). Finally, you can use math.sqrt to compute and +return the result: + +:: + + def distance(x1, y1, x2, y2): + dx = x2 - x1 + dy = y2 - y1 + dsquared = dx**2 + dy**2 + result = math.sqrt(dsquared) + return result + +If that works correctly, you are done. Otherwise, you might want to +print the value of result before the return statement. + +The final version of the function doesn’t display anything when it runs; +it only returns a value. The print statements we wrote are useful for +debugging, but once you get the function working, you should remove +them. Code like that is called **scaffolding** because it is helpful for +building the program but is not part of the final product. + +When you start out, you should add only a line or two of code at a time. +As you gain more experience, you might find yourself writing and +debugging bigger chunks. Either way, incremental development can save +you a lot of debugging time. + +The key aspects of the process are: + +#. Start with a working program and make small incremental changes. At + any point, if there is an error, you should have a good idea where it + is. + +#. Use variables to hold intermediate values so you can display and + check them. + +#. Once the program is working, you might want to remove some of the + scaffolding or consolidate multiple statements into compound + expressions, but only if it does not make the program difficult to + read. + +As an exercise, use incremental development to write a function called +hypotenuse that returns the length of the hypotenuse of a right triangle +given the lengths of the other two legs as arguments. Record each stage +of the development process as you go. + +Composition +----------- + +As you should expect by now, you can call one function from within +another. As an example, we’ll write a function that takes two points, +the center of the circle and a point on the perimeter, and computes the +area of the circle. + +Assume that the center point is stored in the variables xc and yc, and +the perimeter point is in xp and yp. The first step is to find the +radius of the circle, which is the distance between the two points. We +just wrote a function, distance, that does that: + +:: + + radius = distance(xc, yc, xp, yp) + +The next step is to find the area of a circle with that radius; we just +wrote that, too: + +:: + + result = area(radius) + +Encapsulating these steps in a function, we get: + +:: + + def circle_area(xc, yc, xp, yp): + radius = distance(xc, yc, xp, yp) + result = area(radius) + return result + +The temporary variables radius and result are useful for development and +debugging, but once the program is working, we can make it more concise +by composing the function calls: + +:: + + def circle_area(xc, yc, xp, yp): + return area(distance(xc, yc, xp, yp)) + +Boolean functions +----------------- + +Functions can return booleans, which is often convenient for hiding +complicated tests inside functions. For example: + +:: + + def is_divisible(x, y): + if x % y == 0: + return True + else: + return False + +It is common to give boolean functions names that sound like yes/no +questions; ``is_divisible`` returns either True or False to indicate +whether x is divisible by y. + +Here is an example: + +:: + + >>> is_divisible(6, 4) + False + >>> is_divisible(6, 3) + True + +The result of the == operator is a boolean, so we can write the function +more concisely by returning it directly: + +:: + + def is_divisible(x, y): + return x % y == 0 + +Boolean functions are often used in conditional statements: + +:: + + if is_divisible(x, y): + print('x is divisible by y') + +It might be tempting to write something like: + +:: + + if is_divisible(x, y) == True: + print('x is divisible by y' + +But the extra comparison is unnecessary. + +As an exercise, write a function ``is_between(x, y, z)`` that returns +True if :math:`x \le y \le z` or False otherwise. + +More recursion +-------------- + +We have only covered a small subset of Python, but you might be +interested to know that this subset is a *complete* programming +language, which means that anything that can be computed can be +expressed in this language. Any program ever written could be rewritten +using only the language features you have learned so far (actually, you +would need a few commands to control devices like the mouse, disks, +etc., but that’s all). + +Proving that claim is a nontrivial exercise first accomplished by Alan +Turing, one of the first computer scientists (some would argue that he +was a mathematician, but a lot of early computer scientists started as +mathematicians). Accordingly, it is known as the Turing Thesis. For a +more complete (and accurate) discussion of the Turing Thesis, I +recommend Michael Sipser’s book *Introduction to the Theory of +Computation*. + +To give you an idea of what you can do with the tools you have learned +so far, we’ll evaluate a few recursively defined mathematical functions. +A recursive definition is similar to a circular definition, in the sense +that the definition contains a reference to the thing being defined. A +truly circular definition is not very useful: + +vorpal: + An adjective used to describe something that is vorpal. + +If you saw that definition in the dictionary, you might be annoyed. On +the other hand, if you looked up the definition of the factorial +function, denoted with the symbol :math:`!`, you might get something +like this: + +.. math:: + + \begin{aligned} + && 0! = 1 \\ + && n! = n (n-1)!\end{aligned} + +This definition says that the factorial of 0 is 1, and the factorial of +any other value, :math:`n`, is :math:`n` multiplied by the factorial of +:math:`n-1`. + +So :math:`3!` is 3 times :math:`2!`, which is 2 times :math:`1!`, which +is 1 times :math:`0!`. Putting it all together, :math:`3!` equals 3 +times 2 times 1 times 1, which is 6. + +If you can write a recursive definition of something, you can write a +Python program to evaluate it. The first step is to decide what the +parameters should be. In this case it should be clear that factorial +takes an integer: + +:: + + def factorial(n): + +If the argument happens to be 0, all we have to do is return 1: + +:: + + def factorial(n): + if n == 0: + return 1 + +Otherwise, and this is the interesting part, we have to make a recursive +call to find the factorial of :math:`n-1` and then multiply it by +:math:`n`: + +:: + + def factorial(n): + if n == 0: + return 1 + else: + recurse = factorial(n-1) + result = n * recurse + return result + +The flow of execution for this program is similar to the flow of +countdown in Section [recursion]. If we call factorial with the value 3: + +Since 3 is not 0, we take the second branch and calculate the factorial +of n-1... + + Since 2 is not 0, we take the second branch and calculate the + factorial of n-1... + + Since 1 is not 0, we take the second branch and calculate the + factorial of n-1... + + Since 0 equals 0, we take the first branch and return 1 + without making any more recursive calls. + + The return value, 1, is multiplied by :math:`n`, which is 1, and + the result is returned. + + The return value, 1, is multiplied by :math:`n`, which is 2, and the + result is returned. + +The return value (2) is multiplied by :math:`n`, which is 3, and the +result, 6, becomes the return value of the function call that started +the whole process. + +Figure [fig.stack3] shows what the stack diagram looks like for this +sequence of function calls. + +.. figure:: figs/stack3.pdf + :alt: Stack diagram. + + Stack diagram. + +The return values are shown being passed back up the stack. In each +frame, the return value is the value of result, which is the product of +n and recurse. + +In the last frame, the local variables recurse and result do not exist, +because the branch that creates them does not run. + +Leap of faith +------------- + +Following the flow of execution is one way to read programs, but it can +quickly become overwhelming. An alternative is what I call the “leap of +faith”. When you come to a function call, instead of following the flow +of execution, you *assume* that the function works correctly and returns +the right result. + +In fact, you are already practicing this leap of faith when you use +built-in functions. When you call math.cos or math.exp, you don’t +examine the bodies of those functions. You just assume that they work +because the people who wrote the built-in functions were good +programmers. + +The same is true when you call one of your own functions. For example, +in Section [boolean], we wrote a function called ``is_divisible`` that +determines whether one number is divisible by another. Once we have +convinced ourselves that this function is correct—by examining the code +and testing—we can use the function without looking at the body again. + +The same is true of recursive programs. When you get to the recursive +call, instead of following the flow of execution, you should assume that +the recursive call works (returns the correct result) and then ask +yourself, “Assuming that I can find the factorial of :math:`n-1`, can I +compute the factorial of :math:`n`?” It is clear that you can, by +multiplying by :math:`n`. + +Of course, it’s a bit strange to assume that the function works +correctly when you haven’t finished writing it, but that’s why it’s +called a leap of faith! + +One more example +---------------- + +After factorial, the most common example of a recursively defined +mathematical function is fibonacci, which has the following definition +(see http://en.wikipedia.org/wiki/Fibonacci_number): + +.. math:: + + \begin{aligned} + && \mathrm{fibonacci}(0) = 0 \\ + && \mathrm{fibonacci}(1) = 1 \\ + && \mathrm{fibonacci}(n) = \mathrm{fibonacci}(n-1) + \mathrm{fibonacci}(n-2)\end{aligned} + +Translated into Python, it looks like this: + +:: + + def fibonacci (n): + if n == 0: + return 0 + elif n == 1: + return 1 + else: + return fibonacci(n-1) + fibonacci(n-2) + +If you try to follow the flow of execution here, even for fairly small +values of :math:`n`, your head explodes. But according to the leap of +faith, if you assume that the two recursive calls work correctly, then +it is clear that you get the right result by adding them together. + +Checking types +-------------- + +What happens if we call factorial and give it 1.5 as an argument? + +:: + + >>> factorial(1.5) + RuntimeError: Maximum recursion depth exceeded + +It looks like an infinite recursion. How can that be? The function has a +base case—when n == 0. But if n is not an integer, we can *miss* the +base case and recurse forever. + +In the first recursive call, the value of n is 0.5. In the next, it is +-0.5. From there, it gets smaller (more negative), but it will never be +0. + +We have two choices. We can try to generalize the factorial function to +work with floating-point numbers, or we can make factorial check the +type of its argument. The first option is called the gamma function and +it’s a little beyond the scope of this book. So we’ll go for the second. + +We can use the built-in function isinstance to verify the type of the +argument. While we’re at it, we can also make sure the argument is +positive: + +:: + + def factorial (n): + if not isinstance(n, int): + print('Factorial is only defined for integers.') + return None + elif n < 0: + print('Factorial is not defined for negative integers.') + return None + elif n == 0: + return 1 + else: + return n * factorial(n-1) + +The first base case handles nonintegers; the second handles negative +integers. In both cases, the program prints an error message and returns +None to indicate that something went wrong: + +:: + + >>> factorial('fred') + Factorial is only defined for integers. + None + >>> factorial(-2) + Factorial is not defined for negative integers. + None + +If we get past both checks, we know that :math:`n` is positive or zero, +so we can prove that the recursion terminates. + +This program demonstrates a pattern sometimes called a **guardian**. The +first two conditionals act as guardians, protecting the code that +follows from values that might cause an error. The guardians make it +possible to prove the correctness of the code. + +In Section [raise] we will see a more flexible alternative to printing +an error message: raising an exception. + +Debugging +--------- + +Breaking a large program into smaller functions creates natural +checkpoints for debugging. If a function is not working, there are three +possibilities to consider: + +- There is something wrong with the arguments the function is getting; + a precondition is violated. + +- There is something wrong with the function; a postcondition is + violated. + +- There is something wrong with the return value or the way it is being + used. + +To rule out the first possibility, you can add a print statement at the +beginning of the function and display the values of the parameters (and +maybe their types). Or you can write code that checks the preconditions +explicitly. + +If the parameters look good, add a print statement before each return +statement and display the return value. If possible, check the result by +hand. Consider calling the function with values that make it easy to +check the result (as in Section [incremental.development]). + +If the function seems to be working, look at the function call to make +sure the return value is being used correctly (or used at all!). + +Adding print statements at the beginning and end of a function can help +make the flow of execution more visible. For example, here is a version +of factorial with print statements: + +:: + + def factorial(n): + space = ' ' * (4 * n) + print(space, 'factorial', n) + if n == 0: + print(space, 'returning 1') + return 1 + else: + recurse = factorial(n-1) + result = n * recurse + print(space, 'returning', result) + return result + +space is a string of space characters that controls the indentation of +the output. Here is the result of factorial(4) : + +:: + + factorial 4 + factorial 3 + factorial 2 + factorial 1 + factorial 0 + returning 1 + returning 1 + returning 2 + returning 6 + returning 24 + +If you are confused about the flow of execution, this kind of output can +be helpful. It takes some time to develop effective scaffolding, but a +little bit of scaffolding can save a lot of debugging. + +Glossary +-------- + +temporary variable: + A variable used to store an intermediate value in a complex + calculation. + +dead code: + Part of a program that can never run, often because it appears after + a return statement. + +incremental development: + A program development plan intended to avoid debugging by adding and + testing only a small amount of code at a time. + +scaffolding: + Code that is used during program development but is not part of the + final version. + +guardian: + A programming pattern that uses a conditional statement to check for + and handle circumstances that might cause an error. + +Exercises +--------- + +Draw a stack diagram for the following program. What does the program +print? + +:: + + def b(z): + prod = a(z, z) + print(z, prod) + return prod + + def a(x, y): + x = x + 1 + return x * y + + def c(x, y, z): + total = x + y + z + square = b(total)**2 + return square + + x = 1 + y = x + 1 + print(c(x, y+3, x+y)) + +[ackermann] + +The Ackermann function, :math:`A(m, n)`, is defined: + +.. math:: + + \begin{aligned} + A(m, n) = \begin{cases} + n+1 & \mbox{if } m = 0 \\ + A(m-1, 1) & \mbox{if } m > 0 \mbox{ and } n = 0 \\ + A(m-1, A(m, n-1)) & \mbox{if } m > 0 \mbox{ and } n > 0. + \end{cases} \end{aligned} + +See http://en.wikipedia.org/wiki/Ackermann_function. Write a function +named ack that evaluates the Ackermann function. Use your function to +evaluate ack(3, 4), which should be 125. What happens for larger values +of m and n? Solution: http://thinkpython2.com/code/ackermann.py. + +[palindrome] + +A palindrome is a word that is spelled the same backward and forward, +like “noon” and “redivider”. Recursively, a word is a palindrome if the +first and last letters are the same and the middle is a palindrome. + +The following are functions that take a string argument and return the +first, last, and middle letters: + +:: + + def first(word): + return word[0] + + def last(word): + return word[-1] + + def middle(word): + return word[1:-1] + +We’ll see how they work in Chapter [strings]. + +#. Type these functions into a file named palindrome.py and test them + out. What happens if you call middle with a string with two letters? + One letter? What about the empty string, which is written ``''`` and + contains no letters? + +#. Write a function called ``is_palindrome`` that takes a string + argument and returns True if it is a palindrome and False otherwise. + Remember that you can use the built-in function len to check the + length of a string. + +Solution: http://thinkpython2.com/code/palindrome_soln.py. + +A number, :math:`a`, is a power of :math:`b` if it is divisible by +:math:`b` and :math:`a/b` is a power of :math:`b`. Write a function +called ``is_power`` that takes parameters a and b and returns True if a +is a power of b. Note: you will have to think about the base case. + +The greatest common divisor (GCD) of :math:`a` and :math:`b` is the +largest number that divides both of them with no remainder. + +One way to find the GCD of two numbers is based on the observation that +if :math:`r` is the remainder when :math:`a` is divided by :math:`b`, +then :math:`gcd(a, +b) = gcd(b, r)`. As a base case, we can use :math:`gcd(a, 0) = a`. + +Write a function called ``gcd`` that takes parameters a and b and +returns their greatest common divisor. + +Credit: This exercise is based on an example from Abelson and Sussman’s +*Structure and Interpretation of Computer Programs*. + +Iteration +========= + +This chapter is about iteration, which is the ability to run a block of +statements repeatedly. We saw a kind of iteration, using recursion, in +Section [recursion]. We saw another kind, using a for loop, in +Section [repetition]. In this chapter we’ll see yet another kind, using +a while statement. But first I want to say a little more about variable +assignment. + +Reassignment +------------ + +As you may have discovered, it is legal to make more than one assignment +to the same variable. A new assignment makes an existing variable refer +to a new value (and stop referring to the old value). + +:: + + >>> x = 5 + >>> x + 5 + >>> x = 7 + >>> x + 7 + +The first time we display x, its value is 5; the second time, its value +is 7. + +Figure [fig.assign2] shows what **reassignment** looks like in a state +diagram. + +At this point I want to address a common source of confusion. Because +Python uses the equal sign (=) for assignment, it is tempting to +interpret a statement like a = b as a mathematical proposition of +equality; that is, the claim that a and b are equal. But this +interpretation is wrong. + +First, equality is a symmetric relationship and assignment is not. For +example, in mathematics, if :math:`a=7` then :math:`7=a`. But in Python, +the statement a = 7 is legal and 7 = a is not. + +Also, in mathematics, a proposition of equality is either true or false +for all time. If :math:`a=b` now, then :math:`a` will always equal +:math:`b`. In Python, an assignment statement can make two variables +equal, but they don’t have to stay that way: + +:: + + >>> a = 5 + >>> b = a # a and b are now equal + >>> a = 3 # a and b are no longer equal + >>> b + 5 + +The third line changes the value of a but does not change the value of +b, so they are no longer equal. + +Reassigning variables is often useful, but you should use it with +caution. If the values of variables change frequently, it can make the +code difficult to read and debug. + +.. figure:: figs/assign2.pdf + :alt: State diagram. + + State diagram. + +Updating variables +------------------ + +A common kind of reassignment is an **update**, where the new value of +the variable depends on the old. + +:: + + >>> x = x + 1 + +This means “get the current value of x, add one, and then update x with +the new value.” + +If you try to update a variable that doesn’t exist, you get an error, +because Python evaluates the right side before it assigns a value to x: + +:: + + >>> x = x + 1 + NameError: name 'x' is not defined + +Before you can update a variable, you have to **initialize** it, usually +with a simple assignment: + +:: + + >>> x = 0 + >>> x = x + 1 + +Updating a variable by adding 1 is called an **increment**; subtracting +1 is called a **decrement**. + +The while statement +------------------- + +Computers are often used to automate repetitive tasks. Repeating +identical or similar tasks without making errors is something that +computers do well and people do poorly. In a computer program, +repetition is also called **iteration**. + +We have already seen two functions, countdown and ``print_n``, that +iterate using recursion. Because iteration is so common, Python provides +language features to make it easier. One is the for statement we saw in +Section [repetition]. We’ll get back to that later. + +Another is the while statement. Here is a version of countdown that uses +a while statement: + +:: + + def countdown(n): + while n > 0: + print(n) + n = n - 1 + print('Blastoff!') + +You can almost read the while statement as if it were English. It means, +“While n is greater than 0, display the value of n and then decrement n. +When you get to 0, display the word Blastoff!” + +More formally, here is the flow of execution for a while statement: + +#. Determine whether the condition is true or false. + +#. If false, exit the while statement and continue execution at the next + statement. + +#. If the condition is true, run the body and then go back to step 1. + +This type of flow is called a loop because the third step loops back +around to the top. + +The body of the loop should change the value of one or more variables so +that the condition becomes false eventually and the loop terminates. +Otherwise the loop will repeat forever, which is called an **infinite +loop**. An endless source of amusement for computer scientists is the +observation that the directions on shampoo, “Lather, rinse, repeat”, are +an infinite loop. + +In the case of countdown, we can prove that the loop terminates: if n is +zero or negative, the loop never runs. Otherwise, n gets smaller each +time through the loop, so eventually we have to get to 0. + +For some other loops, it is not so easy to tell. For example: + +:: + + def sequence(n): + while n != 1: + print(n) + if n % 2 == 0: # n is even + n = n / 2 + else: # n is odd + n = n*3 + 1 + +The condition for this loop is n != 1, so the loop will continue until n +is 1, which makes the condition false. + +Each time through the loop, the program outputs the value of n and then +checks whether it is even or odd. If it is even, n is divided by 2. If +it is odd, the value of n is replaced with n\*3 + 1. For example, if the +argument passed to sequence is 3, the resulting values of n are 3, 10, +5, 16, 8, 4, 2, 1. + +Since n sometimes increases and sometimes decreases, there is no obvious +proof that n will ever reach 1, or that the program terminates. For some +particular values of n, we can prove termination. For example, if the +starting value is a power of two, n will be even every time through the +loop until it reaches 1. The previous example ends with such a sequence, +starting with 16. + +The hard question is whether we can prove that this program terminates +for *all* positive values of n. So far, no one has been able to prove it +*or* disprove it! (See http://en.wikipedia.org/wiki/Collatz_conjecture.) + +As an exercise, rewrite the function ``print_n`` from +Section [recursion] using iteration instead of recursion. + +break +----- + +Sometimes you don’t know it’s time to end a loop until you get half way +through the body. In that case you can use the break statement to jump +out of the loop. + +For example, suppose you want to take input from the user until they +type done. You could write: + +:: + + while True: + line = input('> ') + if line == 'done': + break + print(line) + + print('Done!') + +The loop condition is True, which is always true, so the loop runs until +it hits the break statement. + +Each time through, it prompts the user with an angle bracket. If the +user types done, the break statement exits the loop. Otherwise the +program echoes whatever the user types and goes back to the top of the +loop. Here’s a sample run: + +:: + + > not done + not done + > done + Done! + +This way of writing while loops is common because you can check the +condition anywhere in the loop (not just at the top) and you can express +the stop condition affirmatively (“stop when this happens”) rather than +negatively (“keep going until that happens”). + +Square roots +------------ + +Loops are often used in programs that compute numerical results by +starting with an approximate answer and iteratively improving it. + +For example, one way of computing square roots is Newton’s method. +Suppose that you want to know the square root of :math:`a`. If you start +with almost any estimate, :math:`x`, you can compute a better estimate +with the following formula: + +.. math:: y = \frac{x + a/x}{2} + +For example, if :math:`a` is 4 and :math:`x` is 3: + +:: + + >>> a = 4 + >>> x = 3 + >>> y = (x + a/x) / 2 + >>> y + 2.16666666667 + +The result is closer to the correct answer (:math:`\sqrt{4} = 2`). If we +repeat the process with the new estimate, it gets even closer: + +:: + + >>> x = y + >>> y = (x + a/x) / 2 + >>> y + 2.00641025641 + +After a few more updates, the estimate is almost exact: + +:: + + >>> x = y + >>> y = (x + a/x) / 2 + >>> y + 2.00001024003 + >>> x = y + >>> y = (x + a/x) / 2 + >>> y + 2.00000000003 + +In general we don’t know ahead of time how many steps it takes to get to +the right answer, but we know when we get there because the estimate +stops changing: + +:: + + >>> x = y + >>> y = (x + a/x) / 2 + >>> y + 2.0 + >>> x = y + >>> y = (x + a/x) / 2 + >>> y + 2.0 + +When y == x, we can stop. Here is a loop that starts with an initial +estimate, x, and improves it until it stops changing: + +:: + + while True: + print(x) + y = (x + a/x) / 2 + if y == x: + break + x = y + +For most values of a this works fine, but in general it is dangerous to +test float equality. Floating-point values are only approximately right: +most rational numbers, like :math:`1/3`, and irrational numbers, like +:math:`\sqrt{2}`, can’t be represented exactly with a float. + +Rather than checking whether x and y are exactly equal, it is safer to +use the built-in function abs to compute the absolute value, or +magnitude, of the difference between them: + +:: + + if abs(y-x) < epsilon: + break + +Where ``epsilon`` has a value like 0.0000001 that determines how close +is close enough. + +Algorithms +---------- + +Newton’s method is an example of an **algorithm**: it is a mechanical +process for solving a category of problems (in this case, computing +square roots). + +To understand what an algorithm is, it might help to start with +something that is not an algorithm. When you learned to multiply +single-digit numbers, you probably memorized the multiplication table. +In effect, you memorized 100 specific solutions. That kind of knowledge +is not algorithmic. + +But if you were “lazy”, you might have learned a few tricks. For +example, to find the product of :math:`n` and 9, you can write +:math:`n-1` as the first digit and :math:`10-n` as the second digit. +This trick is a general solution for multiplying any single-digit number +by 9. That’s an algorithm! + +Similarly, the techniques you learned for addition with carrying, +subtraction with borrowing, and long division are all algorithms. One of +the characteristics of algorithms is that they do not require any +intelligence to carry out. They are mechanical processes where each step +follows from the last according to a simple set of rules. + +Executing algorithms is boring, but designing them is interesting, +intellectually challenging, and a central part of computer science. + +Some of the things that people do naturally, without difficulty or +conscious thought, are the hardest to express algorithmically. +Understanding natural language is a good example. We all do it, but so +far no one has been able to explain *how* we do it, at least not in the +form of an algorithm. + +Debugging +--------- + +As you start writing bigger programs, you might find yourself spending +more time debugging. More code means more chances to make an error and +more places for bugs to hide. + +One way to cut your debugging time is “debugging by bisection”. For +example, if there are 100 lines in your program and you check them one +at a time, it would take 100 steps. + +Instead, try to break the problem in half. Look at the middle of the +program, or near it, for an intermediate value you can check. Add a +print statement (or something else that has a verifiable effect) and run +the program. + +If the mid-point check is incorrect, there must be a problem in the +first half of the program. If it is correct, the problem is in the +second half. + +Every time you perform a check like this, you halve the number of lines +you have to search. After six steps (which is fewer than 100), you would +be down to one or two lines of code, at least in theory. + +In practice it is not always clear what the “middle of the program” is +and not always possible to check it. It doesn’t make sense to count +lines and find the exact midpoint. Instead, think about places in the +program where there might be errors and places where it is easy to put a +check. Then choose a spot where you think the chances are about the same +that the bug is before or after the check. + +Glossary +-------- + +reassignment: + Assigning a new value to a variable that already exists. + +update: + An assignment where the new value of the variable depends on the + old. + +initialization: + An assignment that gives an initial value to a variable that will be + updated. + +increment: + An update that increases the value of a variable (often by one). + +decrement: + An update that decreases the value of a variable. + +iteration: + Repeated execution of a set of statements using either a recursive + function call or a loop. + +infinite loop: + A loop in which the terminating condition is never satisfied. + +algorithm: + A general process for solving a category of problems. + +Exercises +--------- + +Copy the loop from Section [squareroot] and encapsulate it in a function +called ``mysqrt`` that takes a as a parameter, chooses a reasonable +value of x, and returns an estimate of the square root of a. + +To test it, write a function named ``test_square_root`` that prints a +table like this: + +:: + + a mysqrt(a) math.sqrt(a) diff + - --------- ------------ ---- + 1.0 1.0 1.0 0.0 + 2.0 1.41421356237 1.41421356237 2.22044604925e-16 + 3.0 1.73205080757 1.73205080757 0.0 + 4.0 2.0 2.0 0.0 + 5.0 2.2360679775 2.2360679775 0.0 + 6.0 2.44948974278 2.44948974278 0.0 + 7.0 2.64575131106 2.64575131106 0.0 + 8.0 2.82842712475 2.82842712475 4.4408920985e-16 + 9.0 3.0 3.0 0.0 + +The first column is a number, :math:`a`; the second column is the square +root of :math:`a` computed with ``mysqrt``; the third column is the +square root computed by math.sqrt; the fourth column is the absolute +value of the difference between the two estimates. + +The built-in function eval takes a string and evaluates it using the +Python interpreter. For example: + +:: + + >>> eval('1 + 2 * 3') + 7 + >>> import math + >>> eval('math.sqrt(5)') + 2.2360679774997898 + >>> eval('type(math.pi)') + + +Write a function called ``eval_loop`` that iteratively prompts the user, +takes the resulting input and evaluates it using eval, and prints the +result. + +It should continue until the user enters ``'done'``, and then return the +value of the last expression it evaluated. + +The mathematician Srinivasa Ramanujan found an infinite series that can +be used to generate a numerical approximation of :math:`1 / \pi`: + +.. math:: + + \frac{1}{\pi} = \frac{2\sqrt{2}}{9801} + \sum^\infty_{k=0} \frac{(4k)!(1103+26390k)}{(k!)^4 396^{4k}} + +Write a function called ``estimate_pi`` that uses this formula to +compute and return an estimate of :math:`\pi`. It should use a while +loop to compute terms of the summation until the last term is smaller +than 1e-15 (which is Python notation for :math:`10^{-15}`). You can +check the result by comparing it to math.pi. + +Solution: http://thinkpython2.com/code/pi.py. + +Strings +======= + +Strings are not like integers, floats, and booleans. A string is a +**sequence**, which means it is an ordered collection of other values. +In this chapter you’ll see how to access the characters that make up a +string, and you’ll learn about some of the methods strings provide. + +A string is a sequence +---------------------- + +A string is a sequence of characters. You can access the characters one +at a time with the bracket operator: + +:: + + >>> fruit = 'banana' + >>> letter = fruit[1] + +The second statement selects character number 1 from fruit and assigns +it to letter. + +The expression in brackets is called an **index**. The index indicates +which character in the sequence you want (hence the name). + +But you might not get what you expect: + +:: + + >>> letter + 'a' + +For most people, the first letter of ``'banana'`` is b, not a. But for +computer scientists, the index is an offset from the beginning of the +string, and the offset of the first letter is zero. + +:: + + >>> letter = fruit[0] + >>> letter + 'b' + +So b is the 0th letter (“zero-eth”) of ``'banana'``, a is the 1th letter +(“one-eth”), and n is the 2th letter (“two-eth”). + +As an index you can use an expression that contains variables and +operators: + +:: + + >>> i = 1 + >>> fruit[i] + 'a' + >>> fruit[i+1] + 'n' + +But the value of the index has to be an integer. Otherwise you get: + +:: + + >>> letter = fruit[1.5] + TypeError: string indices must be integers + +len +--- + +len is a built-in function that returns the number of characters in a +string: + +:: + + >>> fruit = 'banana' + >>> len(fruit) + 6 + +To get the last letter of a string, you might be tempted to try +something like this: + +:: + + >>> length = len(fruit) + >>> last = fruit[length] + IndexError: string index out of range + +The reason for the IndexError is that there is no letter in ’banana’ +with the index 6. Since we started counting at zero, the six letters are +numbered 0 to 5. To get the last character, you have to subtract 1 from +length: + +:: + + >>> last = fruit[length-1] + >>> last + 'a' + +Or you can use negative indices, which count backward from the end of +the string. The expression fruit[-1] yields the last letter, fruit[-2] +yields the second to last, and so on. + +Traversal with a for loop +------------------------- + +A lot of computations involve processing a string one character at a +time. Often they start at the beginning, select each character in turn, +do something to it, and continue until the end. This pattern of +processing is called a **traversal**. One way to write a traversal is +with a while loop: + +:: + + index = 0 + while index < len(fruit): + letter = fruit[index] + print(letter) + index = index + 1 + +This loop traverses the string and displays each letter on a line by +itself. The loop condition is index < len(fruit), so when index is equal +to the length of the string, the condition is false, and the body of the +loop doesn’t run. The last character accessed is the one with the index +len(fruit)-1, which is the last character in the string. + +As an exercise, write a function that takes a string as an argument and +displays the letters backward, one per line. + +Another way to write a traversal is with a for loop: + +:: + + for letter in fruit: + print(letter) + +Each time through the loop, the next character in the string is assigned +to the variable letter. The loop continues until no characters are left. + +The following example shows how to use concatenation (string addition) +and a for loop to generate an abecedarian series (that is, in +alphabetical order). In Robert McCloskey’s book *Make Way for +Ducklings*, the names of the ducklings are Jack, Kack, Lack, Mack, Nack, +Ouack, Pack, and Quack. This loop outputs these names in order: + +:: + + prefixes = 'JKLMNOPQ' + suffix = 'ack' + + for letter in prefixes: + print(letter + suffix) + +The output is: + +:: + + Jack + Kack + Lack + Mack + Nack + Oack + Pack + Qack + +Of course, that’s not quite right because “Ouack” and “Quack” are +misspelled. As an exercise, modify the program to fix this error. + +String slices +------------- + +A segment of a string is called a **slice**. Selecting a slice is +similar to selecting a character: + +:: + + >>> s = 'Monty Python' + >>> s[0:5] + 'Monty' + >>> s[6:12] + 'Python' + +The operator returns the part of the string from the “n-eth” character +to the “m-eth” character, including the first but excluding the last. +This behavior is counterintuitive, but it might help to imagine the +indices pointing *between* the characters, as in Figure [fig.banana]. + +.. figure:: figs/banana.pdf + :alt: Slice indices. + + Slice indices. + +If you omit the first index (before the colon), the slice starts at the +beginning of the string. If you omit the second index, the slice goes to +the end of the string: + +:: + + >>> fruit = 'banana' + >>> fruit[:3] + 'ban' + >>> fruit[3:] + 'ana' + +If the first index is greater than or equal to the second the result is +an **empty string**, represented by two quotation marks: + +:: + + >>> fruit = 'banana' + >>> fruit[3:3] + '' + +An empty string contains no characters and has length 0, but other than +that, it is the same as any other string. + +Continuing this example, what do you think fruit[:] means? Try it and +see. + +Strings are immutable +--------------------- + +It is tempting to use the operator on the left side of an assignment, +with the intention of changing a character in a string. For example: + +:: + + >>> greeting = 'Hello, world!' + >>> greeting[0] = 'J' + TypeError: 'str' object does not support item assignment + +The “object” in this case is the string and the “item” is the character +you tried to assign. For now, an object is the same thing as a value, +but we will refine that definition later (Section [equivalence]). + +The reason for the error is that strings are **immutable**, which means +you can’t change an existing string. The best you can do is create a new +string that is a variation on the original: + +:: + + >>> greeting = 'Hello, world!' + >>> new_greeting = 'J' + greeting[1:] + >>> new_greeting + 'Jello, world!' + +This example concatenates a new first letter onto a slice of greeting. +It has no effect on the original string. + +Searching +--------- + +What does the following function do? + +:: + + def find(word, letter): + index = 0 + while index < len(word): + if word[index] == letter: + return index + index = index + 1 + return -1 + +In a sense, find is the inverse of the operator. Instead of taking an +index and extracting the corresponding character, it takes a character +and finds the index where that character appears. If the character is +not found, the function returns -1. + +This is the first example we have seen of a return statement inside a +loop. If word[index] == letter, the function breaks out of the loop and +returns immediately. + +If the character doesn’t appear in the string, the program exits the +loop normally and returns -1. + +This pattern of computation—traversing a sequence and returning when we +find what we are looking for—is called a **search**. + +As an exercise, modify find so that it has a third parameter, the index +in word where it should start looking. + +Looping and counting +-------------------- + +The following program counts the number of times the letter a appears in +a string: + +:: + + word = 'banana' + count = 0 + for letter in word: + if letter == 'a': + count = count + 1 + print(count) + +This program demonstrates another pattern of computation called a +**counter**. The variable count is initialized to 0 and then incremented +each time an a is found. When the loop exits, count contains the +result—the total number of a’s. + +As an exercise, encapsulate this code in a function named count, and +generalize it so that it accepts the string and the letter as arguments. + +Then rewrite the function so that instead of traversing the string, it +uses the three-parameter version of find from the previous section. + +String methods +-------------- + +Strings provide methods that perform a variety of useful operations. A +method is similar to a function—it takes arguments and returns a +value—but the syntax is different. For example, the method upper takes a +string and returns a new string with all uppercase letters. + +Instead of the function syntax upper(word), it uses the method syntax +word.upper(). + +:: + + >>> word = 'banana' + >>> new_word = word.upper() + >>> new_word + 'BANANA' + +This form of dot notation specifies the name of the method, upper, and +the name of the string to apply the method to, word. The empty +parentheses indicate that this method takes no arguments. + +A method call is called an **invocation**; in this case, we would say +that we are invoking upper on word. + +As it turns out, there is a string method named find that is remarkably +similar to the function we wrote: + +:: + + >>> word = 'banana' + >>> index = word.find('a') + >>> index + 1 + +In this example, we invoke find on word and pass the letter we are +looking for as a parameter. + +Actually, the find method is more general than our function; it can find +substrings, not just characters: + +:: + + >>> word.find('na') + 2 + +By default, find starts at the beginning of the string, but it can take +a second argument, the index where it should start: + +:: + + >>> word.find('na', 3) + 4 + +This is an example of an **optional argument**; find can also take a +third argument, the index where it should stop: + +:: + + >>> name = 'bob' + >>> name.find('b', 1, 2) + -1 + +This search fails because b does not appear in the index range from 1 to +2, not including 2. Searching up to, but not including, the second index +makes find consistent with the slice operator. + +The in operator +--------------- + +The word in is a boolean operator that takes two strings and returns +True if the first appears as a substring in the second: + +:: + + >>> 'a' in 'banana' + True + >>> 'seed' in 'banana' + False + +For example, the following function prints all the letters from word1 +that also appear in word2: + +:: + + def in_both(word1, word2): + for letter in word1: + if letter in word2: + print(letter) + +With well-chosen variable names, Python sometimes reads like English. +You could read this loop, “for (each) letter in (the first) word, if +(the) letter (appears) in (the second) word, print (the) letter.” + +Here’s what you get if you compare apples and oranges: + +:: + + >>> in_both('apples', 'oranges') + a + e + s + +String comparison +----------------- + +The relational operators work on strings. To see if two strings are +equal: + +:: + + if word == 'banana': + print('All right, bananas.') + +Other relational operations are useful for putting words in alphabetical +order: + +:: + + if word < 'banana': + print('Your word, ' + word + ', comes before banana.') + elif word > 'banana': + print('Your word, ' + word + ', comes after banana.') + else: + print('All right, bananas.') + +Python does not handle uppercase and lowercase letters the same way +people do. All the uppercase letters come before all the lowercase +letters, so: + +:: + + Your word, Pineapple, comes before banana. + +A common way to address this problem is to convert strings to a standard +format, such as all lowercase, before performing the comparison. Keep +that in mind in case you have to defend yourself against a man armed +with a Pineapple. + +Debugging +--------- + +When you use indices to traverse the values in a sequence, it is tricky +to get the beginning and end of the traversal right. Here is a function +that is supposed to compare two words and return True if one of the +words is the reverse of the other, but it contains two errors: + +:: + + def is_reverse(word1, word2): + if len(word1) != len(word2): + return False + + i = 0 + j = len(word2) + + while j > 0: + if word1[i] != word2[j]: + return False + i = i+1 + j = j-1 + + return True + +The first if statement checks whether the words are the same length. If +not, we can return False immediately. Otherwise, for the rest of the +function, we can assume that the words are the same length. This is an +example of the guardian pattern in Section [guardian]. + +i and j are indices: i traverses word1 forward while j traverses word2 +backward. If we find two letters that don’t match, we can return False +immediately. If we get through the whole loop and all the letters match, +we return True. + +If we test this function with the words “pots” and “stop”, we expect the +return value True, but we get an IndexError: + +:: + + >>> is_reverse('pots', 'stop') + ... + File "reverse.py", line 15, in is_reverse + if word1[i] != word2[j]: + IndexError: string index out of range + +For debugging this kind of error, my first move is to print the values +of the indices immediately before the line where the error appears. + +:: + + while j > 0: + print(i, j) # print here + + if word1[i] != word2[j]: + return False + i = i+1 + j = j-1 + +Now when I run the program again, I get more information: + +:: + + >>> is_reverse('pots', 'stop') + 0 4 + ... + IndexError: string index out of range + +The first time through the loop, the value of j is 4, which is out of +range for the string ``'pots'``. The index of the last character is 3, +so the initial value for j should be len(word2)-1. + +If I fix that error and run the program again, I get: + +:: + + >>> is_reverse('pots', 'stop') + 0 3 + 1 2 + 2 1 + True + +This time we get the right answer, but it looks like the loop only ran +three times, which is suspicious. To get a better idea of what is +happening, it is useful to draw a state diagram. During the first +iteration, the frame for ``is_reverse`` is shown in Figure [fig.state4]. + +.. figure:: figs/state4.pdf + :alt: State diagram. + + State diagram. + +I took some license by arranging the variables in the frame and adding +dotted lines to show that the values of i and j indicate characters in +word1 and word2. + +Starting with this diagram, run the program on paper, changing the +values of i and j during each iteration. Find and fix the second error +in this function. [isreverse] + +Glossary +-------- + +object: + Something a variable can refer to. For now, you can use “object” and + “value” interchangeably. + +sequence: + An ordered collection of values where each value is identified by an + integer index. + +item: + One of the values in a sequence. + +index: + An integer value used to select an item in a sequence, such as a + character in a string. In Python indices start from 0. + +slice: + A part of a string specified by a range of indices. + +empty string: + A string with no characters and length 0, represented by two + quotation marks. + +immutable: + The property of a sequence whose items cannot be changed. + +traverse: + To iterate through the items in a sequence, performing a similar + operation on each. + +search: + A pattern of traversal that stops when it finds what it is looking + for. + +counter: + A variable used to count something, usually initialized to zero and + then incremented. + +invocation: + A statement that calls a method. + +optional argument: + A function or method argument that is not required. + +Exercises +--------- + +Read the documentation of the string methods at +http://docs.python.org/3/library/stdtypes.html#string-methods. You might +want to experiment with some of them to make sure you understand how +they work. strip and replace are particularly useful. + +The documentation uses a syntax that might be confusing. For example, in +``find(sub[, start[, end]])``, the brackets indicate optional arguments. +So sub is required, but start is optional, and if you include start, +then end is optional. + +There is a string method called count that is similar to the function in +Section [counter]. Read the documentation of this method and write an +invocation that counts the number of a’s in ``'banana'``. + +A string slice can take a third index that specifies the “step size”; +that is, the number of spaces between successive characters. A step size +of 2 means every other character; 3 means every third, etc. + +:: + + >>> fruit = 'banana' + >>> fruit[0:5:2] + 'bnn' + +A step size of -1 goes through the word backwards, so the slice +``[::-1]`` generates a reversed string. + +Use this idiom to write a one-line version of ``is_palindrome`` from +Exercise [palindrome]. + +The following functions are all *intended* to check whether a string +contains any lowercase letters, but at least some of them are wrong. For +each function, describe what the function actually does (assuming that +the parameter is a string). + +:: + + def any_lowercase1(s): + for c in s: + if c.islower(): + return True + else: + return False + + def any_lowercase2(s): + for c in s: + if 'c'.islower(): + return 'True' + else: + return 'False' + + def any_lowercase3(s): + for c in s: + flag = c.islower() + return flag + + def any_lowercase4(s): + flag = False + for c in s: + flag = flag or c.islower() + return flag + + def any_lowercase5(s): + for c in s: + if not c.islower(): + return False + return True + +[exrotate] A Caesar cypher is a weak form of encryption that involves +“rotating” each letter by a fixed number of places. To rotate a letter +means to shift it through the alphabet, wrapping around to the beginning +if necessary, so ’A’ rotated by 3 is ’D’ and ’Z’ rotated by 1 is ’A’. + +To rotate a word, rotate each letter by the same amount. For example, +“cheer” rotated by 7 is “jolly” and “melon” rotated by -10 is “cubed”. +In the movie *2001: A Space Odyssey*, the ship computer is called HAL, +which is IBM rotated by -1. + +Write a function called ``rotate_word`` that takes a string and an +integer as parameters, and returns a new string that contains the +letters from the original string rotated by the given amount. + +You might want to use the built-in function ord, which converts a +character to a numeric code, and chr, which converts numeric codes to +characters. Letters of the alphabet are encoded in alphabetical order, +so for example: + +:: + + >>> ord('c') - ord('a') + 2 + +Because ``'c'`` is the two-eth letter of the alphabet. But beware: the +numeric codes for upper case letters are different. + +Potentially offensive jokes on the Internet are sometimes encoded in +ROT13, which is a Caesar cypher with rotation 13. If you are not easily +offended, find and decode some of them. Solution: +http://thinkpython2.com/code/rotate.py. + +Case study: word play +===================== + +This chapter presents the second case study, which involves solving word +puzzles by searching for words that have certain properties. For +example, we’ll find the longest palindromes in English and search for +words whose letters appear in alphabetical order. And I will present +another program development plan: reduction to a previously solved +problem. + +Reading word lists +------------------ + +For the exercises in this chapter we need a list of English words. There +are lots of word lists available on the Web, but the one most suitable +for our purpose is one of the word lists collected and contributed to +the public domain by Grady Ward as part of the Moby lexicon project (see +http://wikipedia.org/wiki/Moby_Project). It is a list of 113,809 +official crosswords; that is, words that are considered valid in +crossword puzzles and other word games. In the Moby collection, the +filename is 113809of.fic; you can download a copy, with the simpler name +words.txt, from http://thinkpython2.com/code/words.txt. + +This file is in plain text, so you can open it with a text editor, but +you can also read it from Python. The built-in function open takes the +name of the file as a parameter and returns a **file object** you can +use to read the file. + +:: + + >>> fin = open('words.txt') + +fin is a common name for a file object used for input. The file object +provides several methods for reading, including readline, which reads +characters from the file until it gets to a newline and returns the +result as a string: + +:: + + >>> fin.readline() + 'aa\r\n' + +The first word in this particular list is “aa”, which is a kind of lava. +The sequence ``\r\n`` represents two whitespace characters, a carriage +return and a newline, that separate this word from the next. + +The file object keeps track of where it is in the file, so if you call +readline again, you get the next word: + +:: + + >>> fin.readline() + 'aah\r\n' + +The next word is “aah”, which is a perfectly legitimate word, so stop +looking at me like that. Or, if it’s the whitespace that’s bothering +you, we can get rid of it with the string method strip: + +:: + + >>> line = fin.readline() + >>> word = line.strip() + >>> word + 'aahed' + +You can also use a file object as part of a for loop. This program reads +words.txt and prints each word, one per line: + +:: + + fin = open('words.txt') + for line in fin: + word = line.strip() + print(word) + +Exercises +--------- + +There are solutions to these exercises in the next section. You should +at least attempt each one before you read the solutions. + +Write a program that reads words.txt and prints only the words with more +than 20 characters (not counting whitespace). + +In 1939 Ernest Vincent Wright published a 50,000 word novel called +*Gadsby* that does not contain the letter “e”. Since “e” is the most +common letter in English, that’s not easy to do. + +In fact, it is difficult to construct a solitary thought without using +that most common symbol. It is slow going at first, but with caution and +hours of training you can gradually gain facility. + +All right, I’ll stop now. + +Write a function called ``has_no_e`` that returns True if the given word +doesn’t have the letter “e” in it. + +Modify your program from the previous section to print only the words +that have no “e” and compute the percentage of the words in the list +that have no “e”. + +Write a function named avoids that takes a word and a string of +forbidden letters, and that returns True if the word doesn’t use any of +the forbidden letters. + +Modify your program to prompt the user to enter a string of forbidden +letters and then print the number of words that don’t contain any of +them. Can you find a combination of 5 forbidden letters that excludes +the smallest number of words? + +Write a function named ``uses_only`` that takes a word and a string of +letters, and that returns True if the word contains only letters in the +list. Can you make a sentence using only the letters acefhlo? Other than +“Hoe alfalfa?” + +Write a function named ``uses_all`` that takes a word and a string of +required letters, and that returns True if the word uses all the +required letters at least once. How many words are there that use all +the vowels aeiou? How about aeiouy? + +Write a function called ``is_abecedarian`` that returns True if the +letters in a word appear in alphabetical order (double letters are ok). +How many abecedarian words are there? + +Search +------ + +All of the exercises in the previous section have something in common; +they can be solved with the search pattern we saw in Section [find]. The +simplest example is: + +:: + + def has_no_e(word): + for letter in word: + if letter == 'e': + return False + return True + +The for loop traverses the characters in word. If we find the letter +“e”, we can immediately return False; otherwise we have to go to the +next letter. If we exit the loop normally, that means we didn’t find an +“e”, so we return True. + +You could write this function more concisely using the in operator, but +I started with this version because it demonstrates the logic of the +search pattern. + +is a more general version of ``has_no_e`` but it has the same structure: + +:: + + def avoids(word, forbidden): + for letter in word: + if letter in forbidden: + return False + return True + +We can return False as soon as we find a forbidden letter; if we get to +the end of the loop, we return True. + +``uses_only`` is similar except that the sense of the condition is +reversed: + +:: + + def uses_only(word, available): + for letter in word: + if letter not in available: + return False + return True + +Instead of a list of forbidden letters, we have a list of available +letters. If we find a letter in word that is not in available, we can +return False. + +``uses_all`` is similar except that we reverse the role of the word and +the string of letters: + +:: + + def uses_all(word, required): + for letter in required: + if letter not in word: + return False + return True + +Instead of traversing the letters in word, the loop traverses the +required letters. If any of the required letters do not appear in the +word, we can return False. + +If you were really thinking like a computer scientist, you would have +recognized that ``uses_all`` was an instance of a previously solved +problem, and you would have written: + +:: + + def uses_all(word, required): + return uses_only(required, word) + +This is an example of a program development plan called **reduction to a +previously solved problem**, which means that you recognize the problem +you are working on as an instance of a solved problem and apply an +existing solution. + +Looping with indices +-------------------- + +I wrote the functions in the previous section with for loops because I +only needed the characters in the strings; I didn’t have to do anything +with the indices. + +For ``is_abecedarian`` we have to compare adjacent letters, which is a +little tricky with a for loop: + +:: + + def is_abecedarian(word): + previous = word[0] + for c in word: + if c < previous: + return False + previous = c + return True + +An alternative is to use recursion: + +:: + + def is_abecedarian(word): + if len(word) <= 1: + return True + if word[0] > word[1]: + return False + return is_abecedarian(word[1:]) + +Another option is to use a while loop: + +:: + + def is_abecedarian(word): + i = 0 + while i < len(word)-1: + if word[i+1] < word[i]: + return False + i = i+1 + return True + +The loop starts at i=0 and ends when i=len(word)-1. Each time through +the loop, it compares the :math:`i`\ th character (which you can think +of as the current character) to the :math:`i+1`\ th character (which you +can think of as the next). + +If the next character is less than (alphabetically before) the current +one, then we have discovered a break in the abecedarian trend, and we +return False. + +If we get to the end of the loop without finding a fault, then the word +passes the test. To convince yourself that the loop ends correctly, +consider an example like ``'flossy'``. The length of the word is 6, so +the last time the loop runs is when i is 4, which is the index of the +second-to-last character. On the last iteration, it compares the +second-to-last character to the last, which is what we want. + +Here is a version of ``is_palindrome`` (see Exercise [palindrome]) that +uses two indices; one starts at the beginning and goes up; the other +starts at the end and goes down. + +:: + + def is_palindrome(word): + i = 0 + j = len(word)-1 + + while i>> cheeses = ['Cheddar', 'Edam', 'Gouda'] + >>> numbers = [42, 123] + >>> empty = [] + >>> print(cheeses, numbers, empty) + ['Cheddar', 'Edam', 'Gouda'] [42, 123] [] + +Lists are mutable +----------------- + +The syntax for accessing the elements of a list is the same as for +accessing the characters of a string—the bracket operator. The +expression inside the brackets specifies the index. Remember that the +indices start at 0: + +:: + + >>> cheeses[0] + 'Cheddar' + +Unlike strings, lists are mutable. When the bracket operator appears on +the left side of an assignment, it identifies the element of the list +that will be assigned. + +:: + + >>> numbers = [42, 123] + >>> numbers[1] = 5 + >>> numbers + [42, 5] + +The one-eth element of numbers, which used to be 123, is now 5. + +Figure [fig.liststate] shows the state diagram for cheeses, numbers and +empty: + +.. figure:: figs/liststate.pdf + :alt: State diagram. + + State diagram. + +Lists are represented by boxes with the word “list” outside and the +elements of the list inside. cheeses refers to a list with three +elements indexed 0, 1 and 2. numbers contains two elements; the diagram +shows that the value of the second element has been reassigned from 123 +to 5. empty refers to a list with no elements. + +List indices work the same way as string indices: + +- Any integer expression can be used as an index. + +- If you try to read or write an element that does not exist, you get + an IndexError. + +- If an index has a negative value, it counts backward from the end of + the list. + +The in operator also works on lists. + +:: + + >>> cheeses = ['Cheddar', 'Edam', 'Gouda'] + >>> 'Edam' in cheeses + True + >>> 'Brie' in cheeses + False + +Traversing a list +----------------- + +The most common way to traverse the elements of a list is with a for +loop. The syntax is the same as for strings: + +:: + + for cheese in cheeses: + print(cheese) + +This works well if you only need to read the elements of the list. But +if you want to write or update the elements, you need the indices. A +common way to do that is to combine the built-in functions range and +len: + +:: + + for i in range(len(numbers)): + numbers[i] = numbers[i] * 2 + +This loop traverses the list and updates each element. len returns the +number of elements in the list. range returns a list of indices from 0 +to :math:`n-1`, where :math:`n` is the length of the list. Each time +through the loop i gets the index of the next element. The assignment +statement in the body uses i to read the old value of the element and to +assign the new value. + +A for loop over an empty list never runs the body: + +:: + + for x in []: + print('This never happens.') + +Although a list can contain another list, the nested list still counts +as a single element. The length of this list is four: + +:: + + ['spam', 1, ['Brie', 'Roquefort', 'Pol le Veq'], [1, 2, 3]] + +List operations +--------------- + +The + operator concatenates lists: + +:: + + >>> a = [1, 2, 3] + >>> b = [4, 5, 6] + >>> c = a + b + >>> c + [1, 2, 3, 4, 5, 6] + +The operator repeats a list a given number of times: + +:: + + >>> [0] * 4 + [0, 0, 0, 0] + >>> [1, 2, 3] * 3 + [1, 2, 3, 1, 2, 3, 1, 2, 3] + +The first example repeats four times. The second example repeats the +list three times. + +List slices +----------- + +The slice operator also works on lists: + +:: + + >>> t = ['a', 'b', 'c', 'd', 'e', 'f'] + >>> t[1:3] + ['b', 'c'] + >>> t[:4] + ['a', 'b', 'c', 'd'] + >>> t[3:] + ['d', 'e', 'f'] + +If you omit the first index, the slice starts at the beginning. If you +omit the second, the slice goes to the end. So if you omit both, the +slice is a copy of the whole list. + +:: + + >>> t[:] + ['a', 'b', 'c', 'd', 'e', 'f'] + +Since lists are mutable, it is often useful to make a copy before +performing operations that modify lists. + +A slice operator on the left side of an assignment can update multiple +elements: + +:: + + >>> t = ['a', 'b', 'c', 'd', 'e', 'f'] + >>> t[1:3] = ['x', 'y'] + >>> t + ['a', 'x', 'y', 'd', 'e', 'f'] + +List methods +------------ + +Python provides methods that operate on lists. For example, append adds +a new element to the end of a list: + +:: + + >>> t = ['a', 'b', 'c'] + >>> t.append('d') + >>> t + ['a', 'b', 'c', 'd'] + +extend takes a list as an argument and appends all of the elements: + +:: + + >>> t1 = ['a', 'b', 'c'] + >>> t2 = ['d', 'e'] + >>> t1.extend(t2) + >>> t1 + ['a', 'b', 'c', 'd', 'e'] + +This example leaves t2 unmodified. + +sort arranges the elements of the list from low to high: + +:: + + >>> t = ['d', 'c', 'e', 'b', 'a'] + >>> t.sort() + >>> t + ['a', 'b', 'c', 'd', 'e'] + +Most list methods are void; they modify the list and return None. If you +accidentally write t = t.sort(), you will be disappointed with the +result. + +Map, filter and reduce +---------------------- + +To add up all the numbers in a list, you can use a loop like this: + +:: + + def add_all(t): + total = 0 + for x in t: + total += x + return total + +total is initialized to 0. Each time through the loop, x gets one +element from the list. The += operator provides a short way to update a +variable. This **augmented assignment statement**, + +:: + + total += x + +is equivalent to + +:: + + total = total + x + +As the loop runs, total accumulates the sum of the elements; a variable +used this way is sometimes called an **accumulator**. + +Adding up the elements of a list is such a common operation that Python +provides it as a built-in function, sum: + +:: + + >>> t = [1, 2, 3] + >>> sum(t) + 6 + +An operation like this that combines a sequence of elements into a +single value is sometimes called **reduce**. + +Sometimes you want to traverse one list while building another. For +example, the following function takes a list of strings and returns a +new list that contains capitalized strings: + +:: + + def capitalize_all(t): + res = [] + for s in t: + res.append(s.capitalize()) + return res + +res is initialized with an empty list; each time through the loop, we +append the next element. So res is another kind of accumulator. + +An operation like ``capitalize_all`` is sometimes called a **map** +because it “maps” a function (in this case the method capitalize) onto +each of the elements in a sequence. + +Another common operation is to select some of the elements from a list +and return a sublist. For example, the following function takes a list +of strings and returns a list that contains only the uppercase strings: + +:: + + def only_upper(t): + res = [] + for s in t: + if s.isupper(): + res.append(s) + return res + +isupper is a string method that returns True if the string contains only +upper case letters. + +An operation like ``only_upper`` is called a **filter** because it +selects some of the elements and filters out the others. + +Most common list operations can be expressed as a combination of map, +filter and reduce. + +Deleting elements +----------------- + +There are several ways to delete elements from a list. If you know the +index of the element you want, you can use pop: + +:: + + >>> t = ['a', 'b', 'c'] + >>> x = t.pop(1) + >>> t + ['a', 'c'] + >>> x + 'b' + +pop modifies the list and returns the element that was removed. If you +don’t provide an index, it deletes and returns the last element. + +If you don’t need the removed value, you can use the del operator: + +:: + + >>> t = ['a', 'b', 'c'] + >>> del t[1] + >>> t + ['a', 'c'] + +If you know the element you want to remove (but not the index), you can +use remove: + +:: + + >>> t = ['a', 'b', 'c'] + >>> t.remove('b') + >>> t + ['a', 'c'] + +The return value from remove is None. + +To remove more than one element, you can use del with a slice index: + +:: + + >>> t = ['a', 'b', 'c', 'd', 'e', 'f'] + >>> del t[1:5] + >>> t + ['a', 'f'] + +As usual, the slice selects all the elements up to but not including the +second index. + +Lists and strings +----------------- + +A string is a sequence of characters and a list is a sequence of values, +but a list of characters is not the same as a string. To convert from a +string to a list of characters, you can use list: + +:: + + >>> s = 'spam' + >>> t = list(s) + >>> t + ['s', 'p', 'a', 'm'] + +Because list is the name of a built-in function, you should avoid using +it as a variable name. I also avoid l because it looks too much like 1. +So that’s why I use t. + +The list function breaks a string into individual letters. If you want +to break a string into words, you can use the split method: + +:: + + >>> s = 'pining for the fjords' + >>> t = s.split() + >>> t + ['pining', 'for', 'the', 'fjords'] + +An optional argument called a **delimiter** specifies which characters +to use as word boundaries. The following example uses a hyphen as a +delimiter: + +:: + + >>> s = 'spam-spam-spam' + >>> delimiter = '-' + >>> t = s.split(delimiter) + >>> t + ['spam', 'spam', 'spam'] + +join is the inverse of split. It takes a list of strings and +concatenates the elements. join is a string method, so you have to +invoke it on the delimiter and pass the list as a parameter: + +:: + + >>> t = ['pining', 'for', 'the', 'fjords'] + >>> delimiter = ' ' + >>> s = delimiter.join(t) + >>> s + 'pining for the fjords' + +In this case the delimiter is a space character, so join puts a space +between words. To concatenate strings without spaces, you can use the +empty string, ``''``, as a delimiter. + +Objects and values +------------------ + +If we run these assignment statements: + +:: + + a = 'banana' + b = 'banana' + +We know that a and b both refer to a string, but we don’t know whether +they refer to the *same* string. There are two possible states, shown in +Figure [fig.list1]. + +.. figure:: figs/list1.pdf + :alt: State diagram. + + State diagram. + +In one case, a and b refer to two different objects that have the same +value. In the second case, they refer to the same object. + +To check whether two variables refer to the same object, you can use the +is operator. + +:: + + >>> a = 'banana' + >>> b = 'banana' + >>> a is b + True + +In this example, Python only created one string object, and both a and b +refer to it. But when you create two lists, you get two objects: + +:: + + >>> a = [1, 2, 3] + >>> b = [1, 2, 3] + >>> a is b + False + +So the state diagram looks like Figure [fig.list2]. + +.. figure:: figs/list2.pdf + :alt: State diagram. + + State diagram. + +In this case we would say that the two lists are **equivalent**, because +they have the same elements, but not **identical**, because they are not +the same object. If two objects are identical, they are also equivalent, +but if they are equivalent, they are not necessarily identical. + +Until now, we have been using “object” and “value” interchangeably, but +it is more precise to say that an object has a value. If you evaluate , +you get a list object whose value is a sequence of integers. If another +list has the same elements, we say it has the same value, but it is not +the same object. + +Aliasing +-------- + +If a refers to an object and you assign b = a, then both variables refer +to the same object: + +:: + + >>> a = [1, 2, 3] + >>> b = a + >>> b is a + True + +The state diagram looks like Figure [fig.list3]. + +.. figure:: figs/list3.pdf + :alt: State diagram. + + State diagram. + +The association of a variable with an object is called a **reference**. +In this example, there are two references to the same object. + +An object with more than one reference has more than one name, so we say +that the object is **aliased**. + +If the aliased object is mutable, changes made with one alias affect the +other: + +:: + + >>> b[0] = 42 + >>> a + [42, 2, 3] + +Although this behavior can be useful, it is error-prone. In general, it +is safer to avoid aliasing when you are working with mutable objects. + +For immutable objects like strings, aliasing is not as much of a +problem. In this example: + +:: + + a = 'banana' + b = 'banana' + +It almost never makes a difference whether a and b refer to the same +string or not. + +List arguments +-------------- + +When you pass a list to a function, the function gets a reference to the +list. If the function modifies the list, the caller sees the change. For +example, ``delete_head`` removes the first element from a list: + +:: + + def delete_head(t): + del t[0] + +Here’s how it is used: + +:: + + >>> letters = ['a', 'b', 'c'] + >>> delete_head(letters) + >>> letters + ['b', 'c'] + +The parameter t and the variable letters are aliases for the same +object. The stack diagram looks like Figure [fig.stack5]. + +.. figure:: figs/stack5.pdf + :alt: Stack diagram. + + Stack diagram. + +Since the list is shared by two frames, I drew it between them. + +It is important to distinguish between operations that modify lists and +operations that create new lists. For example, the append method +modifies a list, but the + operator creates a new list: + +:: + + >>> t1 = [1, 2] + >>> t2 = t1.append(3) + >>> t1 + [1, 2, 3] + >>> t2 + None + +append modifies the list and returns None. + +:: + + >>> t3 = t1 + [4] + >>> t1 + [1, 2, 3] + >>> t3 + [1, 2, 3, 4] + >>> t1 + +The + operator creates a new list and leaves the original list +unchanged. + +This difference is important when you write functions that are supposed +to modify lists. For example, this function *does not* delete the head +of a list: + +:: + + def bad_delete_head(t): + t = t[1:] # WRONG! + +The slice operator creates a new list and the assignment makes t refer +to it, but that doesn’t affect the caller. + +:: + + >>> t4 = [1, 2, 3] + >>> bad_delete_head(t4) + >>> t4 + [1, 2, 3] + +At the beginning of ``bad_delete_head``, t and t4 refer to the same +list. At the end, t refers to a new list, but t4 still refers to the +original, unmodified list. + +An alternative is to write a function that creates and returns a new +list. For example, tail returns all but the first element of a list: + +:: + + def tail(t): + return t[1:] + +This function leaves the original list unmodified. Here’s how it is +used: + +:: + + >>> letters = ['a', 'b', 'c'] + >>> rest = tail(letters) + >>> rest + ['b', 'c'] + +Debugging +--------- + +Careless use of lists (and other mutable objects) can lead to long hours +of debugging. Here are some common pitfalls and ways to avoid them: + +#. Most list methods modify the argument and return None. This is the + opposite of the string methods, which return a new string and leave + the original alone. + + If you are used to writing string code like this: + + :: + + word = word.strip() + + It is tempting to write list code like this: + + :: + + t = t.sort() # WRONG! + + Because sort returns None, the next operation you perform with t is + likely to fail. + + Before using list methods and operators, you should read the + documentation carefully and then test them in interactive mode. + +#. Pick an idiom and stick with it. + + Part of the problem with lists is that there are too many ways to do + things. For example, to remove an element from a list, you can use + pop, remove, del, or even a slice assignment. + + To add an element, you can use the append method or the + operator. + Assuming that t is a list and x is a list element, these are correct: + + :: + + t.append(x) + t = t + [x] + t += [x] + + And these are wrong: + + :: + + t.append([x]) # WRONG! + t = t.append(x) # WRONG! + t + [x] # WRONG! + t = t + x # WRONG! + + Try out each of these examples in interactive mode to make sure you + understand what they do. Notice that only the last one causes a + runtime error; the other three are legal, but they do the wrong + thing. + +#. Make copies to avoid aliasing. + + If you want to use a method like sort that modifies the argument, but + you need to keep the original list as well, you can make a copy. + + :: + + >>> t = [3, 1, 2] + >>> t2 = t[:] + >>> t2.sort() + >>> t + [3, 1, 2] + >>> t2 + [1, 2, 3] + + In this example you could also use the built-in function sorted, + which returns a new, sorted list and leaves the original alone. + + :: + + >>> t2 = sorted(t) + >>> t + [3, 1, 2] + >>> t2 + [1, 2, 3] + +Glossary +-------- + +list: + A sequence of values. + +element: + One of the values in a list (or other sequence), also called items. + +nested list: + A list that is an element of another list. + +accumulator: + A variable used in a loop to add up or accumulate a result. + +augmented assignment: + A statement that updates the value of a variable using an operator + like ``+=``. + +reduce: + A processing pattern that traverses a sequence and accumulates the + elements into a single result. + +map: + A processing pattern that traverses a sequence and performs an + operation on each element. + +filter: + A processing pattern that traverses a list and selects the elements + that satisfy some criterion. + +object: + Something a variable can refer to. An object has a type and a value. + +equivalent: + Having the same value. + +identical: + Being the same object (which implies equivalence). + +reference: + The association between a variable and its value. + +aliasing: + A circumstance where two or more variables refer to the same object. + +delimiter: + A character or string used to indicate where a string should be + split. + +Exercises +--------- + +You can download solutions to these exercises from +http://thinkpython2.com/code/list_exercises.py. + +Write a function called ``nested_sum`` that takes a list of lists of +integers and adds up the elements from all of the nested lists. For +example: + +:: + + >>> t = [[1, 2], [3], [4, 5, 6]] + >>> nested_sum(t) + 21 + +[cumulative] + +Write a function called cumsum that takes a list of numbers and returns +the cumulative sum; that is, a new list where the :math:`i`\ th element +is the sum of the first :math:`i+1` elements from the original list. For +example: + +:: + + >>> t = [1, 2, 3] + >>> cumsum(t) + [1, 3, 6] + +Write a function called ``middle`` that takes a list and returns a new +list that contains all but the first and last elements. For example: + +:: + + >>> t = [1, 2, 3, 4] + >>> middle(t) + [2, 3] + +Write a function called ``chop`` that takes a list, modifies it by +removing the first and last elements, and returns None. For example: + +:: + + >>> t = [1, 2, 3, 4] + >>> chop(t) + >>> t + [2, 3] + +Write a function called ``is_sorted`` that takes a list as a parameter +and returns True if the list is sorted in ascending order and False +otherwise. For example: + +:: + + >>> is_sorted([1, 2, 2]) + True + >>> is_sorted(['b', 'a']) + False + +[anagram] + +Two words are anagrams if you can rearrange the letters from one to +spell the other. Write a function called ``is_anagram`` that takes two +strings and returns True if they are anagrams. + +[duplicate] + +Write a function called ``has_duplicates`` that takes a list and returns +True if there is any element that appears more than once. It should not +modify the original list. + +This exercise pertains to the so-called Birthday Paradox, which you can +read about at http://en.wikipedia.org/wiki/Birthday_paradox. + +If there are 23 students in your class, what are the chances that two of +you have the same birthday? You can estimate this probability by +generating random samples of 23 birthdays and checking for matches. +Hint: you can generate random birthdays with the randint function in the +random module. + +You can download my solution from +http://thinkpython2.com/code/birthday.py. + +Write a function that reads the file words.txt and builds a list with +one element per word. Write two versions of this function, one using the +append method and the other using the idiom t = t + [x]. Which one takes +longer to run? Why? + +Solution: http://thinkpython2.com/code/wordlist.py. + +[wordlist1] [bisection] + +To check whether a word is in the word list, you could use the in +operator, but it would be slow because it searches through the words in +order. + +Because the words are in alphabetical order, we can speed things up with +a bisection search (also known as binary search), which is similar to +what you do when you look a word up in the dictionary. You start in the +middle and check to see whether the word you are looking for comes +before the word in the middle of the list. If so, you search the first +half of the list the same way. Otherwise you search the second half. + +Either way, you cut the remaining search space in half. If the word list +has 113,809 words, it will take about 17 steps to find the word or +conclude that it’s not there. + +Write a function called ``in_bisect`` that takes a sorted list and a +target value and returns the index of the value in the list if it’s +there, or None if it’s not. + +Or you could read the documentation of the bisect module and use that! +Solution: http://thinkpython2.com/code/inlist.py. + +Two words are a “reverse pair” if each is the reverse of the other. +Write a program that finds all the reverse pairs in the word list. +Solution: http://thinkpython2.com/code/reverse_pair.py. + +Two words “interlock” if taking alternating letters from each forms a +new word. For example, “shoe” and “cold” interlock to form “schooled”. +Solution: http://thinkpython2.com/code/interlock.py. Credit: This +exercise is inspired by an example at http://puzzlers.org. + +#. Write a program that finds all pairs of words that interlock. Hint: + don’t enumerate all pairs! + +#. Can you find any words that are three-way interlocked; that is, every + third letter forms a word, starting from the first, second or third? + +Dictionaries +============ + +This chapter presents another built-in type called a dictionary. +Dictionaries are one of Python’s best features; they are the building +blocks of many efficient and elegant algorithms. + +A dictionary is a mapping +------------------------- + +A **dictionary** is like a list, but more general. In a list, the +indices have to be integers; in a dictionary they can be (almost) any +type. + +A dictionary contains a collection of indices, which are called +**keys**, and a collection of values. Each key is associated with a +single value. The association of a key and a value is called a +**key-value pair** or sometimes an **item**. + +In mathematical language, a dictionary represents a **mapping** from +keys to values, so you can also say that each key “maps to” a value. As +an example, we’ll build a dictionary that maps from English to Spanish +words, so the keys and the values are all strings. + +The function dict creates a new dictionary with no items. Because dict +is the name of a built-in function, you should avoid using it as a +variable name. + +:: + + >>> eng2sp = dict() + >>> eng2sp + {} + +The squiggly-brackets, ``{}``, represent an empty dictionary. To add +items to the dictionary, you can use square brackets: + +:: + + >>> eng2sp['one'] = 'uno' + +This line creates an item that maps from the key ``'one'`` to the value +``'uno'``. If we print the dictionary again, we see a key-value pair +with a colon between the key and value: + +:: + + >>> eng2sp + {'one': 'uno'} + +This output format is also an input format. For example, you can create +a new dictionary with three items: + +:: + + >>> eng2sp = {'one': 'uno', 'two': 'dos', 'three': 'tres'} + +But if you print eng2sp, you might be surprised: + +:: + + >>> eng2sp + {'one': 'uno', 'three': 'tres', 'two': 'dos'} + +The order of the key-value pairs might not be the same. If you type the +same example on your computer, you might get a different result. In +general, the order of items in a dictionary is unpredictable. + +But that’s not a problem because the elements of a dictionary are never +indexed with integer indices. Instead, you use the keys to look up the +corresponding values: + +:: + + >>> eng2sp['two'] + 'dos' + +The key ``'two'`` always maps to the value ``'dos'`` so the order of the +items doesn’t matter. + +If the key isn’t in the dictionary, you get an exception: + +:: + + >>> eng2sp['four'] + KeyError: 'four' + +The len function works on dictionaries; it returns the number of +key-value pairs: + +:: + + >>> len(eng2sp) + 3 + +The in operator works on dictionaries, too; it tells you whether +something appears as a *key* in the dictionary (appearing as a value is +not good enough). + +:: + + >>> 'one' in eng2sp + True + >>> 'uno' in eng2sp + False + +To see whether something appears as a value in a dictionary, you can use +the method values, which returns a collection of values, and then use +the in operator: + +:: + + >>> vals = eng2sp.values() + >>> 'uno' in vals + True + +The in operator uses different algorithms for lists and dictionaries. +For lists, it searches the elements of the list in order, as in +Section [find]. As the list gets longer, the search time gets longer in +direct proportion. + +For dictionaries, Python uses an algorithm called a **hashtable** that +has a remarkable property: the in operator takes about the same amount +of time no matter how many items are in the dictionary. I explain how +that’s possible in Section [hashtable], but the explanation might not +make sense until you’ve read a few more chapters. + +Dictionary as a collection of counters +-------------------------------------- + +Suppose you are given a string and you want to count how many times each +letter appears. There are several ways you could do it: + +#. You could create 26 variables, one for each letter of the alphabet. + Then you could traverse the string and, for each character, increment + the corresponding counter, probably using a chained conditional. + +#. You could create a list with 26 elements. Then you could convert each + character to a number (using the built-in function ord), use the + number as an index into the list, and increment the appropriate + counter. + +#. You could create a dictionary with characters as keys and counters as + the corresponding values. The first time you see a character, you + would add an item to the dictionary. After that you would increment + the value of an existing item. + +Each of these options performs the same computation, but each of them +implements that computation in a different way. + +An **implementation** is a way of performing a computation; some +implementations are better than others. For example, an advantage of the +dictionary implementation is that we don’t have to know ahead of time +which letters appear in the string and we only have to make room for the +letters that do appear. + +Here is what the code might look like: + +:: + + def histogram(s): + d = dict() + for c in s: + if c not in d: + d[c] = 1 + else: + d[c] += 1 + return d + +The name of the function is histogram, which is a statistical term for a +collection of counters (or frequencies). + +The first line of the function creates an empty dictionary. The for loop +traverses the string. Each time through the loop, if the character c is +not in the dictionary, we create a new item with key c and the initial +value 1 (since we have seen this letter once). If c is already in the +dictionary we increment d[c]. + +Here’s how it works: + +:: + + >>> h = histogram('brontosaurus') + >>> h + {'a': 1, 'b': 1, 'o': 2, 'n': 1, 's': 2, 'r': 2, 'u': 2, 't': 1} + +The histogram indicates that the letters ``'a'`` and ``'b'`` appear +once; ``'o'`` appears twice, and so on. + +Dictionaries have a method called get that takes a key and a default +value. If the key appears in the dictionary, get returns the +corresponding value; otherwise it returns the default value. For +example: + +:: + + >>> h = histogram('a') + >>> h + {'a': 1} + >>> h.get('a', 0) + 1 + >>> h.get('b', 0) + 0 + +As an exercise, use get to write histogram more concisely. You should be +able to eliminate the if statement. + +Looping and dictionaries +------------------------ + +If you use a dictionary in a for statement, it traverses the keys of the +dictionary. For example, ``print_hist`` prints each key and the +corresponding value: + +:: + + def print_hist(h): + for c in h: + print(c, h[c]) + +Here’s what the output looks like: + +:: + + >>> h = histogram('parrot') + >>> print_hist(h) + a 1 + p 1 + r 2 + t 1 + o 1 + +Again, the keys are in no particular order. To traverse the keys in +sorted order, you can use the built-in function sorted: + +:: + + >>> for key in sorted(h): + ... print(key, h[key]) + a 1 + o 1 + p 1 + r 2 + t 1 + +Reverse lookup +-------------- + +Given a dictionary d and a key k, it is easy to find the corresponding +value v = d[k]. This operation is called a **lookup**. + +But what if you have v and you want to find k? You have two problems: +first, there might be more than one key that maps to the value v. +Depending on the application, you might be able to pick one, or you +might have to make a list that contains all of them. Second, there is no +simple syntax to do a **reverse lookup**; you have to search. + +Here is a function that takes a value and returns the first key that +maps to that value: + +:: + + def reverse_lookup(d, v): + for k in d: + if d[k] == v: + return k + raise LookupError() + +This function is yet another example of the search pattern, but it uses +a feature we haven’t seen before, raise. The **raise statement** causes +an exception; in this case it causes a LookupError, which is a built-in +exception used to indicate that a lookup operation failed. + +If we get to the end of the loop, that means v doesn’t appear in the +dictionary as a value, so we raise an exception. + +Here is an example of a successful reverse lookup: + +:: + + >>> h = histogram('parrot') + >>> key = reverse_lookup(h, 2) + >>> key + 'r' + +And an unsuccessful one: + +:: + + >>> key = reverse_lookup(h, 3) + Traceback (most recent call last): + File "", line 1, in + File "", line 5, in reverse_lookup + LookupError + +The effect when you raise an exception is the same as when Python raises +one: it prints a traceback and an error message. + +The raise statement can take a detailed error message as an optional +argument. For example: + +:: + + >>> raise LookupError('value does not appear in the dictionary') + Traceback (most recent call last): + File "", line 1, in ? + LookupError: value does not appear in the dictionary + +A reverse lookup is much slower than a forward lookup; if you have to do +it often, or if the dictionary gets big, the performance of your program +will suffer. + +Dictionaries and lists +---------------------- + +Lists can appear as values in a dictionary. For example, if you are +given a dictionary that maps from letters to frequencies, you might want +to invert it; that is, create a dictionary that maps from frequencies to +letters. Since there might be several letters with the same frequency, +each value in the inverted dictionary should be a list of letters. + +Here is a function that inverts a dictionary: + +:: + + def invert_dict(d): + inverse = dict() + for key in d: + val = d[key] + if val not in inverse: + inverse[val] = [key] + else: + inverse[val].append(key) + return inverse + +Each time through the loop, key gets a key from d and val gets the +corresponding value. If val is not in inverse, that means we haven’t +seen it before, so we create a new item and initialize it with a +**singleton** (a list that contains a single element). Otherwise we have +seen this value before, so we append the corresponding key to the list. + +Here is an example: + +:: + + >>> hist = histogram('parrot') + >>> hist + {'a': 1, 'p': 1, 'r': 2, 't': 1, 'o': 1} + >>> inverse = invert_dict(hist) + >>> inverse + {1: ['a', 'p', 't', 'o'], 2: ['r']} + +.. figure:: figs/dict1.pdf + :alt: State diagram. + + State diagram. + +Figure [fig.dict1] is a state diagram showing hist and inverse. A +dictionary is represented as a box with the type dict above it and the +key-value pairs inside. If the values are integers, floats or strings, I +draw them inside the box, but I usually draw lists outside the box, just +to keep the diagram simple. + +Lists can be values in a dictionary, as this example shows, but they +cannot be keys. Here’s what happens if you try: + +:: + + >>> t = [1, 2, 3] + >>> d = dict() + >>> d[t] = 'oops' + Traceback (most recent call last): + File "", line 1, in ? + TypeError: list objects are unhashable + +I mentioned earlier that a dictionary is implemented using a hashtable +and that means that the keys have to be **hashable**. + +A **hash** is a function that takes a value (of any kind) and returns an +integer. Dictionaries use these integers, called hash values, to store +and look up key-value pairs. + +This system works fine if the keys are immutable. But if the keys are +mutable, like lists, bad things happen. For example, when you create a +key-value pair, Python hashes the key and stores it in the corresponding +location. If you modify the key and then hash it again, it would go to a +different location. In that case you might have two entries for the same +key, or you might not be able to find a key. Either way, the dictionary +wouldn’t work correctly. + +That’s why keys have to be hashable, and why mutable types like lists +aren’t. The simplest way to get around this limitation is to use tuples, +which we will see in the next chapter. + +Since dictionaries are mutable, they can’t be used as keys, but they +*can* be used as values. + +Memos +----- + +If you played with the fibonacci function from +Section [one.more.example], you might have noticed that the bigger the +argument you provide, the longer the function takes to run. Furthermore, +the run time increases quickly. + +To understand why, consider Figure [fig.fibonacci], which shows the +**call graph** for fibonacci with n=4: + +.. figure:: figs/fibonacci.pdf + :alt: Call graph. + + Call graph. + +A call graph shows a set of function frames, with lines connecting each +frame to the frames of the functions it calls. At the top of the graph, +fibonacci with n=4 calls fibonacci with n=3 and n=2. In turn, fibonacci +with n=3 calls fibonacci with n=2 and n=1. And so on. + +Count how many times fibonacci(0) and fibonacci(1) are called. This is +an inefficient solution to the problem, and it gets worse as the +argument gets bigger. + +One solution is to keep track of values that have already been computed +by storing them in a dictionary. A previously computed value that is +stored for later use is called a **memo**. Here is a “memoized” version +of fibonacci: + +:: + + known = {0:0, 1:1} + + def fibonacci(n): + if n in known: + return known[n] + + res = fibonacci(n-1) + fibonacci(n-2) + known[n] = res + return res + +known is a dictionary that keeps track of the Fibonacci numbers we +already know. It starts with two items: 0 maps to 0 and 1 maps to 1. + +Whenever fibonacci is called, it checks known. If the result is already +there, it can return immediately. Otherwise it has to compute the new +value, add it to the dictionary, and return it. + +If you run this version of fibonacci and compare it with the original, +you will find that it is much faster. + +Global variables +---------------- + +In the previous example, known is created outside the function, so it +belongs to the special frame called ``__main__``. Variables in +``__main__`` are sometimes called **global** because they can be +accessed from any function. Unlike local variables, which disappear when +their function ends, global variables persist from one function call to +the next. + +It is common to use global variables for **flags**; that is, boolean +variables that indicate (“flag”) whether a condition is true. For +example, some programs use a flag named verbose to control the level of +detail in the output: + +:: + + verbose = True + + def example1(): + if verbose: + print('Running example1') + +If you try to reassign a global variable, you might be surprised. The +following example is supposed to keep track of whether the function has +been called: + +:: + + been_called = False + + def example2(): + been_called = True # WRONG + +But if you run it you will see that the value of ``been_called`` doesn’t +change. The problem is that example2 creates a new local variable named +``been_called``. The local variable goes away when the function ends, +and has no effect on the global variable. + +To reassign a global variable inside a function you have to **declare** +the global variable before you use it: + +:: + + been_called = False + + def example2(): + global been_called + been_called = True + +The **global statement** tells the interpreter something like, “In this +function, when I say ``been_called``, I mean the global variable; don’t +create a local one.” + +Here’s an example that tries to update a global variable: + +:: + + count = 0 + + def example3(): + count = count + 1 # WRONG + +If you run it you get: + +:: + + UnboundLocalError: local variable 'count' referenced before assignment + +Python assumes that count is local, and under that assumption you are +reading it before writing it. The solution, again, is to declare count +global. + +:: + + def example3(): + global count + count += 1 + +If a global variable refers to a mutable value, you can modify the value +without declaring the variable: + +:: + + known = {0:0, 1:1} + + def example4(): + known[2] = 1 + +So you can add, remove and replace elements of a global list or +dictionary, but if you want to reassign the variable, you have to +declare it: + +:: + + def example5(): + global known + known = dict() + +Global variables can be useful, but if you have a lot of them, and you +modify them frequently, they can make programs hard to debug. + +Debugging +--------- + +As you work with bigger datasets it can become unwieldy to debug by +printing and checking the output by hand. Here are some suggestions for +debugging large datasets: + +Scale down the input: + If possible, reduce the size of the dataset. For example if the + program reads a text file, start with just the first 10 lines, or + with the smallest example you can find. You can either edit the + files themselves, or (better) modify the program so it reads only + the first n lines. + + If there is an error, you can reduce n to the smallest value that + manifests the error, and then increase it gradually as you find and + correct errors. + +Check summaries and types: + Instead of printing and checking the entire dataset, consider + printing summaries of the data: for example, the number of items in + a dictionary or the total of a list of numbers. + + A common cause of runtime errors is a value that is not the right + type. For debugging this kind of error, it is often enough to print + the type of a value. + +Write self-checks: + Sometimes you can write code to check for errors automatically. For + example, if you are computing the average of a list of numbers, you + could check that the result is not greater than the largest element + in the list or less than the smallest. This is called a “sanity + check” because it detects results that are “insane”. + + Another kind of check compares the results of two different + computations to see if they are consistent. This is called a + “consistency check”. + +Format the output: + Formatting debugging output can make it easier to spot an error. We + saw an example in Section [factdebug]. The pprint module provides a + pprint function that displays built-in types in a more + human-readable format (pprint stands for “pretty print”). + +Again, time you spend building scaffolding can reduce the time you spend +debugging. + +Glossary +-------- + +mapping: + A relationship in which each element of one set corresponds to an + element of another set. + +dictionary: + A mapping from keys to their corresponding values. + +key-value pair: + The representation of the mapping from a key to a value. + +item: + In a dictionary, another name for a key-value pair. + +key: + An object that appears in a dictionary as the first part of a + key-value pair. + +value: + An object that appears in a dictionary as the second part of a + key-value pair. This is more specific than our previous use of the + word “value”. + +implementation: + A way of performing a computation. + +hashtable: + The algorithm used to implement Python dictionaries. + +hash function: + A function used by a hashtable to compute the location for a key. + +hashable: + A type that has a hash function. Immutable types like integers, + floats and strings are hashable; mutable types like lists and + dictionaries are not. + +lookup: + A dictionary operation that takes a key and finds the corresponding + value. + +reverse lookup: + A dictionary operation that takes a value and finds one or more keys + that map to it. + +raise statement: + A statement that (deliberately) raises an exception. + +singleton: + A list (or other sequence) with a single element. + +call graph: + A diagram that shows every frame created during the execution of a + program, with an arrow from each caller to each callee. + +memo: + A computed value stored to avoid unnecessary future computation. + +global variable: + A variable defined outside a function. Global variables can be + accessed from any function. + +global statement: + A statement that declares a variable name global. + +flag: + A boolean variable used to indicate whether a condition is true. + +declaration: + A statement like global that tells the interpreter something about a + variable. + +Exercises +--------- + +[wordlist2] + +Write a function that reads the words in words.txt and stores them as +keys in a dictionary. It doesn’t matter what the values are. Then you +can use the in operator as a fast way to check whether a string is in +the dictionary. + +If you did Exercise [wordlist1], you can compare the speed of this +implementation with the list in operator and the bisection search. + +[setdefault] + +Read the documentation of the dictionary method setdefault and use it to +write a more concise version of ``invert_dict``. Solution: +http://thinkpython2.com/code/invert_dict.py. + +Memoize the Ackermann function from Exercise [ackermann] and see if +memoization makes it possible to evaluate the function with bigger +arguments. Hint: no. Solution: +http://thinkpython2.com/code/ackermann_memo.py. + +If you did Exercise [duplicate], you already have a function named +``has_duplicates`` that takes a list as a parameter and returns True if +there is any object that appears more than once in the list. + +Use a dictionary to write a faster, simpler version of +``has_duplicates``. Solution: +http://thinkpython2.com/code/has_duplicates.py. + +[exrotatepairs] + +Two words are “rotate pairs” if you can rotate one of them and get the +other (see ``rotate_word`` in Exercise [exrotate]). + +Write a program that reads a wordlist and finds all the rotate pairs. +Solution: http://thinkpython2.com/code/rotate_pairs.py. + +Here’s another Puzzler from *Car Talk* +(http://www.cartalk.com/content/puzzlers): + + This was sent in by a fellow named Dan O’Leary. He came upon a + common one-syllable, five-letter word recently that has the + following unique property. When you remove the first letter, the + remaining letters form a homophone of the original word, that is a + word that sounds exactly the same. Replace the first letter, that + is, put it back and remove the second letter and the result is yet + another homophone of the original word. And the question is, what’s + the word? + + Now I’m going to give you an example that doesn’t work. Let’s look + at the five-letter word, ‘wrack.’ W-R-A-C-K, you know like to ‘wrack + with pain.’ If I remove the first letter, I am left with a + four-letter word, ’R-A-C-K.’ As in, ‘Holy cow, did you see the rack + on that buck! It must have been a nine-pointer!’ It’s a perfect + homophone. If you put the ‘w’ back, and remove the ‘r,’ instead, + you’re left with the word, ‘wack,’ which is a real word, it’s just + not a homophone of the other two words. + + But there is, however, at least one word that Dan and we know of, + which will yield two homophones if you remove either of the first + two letters to make two, new four-letter words. The question is, + what’s the word? + +You can use the dictionary from Exercise [wordlist2] to check whether a +string is in the word list. + +To check whether two words are homophones, you can use the CMU +Pronouncing Dictionary. You can download it from +http://www.speech.cs.cmu.edu/cgi-bin/cmudict or from +http://thinkpython2.com/code/c06d and you can also download +http://thinkpython2.com/code/pronounce.py, which provides a function +named ``read_dictionary`` that reads the pronouncing dictionary and +returns a Python dictionary that maps from each word to a string that +describes its primary pronunciation. + +Write a program that lists all the words that solve the Puzzler. +Solution: http://thinkpython2.com/code/homophone.py. + +Tuples +====== + +This chapter presents one more built-in type, the tuple, and then shows +how lists, dictionaries, and tuples work together. I also present a +useful feature for variable-length argument lists, the gather and +scatter operators. + +One note: there is no consensus on how to pronounce “tuple”. Some people +say “tuh-ple”, which rhymes with “supple”. But in the context of +programming, most people say “too-ple”, which rhymes with “quadruple”. + +Tuples are immutable +-------------------- + +A tuple is a sequence of values. The values can be any type, and they +are indexed by integers, so in that respect tuples are a lot like lists. +The important difference is that tuples are immutable. + +Syntactically, a tuple is a comma-separated list of values: + +:: + + >>> t = 'a', 'b', 'c', 'd', 'e' + +Although it is not necessary, it is common to enclose tuples in +parentheses: + +:: + + >>> t = ('a', 'b', 'c', 'd', 'e') + +To create a tuple with a single element, you have to include a final +comma: + +:: + + >>> t1 = 'a', + >>> type(t1) + + +A value in parentheses is not a tuple: + +:: + + >>> t2 = ('a') + >>> type(t2) + + +Another way to create a tuple is the built-in function tuple. With no +argument, it creates an empty tuple: + +:: + + >>> t = tuple() + >>> t + () + +If the argument is a sequence (string, list or tuple), the result is a +tuple with the elements of the sequence: + +:: + + >>> t = tuple('lupins') + >>> t + ('l', 'u', 'p', 'i', 'n', 's') + +Because tuple is the name of a built-in function, you should avoid using +it as a variable name. + +Most list operators also work on tuples. The bracket operator indexes an +element: + +:: + + >>> t = ('a', 'b', 'c', 'd', 'e') + >>> t[0] + 'a' + +And the slice operator selects a range of elements. + +:: + + >>> t[1:3] + ('b', 'c') + +But if you try to modify one of the elements of the tuple, you get an +error: + +:: + + >>> t[0] = 'A' + TypeError: object doesn't support item assignment + +Because tuples are immutable, you can’t modify the elements. But you can +replace one tuple with another: + +:: + + >>> t = ('A',) + t[1:] + >>> t + ('A', 'b', 'c', 'd', 'e') + +This statement makes a new tuple and then makes t refer to it. + +The relational operators work with tuples and other sequences; Python +starts by comparing the first element from each sequence. If they are +equal, it goes on to the next elements, and so on, until it finds +elements that differ. Subsequent elements are not considered (even if +they are really big). + +:: + + >>> (0, 1, 2) < (0, 3, 4) + True + >>> (0, 1, 2000000) < (0, 3, 4) + True + +Tuple assignment +---------------- + +It is often useful to swap the values of two variables. With +conventional assignments, you have to use a temporary variable. For +example, to swap a and b: + +:: + + >>> temp = a + >>> a = b + >>> b = temp + +This solution is cumbersome; **tuple assignment** is more elegant: + +:: + + >>> a, b = b, a + +The left side is a tuple of variables; the right side is a tuple of +expressions. Each value is assigned to its respective variable. All the +expressions on the right side are evaluated before any of the +assignments. + +The number of variables on the left and the number of values on the +right have to be the same: + +:: + + >>> a, b = 1, 2, 3 + ValueError: too many values to unpack + +More generally, the right side can be any kind of sequence (string, list +or tuple). For example, to split an email address into a user name and a +domain, you could write: + +:: + + >>> addr = 'monty@python.org' + >>> uname, domain = addr.split('@') + +The return value from split is a list with two elements; the first +element is assigned to uname, the second to domain. + +:: + + >>> uname + 'monty' + >>> domain + 'python.org' + +Tuples as return values +----------------------- + +Strictly speaking, a function can only return one value, but if the +value is a tuple, the effect is the same as returning multiple values. +For example, if you want to divide two integers and compute the quotient +and remainder, it is inefficient to compute x/y and then x%y. It is +better to compute them both at the same time. + +The built-in function divmod takes two arguments and returns a tuple of +two values, the quotient and remainder. You can store the result as a +tuple: + +:: + + >>> t = divmod(7, 3) + >>> t + (2, 1) + +Or use tuple assignment to store the elements separately: + +:: + + >>> quot, rem = divmod(7, 3) + >>> quot + 2 + >>> rem + 1 + +Here is an example of a function that returns a tuple: + +:: + + def min_max(t): + return min(t), max(t) + +max and min are built-in functions that find the largest and smallest +elements of a sequence. ``min_max`` computes both and returns a tuple of +two values. + +Variable-length argument tuples +------------------------------- + +Functions can take a variable number of arguments. A parameter name that +begins with **gathers** arguments into a tuple. For example, printall +takes any number of arguments and prints them: + +:: + + def printall(*args): + print(args) + +The gather parameter can have any name you like, but args is +conventional. Here’s how the function works: + +:: + + >>> printall(1, 2.0, '3') + (1, 2.0, '3') + +The complement of gather is **scatter**. If you have a sequence of +values and you want to pass it to a function as multiple arguments, you +can use the operator. For example, divmod takes exactly two arguments; +it doesn’t work with a tuple: + +:: + + >>> t = (7, 3) + >>> divmod(t) + TypeError: divmod expected 2 arguments, got 1 + +But if you scatter the tuple, it works: + +:: + + >>> divmod(*t) + (2, 1) + +Many of the built-in functions use variable-length argument tuples. For +example, max and min can take any number of arguments: + +:: + + >>> max(1, 2, 3) + 3 + +But sum does not. + +:: + + >>> sum(1, 2, 3) + TypeError: sum expected at most 2 arguments, got 3 + +As an exercise, write a function called sumall that takes any number of +arguments and returns their sum. + +Lists and tuples +---------------- + +zip is a built-in function that takes two or more sequences and returns +a list of tuples where each tuple contains one element from each +sequence. The name of the function refers to a zipper, which joins and +interleaves two rows of teeth. + +This example zips a string and a list: + +:: + + >>> s = 'abc' + >>> t = [0, 1, 2] + >>> zip(s, t) + + +The result is a **zip object** that knows how to iterate through the +pairs. The most common use of zip is in a for loop: + +:: + + >>> for pair in zip(s, t): + ... print(pair) + ... + ('a', 0) + ('b', 1) + ('c', 2) + +A zip object is a kind of **iterator**, which is any object that +iterates through a sequence. Iterators are similar to lists in some +ways, but unlike lists, you can’t use an index to select an element from +an iterator. + +If you want to use list operators and methods, you can use a zip object +to make a list: + +:: + + >>> list(zip(s, t)) + [('a', 0), ('b', 1), ('c', 2)] + +The result is a list of tuples; in this example, each tuple contains a +character from the string and the corresponding element from the list. + +If the sequences are not the same length, the result has the length of +the shorter one. + +:: + + >>> list(zip('Anne', 'Elk')) + [('A', 'E'), ('n', 'l'), ('n', 'k')] + +You can use tuple assignment in a for loop to traverse a list of tuples: + +:: + + t = [('a', 0), ('b', 1), ('c', 2)] + for letter, number in t: + print(number, letter) + +Each time through the loop, Python selects the next tuple in the list +and assigns the elements to letter and number. The output of this loop +is: + +:: + + 0 a + 1 b + 2 c + +If you combine zip, for and tuple assignment, you get a useful idiom for +traversing two (or more) sequences at the same time. For example, +``has_match`` takes two sequences, t1 and t2, and returns True if there +is an index i such that t1[i] == t2[i]: + +:: + + def has_match(t1, t2): + for x, y in zip(t1, t2): + if x == y: + return True + return False + +If you need to traverse the elements of a sequence and their indices, +you can use the built-in function enumerate: + +:: + + for index, element in enumerate('abc'): + print(index, element) + +The result from enumerate is an enumerate object, which iterates a +sequence of pairs; each pair contains an index (starting from 0) and an +element from the given sequence. In this example, the output is + +:: + + 0 a + 1 b + 2 c + +Again. + +Dictionaries and tuples +----------------------- + +Dictionaries have a method called items that returns a sequence of +tuples, where each tuple is a key-value pair. + +:: + + >>> d = {'a':0, 'b':1, 'c':2} + >>> t = d.items() + >>> t + dict_items([('c', 2), ('a', 0), ('b', 1)]) + +The result is a ``dict_items`` object, which is an iterator that +iterates the key-value pairs. You can use it in a for loop like this: + +:: + + >>> for key, value in d.items(): + ... print(key, value) + ... + c 2 + a 0 + b 1 + +As you should expect from a dictionary, the items are in no particular +order. + +Going in the other direction, you can use a list of tuples to initialize +a new dictionary: + +:: + + >>> t = [('a', 0), ('c', 2), ('b', 1)] + >>> d = dict(t) + >>> d + {'a': 0, 'c': 2, 'b': 1} + +Combining dict with zip yields a concise way to create a dictionary: + +:: + + >>> d = dict(zip('abc', range(3))) + >>> d + {'a': 0, 'c': 2, 'b': 1} + +The dictionary method update also takes a list of tuples and adds them, +as key-value pairs, to an existing dictionary. + +It is common to use tuples as keys in dictionaries (primarily because +you can’t use lists). For example, a telephone directory might map from +last-name, first-name pairs to telephone numbers. Assuming that we have +defined last, first and number, we could write: + +:: + + directory[last, first] = number + +The expression in brackets is a tuple. We could use tuple assignment to +traverse this dictionary. + +:: + + for last, first in directory: + print(first, last, directory[last,first]) + +This loop traverses the keys in directory, which are tuples. It assigns +the elements of each tuple to last and first, then prints the name and +corresponding telephone number. + +There are two ways to represent tuples in a state diagram. The more +detailed version shows the indices and elements just as they appear in a +list. For example, the tuple ``('Cleese', 'John')`` would appear as in +Figure [fig.tuple1]. + +.. figure:: figs/tuple1.pdf + :alt: State diagram. + + State diagram. + +But in a larger diagram you might want to leave out the details. For +example, a diagram of the telephone directory might appear as in +Figure [fig.dict2]. + +.. figure:: figs/dict2.pdf + :alt: State diagram. + + State diagram. + +Here the tuples are shown using Python syntax as a graphical shorthand. +The telephone number in the diagram is the complaints line for the BBC, +so please don’t call it. + +Sequences of sequences +---------------------- + +I have focused on lists of tuples, but almost all of the examples in +this chapter also work with lists of lists, tuples of tuples, and tuples +of lists. To avoid enumerating the possible combinations, it is +sometimes easier to talk about sequences of sequences. + +In many contexts, the different kinds of sequences (strings, lists and +tuples) can be used interchangeably. So how should you choose one over +the others? + +To start with the obvious, strings are more limited than other sequences +because the elements have to be characters. They are also immutable. If +you need the ability to change the characters in a string (as opposed to +creating a new string), you might want to use a list of characters +instead. + +Lists are more common than tuples, mostly because they are mutable. But +there are a few cases where you might prefer tuples: + +#. In some contexts, like a return statement, it is syntactically + simpler to create a tuple than a list. + +#. If you want to use a sequence as a dictionary key, you have to use an + immutable type like a tuple or string. + +#. If you are passing a sequence as an argument to a function, using + tuples reduces the potential for unexpected behavior due to aliasing. + +Because tuples are immutable, they don’t provide methods like sort and +reverse, which modify existing lists. But Python provides the built-in +function sorted, which takes any sequence and returns a new list with +the same elements in sorted order, and reversed, which takes a sequence +and returns an iterator that traverses the list in reverse order. + +Debugging +--------- + +Lists, dictionaries and tuples are examples of **data structures**; in +this chapter we are starting to see compound data structures, like lists +of tuples, or dictionaries that contain tuples as keys and lists as +values. Compound data structures are useful, but they are prone to what +I call **shape errors**; that is, errors caused when a data structure +has the wrong type, size, or structure. For example, if you are +expecting a list with one integer and I give you a plain old integer +(not in a list), it won’t work. + +To help debug these kinds of errors, I have written a module called +structshape that provides a function, also called structshape, that +takes any kind of data structure as an argument and returns a string +that summarizes its shape. You can download it from +http://thinkpython2.com/code/structshape.py + +Here’s the result for a simple list: + +:: + + >>> from structshape import structshape + >>> t = [1, 2, 3] + >>> structshape(t) + 'list of 3 int' + +A fancier program might write “list of 3 int\ *s*”, but it was easier +not to deal with plurals. Here’s a list of lists: + +:: + + >>> t2 = [[1,2], [3,4], [5,6]] + >>> structshape(t2) + 'list of 3 list of 2 int' + +If the elements of the list are not the same type, structshape groups +them, in order, by type: + +:: + + >>> t3 = [1, 2, 3, 4.0, '5', '6', [7], [8], 9] + >>> structshape(t3) + 'list of (3 int, float, 2 str, 2 list of int, int)' + +Here’s a list of tuples: + +:: + + >>> s = 'abc' + >>> lt = list(zip(t, s)) + >>> structshape(lt) + 'list of 3 tuple of (int, str)' + +And here’s a dictionary with 3 items that map integers to strings. + +:: + + >>> d = dict(lt) + >>> structshape(d) + 'dict of 3 int->str' + +If you are having trouble keeping track of your data structures, +structshape can help. + +Glossary +-------- + +tuple: + An immutable sequence of elements. + +tuple assignment: + An assignment with a sequence on the right side and a tuple of + variables on the left. The right side is evaluated and then its + elements are assigned to the variables on the left. + +gather: + The operation of assembling a variable-length argument tuple. + +scatter: + The operation of treating a sequence as a list of arguments. + +zip object: + The result of calling a built-in function zip; an object that + iterates through a sequence of tuples. + +iterator: + An object that can iterate through a sequence, but which does not + provide list operators and methods. + +data structure: + A collection of related values, often organized in lists, + dictionaries, tuples, etc. + +shape error: + An error caused because a value has the wrong shape; that is, the + wrong type or size. + +Exercises +--------- + +Write a function called ``most_frequent`` that takes a string and prints +the letters in decreasing order of frequency. Find text samples from +several different languages and see how letter frequency varies between +languages. Compare your results with the tables at +http://en.wikipedia.org/wiki/Letter_frequencies. Solution: +http://thinkpython2.com/code/most_frequent.py. + +[anagrams] + +More anagrams! + +#. Write a program that reads a word list from a file (see + Section [wordlist]) and prints all the sets of words that are + anagrams. + + Here is an example of what the output might look like: + + :: + + ['deltas', 'desalt', 'lasted', 'salted', 'slated', 'staled'] + ['retainers', 'ternaries'] + ['generating', 'greatening'] + ['resmelts', 'smelters', 'termless'] + + Hint: you might want to build a dictionary that maps from a + collection of letters to a list of words that can be spelled with + those letters. The question is, how can you represent the collection + of letters in a way that can be used as a key? + +#. Modify the previous program so that it prints the longest list of + anagrams first, followed by the second longest, and so on. + +#. In Scrabble a “bingo” is when you play all seven tiles in your rack, + along with a letter on the board, to form an eight-letter word. What + collection of 8 letters forms the most possible bingos? Hint: there + are seven. + + Solution: http://thinkpython2.com/code/anagram_sets.py. + +Two words form a “metathesis pair” if you can transform one into the +other by swapping two letters; for example, “converse” and “conserve”. +Write a program that finds all of the metathesis pairs in the +dictionary. Hint: don’t test all pairs of words, and don’t test all +possible swaps. Solution: http://thinkpython2.com/code/metathesis.py. +Credit: This exercise is inspired by an example at http://puzzlers.org. + +Here’s another Car Talk Puzzler +(http://www.cartalk.com/content/puzzlers): + + What is the longest English word, that remains a valid English word, + as you remove its letters one at a time? + + Now, letters can be removed from either end, or the middle, but you + can’t rearrange any of the letters. Every time you drop a letter, + you wind up with another English word. If you do that, you’re + eventually going to wind up with one letter and that too is going to + be an English word—one that’s found in the dictionary. I want to + know what’s the longest word and how many letters does it have? + + I’m going to give you a little modest example: Sprite. Ok? You start + off with sprite, you take a letter off, one from the interior of the + word, take the r away, and we’re left with the word spite, then we + take the e off the end, we’re left with spit, we take the s off, + we’re left with pit, it, and I. + +Write a program to find all words that can be reduced in this way, and +then find the longest one. + +This exercise is a little more challenging than most, so here are some +suggestions: + +#. You might want to write a function that takes a word and computes a + list of all the words that can be formed by removing one letter. + These are the “children” of the word. + +#. Recursively, a word is reducible if any of its children are + reducible. As a base case, you can consider the empty string + reducible. + +#. The wordlist I provided, words.txt, doesn’t contain single letter + words. So you might want to add “I”, “a”, and the empty string. + +#. To improve the performance of your program, you might want to memoize + the words that are known to be reducible. + +Solution: http://thinkpython2.com/code/reducible.py. + +Case study: data structure selection +==================================== + +At this point you have learned about Python’s core data structures, and +you have seen some of the algorithms that use them. If you would like to +know more about algorithms, this might be a good time to read +Chapter [algorithms]. But you don’t have to read it before you go on; +you can read it whenever you are interested. + +This chapter presents a case study with exercises that let you think +about choosing data structures and practice using them. + +Word frequency analysis +----------------------- + +As usual, you should at least attempt the exercises before you read my +solutions. + +Write a program that reads a file, breaks each line into words, strips +whitespace and punctuation from the words, and converts them to +lowercase. + +Hint: The string module provides a string named whitespace, which +contains space, tab, newline, etc., and punctuation which contains the +punctuation characters. Let’s see if we can make Python swear: + +:: + + >>> import string + >>> string.punctuation + '!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~' + +Also, you might consider using the string methods strip, replace and +translate. + +Go to Project Gutenberg (http://gutenberg.org) and download your +favorite out-of-copyright book in plain text format. + +Modify your program from the previous exercise to read the book you +downloaded, skip over the header information at the beginning of the +file, and process the rest of the words as before. + +Then modify the program to count the total number of words in the book, +and the number of times each word is used. + +Print the number of different words used in the book. Compare different +books by different authors, written in different eras. Which author uses +the most extensive vocabulary? + +Modify the program from the previous exercise to print the 20 most +frequently used words in the book. + +Modify the previous program to read a word list (see Section [wordlist]) +and then print all the words in the book that are not in the word list. +How many of them are typos? How many of them are common words that +*should* be in the word list, and how many of them are really obscure? + +Random numbers +-------------- + +Given the same inputs, most computer programs generate the same outputs +every time, so they are said to be **deterministic**. Determinism is +usually a good thing, since we expect the same calculation to yield the +same result. For some applications, though, we want the computer to be +unpredictable. Games are an obvious example, but there are more. + +Making a program truly nondeterministic turns out to be difficult, but +there are ways to make it at least seem nondeterministic. One of them is +to use algorithms that generate **pseudorandom** numbers. Pseudorandom +numbers are not truly random because they are generated by a +deterministic computation, but just by looking at the numbers it is all +but impossible to distinguish them from random. + +The random module provides functions that generate pseudorandom numbers +(which I will simply call “random” from here on). + +The function random returns a random float between 0.0 and 1.0 +(including 0.0 but not 1.0). Each time you call random, you get the next +number in a long series. To see a sample, run this loop: + +:: + + import random + + for i in range(10): + x = random.random() + print(x) + +The function randint takes parameters low and high and returns an +integer between low and high (including both). + +:: + + >>> random.randint(5, 10) + 5 + >>> random.randint(5, 10) + 9 + +To choose an element from a sequence at random, you can use choice: + +:: + + >>> t = [1, 2, 3] + >>> random.choice(t) + 2 + >>> random.choice(t) + 3 + +The random module also provides functions to generate random values from +continuous distributions including Gaussian, exponential, gamma, and a +few more. + +Write a function named ``choose_from_hist`` that takes a histogram as +defined in Section [histogram] and returns a random value from the +histogram, chosen with probability in proportion to frequency. For +example, for this histogram: + +:: + + >>> t = ['a', 'a', 'b'] + >>> hist = histogram(t) + >>> hist + {'a': 2, 'b': 1} + +your function should return ``'a'`` with probability :math:`2/3` and +``'b'`` with probability :math:`1/3`. + +Word histogram +-------------- + +You should attempt the previous exercises before you go on. You can +download my solution from http://thinkpython2.com/code/analyze_book1.py. +You will also need http://thinkpython2.com/code/emma.txt. + +Here is a program that reads a file and builds a histogram of the words +in the file: + +:: + + import string + + def process_file(filename): + hist = dict() + fp = open(filename) + for line in fp: + process_line(line, hist) + return hist + + def process_line(line, hist): + line = line.replace('-', ' ') + + for word in line.split(): + word = word.strip(string.punctuation + string.whitespace) + word = word.lower() + hist[word] = hist.get(word, 0) + 1 + + hist = process_file('emma.txt') + +This program reads emma.txt, which contains the text of *Emma* by Jane +Austen. + +``process_file`` loops through the lines of the file, passing them one +at a time to ``process_line``. The histogram hist is being used as an +accumulator. + +``process_line`` uses the string method replace to replace hyphens with +spaces before using split to break the line into a list of strings. It +traverses the list of words and uses strip and lower to remove +punctuation and convert to lower case. (It is a shorthand to say that +strings are “converted”; remember that strings are immutable, so methods +like strip and lower return new strings.) + +Finally, ``process_line`` updates the histogram by creating a new item +or incrementing an existing one. + +To count the total number of words in the file, we can add up the +frequencies in the histogram: + +:: + + def total_words(hist): + return sum(hist.values()) + +The number of different words is just the number of items in the +dictionary: + +:: + + def different_words(hist): + return len(hist) + +Here is some code to print the results: + +:: + + print('Total number of words:', total_words(hist)) + print('Number of different words:', different_words(hist)) + +And the results: + +:: + + Total number of words: 161080 + Number of different words: 7214 + +Most common words +----------------- + +To find the most common words, we can make a list of tuples, where each +tuple contains a word and its frequency, and sort it. + +The following function takes a histogram and returns a list of +word-frequency tuples: + +:: + + def most_common(hist): + t = [] + for key, value in hist.items(): + t.append((value, key)) + + t.sort(reverse=True) + return t + +In each tuple, the frequency appears first, so the resulting list is +sorted by frequency. Here is a loop that prints the ten most common +words: + +:: + + t = most_common(hist) + print('The most common words are:') + for freq, word in t[:10]: + print(word, freq, sep='\t') + +I use the keyword argument sep to tell print to use a tab character as a +“separator”, rather than a space, so the second column is lined up. Here +are the results from *Emma*: + +:: + + The most common words are: + to 5242 + the 5205 + and 4897 + of 4295 + i 3191 + a 3130 + it 2529 + her 2483 + was 2400 + she 2364 + +This code can be simplified using the key parameter of the sort +function. If you are curious, you can read about it at +https://wiki.python.org/moin/HowTo/Sorting. + +Optional parameters +------------------- + +We have seen built-in functions and methods that take optional +arguments. It is possible to write programmer-defined functions with +optional arguments, too. For example, here is a function that prints the +most common words in a histogram + +:: + + def print_most_common(hist, num=10): + t = most_common(hist) + print('The most common words are:') + for freq, word in t[:num]: + print(word, freq, sep='\t') + +The first parameter is required; the second is optional. The **default +value** of num is 10. + +If you only provide one argument: + +:: + + print_most_common(hist) + +num gets the default value. If you provide two arguments: + +:: + + print_most_common(hist, 20) + +num gets the value of the argument instead. In other words, the optional +argument **overrides** the default value. + +If a function has both required and optional parameters, all the +required parameters have to come first, followed by the optional ones. + +Dictionary subtraction +---------------------- + +Finding the words from the book that are not in the word list from +words.txt is a problem you might recognize as set subtraction; that is, +we want to find all the words from one set (the words in the book) that +are not in the other (the words in the list). + +subtract takes dictionaries d1 and d2 and returns a new dictionary that +contains all the keys from d1 that are not in d2. Since we don’t really +care about the values, we set them all to None. + +:: + + def subtract(d1, d2): + res = dict() + for key in d1: + if key not in d2: + res[key] = None + return res + +To find the words in the book that are not in words.txt, we can use +``process_file`` to build a histogram for words.txt, and then subtract: + +:: + + words = process_file('words.txt') + diff = subtract(hist, words) + + print("Words in the book that aren't in the word list:") + for word in diff.keys(): + print(word, end=' ') + +Here are some of the results from *Emma*: + +:: + + Words in the book that aren't in the word list: + rencontre jane's blanche woodhouses disingenuousness + friend's venice apartment ... + +Some of these words are names and possessives. Others, like “rencontre”, +are no longer in common use. But a few are common words that should +really be in the list! + +Python provides a data structure called set that provides many common +set operations. You can read about them in Section [sets], or read the +documentation at +http://docs.python.org/3/library/stdtypes.html#types-set. + +Write a program that uses set subtraction to find words in the book that +are not in the word list. Solution: +http://thinkpython2.com/code/analyze_book2.py. + +Random words +------------ + +To choose a random word from the histogram, the simplest algorithm is to +build a list with multiple copies of each word, according to the +observed frequency, and then choose from the list: + +:: + + def random_word(h): + t = [] + for word, freq in h.items(): + t.extend([word] * freq) + + return random.choice(t) + +The expression \* freq creates a list with freq copies of the string +word. The extend method is similar to append except that the argument is +a sequence. + +This algorithm works, but it is not very efficient; each time you choose +a random word, it rebuilds the list, which is as big as the original +book. An obvious improvement is to build the list once and then make +multiple selections, but the list is still big. + +An alternative is: + +#. Use keys to get a list of the words in the book. + +#. Build a list that contains the cumulative sum of the word frequencies + (see Exercise [cumulative]). The last item in this list is the total + number of words in the book, :math:`n`. + +#. Choose a random number from 1 to :math:`n`. Use a bisection search + (See Exercise [bisection]) to find the index where the random number + would be inserted in the cumulative sum. + +#. Use the index to find the corresponding word in the word list. + +[randhist] + +Write a program that uses this algorithm to choose a random word from +the book. Solution: http://thinkpython2.com/code/analyze_book3.py. + +Markov analysis +--------------- + +If you choose words from the book at random, you can get a sense of the +vocabulary, but you probably won’t get a sentence: + +:: + + this the small regard harriet which knightley's it most things + +A series of random words seldom makes sense because there is no +relationship between successive words. For example, in a real sentence +you would expect an article like “the” to be followed by an adjective or +a noun, and probably not a verb or adverb. + +One way to measure these kinds of relationships is Markov analysis, +which characterizes, for a given sequence of words, the probability of +the words that might come next. For example, the song *Eric, the Half a +Bee* begins: + + | Half a bee, philosophically, + | Must, ipso facto, half not be. + | But half the bee has got to be + | Vis a vis, its entity. D’you see? + | But can a bee be said to be + | Or not to be an entire bee + | When half the bee is not a bee + | Due to some ancient injury? + +In this text, the phrase “half the” is always followed by the word +“bee”, but the phrase “the bee” might be followed by either “has” or +“is”. + +The result of Markov analysis is a mapping from each prefix (like “half +the” and “the bee”) to all possible suffixes (like “has” and “is”). + +Given this mapping, you can generate a random text by starting with any +prefix and choosing at random from the possible suffixes. Next, you can +combine the end of the prefix and the new suffix to form the next +prefix, and repeat. + +For example, if you start with the prefix “Half a”, then the next word +has to be “bee”, because the prefix only appears once in the text. The +next prefix is “a bee”, so the next suffix might be “philosophically”, +“be” or “due”. + +In this example the length of the prefix is always two, but you can do +Markov analysis with any prefix length. + +Markov analysis: + +#. Write a program to read a text from a file and perform Markov + analysis. The result should be a dictionary that maps from prefixes + to a collection of possible suffixes. The collection might be a list, + tuple, or dictionary; it is up to you to make an appropriate choice. + You can test your program with prefix length two, but you should + write the program in a way that makes it easy to try other lengths. + +#. Add a function to the previous program to generate random text based + on the Markov analysis. Here is an example from *Emma* with prefix + length 2: + + He was very clever, be it sweetness or be angry, ashamed or only + amused, at such a stroke. She had never thought of Hannah till + you were never meant for me?“ ”I cannot make speeches, Emma:" he + soon cut it all himself. + + For this example, I left the punctuation attached to the words. The + result is almost syntactically correct, but not quite. Semantically, + it almost makes sense, but not quite. + + What happens if you increase the prefix length? Does the random text + make more sense? + +#. Once your program is working, you might want to try a mash-up: if you + combine text from two or more books, the random text you generate + will blend the vocabulary and phrases from the sources in interesting + ways. + +Credit: This case study is based on an example from Kernighan and Pike, +*The Practice of Programming*, Addison-Wesley, 1999. + +You should attempt this exercise before you go on; then you can can +download my solution from http://thinkpython2.com/code/markov.py. You +will also need http://thinkpython2.com/code/emma.txt. + +Data structures +--------------- + +Using Markov analysis to generate random text is fun, but there is also +a point to this exercise: data structure selection. In your solution to +the previous exercises, you had to choose: + +- How to represent the prefixes. + +- How to represent the collection of possible suffixes. + +- How to represent the mapping from each prefix to the collection of + possible suffixes. + +The last one is easy: a dictionary is the obvious choice for a mapping +from keys to corresponding values. + +For the prefixes, the most obvious options are string, list of strings, +or tuple of strings. + +For the suffixes, one option is a list; another is a histogram +(dictionary). + +How should you choose? The first step is to think about the operations +you will need to implement for each data structure. For the prefixes, we +need to be able to remove words from the beginning and add to the end. +For example, if the current prefix is “Half a”, and the next word is +“bee”, you need to be able to form the next prefix, “a bee”. + +Your first choice might be a list, since it is easy to add and remove +elements, but we also need to be able to use the prefixes as keys in a +dictionary, so that rules out lists. With tuples, you can’t append or +remove, but you can use the addition operator to form a new tuple: + +:: + + def shift(prefix, word): + return prefix[1:] + (word,) + +shift takes a tuple of words, prefix, and a string, word, and forms a +new tuple that has all the words in prefix except the first, and word +added to the end. + +For the collection of suffixes, the operations we need to perform +include adding a new suffix (or increasing the frequency of an existing +one), and choosing a random suffix. + +Adding a new suffix is equally easy for the list implementation or the +histogram. Choosing a random element from a list is easy; choosing from +a histogram is harder to do efficiently (see Exercise [randhist]). + +So far we have been talking mostly about ease of implementation, but +there are other factors to consider in choosing data structures. One is +run time. Sometimes there is a theoretical reason to expect one data +structure to be faster than other; for example, I mentioned that the in +operator is faster for dictionaries than for lists, at least when the +number of elements is large. + +But often you don’t know ahead of time which implementation will be +faster. One option is to implement both of them and see which is better. +This approach is called **benchmarking**. A practical alternative is to +choose the data structure that is easiest to implement, and then see if +it is fast enough for the intended application. If so, there is no need +to go on. If not, there are tools, like the profile module, that can +identify the places in a program that take the most time. + +The other factor to consider is storage space. For example, using a +histogram for the collection of suffixes might take less space because +you only have to store each word once, no matter how many times it +appears in the text. In some cases, saving space can also make your +program run faster, and in the extreme, your program might not run at +all if you run out of memory. But for many applications, space is a +secondary consideration after run time. + +One final thought: in this discussion, I have implied that we should use +one data structure for both analysis and generation. But since these are +separate phases, it would also be possible to use one structure for +analysis and then convert to another structure for generation. This +would be a net win if the time saved during generation exceeded the time +spent in conversion. + +Debugging +--------- + +When you are debugging a program, and especially if you are working on a +hard bug, there are five things to try: + +Reading: + Examine your code, read it back to yourself, and check that it says + what you meant to say. + +Running: + Experiment by making changes and running different versions. Often + if you display the right thing at the right place in the program, + the problem becomes obvious, but sometimes you have to build + scaffolding. + +Ruminating: + Take some time to think! What kind of error is it: syntax, runtime, + or semantic? What information can you get from the error messages, + or from the output of the program? What kind of error could cause + the problem you’re seeing? What did you change last, before the + problem appeared? + +Rubberducking: + If you explain the problem to someone else, you sometimes find the + answer before you finish asking the question. Often you don’t need + the other person; you could just talk to a rubber duck. And that’s + the origin of the well-known strategy called **rubber duck + debugging**. I am not making this up; see + https://en.wikipedia.org/wiki/Rubber_duck_debugging. + +Retreating: + At some point, the best thing to do is back off, undoing recent + changes, until you get back to a program that works and that you + understand. Then you can start rebuilding. + +Beginning programmers sometimes get stuck on one of these activities and +forget the others. Each activity comes with its own failure mode. + +For example, reading your code might help if the problem is a +typographical error, but not if the problem is a conceptual +misunderstanding. If you don’t understand what your program does, you +can read it 100 times and never see the error, because the error is in +your head. + +Running experiments can help, especially if you run small, simple tests. +But if you run experiments without thinking or reading your code, you +might fall into a pattern I call “random walk programming”, which is the +process of making random changes until the program does the right thing. +Needless to say, random walk programming can take a long time. + +You have to take time to think. Debugging is like an experimental +science. You should have at least one hypothesis about what the problem +is. If there are two or more possibilities, try to think of a test that +would eliminate one of them. + +But even the best debugging techniques will fail if there are too many +errors, or if the code you are trying to fix is too big and complicated. +Sometimes the best option is to retreat, simplifying the program until +you get to something that works and that you understand. + +Beginning programmers are often reluctant to retreat because they can’t +stand to delete a line of code (even if it’s wrong). If it makes you +feel better, copy your program into another file before you start +stripping it down. Then you can copy the pieces back one at a time. + +Finding a hard bug requires reading, running, ruminating, and sometimes +retreating. If you get stuck on one of these activities, try the others. + +Glossary +-------- + +deterministic: + Pertaining to a program that does the same thing each time it runs, + given the same inputs. + +pseudorandom: + Pertaining to a sequence of numbers that appears to be random, but + is generated by a deterministic program. + +default value: + The value given to an optional parameter if no argument is provided. + +override: + To replace a default value with an argument. + +benchmarking: + The process of choosing between data structures by implementing + alternatives and testing them on a sample of the possible inputs. + +rubber duck debugging: + Debugging by explaining your problem to an inanimate object such as + a rubber duck. Articulating the problem can help you solve it, even + if the rubber duck doesn’t know Python. + +Exercises +--------- + +The “rank” of a word is its position in a list of words sorted by +frequency: the most common word has rank 1, the second most common has +rank 2, etc. + +Zipf’s law describes a relationship between the ranks and frequencies of +words in natural languages (http://en.wikipedia.org/wiki/Zipf's_law). +Specifically, it predicts that the frequency, :math:`f`, of the word +with rank :math:`r` is: + +.. math:: f = c r^{-s} + +where :math:`s` and :math:`c` are parameters that depend on the language +and the text. If you take the logarithm of both sides of this equation, +you get: + +.. math:: \log f = \log c - s \log r + +So if you plot log :math:`f` versus log :math:`r`, you should get a +straight line with slope :math:`-s` and intercept log :math:`c`. + +Write a program that reads a text from a file, counts word frequencies, +and prints one line for each word, in descending order of frequency, +with log :math:`f` and log :math:`r`. Use the graphing program of your +choice to plot the results and check whether they form a straight line. +Can you estimate the value of :math:`s`? + +Solution: http://thinkpython2.com/code/zipf.py. To run my solution, you +need the plotting module matplotlib. If you installed Anaconda, you +already have matplotlib; otherwise you might have to install it. + +Files +===== + +This chapter introduces the idea of “persistent” programs that keep data +in permanent storage, and shows how to use different kinds of permanent +storage, like files and databases. + +Persistence +----------- + +Most of the programs we have seen so far are transient in the sense that +they run for a short time and produce some output, but when they end, +their data disappears. If you run the program again, it starts with a +clean slate. + +Other programs are **persistent**: they run for a long time (or all the +time); they keep at least some of their data in permanent storage (a +hard drive, for example); and if they shut down and restart, they pick +up where they left off. + +Examples of persistent programs are operating systems, which run pretty +much whenever a computer is on, and web servers, which run all the time, +waiting for requests to come in on the network. + +One of the simplest ways for programs to maintain their data is by +reading and writing text files. We have already seen programs that read +text files; in this chapter we will see programs that write them. + +An alternative is to store the state of the program in a database. In +this chapter I will present a simple database and a module, pickle, that +makes it easy to store program data. + +Reading and writing +------------------- + +A text file is a sequence of characters stored on a permanent medium +like a hard drive, flash memory, or CD-ROM. We saw how to open and read +a file in Section [wordlist]. + +To write a file, you have to open it with mode ``'w'`` as a second +parameter: + +:: + + >>> fout = open('output.txt', 'w') + +If the file already exists, opening it in write mode clears out the old +data and starts fresh, so be careful! If the file doesn’t exist, a new +one is created. + +open returns a file object that provides methods for working with the +file. The write method puts data into the file. + +:: + + >>> line1 = "This here's the wattle,\n" + >>> fout.write(line1) + 24 + +The return value is the number of characters that were written. The file +object keeps track of where it is, so if you call write again, it adds +the new data to the end of the file. + +:: + + >>> line2 = "the emblem of our land.\n" + >>> fout.write(line2) + 24 + +When you are done writing, you should close the file. + +:: + + >>> fout.close() + +If you don’t close the file, it gets closed for you when the program +ends. + +Format operator +--------------- + +The argument of write has to be a string, so if we want to put other +values in a file, we have to convert them to strings. The easiest way to +do that is with str: + +:: + + >>> x = 52 + >>> fout.write(str(x)) + +An alternative is to use the **format operator**, %. When applied to +integers, % is the modulus operator. But when the first operand is a +string, % is the format operator. + +The first operand is the **format string**, which contains one or more +**format sequences**, which specify how the second operand is formatted. +The result is a string. + +For example, the format sequence ``'%d'`` means that the second operand +should be formatted as a decimal integer: + +:: + + >>> camels = 42 + >>> '%d' % camels + '42' + +The result is the string ``'42'``, which is not to be confused with the +integer value 42. + +A format sequence can appear anywhere in the string, so you can embed a +value in a sentence: + +:: + + >>> 'I have spotted %d camels.' % camels + 'I have spotted 42 camels.' + +If there is more than one format sequence in the string, the second +argument has to be a tuple. Each format sequence is matched with an +element of the tuple, in order. + +The following example uses ``'%d'`` to format an integer, ``'%g'`` to +format a floating-point number, and ``'%s'`` to format a string: + +:: + + >>> 'In %d years I have spotted %g %s.' % (3, 0.1, 'camels') + 'In 3 years I have spotted 0.1 camels.' + +The number of elements in the tuple has to match the number of format +sequences in the string. Also, the types of the elements have to match +the format sequences: + +:: + + >>> '%d %d %d' % (1, 2) + TypeError: not enough arguments for format string + >>> '%d' % 'dollars' + TypeError: %d format: a number is required, not str + +In the first example, there aren’t enough elements; in the second, the +element is the wrong type. + +For more information on the format operator, see +https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting. +A more powerful alternative is the string format method, which you can +read about at +https://docs.python.org/3/library/stdtypes.html#str.format. + +Filenames and paths +------------------- + +Files are organized into **directories** (also called “folders”). Every +running program has a “current directory”, which is the default +directory for most operations. For example, when you open a file for +reading, Python looks for it in the current directory. + +The os module provides functions for working with files and directories +(“os” stands for “operating system”). os.getcwd returns the name of the +current directory: + +:: + + >>> import os + >>> cwd = os.getcwd() + >>> cwd + '/home/dinsdale' + +cwd stands for “current working directory”. The result in this example +is /home/dinsdale, which is the home directory of a user named dinsdale. + +A string like ``'/home/dinsdale'`` that identifies a file or directory +is called a **path**. + +A simple filename, like memo.txt is also considered a path, but it is a +**relative path** because it relates to the current directory. If the +current directory is /home/dinsdale, the filename memo.txt would refer +to /home/dinsdale/memo.txt. + +A path that begins with / does not depend on the current directory; it +is called an **absolute path**. To find the absolute path to a file, you +can use os.path.abspath: + +:: + + >>> os.path.abspath('memo.txt') + '/home/dinsdale/memo.txt' + +os.path provides other functions for working with filenames and paths. +For example, os.path.exists checks whether a file or directory exists: + +:: + + >>> os.path.exists('memo.txt') + True + +If it exists, os.path.isdir checks whether it’s a directory: + +:: + + >>> os.path.isdir('memo.txt') + False + >>> os.path.isdir('/home/dinsdale') + True + +Similarly, os.path.isfile checks whether it’s a file. + +os.listdir returns a list of the files (and other directories) in the +given directory: + +:: + + >>> os.listdir(cwd) + ['music', 'photos', 'memo.txt'] + +To demonstrate these functions, the following example “walks” through a +directory, prints the names of all the files, and calls itself +recursively on all the directories. + +:: + + def walk(dirname): + for name in os.listdir(dirname): + path = os.path.join(dirname, name) + + if os.path.isfile(path): + print(path) + else: + walk(path) + +os.path.join takes a directory and a file name and joins them into a +complete path. + +The os module provides a function called walk that is similar to this +one but more versatile. As an exercise, read the documentation and use +it to print the names of the files in a given directory and its +subdirectories. You can download my solution from +http://thinkpython2.com/code/walk.py. + +Catching exceptions +------------------- + +A lot of things can go wrong when you try to read and write files. If +you try to open a file that doesn’t exist, you get an IOError: + +:: + + >>> fin = open('bad_file') + IOError: [Errno 2] No such file or directory: 'bad_file' + +If you don’t have permission to access a file: + +:: + + >>> fout = open('/etc/passwd', 'w') + PermissionError: [Errno 13] Permission denied: '/etc/passwd' + +And if you try to open a directory for reading, you get + +:: + + >>> fin = open('/home') + IsADirectoryError: [Errno 21] Is a directory: '/home' + +To avoid these errors, you could use functions like os.path.exists and +os.path.isfile, but it would take a lot of time and code to check all +the possibilities (if “Errno 21” is any indication, there are at least +21 things that can go wrong). + +It is better to go ahead and try—and deal with problems if they +happen—which is exactly what the try statement does. The syntax is +similar to an if...else statement: + +:: + + try: + fin = open('bad_file') + except: + print('Something went wrong.') + +Python starts by executing the try clause. If all goes well, it skips +the except clause and proceeds. If an exception occurs, it jumps out of +the try clause and runs the except clause. + +Handling an exception with a try statement is called **catching** an +exception. In this example, the except clause prints an error message +that is not very helpful. In general, catching an exception gives you a +chance to fix the problem, or try again, or at least end the program +gracefully. + +Databases +--------- + +A **database** is a file that is organized for storing data. Many +databases are organized like a dictionary in the sense that they map +from keys to values. The biggest difference between a database and a +dictionary is that the database is on disk (or other permanent storage), +so it persists after the program ends. + +The module dbm provides an interface for creating and updating database +files. As an example, I’ll create a database that contains captions for +image files. + +Opening a database is similar to opening other files: + +:: + + >>> import dbm + >>> db = dbm.open('captions', 'c') + +The mode ``'c'`` means that the database should be created if it doesn’t +already exist. The result is a database object that can be used (for +most operations) like a dictionary. + +When you create a new item, dbm updates the database file. + +:: + + >>> db['cleese.png'] = 'Photo of John Cleese.' + +When you access one of the items, dbm reads the file: + +:: + + >>> db['cleese.png'] + b'Photo of John Cleese.' + +The result is a **bytes object**, which is why it begins with b. A bytes +object is similar to a string in many ways. When you get farther into +Python, the difference becomes important, but for now we can ignore it. + +If you make another assignment to an existing key, dbm replaces the old +value: + +:: + + >>> db['cleese.png'] = 'Photo of John Cleese doing a silly walk.' + >>> db['cleese.png'] + b'Photo of John Cleese doing a silly walk.' + +Some dictionary methods, like keys and items, don’t work with database +objects. But iteration with a for loop works: + +:: + + for key in db: + print(key, db[key]) + +As with other files, you should close the database when you are done: + +:: + + >>> db.close() + +Pickling +-------- + +A limitation of dbm is that the keys and values have to be strings or +bytes. If you try to use any other type, you get an error. + +The pickle module can help. It translates almost any type of object into +a string suitable for storage in a database, and then translates strings +back into objects. + +pickle.dumps takes an object as a parameter and returns a string +representation (dumps is short for “dump string”): + +:: + + >>> import pickle + >>> t = [1, 2, 3] + >>> pickle.dumps(t) + b'\x80\x03]q\x00(K\x01K\x02K\x03e.' + +The format isn’t obvious to human readers; it is meant to be easy for +pickle to interpret. pickle.loads (“load string”) reconstitutes the +object: + +:: + + >>> t1 = [1, 2, 3] + >>> s = pickle.dumps(t1) + >>> t2 = pickle.loads(s) + >>> t2 + [1, 2, 3] + +Although the new object has the same value as the old, it is not (in +general) the same object: + +:: + + >>> t1 == t2 + True + >>> t1 is t2 + False + +In other words, pickling and then unpickling has the same effect as +copying the object. + +You can use pickle to store non-strings in a database. In fact, this +combination is so common that it has been encapsulated in a module +called shelve. + +Pipes +----- + +Most operating systems provide a command-line interface, also known as a +**shell**. Shells usually provide commands to navigate the file system +and launch applications. For example, in Unix you can change directories +with cd, display the contents of a directory with ls, and launch a web +browser by typing (for example) firefox. + +Any program that you can launch from the shell can also be launched from +Python using a **pipe object**, which represents a running program. + +For example, the Unix command ls -l normally displays the contents of +the current directory in long format. You can launch ls with +os.popen [1]_: + +:: + + >>> cmd = 'ls -l' + >>> fp = os.popen(cmd) + +The argument is a string that contains a shell command. The return value +is an object that behaves like an open file. You can read the output +from the ls process one line at a time with readline or get the whole +thing at once with read: + +:: + + >>> res = fp.read() + +When you are done, you close the pipe like a file: + +:: + + >>> stat = fp.close() + >>> print(stat) + None + +The return value is the final status of the ls process; None means that +it ended normally (with no errors). + +For example, most Unix systems provide a command called md5sum that +reads the contents of a file and computes a “checksum”. You can read +about MD5 at http://en.wikipedia.org/wiki/Md5. This command provides an +efficient way to check whether two files have the same contents. The +probability that different contents yield the same checksum is very +small (that is, unlikely to happen before the universe collapses). + +You can use a pipe to run md5sum from Python and get the result: + +:: + + >>> filename = 'book.tex' + >>> cmd = 'md5sum ' + filename + >>> fp = os.popen(cmd) + >>> res = fp.read() + >>> stat = fp.close() + >>> print(res) + 1e0033f0ed0656636de0d75144ba32e0 book.tex + >>> print(stat) + None + +Writing modules +--------------- + +Any file that contains Python code can be imported as a module. For +example, suppose you have a file named wc.py with the following code: + +:: + + def linecount(filename): + count = 0 + for line in open(filename): + count += 1 + return count + + print(linecount('wc.py')) + +If you run this program, it reads itself and prints the number of lines +in the file, which is 7. You can also import it like this: + +:: + + >>> import wc + 7 + +Now you have a module object wc: + +:: + + >>> wc + + +The module object provides ``linecount``: + +:: + + >>> wc.linecount('wc.py') + 7 + +So that’s how you write modules in Python. + +The only problem with this example is that when you import the module it +runs the test code at the bottom. Normally when you import a module, it +defines new functions but it doesn’t run them. + +Programs that will be imported as modules often use the following idiom: + +:: + + if __name__ == '__main__': + print(linecount('wc.py')) + +``__name__`` is a built-in variable that is set when the program starts. +If the program is running as a script, ``__name__`` has the value +``'__main__'``; in that case, the test code runs. Otherwise, if the +module is being imported, the test code is skipped. + +As an exercise, type this example into a file named wc.py and run it as +a script. Then run the Python interpreter and import wc. What is the +value of ``__name__`` when the module is being imported? + +Warning: If you import a module that has already been imported, Python +does nothing. It does not re-read the file, even if it has changed. + +If you want to reload a module, you can use the built-in function +reload, but it can be tricky, so the safest thing to do is restart the +interpreter and then import the module again. + +Debugging +--------- + +When you are reading and writing files, you might run into problems with +whitespace. These errors can be hard to debug because spaces, tabs and +newlines are normally invisible: + +:: + + >>> s = '1 2\t 3\n 4' + >>> print(s) + 1 2 3 + 4 + +The built-in function repr can help. It takes any object as an argument +and returns a string representation of the object. For strings, it +represents whitespace characters with backslash sequences: + +:: + + >>> print(repr(s)) + '1 2\t 3\n 4' + +This can be helpful for debugging. + +One other problem you might run into is that different systems use +different characters to indicate the end of a line. Some systems use a +newline, represented ``\n``. Others use a return character, represented +``\r``. Some use both. If you move files between different systems, +these inconsistencies can cause problems. + +For most systems, there are applications to convert from one format to +another. You can find them (and read more about this issue) at +http://en.wikipedia.org/wiki/Newline. Or, of course, you could write one +yourself. + +Glossary +-------- + +persistent: + Pertaining to a program that runs indefinitely and keeps at least + some of its data in permanent storage. + +format operator: + An operator, %, that takes a format string and a tuple and generates + a string that includes the elements of the tuple formatted as + specified by the format string. + +format string: + A string, used with the format operator, that contains format + sequences. + +format sequence: + A sequence of characters in a format string, like %d, that specifies + how a value should be formatted. + +text file: + A sequence of characters stored in permanent storage like a hard + drive. + +directory: + A named collection of files, also called a folder. + +path: + A string that identifies a file. + +relative path: + A path that starts from the current directory. + +absolute path: + A path that starts from the topmost directory in the file system. + +catch: + To prevent an exception from terminating a program using the try and + except statements. + +database: + A file whose contents are organized like a dictionary with keys that + correspond to values. + +bytes object: + An object similar to a string. + +shell: + A program that allows users to type commands and then executes them + by starting other programs. + +pipe object: + An object that represents a running program, allowing a Python + program to run commands and read the results. + +Exercises +--------- + +Write a function called sed that takes as arguments a pattern string, a +replacement string, and two filenames; it should read the first file and +write the contents into the second file (creating it if necessary). If +the pattern string appears anywhere in the file, it should be replaced +with the replacement string. + +If an error occurs while opening, reading, writing or closing files, +your program should catch the exception, print an error message, and +exit. Solution: http://thinkpython2.com/code/sed.py. + +If you download my solution to Exercise [anagrams] from +http://thinkpython2.com/code/anagram_sets.py, you’ll see that it creates +a dictionary that maps from a sorted string of letters to the list of +words that can be spelled with those letters. For example, ``'opst'`` +maps to the list ``['opts', 'post', 'pots', 'spot', 'stop', 'tops']``. + +Write a module that imports ``anagram_sets`` and provides two new +functions: ``store_anagrams`` should store the anagram dictionary in a +“shelf”; ``read_anagrams`` should look up a word and return a list of +its anagrams. Solution: http://thinkpython2.com/code/anagram_db.py. + +[checksum] + +In a large collection of MP3 files, there may be more than one copy of +the same song, stored in different directories or with different file +names. The goal of this exercise is to search for duplicates. + +#. Write a program that searches a directory and all of its + subdirectories, recursively, and returns a list of complete paths for + all files with a given suffix (like .mp3). Hint: os.path provides + several useful functions for manipulating file and path names. + +#. To recognize duplicates, you can use md5sum to compute a “checksum” + for each files. If two files have the same checksum, they probably + have the same contents. + +#. To double-check, you can use the Unix command diff. + +Solution: http://thinkpython2.com/code/find_duplicates.py. + +Classes and objects +=================== + +At this point you know how to use functions to organize code and +built-in types to organize data. The next step is to learn +“object-oriented programming”, which uses programmer-defined types to +organize both code and data. Object-oriented programming is a big topic; +it will take a few chapters to get there. + +Code examples from this chapter are available from +http://thinkpython2.com/code/Point1.py; solutions to the exercises are +available from http://thinkpython2.com/code/Point1_soln.py. + +Programmer-defined types +------------------------ + +We have used many of Python’s built-in types; now we are going to define +a new type. As an example, we will create a type called Point that +represents a point in two-dimensional space. + +In mathematical notation, points are often written in parentheses with a +comma separating the coordinates. For example, :math:`(0,0)` represents +the origin, and :math:`(x,y)` represents the point :math:`x` units to +the right and :math:`y` units up from the origin. + +There are several ways we might represent points in Python: + +- We could store the coordinates separately in two variables, x and y. + +- We could store the coordinates as elements in a list or tuple. + +- We could create a new type to represent points as objects. + +Creating a new type is more complicated than the other options, but it +has advantages that will be apparent soon. + +A programmer-defined type is also called a **class**. A class definition +looks like this: + +:: + + class Point: + """Represents a point in 2-D space.""" + +The header indicates that the new class is called Point. The body is a +docstring that explains what the class is for. You can define variables +and methods inside a class definition, but we will get back to that +later. + +Defining a class named Point creates a **class object**. + +:: + + >>> Point + + +Because Point is defined at the top level, its “full name” is +``__main__.Point``. + +The class object is like a factory for creating objects. To create a +Point, you call Point as if it were a function. + +:: + + >>> blank = Point() + >>> blank + <__main__.Point object at 0xb7e9d3ac> + +The return value is a reference to a Point object, which we assign to +blank. + +Creating a new object is called **instantiation**, and the object is an +**instance** of the class. + +When you print an instance, Python tells you what class it belongs to +and where it is stored in memory (the prefix 0x means that the following +number is in hexadecimal). + +Every object is an instance of some class, so “object” and “instance” +are interchangeable. But in this chapter I use “instance” to indicate +that I am talking about a programmer-defined type. + +Attributes +---------- + +You can assign values to an instance using dot notation: + +:: + + >>> blank.x = 3.0 + >>> blank.y = 4.0 + +This syntax is similar to the syntax for selecting a variable from a +module, such as math.pi or string.whitespace. In this case, though, we +are assigning values to named elements of an object. These elements are +called **attributes**. + +As a noun, “AT-trib-ute” is pronounced with emphasis on the first +syllable, as opposed to “a-TRIB-ute”, which is a verb. + +The following diagram shows the result of these assignments. A state +diagram that shows an object and its attributes is called an **object +diagram**; see Figure [fig.point]. + +.. figure:: figs/point.pdf + :alt: Object diagram. + + Object diagram. + +The variable blank refers to a Point object, which contains two +attributes. Each attribute refers to a floating-point number. + +You can read the value of an attribute using the same syntax: + +:: + + >>> blank.y + 4.0 + >>> x = blank.x + >>> x + 3.0 + +The expression blank.x means, “Go to the object blank refers to and get +the value of x.” In the example, we assign that value to a variable +named x. There is no conflict between the variable x and the attribute +x. + +You can use dot notation as part of any expression. For example: + +:: + + >>> '(%g, %g)' % (blank.x, blank.y) + '(3.0, 4.0)' + >>> distance = math.sqrt(blank.x**2 + blank.y**2) + >>> distance + 5.0 + +You can pass an instance as an argument in the usual way. For example: + +:: + + def print_point(p): + print('(%g, %g)' % (p.x, p.y)) + +``print_point`` takes a point as an argument and displays it in +mathematical notation. To invoke it, you can pass blank as an argument: + +:: + + >>> print_point(blank) + (3.0, 4.0) + +Inside the function, p is an alias for blank, so if the function +modifies p, blank changes. + +As an exercise, write a function called ``distance_between_points`` that +takes two Points as arguments and returns the distance between them. + +Rectangles +---------- + +Sometimes it is obvious what the attributes of an object should be, but +other times you have to make decisions. For example, imagine you are +designing a class to represent rectangles. What attributes would you use +to specify the location and size of a rectangle? You can ignore angle; +to keep things simple, assume that the rectangle is either vertical or +horizontal. + +There are at least two possibilities: + +- You could specify one corner of the rectangle (or the center), the + width, and the height. + +- You could specify two opposing corners. + +At this point it is hard to say whether either is better than the other, +so we’ll implement the first one, just as an example. + +Here is the class definition: + +:: + + class Rectangle: + """Represents a rectangle. + + attributes: width, height, corner. + """ + +The docstring lists the attributes: width and height are numbers; corner +is a Point object that specifies the lower-left corner. + +To represent a rectangle, you have to instantiate a Rectangle object and +assign values to the attributes: + +:: + + box = Rectangle() + box.width = 100.0 + box.height = 200.0 + box.corner = Point() + box.corner.x = 0.0 + box.corner.y = 0.0 + +The expression box.corner.x means, “Go to the object box refers to and +select the attribute named corner; then go to that object and select the +attribute named x.” + +.. figure:: figs/rectangle.pdf + :alt: Object diagram. + + Object diagram. + +Figure [fig.rectangle] shows the state of this object. An object that is +an attribute of another object is **embedded**. + +Instances as return values +-------------------------- + +Functions can return instances. For example, ``find_center`` takes a +Rectangle as an argument and returns a Point that contains the +coordinates of the center of the Rectangle: + +:: + + def find_center(rect): + p = Point() + p.x = rect.corner.x + rect.width/2 + p.y = rect.corner.y + rect.height/2 + return p + +Here is an example that passes box as an argument and assigns the +resulting Point to center: + +:: + + >>> center = find_center(box) + >>> print_point(center) + (50, 100) + +Objects are mutable +------------------- + +You can change the state of an object by making an assignment to one of +its attributes. For example, to change the size of a rectangle without +changing its position, you can modify the values of width and height: + +:: + + box.width = box.width + 50 + box.height = box.height + 100 + +You can also write functions that modify objects. For example, +``grow_rectangle`` takes a Rectangle object and two numbers, dwidth and +dheight, and adds the numbers to the width and height of the rectangle: + +:: + + def grow_rectangle(rect, dwidth, dheight): + rect.width += dwidth + rect.height += dheight + +Here is an example that demonstrates the effect: + +:: + + >>> box.width, box.height + (150.0, 300.0) + >>> grow_rectangle(box, 50, 100) + >>> box.width, box.height + (200.0, 400.0) + +Inside the function, rect is an alias for box, so when the function +modifies rect, box changes. + +As an exercise, write a function named ``move_rectangle`` that takes a +Rectangle and two numbers named dx and dy. It should change the location +of the rectangle by adding dx to the x coordinate of corner and adding +dy to the y coordinate of corner. + +Copying +------- + +Aliasing can make a program difficult to read because changes in one +place might have unexpected effects in another place. It is hard to keep +track of all the variables that might refer to a given object. + +Copying an object is often an alternative to aliasing. The copy module +contains a function called copy that can duplicate any object: + +:: + + >>> p1 = Point() + >>> p1.x = 3.0 + >>> p1.y = 4.0 + + >>> import copy + >>> p2 = copy.copy(p1) + +p1 and p2 contain the same data, but they are not the same Point. + +:: + + >>> print_point(p1) + (3, 4) + >>> print_point(p2) + (3, 4) + >>> p1 is p2 + False + >>> p1 == p2 + False + +The is operator indicates that p1 and p2 are not the same object, which +is what we expected. But you might have expected == to yield True +because these points contain the same data. In that case, you will be +disappointed to learn that for instances, the default behavior of the == +operator is the same as the is operator; it checks object identity, not +object equivalence. That’s because for programmer-defined types, Python +doesn’t know what should be considered equivalent. At least, not yet. + +If you use copy.copy to duplicate a Rectangle, you will find that it +copies the Rectangle object but not the embedded Point. + +:: + + >>> box2 = copy.copy(box) + >>> box2 is box + False + >>> box2.corner is box.corner + True + +.. figure:: figs/rectangle2.pdf + :alt: Object diagram. + + Object diagram. + +Figure [fig.rectangle2] shows what the object diagram looks like. This +operation is called a **shallow copy** because it copies the object and +any references it contains, but not the embedded objects. + +For most applications, this is not what you want. In this example, +invoking ``grow_rectangle`` on one of the Rectangles would not affect +the other, but invoking ``move_rectangle`` on either would affect both! +This behavior is confusing and error-prone. + +Fortunately, the copy module provides a method named deepcopy that +copies not only the object but also the objects it refers to, and the +objects *they* refer to, and so on. You will not be surprised to learn +that this operation is called a **deep copy**. + +:: + + >>> box3 = copy.deepcopy(box) + >>> box3 is box + False + >>> box3.corner is box.corner + False + +box3 and box are completely separate objects. + +As an exercise, write a version of ``move_rectangle`` that creates and +returns a new Rectangle instead of modifying the old one. + +Debugging +--------- + +When you start working with objects, you are likely to encounter some +new exceptions. If you try to access an attribute that doesn’t exist, +you get an AttributeError: + +:: + + >>> p = Point() + >>> p.x = 3 + >>> p.y = 4 + >>> p.z + AttributeError: Point instance has no attribute 'z' + +If you are not sure what type an object is, you can ask: + +:: + + >>> type(p) + + +You can also use isinstance to check whether an object is an instance of +a class: + +:: + + >>> isinstance(p, Point) + True + +If you are not sure whether an object has a particular attribute, you +can use the built-in function hasattr: + +:: + + >>> hasattr(p, 'x') + True + >>> hasattr(p, 'z') + False + +The first argument can be any object; the second argument is a *string* +that contains the name of the attribute. + +You can also use a try statement to see if the object has the attributes +you need: + +:: + + try: + x = p.x + except AttributeError: + x = 0 + +This approach can make it easier to write functions that work with +different types; more on that topic is coming up in +Section [polymorphism]. + +Glossary +-------- + +class: + A programmer-defined type. A class definition creates a new class + object. + +class object: + An object that contains information about a programmer-defined type. + The class object can be used to create instances of the type. + +instance: + An object that belongs to a class. + +instantiate: + To create a new object. + +attribute: + One of the named values associated with an object. + +embedded object: + An object that is stored as an attribute of another object. + +shallow copy: + To copy the contents of an object, including any references to + embedded objects; implemented by the copy function in the copy + module. + +deep copy: + To copy the contents of an object as well as any embedded objects, + and any objects embedded in them, and so on; implemented by the + deepcopy function in the copy module. + +object diagram: + A diagram that shows objects, their attributes, and the values of + the attributes. + +Exercises +--------- + +Write a definition for a class named Circle with attributes center and +radius, where center is a Point object and radius is a number. + +Instantiate a Circle object that represents a circle with its center at +:math:`(150, 100)` and radius 75. + +Write a function named ``point_in_circle`` that takes a Circle and a +Point and returns True if the Point lies in or on the boundary of the +circle. + +Write a function named ``rect_in_circle`` that takes a Circle and a +Rectangle and returns True if the Rectangle lies entirely in or on the +boundary of the circle. + +Write a function named ``rect_circle_overlap`` that takes a Circle and a +Rectangle and returns True if any of the corners of the Rectangle fall +inside the circle. Or as a more challenging version, return True if any +part of the Rectangle falls inside the circle. + +Solution: http://thinkpython2.com/code/Circle.py. + +Write a function called ``draw_rect`` that takes a Turtle object and a +Rectangle and uses the Turtle to draw the Rectangle. See +Chapter [turtlechap] for examples using Turtle objects. + +Write a function called ``draw_circle`` that takes a Turtle and a Circle +and draws the Circle. + +Solution: http://thinkpython2.com/code/draw.py. + +Classes and functions +===================== + +Now that we know how to create new types, the next step is to write +functions that take programmer-defined objects as parameters and return +them as results. In this chapter I also present “functional programming +style” and two new program development plans. + +Code examples from this chapter are available from +http://thinkpython2.com/code/Time1.py. Solutions to the exercises are at +http://thinkpython2.com/code/Time1_soln.py. + +Time +---- + +As another example of a programmer-defined type, we’ll define a class +called Time that records the time of day. The class definition looks +like this: + +:: + + class Time: + """Represents the time of day. + + attributes: hour, minute, second + """ + +We can create a new Time object and assign attributes for hours, +minutes, and seconds: + +:: + + time = Time() + time.hour = 11 + time.minute = 59 + time.second = 30 + +The state diagram for the Time object looks like Figure [fig.time]. + +As an exercise, write a function called ``print_time`` that takes a Time +object and prints it in the form hour:minute:second. Hint: the format +sequence ``'%.2d'`` prints an integer using at least two digits, +including a leading zero if necessary. + +Write a boolean function called ``is_after`` that takes two Time +objects, t1 and t2, and returns True if t1 follows t2 chronologically +and False otherwise. Challenge: don’t use an if statement. + +.. figure:: figs/time.pdf + :alt: Object diagram. + + Object diagram. + +Pure functions +-------------- + +In the next few sections, we’ll write two functions that add time +values. They demonstrate two kinds of functions: pure functions and +modifiers. They also demonstrate a development plan I’ll call +**prototype and patch**, which is a way of tackling a complex problem by +starting with a simple prototype and incrementally dealing with the +complications. + +Here is a simple prototype of ``add_time``: + +:: + + def add_time(t1, t2): + sum = Time() + sum.hour = t1.hour + t2.hour + sum.minute = t1.minute + t2.minute + sum.second = t1.second + t2.second + return sum + +The function creates a new Time object, initializes its attributes, and +returns a reference to the new object. This is called a **pure +function** because it does not modify any of the objects passed to it as +arguments and it has no effect, like displaying a value or getting user +input, other than returning a value. + +To test this function, I’ll create two Time objects: start contains the +start time of a movie, like *Monty Python and the Holy Grail*, and +duration contains the run time of the movie, which is one hour 35 +minutes. + +``add_time`` figures out when the movie will be done. + +:: + + >>> start = Time() + >>> start.hour = 9 + >>> start.minute = 45 + >>> start.second = 0 + + >>> duration = Time() + >>> duration.hour = 1 + >>> duration.minute = 35 + >>> duration.second = 0 + + >>> done = add_time(start, duration) + >>> print_time(done) + 10:80:00 + +The result, 10:80:00 might not be what you were hoping for. The problem +is that this function does not deal with cases where the number of +seconds or minutes adds up to more than sixty. When that happens, we +have to “carry” the extra seconds into the minute column or the extra +minutes into the hour column. + +Here’s an improved version: + +:: + + def add_time(t1, t2): + sum = Time() + sum.hour = t1.hour + t2.hour + sum.minute = t1.minute + t2.minute + sum.second = t1.second + t2.second + + if sum.second >= 60: + sum.second -= 60 + sum.minute += 1 + + if sum.minute >= 60: + sum.minute -= 60 + sum.hour += 1 + + return sum + +Although this function is correct, it is starting to get big. We will +see a shorter alternative later. + +Modifiers +--------- + +Sometimes it is useful for a function to modify the objects it gets as +parameters. In that case, the changes are visible to the caller. +Functions that work this way are called **modifiers**. + +increment, which adds a given number of seconds to a Time object, can be +written naturally as a modifier. Here is a rough draft: + +:: + + def increment(time, seconds): + time.second += seconds + + if time.second >= 60: + time.second -= 60 + time.minute += 1 + + if time.minute >= 60: + time.minute -= 60 + time.hour += 1 + +The first line performs the basic operation; the remainder deals with +the special cases we saw before. + +Is this function correct? What happens if seconds is much greater than +sixty? + +In that case, it is not enough to carry once; we have to keep doing it +until time.second is less than sixty. One solution is to replace the if +statements with while statements. That would make the function correct, +but not very efficient. As an exercise, write a correct version of +increment that doesn’t contain any loops. + +Anything that can be done with modifiers can also be done with pure +functions. In fact, some programming languages only allow pure +functions. There is some evidence that programs that use pure functions +are faster to develop and less error-prone than programs that use +modifiers. But modifiers are convenient at times, and functional +programs tend to be less efficient. + +In general, I recommend that you write pure functions whenever it is +reasonable and resort to modifiers only if there is a compelling +advantage. This approach might be called a **functional programming +style**. + +As an exercise, write a “pure” version of increment that creates and +returns a new Time object rather than modifying the parameter. + +Prototyping versus planning +--------------------------- + +The development plan I am demonstrating is called “prototype and patch”. +For each function, I wrote a prototype that performed the basic +calculation and then tested it, patching errors along the way. + +This approach can be effective, especially if you don’t yet have a deep +understanding of the problem. But incremental corrections can generate +code that is unnecessarily complicated—since it deals with many special +cases—and unreliable—since it is hard to know if you have found all the +errors. + +An alternative is **designed development**, in which high-level insight +into the problem can make the programming much easier. In this case, the +insight is that a Time object is really a three-digit number in base 60 +(see http://en.wikipedia.org/wiki/Sexagesimal.)! The second attribute is +the “ones column”, the minute attribute is the “sixties column”, and the +hour attribute is the “thirty-six hundreds column”. + +When we wrote ``add_time`` and increment, we were effectively doing +addition in base 60, which is why we had to carry from one column to the +next. + +This observation suggests another approach to the whole problem—we can +convert Time objects to integers and take advantage of the fact that the +computer knows how to do integer arithmetic. + +Here is a function that converts Times to integers: + +:: + + def time_to_int(time): + minutes = time.hour * 60 + time.minute + seconds = minutes * 60 + time.second + return seconds + +And here is a function that converts an integer to a Time (recall that +divmod divides the first argument by the second and returns the quotient +and remainder as a tuple). + +:: + + def int_to_time(seconds): + time = Time() + minutes, time.second = divmod(seconds, 60) + time.hour, time.minute = divmod(minutes, 60) + return time + +You might have to think a bit, and run some tests, to convince yourself +that these functions are correct. One way to test them is to check that +``time_to_int(int_to_time(x)) == x`` for many values of x. This is an +example of a consistency check. + +Once you are convinced they are correct, you can use them to rewrite +``add_time``: + +:: + + def add_time(t1, t2): + seconds = time_to_int(t1) + time_to_int(t2) + return int_to_time(seconds) + +This version is shorter than the original, and easier to verify. As an +exercise, rewrite increment using ``time_to_int`` and ``int_to_time``. + +In some ways, converting from base 60 to base 10 and back is harder than +just dealing with times. Base conversion is more abstract; our intuition +for dealing with time values is better. + +But if we have the insight to treat times as base 60 numbers and make +the investment of writing the conversion functions (``time_to_int`` and +``int_to_time``), we get a program that is shorter, easier to read and +debug, and more reliable. + +It is also easier to add features later. For example, imagine +subtracting two Times to find the duration between them. The naive +approach would be to implement subtraction with borrowing. Using the +conversion functions would be easier and more likely to be correct. + +Ironically, sometimes making a problem harder (or more general) makes it +easier (because there are fewer special cases and fewer opportunities +for error). + +Debugging +--------- + +A Time object is well-formed if the values of minute and second are +between 0 and 60 (including 0 but not 60) and if hour is positive. hour +and minute should be integral values, but we might allow second to have +a fraction part. + +Requirements like these are called **invariants** because they should +always be true. To put it a different way, if they are not true, +something has gone wrong. + +Writing code to check invariants can help detect errors and find their +causes. For example, you might have a function like ``valid_time`` that +takes a Time object and returns False if it violates an invariant: + +:: + + def valid_time(time): + if time.hour < 0 or time.minute < 0 or time.second < 0: + return False + if time.minute >= 60 or time.second >= 60: + return False + return True + +At the beginning of each function you could check the arguments to make +sure they are valid: + +:: + + def add_time(t1, t2): + if not valid_time(t1) or not valid_time(t2): + raise ValueError('invalid Time object in add_time') + seconds = time_to_int(t1) + time_to_int(t2) + return int_to_time(seconds) + +Or you could use an **assert statement**, which checks a given invariant +and raises an exception if it fails: + +:: + + def add_time(t1, t2): + assert valid_time(t1) and valid_time(t2) + seconds = time_to_int(t1) + time_to_int(t2) + return int_to_time(seconds) + +assert statements are useful because they distinguish code that deals +with normal conditions from code that checks for errors. + +Glossary +-------- + +prototype and patch: + A development plan that involves writing a rough draft of a program, + testing, and correcting errors as they are found. + +designed development: + A development plan that involves high-level insight into the problem + and more planning than incremental development or prototype + development. + +pure function: + A function that does not modify any of the objects it receives as + arguments. Most pure functions are fruitful. + +modifier: + A function that changes one or more of the objects it receives as + arguments. Most modifiers are void; that is, they return None. + +functional programming style: + A style of program design in which the majority of functions are + pure. + +invariant: + A condition that should always be true during the execution of a + program. + +assert statement: + A statement that check a condition and raises an exception if it + fails. + +Exercises +--------- + +Code examples from this chapter are available from +http://thinkpython2.com/code/Time1.py; solutions to the exercises are +available from http://thinkpython2.com/code/Time1_soln.py. + +Write a function called ``mul_time`` that takes a Time object and a +number and returns a new Time object that contains the product of the +original Time and the number. + +Then use ``mul_time`` to write a function that takes a Time object that +represents the finishing time in a race, and a number that represents +the distance, and returns a Time object that represents the average pace +(time per mile). + +The datetime module provides time objects that are similar to the Time +objects in this chapter, but they provide a rich set of methods and +operators. Read the documentation at +http://docs.python.org/3/library/datetime.html. + +#. Use the datetime module to write a program that gets the current date + and prints the day of the week. + +#. Write a program that takes a birthday as input and prints the user’s + age and the number of days, hours, minutes and seconds until their + next birthday. + +#. For two people born on different days, there is a day when one is + twice as old as the other. That’s their Double Day. Write a program + that takes two birthdays and computes their Double Day. + +#. For a little more challenge, write the more general version that + computes the day when one person is :math:`n` times older than the + other. + +Solution: http://thinkpython2.com/code/double.py + +Classes and methods +=================== + +Although we are using some of Python’s object-oriented features, the +programs from the last two chapters are not really object-oriented +because they don’t represent the relationships between +programmer-defined types and the functions that operate on them. The +next step is to transform those functions into methods that make the +relationships explicit. + +Code examples from this chapter are available from +http://thinkpython2.com/code/Time2.py, and solutions to the exercises +are in http://thinkpython2.com/code/Point2_soln.py. + +Object-oriented features +------------------------ + +Python is an **object-oriented programming language**, which means that +it provides features that support object-oriented programming, which has +these defining characteristics: + +- Programs include class and method definitions. + +- Most of the computation is expressed in terms of operations on + objects. + +- Objects often represent things in the real world, and methods often + correspond to the ways things in the real world interact. + +For example, the Time class defined in Chapter [time] corresponds to the +way people record the time of day, and the functions we defined +correspond to the kinds of things people do with times. Similarly, the +Point and Rectangle classes in Chapter [clobjects] correspond to the +mathematical concepts of a point and a rectangle. + +So far, we have not taken advantage of the features Python provides to +support object-oriented programming. These features are not strictly +necessary; most of them provide alternative syntax for things we have +already done. But in many cases, the alternative is more concise and +more accurately conveys the structure of the program. + +For example, in Time1.py there is no obvious connection between the +class definition and the function definitions that follow. With some +examination, it is apparent that every function takes at least one Time +object as an argument. + +This observation is the motivation for **methods**; a method is a +function that is associated with a particular class. We have seen +methods for strings, lists, dictionaries and tuples. In this chapter, we +will define methods for programmer-defined types. + +Methods are semantically the same as functions, but there are two +syntactic differences: + +- Methods are defined inside a class definition in order to make the + relationship between the class and the method explicit. + +- The syntax for invoking a method is different from the syntax for + calling a function. + +In the next few sections, we will take the functions from the previous +two chapters and transform them into methods. This transformation is +purely mechanical; you can do it by following a sequence of steps. If +you are comfortable converting from one form to another, you will be +able to choose the best form for whatever you are doing. + +Printing objects +---------------- + +In Chapter [time], we defined a class named Time and in +Section [isafter], you wrote a function named ``print_time``: + +:: + + class Time: + """Represents the time of day.""" + + def print_time(time): + print('%.2d:%.2d:%.2d' % (time.hour, time.minute, time.second)) + +To call this function, you have to pass a Time object as an argument: + +:: + + >>> start = Time() + >>> start.hour = 9 + >>> start.minute = 45 + >>> start.second = 00 + >>> print_time(start) + 09:45:00 + +To make ``print_time`` a method, all we have to do is move the function +definition inside the class definition. Notice the change in +indentation. + +:: + + class Time: + def print_time(time): + print('%.2d:%.2d:%.2d' % (time.hour, time.minute, time.second)) + +Now there are two ways to call ``print_time``. The first (and less +common) way is to use function syntax: + +:: + + >>> Time.print_time(start) + 09:45:00 + +In this use of dot notation, Time is the name of the class, and +``print_time`` is the name of the method. start is passed as a +parameter. + +The second (and more concise) way is to use method syntax: + +:: + + >>> start.print_time() + 09:45:00 + +In this use of dot notation, ``print_time`` is the name of the method +(again), and start is the object the method is invoked on, which is +called the **subject**. Just as the subject of a sentence is what the +sentence is about, the subject of a method invocation is what the method +is about. + +Inside the method, the subject is assigned to the first parameter, so in +this case start is assigned to time. + +By convention, the first parameter of a method is called self, so it +would be more common to write ``print_time`` like this: + +:: + + class Time: + def print_time(self): + print('%.2d:%.2d:%.2d' % (self.hour, self.minute, self.second)) + +The reason for this convention is an implicit metaphor: + +- The syntax for a function call, ``print_time(start)``, suggests that + the function is the active agent. It says something like, “Hey + ``print_time``! Here’s an object for you to print.” + +- In object-oriented programming, the objects are the active agents. A + method invocation like ``start.print_time()`` says “Hey start! Please + print yourself.” + +This change in perspective might be more polite, but it is not obvious +that it is useful. In the examples we have seen so far, it may not be. +But sometimes shifting responsibility from the functions onto the +objects makes it possible to write more versatile functions (or +methods), and makes it easier to maintain and reuse code. + +As an exercise, rewrite ``time_to_int`` (from Section [prototype]) as a +method. You might be tempted to rewrite ``int_to_time`` as a method, +too, but that doesn’t really make sense because there would be no object +to invoke it on. + +Another example +--------------- + +Here’s a version of increment (from Section [increment]) rewritten as a +method: + +:: + + # inside class Time: + + def increment(self, seconds): + seconds += self.time_to_int() + return int_to_time(seconds) + +This version assumes that ``time_to_int`` is written as a method. Also, +note that it is a pure function, not a modifier. + +Here’s how you would invoke increment: + +:: + + >>> start.print_time() + 09:45:00 + >>> end = start.increment(1337) + >>> end.print_time() + 10:07:17 + +The subject, start, gets assigned to the first parameter, self. The +argument, 1337, gets assigned to the second parameter, seconds. + +This mechanism can be confusing, especially if you make an error. For +example, if you invoke increment with two arguments, you get: + +:: + + >>> end = start.increment(1337, 460) + TypeError: increment() takes 2 positional arguments but 3 were given + +The error message is initially confusing, because there are only two +arguments in parentheses. But the subject is also considered an +argument, so all together that’s three. + +By the way, a **positional argument** is an argument that doesn’t have a +parameter name; that is, it is not a keyword argument. In this function +call: + +:: + + sketch(parrot, cage, dead=True) + +parrot and cage are positional, and dead is a keyword argument. + +A more complicated example +-------------------------- + +Rewriting ``is_after`` (from Section [isafter]) is slightly more +complicated because it takes two Time objects as parameters. In this +case it is conventional to name the first parameter self and the second +parameter other: + +:: + + # inside class Time: + + def is_after(self, other): + return self.time_to_int() > other.time_to_int() + +To use this method, you have to invoke it on one object and pass the +other as an argument: + +:: + + >>> end.is_after(start) + True + +One nice thing about this syntax is that it almost reads like English: +“end is after start?” + +The init method +--------------- + +The init method (short for “initialization”) is a special method that +gets invoked when an object is instantiated. Its full name is +``__init__`` (two underscore characters, followed by init, and then two +more underscores). An init method for the Time class might look like +this: + +:: + + # inside class Time: + + def __init__(self, hour=0, minute=0, second=0): + self.hour = hour + self.minute = minute + self.second = second + +It is common for the parameters of ``__init__`` to have the same names +as the attributes. The statement + +:: + + self.hour = hour + +stores the value of the parameter hour as an attribute of self. + +The parameters are optional, so if you call Time with no arguments, you +get the default values. + +:: + + >>> time = Time() + >>> time.print_time() + 00:00:00 + +If you provide one argument, it overrides hour: + +:: + + >>> time = Time (9) + >>> time.print_time() + 09:00:00 + +If you provide two arguments, they override hour and minute. + +:: + + >>> time = Time(9, 45) + >>> time.print_time() + 09:45:00 + +And if you provide three arguments, they override all three default +values. + +As an exercise, write an init method for the Point class that takes x +and y as optional parameters and assigns them to the corresponding +attributes. + +The \_\_str\_\_ method +---------------------- + +``__str__`` is a special method, like ``__init__``, that is supposed to +return a string representation of an object. + +For example, here is a str method for Time objects: + +:: + + # inside class Time: + + def __str__(self): + return '%.2d:%.2d:%.2d' % (self.hour, self.minute, self.second) + +When you print an object, Python invokes the str method: + +:: + + >>> time = Time(9, 45) + >>> print(time) + 09:45:00 + +When I write a new class, I almost always start by writing ``__init__``, +which makes it easier to instantiate objects, and ``__str__``, which is +useful for debugging. + +As an exercise, write a str method for the Point class. Create a Point +object and print it. + +Operator overloading +-------------------- + +By defining other special methods, you can specify the behavior of +operators on programmer-defined types. For example, if you define a +method named ``__add__`` for the Time class, you can use the + operator +on Time objects. + +Here is what the definition might look like: + +:: + + # inside class Time: + + def __add__(self, other): + seconds = self.time_to_int() + other.time_to_int() + return int_to_time(seconds) + +And here is how you could use it: + +:: + + >>> start = Time(9, 45) + >>> duration = Time(1, 35) + >>> print(start + duration) + 11:20:00 + +When you apply the + operator to Time objects, Python invokes +``__add__``. When you print the result, Python invokes ``__str__``. So +there is a lot happening behind the scenes! + +Changing the behavior of an operator so that it works with +programmer-defined types is called **operator overloading**. For every +operator in Python there is a corresponding special method, like +``__add__``. For more details, see +http://docs.python.org/3/reference/datamodel.html#specialnames. + +As an exercise, write an add method for the Point class. + +Type-based dispatch +------------------- + +In the previous section we added two Time objects, but you also might +want to add an integer to a Time object. The following is a version of +``__add__`` that checks the type of other and invokes either +``add_time`` or increment: + +:: + + # inside class Time: + + def __add__(self, other): + if isinstance(other, Time): + return self.add_time(other) + else: + return self.increment(other) + + def add_time(self, other): + seconds = self.time_to_int() + other.time_to_int() + return int_to_time(seconds) + + def increment(self, seconds): + seconds += self.time_to_int() + return int_to_time(seconds) + +The built-in function isinstance takes a value and a class object, and +returns True if the value is an instance of the class. + +If other is a Time object, ``__add__`` invokes ``add_time``. Otherwise +it assumes that the parameter is a number and invokes increment. This +operation is called a **type-based dispatch** because it dispatches the +computation to different methods based on the type of the arguments. + +Here are examples that use the + operator with different types: + +:: + + >>> start = Time(9, 45) + >>> duration = Time(1, 35) + >>> print(start + duration) + 11:20:00 + >>> print(start + 1337) + 10:07:17 + +Unfortunately, this implementation of addition is not commutative. If +the integer is the first operand, you get + +:: + + >>> print(1337 + start) + TypeError: unsupported operand type(s) for +: 'int' and 'instance' + +The problem is, instead of asking the Time object to add an integer, +Python is asking an integer to add a Time object, and it doesn’t know +how. But there is a clever solution for this problem: the special method +``__radd__``, which stands for “right-side add”. This method is invoked +when a Time object appears on the right side of the + operator. Here’s +the definition: + +:: + + # inside class Time: + + def __radd__(self, other): + return self.__add__(other) + +And here’s how it’s used: + +:: + + >>> print(1337 + start) + 10:07:17 + +As an exercise, write an add method for Points that works with either a +Point object or a tuple: + +- If the second operand is a Point, the method should return a new + Point whose :math:`x` coordinate is the sum of the :math:`x` + coordinates of the operands, and likewise for the :math:`y` + coordinates. + +- If the second operand is a tuple, the method should add the first + element of the tuple to the :math:`x` coordinate and the second + element to the :math:`y` coordinate, and return a new Point with the + result. + +Polymorphism +------------ + +Type-based dispatch is useful when it is necessary, but (fortunately) it +is not always necessary. Often you can avoid it by writing functions +that work correctly for arguments with different types. + +Many of the functions we wrote for strings also work for other sequence +types. For example, in Section [histogram] we used histogram to count +the number of times each letter appears in a word. + +:: + + def histogram(s): + d = dict() + for c in s: + if c not in d: + d[c] = 1 + else: + d[c] = d[c]+1 + return d + +This function also works for lists, tuples, and even dictionaries, as +long as the elements of s are hashable, so they can be used as keys in +d. + +:: + + >>> t = ['spam', 'egg', 'spam', 'spam', 'bacon', 'spam'] + >>> histogram(t) + {'bacon': 1, 'egg': 1, 'spam': 4} + +Functions that work with several types are called **polymorphic**. +Polymorphism can facilitate code reuse. For example, the built-in +function sum, which adds the elements of a sequence, works as long as +the elements of the sequence support addition. + +Since Time objects provide an add method, they work with sum: + +:: + + >>> t1 = Time(7, 43) + >>> t2 = Time(7, 41) + >>> t3 = Time(7, 37) + >>> total = sum([t1, t2, t3]) + >>> print(total) + 23:01:00 + +In general, if all of the operations inside a function work with a given +type, the function works with that type. + +The best kind of polymorphism is the unintentional kind, where you +discover that a function you already wrote can be applied to a type you +never planned for. + +Debugging +--------- + +It is legal to add attributes to objects at any point in the execution +of a program, but if you have objects with the same type that don’t have +the same attributes, it is easy to make mistakes. It is considered a +good idea to initialize all of an object’s attributes in the init +method. + +If you are not sure whether an object has a particular attribute, you +can use the built-in function hasattr (see Section [hasattr]). + +Another way to access attributes is the built-in function vars, which +takes an object and returns a dictionary that maps from attribute names +(as strings) to their values: + +:: + + >>> p = Point(3, 4) + >>> vars(p) + {'y': 4, 'x': 3} + +For purposes of debugging, you might find it useful to keep this +function handy: + +:: + + def print_attributes(obj): + for attr in vars(obj): + print(attr, getattr(obj, attr)) + +``print_attributes`` traverses the dictionary and prints each attribute +name and its corresponding value. + +The built-in function getattr takes an object and an attribute name (as +a string) and returns the attribute’s value. + +Interface and implementation +---------------------------- + +One of the goals of object-oriented design is to make software more +maintainable, which means that you can keep the program working when +other parts of the system change, and modify the program to meet new +requirements. + +A design principle that helps achieve that goal is to keep interfaces +separate from implementations. For objects, that means that the methods +a class provides should not depend on how the attributes are +represented. + +For example, in this chapter we developed a class that represents a time +of day. Methods provided by this class include ``time_to_int``, +``is_after``, and ``add_time``. + +We could implement those methods in several ways. The details of the +implementation depend on how we represent time. In this chapter, the +attributes of a Time object are hour, minute, and second. + +As an alternative, we could replace these attributes with a single +integer representing the number of seconds since midnight. This +implementation would make some methods, like ``is_after``, easier to +write, but it makes other methods harder. + +After you deploy a new class, you might discover a better +implementation. If other parts of the program are using your class, it +might be time-consuming and error-prone to change the interface. + +But if you designed the interface carefully, you can change the +implementation without changing the interface, which means that other +parts of the program don’t have to change. + +Glossary +-------- + +object-oriented language: + A language that provides features, such as programmer-defined types + and methods, that facilitate object-oriented programming. + +object-oriented programming: + A style of programming in which data and the operations that + manipulate it are organized into classes and methods. + +method: + A function that is defined inside a class definition and is invoked + on instances of that class. + +subject: + The object a method is invoked on. + +positional argument: + An argument that does not include a parameter name, so it is not a + keyword argument. + +operator overloading: + Changing the behavior of an operator like + so it works with a + programmer-defined type. + +type-based dispatch: + A programming pattern that checks the type of an operand and invokes + different functions for different types. + +polymorphic: + Pertaining to a function that can work with more than one type. + +information hiding: + The principle that the interface provided by an object should not + depend on its implementation, in particular the representation of + its attributes. + +Exercises +--------- + +Download the code from this chapter from +http://thinkpython2.com/code/Time2.py. Change the attributes of Time to +be a single integer representing seconds since midnight. Then modify the +methods (and the function ``int_to_time``) to work with the new +implementation. You should not have to modify the test code in main. +When you are done, the output should be the same as before. Solution: +http://thinkpython2.com/code/Time2_soln.py. + +[kangaroo] + +This exercise is a cautionary tale about one of the most common, and +difficult to find, errors in Python. Write a definition for a class +named Kangaroo with the following methods: + +#. An ``__init__`` method that initializes an attribute named + ``pouch_contents`` to an empty list. + +#. A method named ``put_in_pouch`` that takes an object of any type and + adds it to ``pouch_contents``. + +#. A ``__str__`` method that returns a string representation of the + Kangaroo object and the contents of the pouch. + +Test your code by creating two Kangaroo objects, assigning them to +variables named kanga and roo, and then adding roo to the contents of +kanga’s pouch. + +Download http://thinkpython2.com/code/BadKangaroo.py. It contains a +solution to the previous problem with one big, nasty bug. Find and fix +the bug. + +If you get stuck, you can download +http://thinkpython2.com/code/GoodKangaroo.py, which explains the problem +and demonstrates a solution. + +Inheritance +=========== + +The language feature most often associated with object-oriented +programming is **inheritance**. Inheritance is the ability to define a +new class that is a modified version of an existing class. In this +chapter I demonstrate inheritance using classes that represent playing +cards, decks of cards, and poker hands. + +If you don’t play poker, you can read about it at +http://en.wikipedia.org/wiki/Poker, but you don’t have to; I’ll tell you +what you need to know for the exercises. + +Code examples from this chapter are available from +http://thinkpython2.com/code/Card.py. + +Card objects +------------ + +There are fifty-two cards in a deck, each of which belongs to one of +four suits and one of thirteen ranks. The suits are Spades, Hearts, +Diamonds, and Clubs (in descending order in bridge). The ranks are Ace, +2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, and King. Depending on the game +that you are playing, an Ace may be higher than King or lower than 2. + +If we want to define a new object to represent a playing card, it is +obvious what the attributes should be: rank and suit. It is not as +obvious what type the attributes should be. One possibility is to use +strings containing words like ``'Spade'`` for suits and ``'Queen'`` for +ranks. One problem with this implementation is that it would not be easy +to compare cards to see which had a higher rank or suit. + +An alternative is to use integers to **encode** the ranks and suits. In +this context, “encode” means that we are going to define a mapping +between numbers and suits, or between numbers and ranks. This kind of +encoding is not meant to be a secret (that would be “encryption”). + +For example, this table shows the suits and the corresponding integer +codes: + ++------------+-------------------+-----+ +| Spades | :math:`\mapsto` | 3 | ++------------+-------------------+-----+ +| Hearts | :math:`\mapsto` | 2 | ++------------+-------------------+-----+ +| Diamonds | :math:`\mapsto` | 1 | ++------------+-------------------+-----+ +| Clubs | :math:`\mapsto` | 0 | ++------------+-------------------+-----+ + +This code makes it easy to compare cards; because higher suits map to +higher numbers, we can compare suits by comparing their codes. + +The mapping for ranks is fairly obvious; each of the numerical ranks +maps to the corresponding integer, and for face cards: + ++---------+-------------------+------+ +| Jack | :math:`\mapsto` | 11 | ++---------+-------------------+------+ +| Queen | :math:`\mapsto` | 12 | ++---------+-------------------+------+ +| King | :math:`\mapsto` | 13 | ++---------+-------------------+------+ + +I am using the :math:`\mapsto` symbol to make it clear that these +mappings are not part of the Python program. They are part of the +program design, but they don’t appear explicitly in the code. + +The class definition for Card looks like this: + +:: + + class Card: + """Represents a standard playing card.""" + + def __init__(self, suit=0, rank=2): + self.suit = suit + self.rank = rank + +As usual, the init method takes an optional parameter for each +attribute. The default card is the 2 of Clubs. + +To create a Card, you call Card with the suit and rank of the card you +want. + +:: + + queen_of_diamonds = Card(1, 12) + +Class attributes +---------------- + +In order to print Card objects in a way that people can easily read, we +need a mapping from the integer codes to the corresponding ranks and +suits. A natural way to do that is with lists of strings. We assign +these lists to **class attributes**: + +:: + + # inside class Card: + + suit_names = ['Clubs', 'Diamonds', 'Hearts', 'Spades'] + rank_names = [None, 'Ace', '2', '3', '4', '5', '6', '7', + '8', '9', '10', 'Jack', 'Queen', 'King'] + + def __str__(self): + return '%s of %s' % (Card.rank_names[self.rank], + Card.suit_names[self.suit]) + +Variables like ``suit_names`` and ``rank_names``, which are defined +inside a class but outside of any method, are called class attributes +because they are associated with the class object Card. + +This term distinguishes them from variables like suit and rank, which +are called **instance attributes** because they are associated with a +particular instance. + +Both kinds of attribute are accessed using dot notation. For example, in +``__str__``, self is a Card object, and self.rank is its rank. +Similarly, Card is a class object, and ``Card.rank_names`` is a list of +strings associated with the class. + +Every card has its own suit and rank, but there is only one copy of +``suit_names`` and ``rank_names``. + +Putting it all together, the expression ``Card.rank_names[self.rank]`` +means “use the attribute rank from the object self as an index into the +list ``rank_names`` from the class Card, and select the appropriate +string.” + +The first element of ``rank_names`` is None because there is no card +with rank zero. By including None as a place-keeper, we get a mapping +with the nice property that the index 2 maps to the string ``'2'``, and +so on. To avoid this tweak, we could have used a dictionary instead of a +list. + +With the methods we have so far, we can create and print cards: + +:: + + >>> card1 = Card(2, 11) + >>> print(card1) + Jack of Hearts + +.. figure:: figs/card1.pdf + :alt: Object diagram. + + Object diagram. + +Figure [fig.card1] is a diagram of the Card class object and one Card +instance. Card is a class object; its type is type. card1 is an instance +of Card, so its type is Card. To save space, I didn’t draw the contents +of ``suit_names`` and ``rank_names``. + +Comparing cards +--------------- + +For built-in types, there are relational operators (<, >, ==, etc.) that +compare values and determine when one is greater than, less than, or +equal to another. For programmer-defined types, we can override the +behavior of the built-in operators by providing a method named +``__lt__``, which stands for “less than”. + +``__lt__`` takes two parameters, self and other, and True if self is +strictly less than other. + +The correct ordering for cards is not obvious. For example, which is +better, the 3 of Clubs or the 2 of Diamonds? One has a higher rank, but +the other has a higher suit. In order to compare cards, you have to +decide whether rank or suit is more important. + +The answer might depend on what game you are playing, but to keep things +simple, we’ll make the arbitrary choice that suit is more important, so +all of the Spades outrank all of the Diamonds, and so on. + +With that decided, we can write ``__lt__``: + +:: + + # inside class Card: + + def __lt__(self, other): + # check the suits + if self.suit < other.suit: return True + if self.suit > other.suit: return False + + # suits are the same... check ranks + return self.rank < other.rank + +You can write this more concisely using tuple comparison: + +:: + + # inside class Card: + + def __lt__(self, other): + t1 = self.suit, self.rank + t2 = other.suit, other.rank + return t1 < t2 + +As an exercise, write an ``__lt__`` method for Time objects. You can use +tuple comparison, but you also might consider comparing integers. + +Decks +----- + +Now that we have Cards, the next step is to define Decks. Since a deck +is made up of cards, it is natural for each Deck to contain a list of +cards as an attribute. + +The following is a class definition for Deck. The init method creates +the attribute cards and generates the standard set of fifty-two cards: + +:: + + class Deck: + + def __init__(self): + self.cards = [] + for suit in range(4): + for rank in range(1, 14): + card = Card(suit, rank) + self.cards.append(card) + +The easiest way to populate the deck is with a nested loop. The outer +loop enumerates the suits from 0 to 3. The inner loop enumerates the +ranks from 1 to 13. Each iteration creates a new Card with the current +suit and rank, and appends it to self.cards. + +Printing the deck +----------------- + +Here is a ``__str__`` method for Deck: + +:: + + #inside class Deck: + + def __str__(self): + res = [] + for card in self.cards: + res.append(str(card)) + return '\n'.join(res) + +This method demonstrates an efficient way to accumulate a large string: +building a list of strings and then using the string method join. The +built-in function str invokes the ``__str__`` method on each card and +returns the string representation. + +Since we invoke join on a newline character, the cards are separated by +newlines. Here’s what the result looks like: + +:: + + >>> deck = Deck() + >>> print(deck) + Ace of Clubs + 2 of Clubs + 3 of Clubs + ... + 10 of Spades + Jack of Spades + Queen of Spades + King of Spades + +Even though the result appears on 52 lines, it is one long string that +contains newlines. + +Add, remove, shuffle and sort +----------------------------- + +To deal cards, we would like a method that removes a card from the deck +and returns it. The list method pop provides a convenient way to do +that: + +:: + + #inside class Deck: + + def pop_card(self): + return self.cards.pop() + +Since pop removes the *last* card in the list, we are dealing from the +bottom of the deck. + +To add a card, we can use the list method append: + +:: + + #inside class Deck: + + def add_card(self, card): + self.cards.append(card) + +A method like this that uses another method without doing much work is +sometimes called a **veneer**. The metaphor comes from woodworking, +where a veneer is a thin layer of good quality wood glued to the surface +of a cheaper piece of wood to improve the appearance. + +In this case ``add_card`` is a “thin” method that expresses a list +operation in terms appropriate for decks. It improves the appearance, or +interface, of the implementation. + +As another example, we can write a Deck method named shuffle using the +function shuffle from the random module: + +:: + + # inside class Deck: + + def shuffle(self): + random.shuffle(self.cards) + +Don’t forget to import random. + +As an exercise, write a Deck method named sort that uses the list method +sort to sort the cards in a Deck. sort uses the ``__lt__`` method we +defined to determine the order. + +Inheritance +----------- + +Inheritance is the ability to define a new class that is a modified +version of an existing class. As an example, let’s say we want a class +to represent a “hand”, that is, the cards held by one player. A hand is +similar to a deck: both are made up of a collection of cards, and both +require operations like adding and removing cards. + +A hand is also different from a deck; there are operations we want for +hands that don’t make sense for a deck. For example, in poker we might +compare two hands to see which one wins. In bridge, we might compute a +score for a hand in order to make a bid. + +This relationship between classes—similar, but different—lends itself to +inheritance. To define a new class that inherits from an existing class, +you put the name of the existing class in parentheses: + +:: + + class Hand(Deck): + """Represents a hand of playing cards.""" + +This definition indicates that Hand inherits from Deck; that means we +can use methods like ``pop_card`` and ``add_card`` for Hands as well as +Decks. + +When a new class inherits from an existing one, the existing one is +called the **parent** and the new class is called the **child**. + +In this example, Hand inherits ``__init__`` from Deck, but it doesn’t +really do what we want: instead of populating the hand with 52 new +cards, the init method for Hands should initialize cards with an empty +list. + +If we provide an init method in the Hand class, it overrides the one in +the Deck class: + +:: + + # inside class Hand: + + def __init__(self, label=''): + self.cards = [] + self.label = label + +When you create a Hand, Python invokes this init method, not the one in +Deck. + +:: + + >>> hand = Hand('new hand') + >>> hand.cards + [] + >>> hand.label + 'new hand' + +The other methods are inherited from Deck, so we can use ``pop_card`` +and ``add_card`` to deal a card: + +:: + + >>> deck = Deck() + >>> card = deck.pop_card() + >>> hand.add_card(card) + >>> print(hand) + King of Spades + +A natural next step is to encapsulate this code in a method called +``move_cards``: + +:: + + #inside class Deck: + + def move_cards(self, hand, num): + for i in range(num): + hand.add_card(self.pop_card()) + +``move_cards`` takes two arguments, a Hand object and the number of +cards to deal. It modifies both self and hand, and returns None. + +In some games, cards are moved from one hand to another, or from a hand +back to the deck. You can use ``move_cards`` for any of these +operations: self can be either a Deck or a Hand, and hand, despite the +name, can also be a Deck. + +Inheritance is a useful feature. Some programs that would be repetitive +without inheritance can be written more elegantly with it. Inheritance +can facilitate code reuse, since you can customize the behavior of +parent classes without having to modify them. In some cases, the +inheritance structure reflects the natural structure of the problem, +which makes the design easier to understand. + +On the other hand, inheritance can make programs difficult to read. When +a method is invoked, it is sometimes not clear where to find its +definition. The relevant code may be spread across several modules. +Also, many of the things that can be done using inheritance can be done +as well or better without it. + +Class diagrams +-------------- + +So far we have seen stack diagrams, which show the state of a program, +and object diagrams, which show the attributes of an object and their +values. These diagrams represent a snapshot in the execution of a +program, so they change as the program runs. + +They are also highly detailed; for some purposes, too detailed. A class +diagram is a more abstract representation of the structure of a program. +Instead of showing individual objects, it shows classes and the +relationships between them. + +There are several kinds of relationship between classes: + +- Objects in one class might contain references to objects in another + class. For example, each Rectangle contains a reference to a Point, + and each Deck contains references to many Cards. This kind of + relationship is called **HAS-A**, as in, “a Rectangle has a Point.” + +- One class might inherit from another. This relationship is called + **IS-A**, as in, “a Hand is a kind of a Deck.” + +- One class might depend on another in the sense that objects in one + class take objects in the second class as parameters, or use objects + in the second class as part of a computation. This kind of + relationship is called a **dependency**. + +A **class diagram** is a graphical representation of these +relationships. For example, Figure [fig.class1] shows the relationships +between Card, Deck and Hand. + +.. figure:: figs/class1.pdf + :alt: Class diagram. + + Class diagram. + +The arrow with a hollow triangle head represents an IS-A relationship; +in this case it indicates that Hand inherits from Deck. + +The standard arrow head represents a HAS-A relationship; in this case a +Deck has references to Card objects. + +The star () near the arrow head is a **multiplicity**; it indicates how +many Cards a Deck has. A multiplicity can be a simple number, like 52, a +range, like 5..7 or a star, which indicates that a Deck can have any +number of Cards. + +There are no dependencies in this diagram. They would normally be shown +with a dashed arrow. Or if there are a lot of dependencies, they are +sometimes omitted. + +A more detailed diagram might show that a Deck actually contains a +*list* of Cards, but built-in types like list and dict are usually not +included in class diagrams. + +Debugging +--------- + +Inheritance can make debugging difficult because when you invoke a +method on an object, it might be hard to figure out which method will be +invoked. + +Suppose you are writing a function that works with Hand objects. You +would like it to work with all kinds of Hands, like PokerHands, +BridgeHands, etc. If you invoke a method like shuffle, you might get the +one defined in Deck, but if any of the subclasses override this method, +you’ll get that version instead. This behavior is usually a good thing, +but it can be confusing. + +Any time you are unsure about the flow of execution through your +program, the simplest solution is to add print statements at the +beginning of the relevant methods. If Deck.shuffle prints a message that +says something like Running Deck.shuffle, then as the program runs it +traces the flow of execution. + +As an alternative, you could use this function, which takes an object +and a method name (as a string) and returns the class that provides the +definition of the method: + +:: + + def find_defining_class(obj, meth_name): + for ty in type(obj).mro(): + if meth_name in ty.__dict__: + return ty + +Here’s an example: + +:: + + >>> hand = Hand() + >>> find_defining_class(hand, 'shuffle') + + +So the shuffle method for this Hand is the one in Deck. + +``find_defining_class`` uses the mro method to get the list of class +objects (types) that will be searched for methods. “MRO” stands for +“method resolution order”, which is the sequence of classes Python +searches to “resolve” a method name. + +Here’s a design suggestion: when you override a method, the interface of +the new method should be the same as the old. It should take the same +parameters, return the same type, and obey the same preconditions and +postconditions. If you follow this rule, you will find that any function +designed to work with an instance of a parent class, like a Deck, will +also work with instances of child classes like a Hand and PokerHand. + +If you violate this rule, which is called the “Liskov substitution +principle”, your code will collapse like (sorry) a house of cards. + +Data encapsulation +------------------ + +The previous chapters demonstrate a development plan we might call +“object-oriented design”. We identified objects we needed—like Point, +Rectangle and Time—and defined classes to represent them. In each case +there is an obvious correspondence between the object and some entity in +the real world (or at least a mathematical world). + +But sometimes it is less obvious what objects you need and how they +should interact. In that case you need a different development plan. In +the same way that we discovered function interfaces by encapsulation and +generalization, we can discover class interfaces by **data +encapsulation**. + +Markov analysis, from Section [markov], provides a good example. If you +download my code from http://thinkpython2.com/code/markov.py, you’ll see +that it uses two global variables—\ ``suffix_map`` and ``prefix``—that +are read and written from several functions. + +:: + + suffix_map = {} + prefix = () + +Because these variables are global, we can only run one analysis at a +time. If we read two texts, their prefixes and suffixes would be added +to the same data structures (which makes for some interesting generated +text). + +To run multiple analyses, and keep them separate, we can encapsulate the +state of each analysis in an object. Here’s what that looks like: + +:: + + class Markov: + + def __init__(self): + self.suffix_map = {} + self.prefix = () + +Next, we transform the functions into methods. For example, here’s +``process_word``: + +:: + + def process_word(self, word, order=2): + if len(self.prefix) < order: + self.prefix += (word,) + return + + try: + self.suffix_map[self.prefix].append(word) + except KeyError: + # if there is no entry for this prefix, make one + self.suffix_map[self.prefix] = [word] + + self.prefix = shift(self.prefix, word) + +Transforming a program like this—changing the design without changing +the behavior—is another example of refactoring (see +Section [refactoring]). + +This example suggests a development plan for designing objects and +methods: + +#. Start by writing functions that read and write global variables (when + necessary). + +#. Once you get the program working, look for associations between + global variables and the functions that use them. + +#. Encapsulate related variables as attributes of an object. + +#. Transform the associated functions into methods of the new class. + +As an exercise, download my Markov code from +http://thinkpython2.com/code/markov.py, and follow the steps described +above to encapsulate the global variables as attributes of a new class +called Markov. Solution: http://thinkpython2.com/code/Markov.py (note +the capital M). + +Glossary +-------- + +encode: + To represent one set of values using another set of values by + constructing a mapping between them. + +class attribute: + An attribute associated with a class object. Class attributes are + defined inside a class definition but outside any method. + +instance attribute: + An attribute associated with an instance of a class. + +veneer: + A method or function that provides a different interface to another + function without doing much computation. + +inheritance: + The ability to define a new class that is a modified version of a + previously defined class. + +parent class: + The class from which a child class inherits. + +child class: + A new class created by inheriting from an existing class; also + called a “subclass”. + +IS-A relationship: + A relationship between a child class and its parent class. + +HAS-A relationship: + A relationship between two classes where instances of one class + contain references to instances of the other. + +dependency: + A relationship between two classes where instances of one class use + instances of the other class, but do not store them as attributes. + +class diagram: + A diagram that shows the classes in a program and the relationships + between them. + +multiplicity: + A notation in a class diagram that shows, for a HAS-A relationship, + how many references there are to instances of another class. + +data encapsulation: + A program development plan that involves a prototype using global + variables and a final version that makes the global variables into + instance attributes. + +Exercises +--------- + +For the following program, draw a UML class diagram that shows these +classes and the relationships among them. + +:: + + class PingPongParent: + pass + + class Ping(PingPongParent): + def __init__(self, pong): + self.pong = pong + + + class Pong(PingPongParent): + def __init__(self, pings=None): + if pings is None: + self.pings = [] + else: + self.pings = pings + + def add_ping(self, ping): + self.pings.append(ping) + + pong = Pong() + ping = Ping(pong) + pong.add_ping(ping) + +Write a Deck method called ``deal_hands`` that takes two parameters, the +number of hands and the number of cards per hand. It should create the +appropriate number of Hand objects, deal the appropriate number of cards +per hand, and return a list of Hands. + +[poker] + +The following are the possible hands in poker, in increasing order of +value and decreasing order of probability: + +pair: + two cards with the same rank + +two pair: + two pairs of cards with the same rank + +three of a kind: + three cards with the same rank + +straight: + five cards with ranks in sequence (aces can be high or low, so + Ace-2-3-4-5 is a straight and so is 10-Jack-Queen-King-Ace, but + Queen-King-Ace-2-3 is not.) + +flush: + five cards with the same suit + +full house: + three cards with one rank, two cards with another + +four of a kind: + four cards with the same rank + +straight flush: + five cards in sequence (as defined above) and with the same suit + +The goal of these exercises is to estimate the probability of drawing +these various hands. + +#. Download the following files from http://thinkpython2.com/code: + + Card.py + : A complete version of the Card, Deck and Hand classes in this + chapter. + + PokerHand.py + : An incomplete implementation of a class that represents a poker + hand, and some code that tests it. + +#. If you run PokerHand.py, it deals seven 7-card poker hands and checks + to see if any of them contains a flush. Read this code carefully + before you go on. + +#. Add methods to PokerHand.py named ``has_pair``, ``has_twopair``, etc. + that return True or False according to whether or not the hand meets + the relevant criteria. Your code should work correctly for “hands” + that contain any number of cards (although 5 and 7 are the most + common sizes). + +#. Write a method named classify that figures out the highest-value + classification for a hand and sets the label attribute accordingly. + For example, a 7-card hand might contain a flush and a pair; it + should be labeled “flush”. + +#. When you are convinced that your classification methods are working, + the next step is to estimate the probabilities of the various hands. + Write a function in PokerHand.py that shuffles a deck of cards, + divides it into hands, classifies the hands, and counts the number of + times various classifications appear. + +#. Print a table of the classifications and their probabilities. Run + your program with larger and larger numbers of hands until the output + values converge to a reasonable degree of accuracy. Compare your + results to the values at http://en.wikipedia.org/wiki/Hand_rankings. + +Solution: http://thinkpython2.com/code/PokerHandSoln.py. + +The Goodies +=========== + +One of my goals for this book has been to teach you as little Python as +possible. When there were two ways to do something, I picked one and +avoided mentioning the other. Or sometimes I put the second one into an +exercise. + +Now I want to go back for some of the good bits that got left behind. +Python provides a number of features that are not really necessary—you +can write good code without them—but with them you can sometimes write +code that’s more concise, readable or efficient, and sometimes all +three. + +Conditional expressions +----------------------- + +We saw conditional statements in Section [conditional.execution]. +Conditional statements are often used to choose one of two values; for +example: + +:: + + if x > 0: + y = math.log(x) + else: + y = float('nan') + +This statement checks whether x is positive. If so, it computes +math.log. If not, math.log would raise a ValueError. To avoid stopping +the program, we generate a “NaN”, which is a special floating-point +value that represents “Not a Number”. + +We can write this statement more concisely using a **conditional +expression**: + +:: + + y = math.log(x) if x > 0 else float('nan') + +You can almost read this line like English: “y gets log-x if x is +greater than 0; otherwise it gets NaN”. + +Recursive functions can sometimes be rewritten using conditional +expressions. For example, here is a recursive version of factorial: + +:: + + def factorial(n): + if n == 0: + return 1 + else: + return n * factorial(n-1) + +We can rewrite it like this: + +:: + + def factorial(n): + return 1 if n == 0 else n * factorial(n-1) + +Another use of conditional expressions is handling optional arguments. +For example, here is the init method from GoodKangaroo (see +Exercise [kangaroo]): + +:: + + def __init__(self, name, contents=None): + self.name = name + if contents == None: + contents = [] + self.pouch_contents = contents + +We can rewrite this one like this: + +:: + + def __init__(self, name, contents=None): + self.name = name + self.pouch_contents = [] if contents == None else contents + +In general, you can replace a conditional statement with a conditional +expression if both branches contain simple expressions that are either +returned or assigned to the same variable. + +List comprehensions +------------------- + +In Section [filter] we saw the map and filter patterns. For example, +this function takes a list of strings, maps the string method capitalize +to the elements, and returns a new list of strings: + +:: + + def capitalize_all(t): + res = [] + for s in t: + res.append(s.capitalize()) + return res + +We can write this more concisely using a **list comprehension**: + +:: + + def capitalize_all(t): + return [s.capitalize() for s in t] + +The bracket operators indicate that we are constructing a new list. The +expression inside the brackets specifies the elements of the list, and +the for clause indicates what sequence we are traversing. + +The syntax of a list comprehension is a little awkward because the loop +variable, s in this example, appears in the expression before we get to +the definition. + +List comprehensions can also be used for filtering. For example, this +function selects only the elements of t that are upper case, and returns +a new list: + +:: + + def only_upper(t): + res = [] + for s in t: + if s.isupper(): + res.append(s) + return res + +We can rewrite it using a list comprehension + +:: + + def only_upper(t): + return [s for s in t if s.isupper()] + +List comprehensions are concise and easy to read, at least for simple +expressions. And they are usually faster than the equivalent for loops, +sometimes much faster. So if you are mad at me for not mentioning them +earlier, I understand. + +But, in my defense, list comprehensions are harder to debug because you +can’t put a print statement inside the loop. I suggest that you use them +only if the computation is simple enough that you are likely to get it +right the first time. And for beginners that means never. + +Generator expressions +--------------------- + +**Generator expressions** are similar to list comprehensions, but with +parentheses instead of square brackets: + +:: + + >>> g = (x**2 for x in range(5)) + >>> g + at 0x7f4c45a786c0> + +The result is a generator object that knows how to iterate through a +sequence of values. But unlike a list comprehension, it does not compute +the values all at once; it waits to be asked. The built-in function next +gets the next value from the generator: + +:: + + >>> next(g) + 0 + >>> next(g) + 1 + +When you get to the end of the sequence, next raises a StopIteration +exception. You can also use a for loop to iterate through the values: + +:: + + >>> for val in g: + ... print(val) + 4 + 9 + 16 + +The generator object keeps track of where it is in the sequence, so the +for loop picks up where next left off. Once the generator is exhausted, +it continues to raise StopException: + +:: + + >>> next(g) + StopIteration + +Generator expressions are often used with functions like sum, max, and +min: + +:: + + >>> sum(x**2 for x in range(5)) + 30 + +any and all +----------- + +Python provides a built-in function, any, that takes a sequence of +boolean values and returns True if any of the values are True. It works +on lists: + +:: + + >>> any([False, False, True]) + True + +But it is often used with generator expressions: + +:: + + >>> any(letter == 't' for letter in 'monty') + True + +That example isn’t very useful because it does the same thing as the in +operator. But we could use any to rewrite some of the search functions +we wrote in Section [search]. For example, we could write avoids like +this: + +:: + + def avoids(word, forbidden): + return not any(letter in forbidden for letter in word) + +The function almost reads like English, “word avoids forbidden if there +are not any forbidden letters in word.” + +Using any with a generator expression is efficient because it stops +immediately if it finds a True value, so it doesn’t have to evaluate the +whole sequence. + +Python provides another built-in function, all, that returns True if +every element of the sequence is True. As an exercise, use all to +re-write ``uses_all`` from Section [search]. + +Sets +---- + +In Section [dictsub] I use dictionaries to find the words that appear in +a document but not in a word list. The function I wrote takes d1, which +contains the words from the document as keys, and d2, which contains the +list of words. It returns a dictionary that contains the keys from d1 +that are not in d2. + +:: + + def subtract(d1, d2): + res = dict() + for key in d1: + if key not in d2: + res[key] = None + return res + +In all of these dictionaries, the values are None because we never use +them. As a result, we waste some storage space. + +Python provides another built-in type, called a set, that behaves like a +collection of dictionary keys with no values. Adding elements to a set +is fast; so is checking membership. And sets provide methods and +operators to compute common set operations. + +For example, set subtraction is available as a method called difference +or as an operator, -. So we can rewrite subtract like this: + +:: + + def subtract(d1, d2): + return set(d1) - set(d2) + +The result is a set instead of a dictionary, but for operations like +iteration, the behavior is the same. + +Some of the exercises in this book can be done concisely and efficiently +with sets. For example, here is a solution to ``has_duplicates``, from +Exercise [duplicate], that uses a dictionary: + +:: + + def has_duplicates(t): + d = {} + for x in t: + if x in d: + return True + d[x] = True + return False + +When an element appears for the first time, it is added to the +dictionary. If the same element appears again, the function returns +True. + +Using sets, we can write the same function like this: + +:: + + def has_duplicates(t): + return len(set(t)) < len(t) + +An element can only appear in a set once, so if an element in t appears +more than once, the set will be smaller than t. If there are no +duplicates, the set will be the same size as t. + +We can also use sets to do some of the exercises in Chapter [wordplay]. +For example, here’s a version of ``uses_only`` with a loop: + +:: + + def uses_only(word, available): + for letter in word: + if letter not in available: + return False + return True + +``uses_only`` checks whether all letters in word are in available. We +can rewrite it like this: + +:: + + def uses_only(word, available): + return set(word) <= set(available) + +The ``<=`` operator checks whether one set is a subset or another, +including the possibility that they are equal, which is true if all the +letters in word appear in available. + +As an exercise, rewrite ``avoids`` using sets. + +Counters +-------- + +A Counter is like a set, except that if an element appears more than +once, the Counter keeps track of how many times it appears. If you are +familiar with the mathematical idea of a **multiset**, a Counter is a +natural way to represent a multiset. + +Counter is defined in a standard module called collections, so you have +to import it. You can initialize a Counter with a string, list, or +anything else that supports iteration: + +:: + + >>> from collections import Counter + >>> count = Counter('parrot') + >>> count + Counter({'r': 2, 't': 1, 'o': 1, 'p': 1, 'a': 1}) + +Counters behave like dictionaries in many ways; they map from each key +to the number of times it appears. As in dictionaries, the keys have to +be hashable. + +Unlike dictionaries, Counters don’t raise an exception if you access an +element that doesn’t appear. Instead, they return 0: + +:: + + >>> count['d'] + 0 + +We can use Counters to rewrite ``is_anagram`` from Exercise [anagram]: + +:: + + def is_anagram(word1, word2): + return Counter(word1) == Counter(word2) + +If two words are anagrams, they contain the same letters with the same +counts, so their Counters are equivalent. + +Counters provide methods and operators to perform set-like operations, +including addition, subtraction, union and intersection. And they +provide an often-useful method, ``most_common``, which returns a list of +value-frequency pairs, sorted from most common to least: + +:: + + >>> count = Counter('parrot') + >>> for val, freq in count.most_common(3): + ... print(val, freq) + r 2 + p 1 + a 1 + +defaultdict +----------- + +The collections module also provides defaultdict, which is like a +dictionary except that if you access a key that doesn’t exist, it can +generate a new value on the fly. + +When you create a defaultdict, you provide a function that’s used to +create new values. A function used to create objects is sometimes called +a **factory**. The built-in functions that create lists, sets, and other +types can be used as factories: + +:: + + >>> from collections import defaultdict + >>> d = defaultdict(list) + +Notice that the argument is list, which is a class object, not list(), +which is a new list. The function you provide doesn’t get called unless +you access a key that doesn’t exist. + +:: + + >>> t = d['new key'] + >>> t + [] + +The new list, which we’re calling t, is also added to the dictionary. So +if we modify t, the change appears in d: + +:: + + >>> t.append('new value') + >>> d + defaultdict(, {'new key': ['new value']}) + +If you are making a dictionary of lists, you can often write simpler +code using defaultdict. In my solution to Exercise [anagrams], which you +can get from http://thinkpython2.com/code/anagram_sets.py, I make a +dictionary that maps from a sorted string of letters to the list of +words that can be spelled with those letters. For example, ’opst’ maps +to the list . + +Here’s the original code: + +:: + + def all_anagrams(filename): + d = {} + for line in open(filename): + word = line.strip().lower() + t = signature(word) + if t not in d: + d[t] = [word] + else: + d[t].append(word) + return d + +This can be simplified using setdefault, which you might have used in +Exercise [setdefault]: + +:: + + def all_anagrams(filename): + d = {} + for line in open(filename): + word = line.strip().lower() + t = signature(word) + d.setdefault(t, []).append(word) + return d + +This solution has the drawback that it makes a new list every time, +regardless of whether it is needed. For lists, that’s no big deal, but +if the factory function is complicated, it might be. + +We can avoid this problem and simplify the code using a defaultdict: + +:: + + def all_anagrams(filename): + d = defaultdict(list) + for line in open(filename): + word = line.strip().lower() + t = signature(word) + d[t].append(word) + return d + +My solution to Exercise [poker], which you can download from +http://thinkpython2.com/code/PokerHandSoln.py, uses setdefault in the +function ``has_straightflush``. This solution has the drawback of +creating a Hand object every time through the loop, whether it is needed +or not. As an exercise, rewrite it using a defaultdict. + +Named tuples +------------ + +Many simple objects are basically collections of related values. For +example, the Point object defined in Chapter [clobjects] contains two +numbers, x and y. When you define a class like this, you usually start +with an init method and a str method: + +:: + + class Point: + + def __init__(self, x=0, y=0): + self.x = x + self.y = y + + def __str__(self): + return '(%g, %g)' % (self.x, self.y) + +This is a lot of code to convey a small amount of information. Python +provides a more concise way to say the same thing: + +:: + + from collections import namedtuple + Point = namedtuple('Point', ['x', 'y']) + +The first argument is the name of the class you want to create. The +second is a list of the attributes Point objects should have, as +strings. The return value from namedtuple is a class object: + +:: + + >>> Point + + +Point automatically provides methods like ``__init__`` and ``__str__`` +so you don’t have to write them. + +To create a Point object, you use the Point class as a function: + +:: + + >>> p = Point(1, 2) + >>> p + Point(x=1, y=2) + +The init method assigns the arguments to attributes using the names you +provided. The str method prints a representation of the Point object and +its attributes. + +You can access the elements of the named tuple by name: + +:: + + >>> p.x, p.y + (1, 2) + +But you can also treat a named tuple as a tuple: + +:: + + >>> p[0], p[1] + (1, 2) + + >>> x, y = p + >>> x, y + (1, 2) + +Named tuples provide a quick way to define simple classes. The drawback +is that simple classes don’t always stay simple. You might decide later +that you want to add methods to a named tuple. In that case, you could +define a new class that inherits from the named tuple: + +:: + + class Pointier(Point): + # add more methods here + +Or you could switch to a conventional class definition. + +Gathering keyword args +---------------------- + +In Section [gather], we saw how to write a function that gathers its +arguments into a tuple: + +:: + + def printall(*args): + print(args) + +You can call this function with any number of positional arguments (that +is, arguments that don’t have keywords): + +:: + + >>> printall(1, 2.0, '3') + (1, 2.0, '3') + +But the operator doesn’t gather keyword arguments: + +:: + + >>> printall(1, 2.0, third='3') + TypeError: printall() got an unexpected keyword argument 'third' + +To gather keyword arguments, you can use the \* operator: + +:: + + def printall(*args, **kwargs): + print(args, kwargs) + +You can call the keyword gathering parameter anything you want, but +kwargs is a common choice. The result is a dictionary that maps keywords +to values: + +:: + + >>> printall(1, 2.0, third='3') + (1, 2.0) {'third': '3'} + +If you have a dictionary of keywords and values, you can use the scatter +operator, \* to call a function: + +:: + + >>> d = dict(x=1, y=2) + >>> Point(**d) + Point(x=1, y=2) + +Without the scatter operator, the function would treat d as a single +positional argument, so it would assign d to x and complain because +there’s nothing to assign to y: + +:: + + >>> d = dict(x=1, y=2) + >>> Point(d) + Traceback (most recent call last): + File "", line 1, in + TypeError: __new__() missing 1 required positional argument: 'y' + +When you are working with functions that have a large number of +parameters, it is often useful to create and pass around dictionaries +that specify frequently used options. + +Glossary +-------- + +conditional expression: + An expression that has one of two values, depending on a condition. + +list comprehension: + An expression with a for loop in square brackets that yields a new + list. + +generator expression: + An expression with a for loop in parentheses that yields a generator + object. + +multiset: + A mathematical entity that represents a mapping between the elements + of a set and the number of times they appear. + +factory: + A function, usually passed as a parameter, used to create objects. + +Exercises +--------- + +The following is a function computes the binomial coefficient +recursively. + +:: + + def binomial_coeff(n, k): + """Compute the binomial coefficient "n choose k". + + n: number of trials + k: number of successes + + returns: int + """ + if k == 0: + return 1 + if n == 0: + return 0 + + res = binomial_coeff(n-1, k) + binomial_coeff(n-1, k-1) + return res + +Rewrite the body of the function using nested conditional expressions. + +One note: this function is not very efficient because it ends up +computing the same values over and over. You could make it more +efficient by memoizing (see Section [memoize]). But you will find that +it’s harder to memoize if you write it using conditional expressions. + +Debugging +========= + +When you are debugging, you should distinguish among different kinds of +errors in order to track them down more quickly: + +- Syntax errors are discovered by the interpreter when it is + translating the source code into byte code. They indicate that there + is something wrong with the structure of the program. Example: + Omitting the colon at the end of a def statement generates the + somewhat redundant message SyntaxError: invalid syntax. + +- Runtime errors are produced by the interpreter if something goes + wrong while the program is running. Most runtime error messages + include information about where the error occurred and what functions + were executing. Example: An infinite recursion eventually causes the + runtime error “maximum recursion depth exceeded”. + +- Semantic errors are problems with a program that runs without + producing error messages but doesn’t do the right thing. Example: An + expression may not be evaluated in the order you expect, yielding an + incorrect result. + +The first step in debugging is to figure out which kind of error you are +dealing with. Although the following sections are organized by error +type, some techniques are applicable in more than one situation. + +Syntax errors +------------- + +Syntax errors are usually easy to fix once you figure out what they are. +Unfortunately, the error messages are often not helpful. The most common +messages are SyntaxError: invalid syntax and SyntaxError: invalid token, +neither of which is very informative. + +On the other hand, the message does tell you where in the program the +problem occurred. Actually, it tells you where Python noticed a problem, +which is not necessarily where the error is. Sometimes the error is +prior to the location of the error message, often on the preceding line. + +If you are building the program incrementally, you should have a good +idea about where the error is. It will be in the last line you added. + +If you are copying code from a book, start by comparing your code to the +book’s code very carefully. Check every character. At the same time, +remember that the book might be wrong, so if you see something that +looks like a syntax error, it might be. + +Here are some ways to avoid the most common syntax errors: + +#. Make sure you are not using a Python keyword for a variable name. + +#. Check that you have a colon at the end of the header of every + compound statement, including for, while, if, and def statements. + +#. Make sure that any strings in the code have matching quotation marks. + Make sure that all quotation marks are “straight quotes”, not “curly + quotes”. + +#. If you have multiline strings with triple quotes (single or double), + make sure you have terminated the string properly. An unterminated + string may cause an invalid token error at the end of your program, + or it may treat the following part of the program as a string until + it comes to the next string. In the second case, it might not produce + an error message at all! + +#. An unclosed opening operator—\ ``(``, ``{``, or ``[``—makes Python + continue with the next line as part of the current statement. + Generally, an error occurs almost immediately in the next line. + +#. Check for the classic = instead of == inside a conditional. + +#. Check the indentation to make sure it lines up the way it is supposed + to. Python can handle space and tabs, but if you mix them it can + cause problems. The best way to avoid this problem is to use a text + editor that knows about Python and generates consistent indentation. + +#. If you have non-ASCII characters in the code (including strings and + comments), that might cause a problem, although Python 3 usually + handles non-ASCII characters. Be careful if you paste in text from a + web page or other source. + +If nothing works, move on to the next section... + +I keep making changes and it makes no difference. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If the interpreter says there is an error and you don’t see it, that +might be because you and the interpreter are not looking at the same +code. Check your programming environment to make sure that the program +you are editing is the one Python is trying to run. + +If you are not sure, try putting an obvious and deliberate syntax error +at the beginning of the program. Now run it again. If the interpreter +doesn’t find the new error, you are not running the new code. + +There are a few likely culprits: + +- You edited the file and forgot to save the changes before running it + again. Some programming environments do this for you, but some don’t. + +- You changed the name of the file, but you are still running the old + name. + +- Something in your development environment is configured incorrectly. + +- If you are writing a module and using import, make sure you don’t + give your module the same name as one of the standard Python modules. + +- If you are using import to read a module, remember that you have to + restart the interpreter or use reload to read a modified file. If you + import the module again, it doesn’t do anything. + +If you get stuck and you can’t figure out what is going on, one approach +is to start again with a new program like “Hello, World!”, and make sure +you can get a known program to run. Then gradually add the pieces of the +original program to the new one. + +Runtime errors +-------------- + +Once your program is syntactically correct, Python can read it and at +least start running it. What could possibly go wrong? + +My program does absolutely nothing. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This problem is most common when your file consists of functions and +classes but does not actually invoke a function to start execution. This +may be intentional if you only plan to import this module to supply +classes and functions. + +If it is not intentional, make sure there is a function call in the +program, and make sure the flow of execution reaches it (see “Flow of +Execution” below). + +My program hangs. +~~~~~~~~~~~~~~~~~ + +If a program stops and seems to be doing nothing, it is “hanging”. Often +that means that it is caught in an infinite loop or infinite recursion. + +- If there is a particular loop that you suspect is the problem, add a + print statement immediately before the loop that says “entering the + loop” and another immediately after that says “exiting the loop”. + + Run the program. If you get the first message and not the second, + you’ve got an infinite loop. Go to the “Infinite Loop” section below. + +- Most of the time, an infinite recursion will cause the program to run + for a while and then produce a “RuntimeError: Maximum recursion depth + exceeded” error. If that happens, go to the “Infinite Recursion” + section below. + + If you are not getting this error but you suspect there is a problem + with a recursive method or function, you can still use the techniques + in the “Infinite Recursion” section. + +- If neither of those steps works, start testing other loops and other + recursive functions and methods. + +- If that doesn’t work, then it is possible that you don’t understand + the flow of execution in your program. Go to the “Flow of Execution” + section below. + +Infinite Loop +^^^^^^^^^^^^^ + +If you think you have an infinite loop and you think you know what loop +is causing the problem, add a print statement at the end of the loop +that prints the values of the variables in the condition and the value +of the condition. + +For example: + +:: + + while x > 0 and y < 0 : + # do something to x + # do something to y + + print('x: ', x) + print('y: ', y) + print("condition: ", (x > 0 and y < 0)) + +Now when you run the program, you will see three lines of output for +each time through the loop. The last time through the loop, the +condition should be False. If the loop keeps going, you will be able to +see the values of x and y, and you might figure out why they are not +being updated correctly. + +Infinite Recursion +^^^^^^^^^^^^^^^^^^ + +Most of the time, infinite recursion causes the program to run for a +while and then produce a Maximum recursion depth exceeded error. + +If you suspect that a function is causing an infinite recursion, make +sure that there is a base case. There should be some condition that +causes the function to return without making a recursive invocation. If +not, you need to rethink the algorithm and identify a base case. + +If there is a base case but the program doesn’t seem to be reaching it, +add a print statement at the beginning of the function that prints the +parameters. Now when you run the program, you will see a few lines of +output every time the function is invoked, and you will see the +parameter values. If the parameters are not moving toward the base case, +you will get some ideas about why not. + +Flow of Execution +^^^^^^^^^^^^^^^^^ + +If you are not sure how the flow of execution is moving through your +program, add print statements to the beginning of each function with a +message like “entering function foo”, where foo is the name of the +function. + +Now when you run the program, it will print a trace of each function as +it is invoked. + +When I run the program I get an exception. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If something goes wrong during runtime, Python prints a message that +includes the name of the exception, the line of the program where the +problem occurred, and a traceback. + +The traceback identifies the function that is currently running, and +then the function that called it, and then the function that called +*that*, and so on. In other words, it traces the sequence of function +calls that got you to where you are, including the line number in your +file where each call occurred. + +The first step is to examine the place in the program where the error +occurred and see if you can figure out what happened. These are some of +the most common runtime errors: + +NameError: + You are trying to use a variable that doesn’t exist in the current + environment. Check if the name is spelled right, or at least + consistently. And remember that local variables are local; you + cannot refer to them from outside the function where they are + defined. + +TypeError: + There are several possible causes: + + - You are trying to use a value improperly. Example: indexing a + string, list, or tuple with something other than an integer. + + - There is a mismatch between the items in a format string and the + items passed for conversion. This can happen if either the number + of items does not match or an invalid conversion is called for. + + - You are passing the wrong number of arguments to a function. For + methods, look at the method definition and check that the first + parameter is self. Then look at the method invocation; make sure + you are invoking the method on an object with the right type and + providing the other arguments correctly. + +KeyError: + You are trying to access an element of a dictionary using a key that + the dictionary does not contain. If the keys are strings, remember + that capitalization matters. + +AttributeError: + You are trying to access an attribute or method that does not exist. + Check the spelling! You can use the built-in function vars to list + the attributes that do exist. + + If an AttributeError indicates that an object has NoneType, that + means that it is None. So the problem is not the attribute name, but + the object. + + The reason the object is none might be that you forgot to return a + value from a function; if you get to the end of a function without + hitting a return statement, it returns None. Another common cause is + using the result from a list method, like sort, that returns None. + +IndexError: + The index you are using to access a list, string, or tuple is + greater than its length minus one. Immediately before the site of + the error, add a print statement to display the value of the index + and the length of the array. Is the array the right size? Is the + index the right value? + +The Python debugger (pdb) is useful for tracking down exceptions because +it allows you to examine the state of the program immediately before the +error. You can read about pdb at +https://docs.python.org/3/library/pdb.html. + +I added so many print statements I get inundated with output. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +One of the problems with using print statements for debugging is that +you can end up buried in output. There are two ways to proceed: simplify +the output or simplify the program. + +To simplify the output, you can remove or comment out print statements +that aren’t helping, or combine them, or format the output so it is +easier to understand. + +To simplify the program, there are several things you can do. First, +scale down the problem the program is working on. For example, if you +are searching a list, search a *small* list. If the program takes input +from the user, give it the simplest input that causes the problem. + +Second, clean up the program. Remove dead code and reorganize the +program to make it as easy to read as possible. For example, if you +suspect that the problem is in a deeply nested part of the program, try +rewriting that part with simpler structure. If you suspect a large +function, try splitting it into smaller functions and testing them +separately. + +Often the process of finding the minimal test case leads you to the bug. +If you find that a program works in one situation but not in another, +that gives you a clue about what is going on. + +Similarly, rewriting a piece of code can help you find subtle bugs. If +you make a change that you think shouldn’t affect the program, and it +does, that can tip you off. + +Semantic errors +--------------- + +In some ways, semantic errors are the hardest to debug, because the +interpreter provides no information about what is wrong. Only you know +what the program is supposed to do. + +The first step is to make a connection between the program text and the +behavior you are seeing. You need a hypothesis about what the program is +actually doing. One of the things that makes that hard is that computers +run so fast. + +You will often wish that you could slow the program down to human speed, +and with some debuggers you can. But the time it takes to insert a few +well-placed print statements is often short compared to setting up the +debugger, inserting and removing breakpoints, and “stepping” the program +to where the error is occurring. + +My program doesn’t work. +~~~~~~~~~~~~~~~~~~~~~~~~ + +You should ask yourself these questions: + +- Is there something the program was supposed to do but which doesn’t + seem to be happening? Find the section of the code that performs that + function and make sure it is executing when you think it should. + +- Is something happening that shouldn’t? Find code in your program that + performs that function and see if it is executing when it shouldn’t. + +- Is a section of code producing an effect that is not what you + expected? Make sure that you understand the code in question, + especially if it involves functions or methods in other Python + modules. Read the documentation for the functions you call. Try them + out by writing simple test cases and checking the results. + +In order to program, you need a mental model of how programs work. If +you write a program that doesn’t do what you expect, often the problem +is not in the program; it’s in your mental model. + +The best way to correct your mental model is to break the program into +its components (usually the functions and methods) and test each +component independently. Once you find the discrepancy between your +model and reality, you can solve the problem. + +Of course, you should be building and testing components as you develop +the program. If you encounter a problem, there should be only a small +amount of new code that is not known to be correct. + +I’ve got a big hairy expression and it doesn’t do what I expect. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Writing complex expressions is fine as long as they are readable, but +they can be hard to debug. It is often a good idea to break a complex +expression into a series of assignments to temporary variables. + +For example: + +:: + + self.hands[i].addCard(self.hands[self.findNeighbor(i)].popCard()) + +This can be rewritten as: + +:: + + neighbor = self.findNeighbor(i) + pickedCard = self.hands[neighbor].popCard() + self.hands[i].addCard(pickedCard) + +The explicit version is easier to read because the variable names +provide additional documentation, and it is easier to debug because you +can check the types of the intermediate variables and display their +values. + +Another problem that can occur with big expressions is that the order of +evaluation may not be what you expect. For example, if you are +translating the expression :math:`\frac{x}{2 \pi}` into Python, you +might write: + +:: + + y = x / 2 * math.pi + +That is not correct because multiplication and division have the same +precedence and are evaluated from left to right. So this expression +computes :math:`x \pi / 2`. + +A good way to debug expressions is to add parentheses to make the order +of evaluation explicit: + +:: + + y = x / (2 * math.pi) + +Whenever you are not sure of the order of evaluation, use parentheses. +Not only will the program be correct (in the sense of doing what you +intended), it will also be more readable for other people who haven’t +memorized the order of operations. + +I’ve got a function that doesn’t return what I expect. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you have a return statement with a complex expression, you don’t have +a chance to print the result before returning. Again, you can use a +temporary variable. For example, instead of: + +:: + + return self.hands[i].removeMatches() + +you could write: + +:: + + count = self.hands[i].removeMatches() + return count + +Now you have the opportunity to display the value of count before +returning. + +I’m really, really stuck and I need help. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +First, try getting away from the computer for a few minutes. Computers +emit waves that affect the brain, causing these symptoms: + +- Frustration and rage. + +- Superstitious beliefs (“the computer hates me”) and magical thinking + (“the program only works when I wear my hat backward”). + +- Random walk programming (the attempt to program by writing every + possible program and choosing the one that does the right thing). + +If you find yourself suffering from any of these symptoms, get up and go +for a walk. When you are calm, think about the program. What is it +doing? What are some possible causes of that behavior? When was the last +time you had a working program, and what did you do next? + +Sometimes it just takes time to find a bug. I often find bugs when I am +away from the computer and let my mind wander. Some of the best places +to find bugs are trains, showers, and in bed, just before you fall +asleep. + +No, I really need help. +~~~~~~~~~~~~~~~~~~~~~~~ + +It happens. Even the best programmers occasionally get stuck. Sometimes +you work on a program so long that you can’t see the error. You need a +fresh pair of eyes. + +Before you bring someone else in, make sure you are prepared. Your +program should be as simple as possible, and you should be working on +the smallest input that causes the error. You should have print +statements in the appropriate places (and the output they produce should +be comprehensible). You should understand the problem well enough to +describe it concisely. + +When you bring someone in to help, be sure to give them the information +they need: + +- If there is an error message, what is it and what part of the program + does it indicate? + +- What was the last thing you did before this error occurred? What were + the last lines of code that you wrote, or what is the new test case + that fails? + +- What have you tried so far, and what have you learned? + +When you find the bug, take a second to think about what you could have +done to find it faster. Next time you see something similar, you will be +able to find the bug more quickly. + +Remember, the goal is not just to make the program work. The goal is to +learn how to make the program work. + +Analysis of Algorithms +====================== + + This appendix is an edited excerpt from *Think Complexity*, by Allen + B. Downey, also published by O’Reilly Media (2012). When you are + done with this book, you might want to move on to that one. + +**Analysis of algorithms** is a branch of computer science that studies +the performance of algorithms, especially their run time and space +requirements. See http://en.wikipedia.org/wiki/Analysis_of_algorithms. + +The practical goal of algorithm analysis is to predict the performance +of different algorithms in order to guide design decisions. + +During the 2008 United States Presidential Campaign, candidate Barack +Obama was asked to perform an impromptu analysis when he visited Google. +Chief executive Eric Schmidt jokingly asked him for “the most efficient +way to sort a million 32-bit integers.” Obama had apparently been tipped +off, because he quickly replied, “I think the bubble sort would be the +wrong way to go.” See http://www.youtube.com/watch?v=k4RRi_ntQc8. + +This is true: bubble sort is conceptually simple but slow for large +datasets. The answer Schmidt was probably looking for is “radix sort” +(http://en.wikipedia.org/wiki/Radix_sort) [2]_. + +The goal of algorithm analysis is to make meaningful comparisons between +algorithms, but there are some problems: + +- The relative performance of the algorithms might depend on + characteristics of the hardware, so one algorithm might be faster on + Machine A, another on Machine B. The general solution to this problem + is to specify a **machine model** and analyze the number of steps, or + operations, an algorithm requires under a given model. + +- Relative performance might depend on the details of the dataset. For + example, some sorting algorithms run faster if the data are already + partially sorted; other algorithms run slower in this case. A common + way to avoid this problem is to analyze the **worst case** scenario. + It is sometimes useful to analyze average case performance, but + that’s usually harder, and it might not be obvious what set of cases + to average over. + +- Relative performance also depends on the size of the problem. A + sorting algorithm that is fast for small lists might be slow for long + lists. The usual solution to this problem is to express run time (or + number of operations) as a function of problem size, and group + functions into categories depending on how quickly they grow as + problem size increases. + +The good thing about this kind of comparison is that it lends itself to +simple classification of algorithms. For example, if I know that the run +time of Algorithm A tends to be proportional to the size of the input, +:math:`n`, and Algorithm B tends to be proportional to :math:`n^2`, then +I expect A to be faster than B, at least for large values of :math:`n`. + +This kind of analysis comes with some caveats, but we’ll get to that +later. + +Order of growth +--------------- + +Suppose you have analyzed two algorithms and expressed their run times +in terms of the size of the input: Algorithm A takes :math:`100n+1` +steps to solve a problem with size :math:`n`; Algorithm B takes +:math:`n^2 + n + 1` steps. + +The following table shows the run time of these algorithms for different +problem sizes: + ++----------+---------------+---------------------+ +| Input | Run time of | Run time of | ++----------+---------------+---------------------+ +| size | Algorithm A | Algorithm B | ++----------+---------------+---------------------+ +| 10 | 1 001 | 111 | ++----------+---------------+---------------------+ +| 100 | 10 001 | 10 101 | ++----------+---------------+---------------------+ +| 1 000 | 100 001 | 1 001 001 | ++----------+---------------+---------------------+ +| 10 000 | 1 000 001 | :math:`> 10^{10}` | ++----------+---------------+---------------------+ + +At :math:`n=10`, Algorithm A looks pretty bad; it takes almost 10 times +longer than Algorithm B. But for :math:`n=100` they are about the same, +and for larger values A is much better. + +The fundamental reason is that for large values of :math:`n`, any +function that contains an :math:`n^2` term will grow faster than a +function whose leading term is :math:`n`. The **leading term** is the +term with the highest exponent. + +For Algorithm A, the leading term has a large coefficient, 100, which is +why B does better than A for small :math:`n`. But regardless of the +coefficients, there will always be some value of :math:`n` where +:math:`a n^2 > b n`, for any values of :math:`a` and :math:`b`. + +The same argument applies to the non-leading terms. Even if the run time +of Algorithm A were :math:`n+1000000`, it would still be better than +Algorithm B for sufficiently large :math:`n`. + +In general, we expect an algorithm with a smaller leading term to be a +better algorithm for large problems, but for smaller problems, there may +be a **crossover point** where another algorithm is better. The location +of the crossover point depends on the details of the algorithms, the +inputs, and the hardware, so it is usually ignored for purposes of +algorithmic analysis. But that doesn’t mean you can forget about it. + +If two algorithms have the same leading order term, it is hard to say +which is better; again, the answer depends on the details. So for +algorithmic analysis, functions with the same leading term are +considered equivalent, even if they have different coefficients. + +An **order of growth** is a set of functions whose growth behavior is +considered equivalent. For example, :math:`2n`, :math:`100n` and +:math:`n+1` belong to the same order of growth, which is written +:math:`O(n)` in **Big-Oh notation** and often called **linear** because +every function in the set grows linearly with :math:`n`. + +All functions with the leading term :math:`n^2` belong to +:math:`O(n^2)`; they are called **quadratic**. + +The following table shows some of the orders of growth that appear most +commonly in algorithmic analysis, in increasing order of badness. + ++-------------------------+-----------------------------------+----+ +| Order of | Name | | ++-------------------------+-----------------------------------+----+ +| growth | | | ++-------------------------+-----------------------------------+----+ +| :math:`O(1)` | constant | | ++-------------------------+-----------------------------------+----+ +| :math:`O(\log_b n)` | logarithmic (for any :math:`b`) | | ++-------------------------+-----------------------------------+----+ +| :math:`O(n)` | linear | | ++-------------------------+-----------------------------------+----+ +| :math:`O(n \log_b n)` | linearithmic | | ++-------------------------+-----------------------------------+----+ +| :math:`O(n^2)` | quadratic | | ++-------------------------+-----------------------------------+----+ +| :math:`O(n^3)` | cubic | | ++-------------------------+-----------------------------------+----+ +| :math:`O(c^n)` | exponential (for any :math:`c`) | | ++-------------------------+-----------------------------------+----+ + +For the logarithmic terms, the base of the logarithm doesn’t matter; +changing bases is the equivalent of multiplying by a constant, which +doesn’t change the order of growth. Similarly, all exponential functions +belong to the same order of growth regardless of the base of the +exponent. Exponential functions grow very quickly, so exponential +algorithms are only useful for small problems. + +Read the Wikipedia page on Big-Oh notation at +http://en.wikipedia.org/wiki/Big_O_notation and answer the following +questions: + +#. What is the order of growth of :math:`n^3 + n^2`? What about + :math:`1000000 n^3 + n^2`? What about :math:`n^3 + 1000000 n^2`? + +#. What is the order of growth of :math:`(n^2 + n) \cdot (n + 1)`? + Before you start multiplying, remember that you only need the leading + term. + +#. If :math:`f` is in :math:`O(g)`, for some unspecified function + :math:`g`, what can we say about :math:`af+b`? + +#. If :math:`f_1` and :math:`f_2` are in :math:`O(g)`, what can we say + about :math:`f_1 + f_2`? + +#. If :math:`f_1` is in :math:`O(g)` and :math:`f_2` is in :math:`O(h)`, + what can we say about :math:`f_1 + f_2`? + +#. If :math:`f_1` is in :math:`O(g)` and :math:`f_2` is :math:`O(h)`, + what can we say about :math:`f_1 \cdot f_2`? + +Programmers who care about performance often find this kind of analysis +hard to swallow. They have a point: sometimes the coefficients and the +non-leading terms make a real difference. Sometimes the details of the +hardware, the programming language, and the characteristics of the input +make a big difference. And for small problems asymptotic behavior is +irrelevant. + +But if you keep those caveats in mind, algorithmic analysis is a useful +tool. At least for large problems, the “better” algorithms is usually +better, and sometimes it is *much* better. The difference between two +algorithms with the same order of growth is usually a constant factor, +but the difference between a good algorithm and a bad algorithm is +unbounded! + +Analysis of basic Python operations +----------------------------------- + +In Python, most arithmetic operations are constant time; multiplication +usually takes longer than addition and subtraction, and division takes +even longer, but these run times don’t depend on the magnitude of the +operands. Very large integers are an exception; in that case the run +time increases with the number of digits. + +Indexing operations—reading or writing elements in a sequence or +dictionary—are also constant time, regardless of the size of the data +structure. + +A for loop that traverses a sequence or dictionary is usually linear, as +long as all of the operations in the body of the loop are constant time. +For example, adding up the elements of a list is linear: + +:: + + total = 0 + for x in t: + total += x + +The built-in function sum is also linear because it does the same thing, +but it tends to be faster because it is a more efficient implementation; +in the language of algorithmic analysis, it has a smaller leading +coefficient. + +As a rule of thumb, if the body of a loop is in :math:`O(n^a)` then the +whole loop is in :math:`O(n^{a+1})`. The exception is if you can show +that the loop exits after a constant number of iterations. If a loop +runs :math:`k` times regardless of :math:`n`, then the loop is in +:math:`O(n^a)`, even for large :math:`k`. + +Multiplying by :math:`k` doesn’t change the order of growth, but neither +does dividing. So if the body of a loop is in :math:`O(n^a)` and it runs +:math:`n/k` times, the loop is in :math:`O(n^{a+1})`, even for large +:math:`k`. + +Most string and tuple operations are linear, except indexing and len, +which are constant time. The built-in functions min and max are linear. +The run-time of a slice operation is proportional to the length of the +output, but independent of the size of the input. + +String concatenation is linear; the run time depends on the sum of the +lengths of the operands. + +All string methods are linear, but if the lengths of the strings are +bounded by a constant—for example, operations on single characters—they +are considered constant time. The string method join is linear; the run +time depends on the total length of the strings. + +Most list methods are linear, but there are some exceptions: + +- Adding an element to the end of a list is constant time on average; + when it runs out of room it occasionally gets copied to a bigger + location, but the total time for :math:`n` operations is + :math:`O(n)`, so the average time for each operation is :math:`O(1)`. + +- Removing an element from the end of a list is constant time. + +- Sorting is :math:`O(n \log n)`. + +Most dictionary operations and methods are constant time, but there are +some exceptions: + +- The run time of update is proportional to the size of the dictionary + passed as a parameter, not the dictionary being updated. + +- keys, values and items are constant time because they return + iterators. But if you loop through the iterators, the loop will be + linear. + +The performance of dictionaries is one of the minor miracles of computer +science. We will see how they work in Section [hashtable]. + +Read the Wikipedia page on sorting algorithms at +http://en.wikipedia.org/wiki/Sorting_algorithm and answer the following +questions: + +#. What is a “comparison sort?” What is the best worst-case order of + growth for a comparison sort? What is the best worst-case order of + growth for any sort algorithm? + +#. What is the order of growth of bubble sort, and why does Barack Obama + think it is “the wrong way to go?” + +#. What is the order of growth of radix sort? What preconditions do we + need to use it? + +#. What is a stable sort and why might it matter in practice? + +#. What is the worst sorting algorithm (that has a name)? + +#. What sort algorithm does the C library use? What sort algorithm does + Python use? Are these algorithms stable? You might have to Google + around to find these answers. + +#. Many of the non-comparison sorts are linear, so why does does Python + use an :math:`O(n \log n)` comparison sort? + +Analysis of search algorithms +----------------------------- + +A **search** is an algorithm that takes a collection and a target item +and determines whether the target is in the collection, often returning +the index of the target. + +The simplest search algorithm is a “linear search”, which traverses the +items of the collection in order, stopping if it finds the target. In +the worst case it has to traverse the entire collection, so the run time +is linear. + +The in operator for sequences uses a linear search; so do string methods +like find and count. + +If the elements of the sequence are in order, you can use a **bisection +search**, which is :math:`O(\log n)`. Bisection search is similar to the +algorithm you might use to look a word up in a dictionary (a paper +dictionary, not the data structure). Instead of starting at the +beginning and checking each item in order, you start with the item in +the middle and check whether the word you are looking for comes before +or after. If it comes before, then you search the first half of the +sequence. Otherwise you search the second half. Either way, you cut the +number of remaining items in half. + +If the sequence has 1,000,000 items, it will take about 20 steps to find +the word or conclude that it’s not there. So that’s about 50,000 times +faster than a linear search. + +Bisection search can be much faster than linear search, but it requires +the sequence to be in order, which might require extra work. + +There is another data structure, called a **hashtable** that is even +faster—it can do a search in constant time—and it doesn’t require the +items to be sorted. Python dictionaries are implemented using +hashtables, which is why most dictionary operations, including the in +operator, are constant time. + +Hashtables +---------- + +To explain how hashtables work and why their performance is so good, I +start with a simple implementation of a map and gradually improve it +until it’s a hashtable. + +I use Python to demonstrate these implementations, but in real life you +wouldn’t write code like this in Python; you would just use a +dictionary! So for the rest of this chapter, you have to imagine that +dictionaries don’t exist and you want to implement a data structure that +maps from keys to values. The operations you have to implement are: + +add(k, v): + Add a new item that maps from key k to value v. With a Python + dictionary, d, this operation is written d[k] = v. + +get(k): + Look up and return the value that corresponds to key k. With a + Python dictionary, d, this operation is written d[k] or d.get(k). + +For now, I assume that each key only appears once. The simplest +implementation of this interface uses a list of tuples, where each tuple +is a key-value pair. + +:: + + class LinearMap: + + def __init__(self): + self.items = [] + + def add(self, k, v): + self.items.append((k, v)) + + def get(self, k): + for key, val in self.items: + if key == k: + return val + raise KeyError + +add appends a key-value tuple to the list of items, which takes constant +time. + +get uses a for loop to search the list: if it finds the target key it +returns the corresponding value; otherwise it raises a KeyError. So get +is linear. + +An alternative is to keep the list sorted by key. Then get could use a +bisection search, which is :math:`O(\log n)`. But inserting a new item +in the middle of a list is linear, so this might not be the best option. +There are other data structures that can implement add and get in log +time, but that’s still not as good as constant time, so let’s move on. + +One way to improve LinearMap is to break the list of key-value pairs +into smaller lists. Here’s an implementation called BetterMap, which is +a list of 100 LinearMaps. As we’ll see in a second, the order of growth +for get is still linear, but BetterMap is a step on the path toward +hashtables: + +:: + + class BetterMap: + + def __init__(self, n=100): + self.maps = [] + for i in range(n): + self.maps.append(LinearMap()) + + def find_map(self, k): + index = hash(k) % len(self.maps) + return self.maps[index] + + def add(self, k, v): + m = self.find_map(k) + m.add(k, v) + + def get(self, k): + m = self.find_map(k) + return m.get(k) + +``__init__`` makes a list of n LinearMaps. + +``find_map`` is used by add and get to figure out which map to put the +new item in, or which map to search. + +``find_map`` uses the built-in function hash, which takes almost any +Python object and returns an integer. A limitation of this +implementation is that it only works with hashable keys. Mutable types +like lists and dictionaries are unhashable. + +Hashable objects that are considered equivalent return the same hash +value, but the converse is not necessarily true: two objects with +different values can return the same hash value. + +``find_map`` uses the modulus operator to wrap the hash values into the +range from 0 to len(self.maps), so the result is a legal index into the +list. Of course, this means that many different hash values will wrap +onto the same index. But if the hash function spreads things out pretty +evenly (which is what hash functions are designed to do), then we expect +:math:`n/100` items per LinearMap. + +Since the run time of LinearMap.get is proportional to the number of +items, we expect BetterMap to be about 100 times faster than LinearMap. +The order of growth is still linear, but the leading coefficient is +smaller. That’s nice, but still not as good as a hashtable. + +Here (finally) is the crucial idea that makes hashtables fast: if you +can keep the maximum length of the LinearMaps bounded, LinearMap.get is +constant time. All you have to do is keep track of the number of items +and when the number of items per LinearMap exceeds a threshold, resize +the hashtable by adding more LinearMaps. + +Here is an implementation of a hashtable: + +:: + + class HashMap: + + def __init__(self): + self.maps = BetterMap(2) + self.num = 0 + + def get(self, k): + return self.maps.get(k) + + def add(self, k, v): + if self.num == len(self.maps.maps): + self.resize() + + self.maps.add(k, v) + self.num += 1 + + def resize(self): + new_maps = BetterMap(self.num * 2) + + for m in self.maps.maps: + for k, v in m.items: + new_maps.add(k, v) + + self.maps = new_maps + +Each HashMap contains a BetterMap; ``__init__`` starts with just 2 +LinearMaps and initializes num, which keeps track of the number of +items. + +get just dispatches to BetterMap. The real work happens in add, which +checks the number of items and the size of the BetterMap: if they are +equal, the average number of items per LinearMap is 1, so it calls +resize. + +resize make a new BetterMap, twice as big as the previous one, and then +“rehashes” the items from the old map to the new. + +Rehashing is necessary because changing the number of LinearMaps changes +the denominator of the modulus operator in ``find_map``. That means that +some objects that used to hash into the same LinearMap will get split up +(which is what we wanted, right?). + +Rehashing is linear, so resize is linear, which might seem bad, since I +promised that add would be constant time. But remember that we don’t +have to resize every time, so add is usually constant time and only +occasionally linear. The total amount of work to run add :math:`n` times +is proportional to :math:`n`, so the average time of each add is +constant time! + +To see how this works, think about starting with an empty HashTable and +adding a sequence of items. We start with 2 LinearMaps, so the first 2 +adds are fast (no resizing required). Let’s say that they take one unit +of work each. The next add requires a resize, so we have to rehash the +first two items (let’s call that 2 more units of work) and then add the +third item (one more unit). Adding the next item costs 1 unit, so the +total so far is 6 units of work for 4 items. + +The next add costs 5 units, but the next three are only one unit each, +so the total is 14 units for the first 8 adds. + +The next add costs 9 units, but then we can add 7 more before the next +resize, so the total is 30 units for the first 16 adds. + +After 32 adds, the total cost is 62 units, and I hope you are starting +to see a pattern. After :math:`n` adds, where :math:`n` is a power of +two, the total cost is :math:`2n-2` units, so the average work per add +is a little less than 2 units. When :math:`n` is a power of two, that’s +the best case; for other values of :math:`n` the average work is a +little higher, but that’s not important. The important thing is that it +is :math:`O(1)`. + +Figure [fig.hash] shows how this works graphically. Each block +represents a unit of work. The columns show the total work for each add +in order from left to right: the first two adds cost 1 units, the third +costs 3 units, etc. + +.. figure:: figs/towers.pdf + :alt: The cost of a hashtable add.[fig.hash] + + The cost of a hashtable add.[fig.hash] + +The extra work of rehashing appears as a sequence of increasingly tall +towers with increasing space between them. Now if you knock over the +towers, spreading the cost of resizing over all adds, you can see +graphically that the total cost after :math:`n` adds is :math:`2n - 2`. + +An important feature of this algorithm is that when we resize the +HashTable it grows geometrically; that is, we multiply the size by a +constant. If you increase the size arithmetically—adding a fixed number +each time—the average time per add is linear. + +You can download my implementation of HashMap from +http://thinkpython2.com/code/Map.py, but remember that there is no +reason to use it; if you want a map, just use a Python dictionary. + +Glossary +-------- + +analysis of algorithms: + A way to compare algorithms in terms of their run time and/or space + requirements. + +machine model: + A simplified representation of a computer used to describe + algorithms. + +worst case: + The input that makes a given algorithm run slowest (or require the + most space. + +leading term: + In a polynomial, the term with the highest exponent. + +crossover point: + The problem size where two algorithms require the same run time or + space. + +order of growth: + A set of functions that all grow in a way considered equivalent for + purposes of analysis of algorithms. For example, all functions that + grow linearly belong to the same order of growth. + +Big-Oh notation: + Notation for representing an order of growth; for example, + :math:`O(n)` represents the set of functions that grow linearly. + +linear: + An algorithm whose run time is proportional to problem size, at + least for large problem sizes. + +quadratic: + An algorithm whose run time is proportional to :math:`n^2`, where + :math:`n` is a measure of problem size. + +search: + The problem of locating an element of a collection (like a list or + dictionary) or determining that it is not present. + +hashtable: + A data structure that represents a collection of key-value pairs and + performs search in constant time. + +.. [1] + popen is deprecated now, which means we are supposed to stop using it + and start using the subprocess module. But for simple cases, I find + subprocess more complicated than necessary. So I am going to keep + using popen until they take it away. + +.. [2] + But if you get a question like this in an interview, I think a better + answer is, “The fastest way to sort a million integers is to use + whatever sort function is provided by the language I’m using. Its + performance is good enough for the vast majority of applications, but + if it turned out that my application was too slow, I would use a + profiler to see where the time was being spent. If it looked like a + faster sort algorithm would have a significant effect on performance, + then I would look around for a good implementation of radix sort.” diff --git a/book/book.tex b/attic/latex/book.tex similarity index 100% rename from book/book.tex rename to attic/latex/book.tex diff --git a/attic/latex/figs/assign2.eps b/attic/latex/figs/assign2.eps new file mode 100644 index 0000000..e0d56f6 --- /dev/null +++ b/attic/latex/figs/assign2.eps @@ -0,0 +1,141 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: assign2.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5d +%%CreationDate: Mon Oct 19 10:19:36 2015 +%%BoundingBox: 0 0 60 42 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 42 moveto 0 0 lineto 60 0 lineto 60 42 lineto closepath clip newpath +-147.8 99.7 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 2475 975 m 3450 975 l 3450 1650 l 2475 1650 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2995 1451 m 3139 1500 l 3158 1443 l 3015 1394 l 3015 1394 l 3119 1462 l 2995 1451 l cp +eoclip +n 2760 1339 m + 3135 1467 l gs col0 s gr gr + +% arrowhead +n 2995 1451 m 3119 1462 l 3015 1394 l col0 s +% Polyline + [15 45] 45 sd +n 2766 1271 m + 3141 1174 l gs col0 s gr [] 0 sd +% Polyline +n 3075 1080 m + 3300 1230 l gs col0 s gr +% Polyline +n 3300 1080 m + 3075 1230 l gs col0 s gr +/Helvetica ff 183.33 scf sf +3150 1530 m +gs 1 -1 sc (7) col0 sh gr +/Helvetica ff 183.33 scf sf +3150 1230 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 183.33 scf sf +2730 1340 m +gs 1 -1 sc (x) dup sw pop neg 0 rm col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/assign2.fig b/attic/latex/figs/assign2.fig new file mode 100644 index 0000000..b239db3 --- /dev/null +++ b/attic/latex/figs/assign2.fig @@ -0,0 +1,23 @@ +#FIG 3.2 Produced by xfig version 3.2.5b +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2760 1339 3135 1467 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 2766 1271 3141 1174 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 + 3075 1080 3300 1230 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 + 3300 1080 3075 1230 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 2475 975 3450 975 3450 1650 2475 1650 2475 975 +4 0 0 50 0 16 11 0.0000 4 120 105 3150 1530 7\001 +4 0 0 50 0 16 11 0.0000 4 120 105 3150 1230 5\001 +4 2 0 50 0 16 11 0.0000 4 90 90 2730 1340 x\001 diff --git a/attic/latex/figs/assign2.fig.bak b/attic/latex/figs/assign2.fig.bak new file mode 100644 index 0000000..df54f87 --- /dev/null +++ b/attic/latex/figs/assign2.fig.bak @@ -0,0 +1,25 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 2325 1080 3300 1530 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2760 1339 3135 1467 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 2766 1271 3141 1174 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 + 3075 1080 3300 1230 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 + 3300 1080 3075 1230 +4 0 0 50 0 16 11 0.0000 4 120 90 3150 1530 7\001 +4 0 0 50 0 16 11 0.0000 4 120 90 3150 1230 5\001 +4 2 0 50 0 16 11 0.0000 4 120 375 2730 1340 bruce\001 +-6 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 2175 975 3450 975 3450 1650 2175 1650 2175 975 diff --git a/attic/latex/figs/assign2.pdf b/attic/latex/figs/assign2.pdf new file mode 100644 index 0000000..a57a3ac Binary files /dev/null and b/attic/latex/figs/assign2.pdf differ diff --git a/attic/latex/figs/banana.eps b/attic/latex/figs/banana.eps new file mode 100644 index 0000000..653aa97 --- /dev/null +++ b/attic/latex/figs/banana.eps @@ -0,0 +1,194 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: banana.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5-alpha7 +%%CreationDate: Thu Jan 3 09:25:45 2008 +%%For: downey@rocky (Allen Downey,,,) +%%BoundingBox: 0 0 195 52 +%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 52 moveto 0 0 lineto 195 0 lineto 195 52 lineto closepath clip newpath +-93.8 99.9 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 1575 825 m 4800 825 l 4800 1350 l 1575 1350 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2338 1110 m 2490 1110 l 2490 1050 l 2338 1050 l 2338 1050 l 2458 1080 l 2338 1110 l cp +eoclip +n 2100 1080 m + 2475 1080 l gs col0 s gr gr + +% arrowhead +n 2338 1110 m 2458 1080 l 2338 1050 l col0 s +% Polyline + [15 45] 45 sd +n 2700 825 m + 2700 1500 l gs col0 s gr [] 0 sd +% Polyline + [15 45] 45 sd +n 3000 825 m + 3000 1500 l gs col0 s gr [] 0 sd +% Polyline + [15 45] 45 sd +n 3300 825 m + 3300 1500 l gs col0 s gr [] 0 sd +% Polyline + [15 45] 45 sd +n 3600 825 m + 3600 1500 l gs col0 s gr [] 0 sd +% Polyline + [15 45] 45 sd +n 3900 825 m + 3900 1500 l gs col0 s gr [] 0 sd +% Polyline + [15 45] 45 sd +n 4200 825 m + 4200 1500 l gs col0 s gr [] 0 sd +% Polyline + [15 45] 45 sd +n 4500 825 m + 4500 1500 l gs col0 s gr [] 0 sd +/Helvetica ff 183.33 scf sf +2025 1125 m +gs 1 -1 sc (fruit) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 366.67 scf sf +2775 1200 m +gs 1 -1 sc (b) col0 sh gr +/Helvetica ff 366.67 scf sf +3075 1200 m +gs 1 -1 sc (a) col0 sh gr +/Helvetica ff 366.67 scf sf +3375 1200 m +gs 1 -1 sc (n) col0 sh gr +/Helvetica ff 366.67 scf sf +3975 1200 m +gs 1 -1 sc (n) col0 sh gr +/Helvetica ff 366.67 scf sf +3675 1200 m +gs 1 -1 sc (a) col0 sh gr +/Helvetica ff 366.67 scf sf +4275 1200 m +gs 1 -1 sc (a) col0 sh gr +/Helvetica ff 366.67 scf sf +4575 1200 m +gs 1 -1 sc (') col0 sh gr +/Helvetica ff 183.33 scf sf +2625 1650 m +gs 1 -1 sc (0) col0 sh gr +/Helvetica ff 183.33 scf sf +2925 1650 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 183.33 scf sf +3225 1650 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 183.33 scf sf +3525 1650 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 183.33 scf sf +3825 1650 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 183.33 scf sf +4125 1650 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 183.33 scf sf +4425 1650 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1650 m +gs 1 -1 sc (index) col0 sh gr +/Helvetica ff 366.67 scf sf +2550 1200 m +gs 1 -1 sc (') col0 sh gr +% here ends figure; +$F2psEnd +rs +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/banana.fig b/attic/latex/figs/banana.fig new file mode 100644 index 0000000..f6fc430 --- /dev/null +++ b/attic/latex/figs/banana.fig @@ -0,0 +1,45 @@ +#FIG 3.2 Produced by xfig version 3.2.5-alpha5 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1080 2475 1080 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 2700 825 2700 1500 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 3000 825 3000 1500 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 3300 825 3300 1500 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 3600 825 3600 1500 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 3900 825 3900 1500 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 4200 825 4200 1500 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 4500 825 4500 1500 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1575 825 4800 825 4800 1350 1575 1350 1575 825 +4 2 0 50 0 16 11 0.0000 4 135 300 2025 1125 fruit\001 +4 0 0 50 0 16 22 0.0000 4 285 210 2775 1200 b\001 +4 0 0 50 0 16 22 0.0000 4 210 195 3075 1200 a\001 +4 0 0 50 0 16 22 0.0000 4 210 210 3375 1200 n\001 +4 0 0 50 0 16 22 0.0000 4 210 210 3975 1200 n\001 +4 0 0 50 0 16 22 0.0000 4 210 195 3675 1200 a\001 +4 0 0 50 0 16 22 0.0000 4 210 195 4275 1200 a\001 +4 0 0 50 0 16 22 0.0000 4 90 90 4575 1200 '\001 +4 0 0 50 0 16 11 0.0000 4 135 105 2625 1650 0\001 +4 0 0 50 0 16 11 0.0000 4 135 105 2925 1650 1\001 +4 0 0 50 0 16 11 0.0000 4 135 105 3225 1650 2\001 +4 0 0 50 0 16 11 0.0000 4 135 105 3525 1650 3\001 +4 0 0 50 0 16 11 0.0000 4 135 105 3825 1650 4\001 +4 0 0 50 0 16 11 0.0000 4 135 105 4125 1650 5\001 +4 0 0 50 0 16 11 0.0000 4 135 105 4425 1650 6\001 +4 0 0 50 0 16 11 0.0000 4 135 450 2025 1650 index\001 +4 0 0 50 0 16 22 0.0000 4 90 90 2550 1200 '\001 diff --git a/attic/latex/figs/banana.pdf b/attic/latex/figs/banana.pdf new file mode 100644 index 0000000..70c6225 Binary files /dev/null and b/attic/latex/figs/banana.pdf differ diff --git a/attic/latex/figs/card1.eps b/attic/latex/figs/card1.eps new file mode 100644 index 0000000..62990d9 --- /dev/null +++ b/attic/latex/figs/card1.eps @@ -0,0 +1,213 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: card1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5 +%%CreationDate: Fri Jun 6 11:05:05 2008 +%%For: downey@rocky (Allen Downey,,,) +%%BoundingBox: 0 0 194 155 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 155 moveto 0 0 lineto 194 0 lineto 194 155 lineto closepath clip newpath +-19.0 203.2 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 3150 1050 m 3525 1050 l 3525 1425 l 3150 1425 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 3150 1800 m 3525 1800 l 3525 2175 l 3150 2175 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1200 1050 m 2850 1050 l 2850 2175 l 1200 2175 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1275 2700 m 2625 2700 l 2625 3375 l 1275 3375 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +1063 1230 m 1215 1230 l 1215 1170 l 1063 1170 l 1063 1170 l 1183 1200 l 1063 1230 l cp +eoclip +n 825 1200 m + 1200 1200 l gs col0 s gr gr + +% arrowhead +n 1063 1230 m 1183 1200 l 1063 1170 l col0 s +% Polyline +gs clippath +3013 1229 m 3165 1227 l 3164 1167 l 3012 1169 l 3012 1169 l 3133 1198 l 3013 1229 l cp +eoclip +n 2625 1205 m + 3150 1198 l gs col0 s gr gr + +% arrowhead +n 3013 1229 m 3133 1198 l 3012 1169 l col0 s +% Polyline +gs clippath +3013 1977 m 3165 1975 l 3164 1915 l 3012 1917 l 3012 1917 l 3133 1946 l 3013 1977 l cp +eoclip +n 2625 1953 m + 3150 1946 l gs col0 s gr gr + +% arrowhead +n 3013 1977 m 3133 1946 l 3012 1917 l col0 s +% Polyline +gs clippath +2038 3202 m 2190 3202 l 2190 3142 l 2038 3142 l 2038 3142 l 2158 3172 l 2038 3202 l cp +eoclip +n 1800 3172 m + 2175 3172 l gs col0 s gr gr + +% arrowhead +n 2038 3202 m 2158 3172 l 2038 3142 l col0 s +% Polyline +gs clippath +2038 2902 m 2190 2902 l 2190 2842 l 2038 2842 l 2038 2842 l 2158 2872 l 2038 2902 l cp +eoclip +n 1800 2872 m + 2175 2872 l gs col0 s gr gr + +% arrowhead +n 2038 2902 m 2158 2872 l 2038 2842 l col0 s +% Polyline +gs clippath +1138 2880 m 1290 2880 l 1290 2820 l 1138 2820 l 1138 2820 l 1258 2850 l 1138 2880 l cp +eoclip +n 900 2850 m + 1275 2850 l gs col0 s gr gr + +% arrowhead +n 1138 2880 m 1258 2850 l 1138 2820 l col0 s +/Helvetica ff 183.33 scf sf +3150 975 m +gs 1 -1 sc (list) col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1275 m +gs 1 -1 sc (suit_names) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +3150 1725 m +gs 1 -1 sc (list) col0 sh gr +/Helvetica ff 183.33 scf sf +2550 2025 m +gs 1 -1 sc (rank_names) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +750 1275 m +gs 1 -1 sc (Card) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1200 975 m +gs 1 -1 sc (type) col0 sh gr +/Helvetica ff 183.33 scf sf +2250 2925 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 183.33 scf sf +2250 3225 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 183.33 scf sf +1725 2925 m +gs 1 -1 sc (suit) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1725 3225 m +gs 1 -1 sc (rank) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +825 2925 m +gs 1 -1 sc (card1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1275 2625 m +gs 1 -1 sc (Card) col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/card1.fig b/attic/latex/figs/card1.fig new file mode 100644 index 0000000..514e2b0 --- /dev/null +++ b/attic/latex/figs/card1.fig @@ -0,0 +1,47 @@ +#FIG 3.2 Produced by xfig version 3.2.5 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 825 1200 1200 1200 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 3150 1050 3525 1050 3525 1425 3150 1425 3150 1050 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2625 1205 3150 1198 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 3150 1800 3525 1800 3525 2175 3150 2175 3150 1800 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2625 1953 3150 1946 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1200 1050 2850 1050 2850 2175 1200 2175 1200 1050 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1800 3172 2175 3172 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1800 2872 2175 2872 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1275 2700 2625 2700 2625 3375 1275 3375 1275 2700 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 900 2850 1275 2850 +4 0 0 50 0 16 11 0.0000 4 135 225 3150 975 list\001 +4 2 0 50 0 16 11 0.0000 4 165 930 2550 1275 suit_names\001 +4 0 0 50 0 16 11 0.0000 4 135 225 3150 1725 list\001 +4 2 0 50 0 16 11 0.0000 4 165 1005 2550 2025 rank_names\001 +4 2 0 50 0 16 11 0.0000 4 135 405 750 1275 Card\001 +4 0 0 50 0 16 11 0.0000 4 180 360 1200 975 type\001 +4 0 0 50 0 16 11 0.0000 4 135 105 2250 2925 1\001 +4 0 0 50 0 16 11 0.0000 4 135 210 2250 3225 11\001 +4 2 0 50 0 16 11 0.0000 4 135 285 1725 2925 suit\001 +4 2 0 50 0 16 11 0.0000 4 135 360 1725 3225 rank\001 +4 2 0 50 0 16 11 0.0000 4 135 480 825 2925 card1\001 +4 0 0 50 0 16 11 0.0000 4 135 405 1275 2625 Card\001 diff --git a/attic/latex/figs/card1.pdf b/attic/latex/figs/card1.pdf new file mode 100644 index 0000000..da70509 Binary files /dev/null and b/attic/latex/figs/card1.pdf differ diff --git a/attic/latex/figs/class1.eps b/attic/latex/figs/class1.eps new file mode 100644 index 0000000..0bd9600 --- /dev/null +++ b/attic/latex/figs/class1.eps @@ -0,0 +1,142 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: class1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5-alpha7 +%%CreationDate: Thu Aug 16 11:40:34 2007 +%%For: downey@rocky (Allen Downey,,,) +%%BoundingBox: 0 0 150 87 +%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 87 moveto 0 0 lineto 150 0 lineto 150 87 lineto closepath clip newpath +-156.8 149.2 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 2625 1050 m 3525 1050 l 3525 1500 l 2625 1500 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 2625 2025 m 3525 2025 l 3525 2475 l 2625 2475 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 4200 1050 m 5100 1050 l 5100 1500 l 4200 1500 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +3150 1627 m 3150 1485 l 3000 1485 l 3000 1627 l 3000 1627 l 3075 1507 l 3150 1627 l cp +eoclip +n 3075 2025 m + 3075 1500 l gs col0 s gr gr + +% arrowhead +n 3150 1627 m 3075 1507 l 3000 1627 l 3150 1627 l cp gs col7 1.00 shd ef gr col0 s +% Polyline +gs clippath +4071 1335 m 4215 1335 l 4215 1215 l 4071 1215 l 4071 1215 l 4191 1275 l 4071 1335 l cp +eoclip +n 3525 1275 m + 4200 1275 l gs col0 s gr gr + +% arrowhead +n 4071 1335 m 4191 1275 l 4071 1215 l col0 s +/Helvetica ff 183.33 scf sf +2850 2325 m +gs 1 -1 sc (Hand) col0 sh gr +/Helvetica ff 183.33 scf sf +2850 1350 m +gs 1 -1 sc (Deck) col0 sh gr +/Helvetica ff 233.33 scf sf +4125 1275 m +gs 1 -1 sc (*) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +4800 1350 m +gs 1 -1 sc (Card) dup sw pop neg 0 rm col0 sh gr +% here ends figure; +$F2psEnd +rs +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/class1.fig b/attic/latex/figs/class1.fig new file mode 100644 index 0000000..1dbd926 --- /dev/null +++ b/attic/latex/figs/class1.fig @@ -0,0 +1,25 @@ +#FIG 3.2 Produced by xfig version 3.2.5-alpha5 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 2625 1050 3525 1050 3525 1500 2625 1500 2625 1050 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 2625 2025 3525 2025 3525 2475 2625 2475 2625 2025 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 1 0 1.00 150.00 120.00 + 3075 2025 3075 1500 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 120.00 120.00 + 3525 1275 4200 1275 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 4200 1050 5100 1050 5100 1500 4200 1500 4200 1050 +4 0 0 50 0 16 11 0.0000 4 135 450 2850 2325 Hand\001 +4 0 0 50 0 16 11 0.0000 4 135 435 2850 1350 Deck\001 +4 2 0 50 0 16 14 0.0000 4 75 90 4125 1275 *\001 +4 2 0 50 0 16 11 0.0000 4 135 405 4800 1350 Card\001 diff --git a/attic/latex/figs/class1.pdf b/attic/latex/figs/class1.pdf new file mode 100644 index 0000000..16091c7 Binary files /dev/null and b/attic/latex/figs/class1.pdf differ diff --git a/attic/latex/figs/compile.eps b/attic/latex/figs/compile.eps new file mode 100644 index 0000000..901f239 --- /dev/null +++ b/attic/latex/figs/compile.eps @@ -0,0 +1,222 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: compile.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5a +%%CreationDate: Wed May 30 11:14:49 2012 +%%BoundingBox: 0 0 385 61 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 61 moveto 0 0 lineto 385 0 lineto 385 61 lineto closepath clip newpath +-2.7 86.0 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 63 +% Polyline +0 slj +0 slc +15.000 slw +n 3936 655 m 3840 548 l 3840 915 l + 3936 813 l gs col0 s gr +% Polyline +n 1304 647 m 1207 540 l 1207 907 l + 1304 805 l gs col0 s gr +% here ends figure; +% +% here starts figure with depth 50 +% Polyline +0 slj +0 slc +7.500 slw +gs clippath +3657 795 m 3869 795 l 3869 705 l 3657 705 l 3657 705 l 3837 750 l 3657 795 l cp +eoclip +n 3525 750 m + 3854 750 l gs col0 s gr gr + +% arrowhead +n 3657 795 m 3837 750 l 3657 705 l col0 s +% Polyline +15.000 slw +n 5002 1248 m 5100 1350 l 5100 984 l + 5002 1089 l gs col0 s gr +% Polyline +7.500 slw +gs clippath +5232 1170 m 5444 1170 l 5444 1080 l 5232 1080 l 5232 1080 l 5412 1125 l 5232 1170 l cp +eoclip +n 5100 1125 m + 5429 1125 l gs col0 s gr gr + +% arrowhead +n 5232 1170 m 5412 1125 l 5232 1080 l col0 s +% Polyline +15.000 slw +n 3936 548 m 5010 548 l 5010 1342 l 3936 1342 l + cp gs col0 s gr +% Polyline +n 2700 525 m 3525 525 l 3525 1350 l 2700 1350 l + cp gs col0 s gr +% Polyline +7.500 slw +gs clippath +1024 787 m 1236 787 l 1236 697 l 1024 697 l 1024 697 l 1204 742 l 1024 787 l cp +eoclip +n 892 742 m + 1221 742 l gs col0 s gr gr + +% arrowhead +n 1024 787 m 1204 742 l 1024 697 l col0 s +% Polyline +15.000 slw +n 67 442 m 742 442 l 892 592 l 892 1342 l 67 1342 l + 67 442 l cp gs col0 s gr +% Polyline +7.500 slw +n 742 442 m 742 592 l + 892 592 l gs col0 s gr +% Polyline +15.000 slw +n 1304 540 m 2274 540 l 2274 1327 l 1304 1327 l + cp gs col0 s gr +% Polyline +n 2274 1225 m 2371 1327 l 2371 961 l + 2274 1066 l gs col0 s gr +% Polyline +7.500 slw +gs clippath +2509 1162 m 2721 1162 l 2721 1072 l 2509 1072 l 2509 1072 l 2689 1117 l 2509 1162 l cp +eoclip +n 2377 1117 m + 2706 1117 l gs col0 s gr gr + +% arrowhead +n 2509 1162 m 2689 1117 l 2509 1072 l col0 s +% Polyline +15.000 slw +n 5694 1296 m 6151 1296 l 6151 1356 l 5694 1356 l + cp gs col0 s gr +% Polyline +n 5598 1357 m 6259 1357 l 6259 1412 l 5598 1412 l + cp gs col0 s gr +% Polyline +n 5413 463 m 6437 463 l 6437 1296 l 5413 1296 l + cp gs col7 1.00 shd ef gr gs col0 s gr +% Polyline +7.500 slw +n 5467 519 m 6381 519 l 6381 1237 l 5467 1237 l + cp gs col7 1.00 shd ef gr gs col0 s gr +/Helvetica ff 166.67 scf sf +2775 1125 m +gs 1 -1 sc (CODE) col0 sh gr +/Helvetica ff 166.67 scf sf +2775 900 m +gs 1 -1 sc (OBJECT) col0 sh gr +/Helvetica ff 166.67 scf sf +4005 975 m +gs 1 -1 sc (EXECUTOR) col0 sh gr +/Helvetica ff 166.67 scf sf +142 1117 m +gs 1 -1 sc (CODE) col0 sh gr +/Helvetica ff 166.67 scf sf +142 892 m +gs 1 -1 sc (SOURCE) col0 sh gr +/Helvetica ff 166.67 scf sf +1342 967 m +gs 1 -1 sc (COMPILER) col0 sh gr +/Helvetica ff 166.67 scf sf +5588 953 m +gs 1 -1 sc (OUTPUT) col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/compile.fig b/attic/latex/figs/compile.fig new file mode 100644 index 0000000..cf882be --- /dev/null +++ b/attic/latex/figs/compile.fig @@ -0,0 +1,54 @@ +#FIG 3.2 Produced by xfig version 3.2.5b +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 90.00 180.00 + 3525 750 3854 750 +2 1 0 2 0 7 63 0 -1 0.000 0 0 -1 0 0 4 + 3936 655 3840 548 3840 915 3936 813 +2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 4 + 5002 1248 5100 1350 5100 984 5002 1089 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 90.00 180.00 + 5100 1125 5429 1125 +2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 + 3936 548 5010 548 5010 1342 3936 1342 3936 548 +2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 + 2700 525 3525 525 3525 1350 2700 1350 2700 525 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 90.00 180.00 + 892 742 1221 742 +2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 6 + 67 442 742 442 892 592 892 1342 67 1342 67 442 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 3 + 742 442 742 592 892 592 +2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 + 1304 540 2274 540 2274 1327 1304 1327 1304 540 +2 1 0 2 0 7 63 0 -1 0.000 0 0 -1 0 0 4 + 1304 647 1207 540 1207 907 1304 805 +2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 4 + 2274 1225 2371 1327 2371 961 2274 1066 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 90.00 180.00 + 2377 1117 2706 1117 +2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 + 5694 1296 6151 1296 6151 1356 5694 1356 5694 1296 +2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 + 5598 1357 6259 1357 6259 1412 5598 1412 5598 1357 +2 2 0 2 0 7 50 0 20 0.000 0 0 -1 0 0 5 + 5413 463 6437 463 6437 1296 5413 1296 5413 463 +2 2 0 1 0 7 50 0 20 0.000 0 0 -1 0 0 5 + 5467 519 6381 519 6381 1237 5467 1237 5467 519 +4 0 0 50 0 16 10 0.0000 4 120 465 2775 1125 CODE\001 +4 0 0 50 0 16 10 0.0000 4 120 600 2775 900 OBJECT\001 +4 0 0 50 0 16 10 0.0000 4 120 855 4005 975 EXECUTOR\001 +4 0 0 50 0 16 10 0.0000 4 120 465 142 1117 CODE\001 +4 0 0 50 0 16 10 0.0000 4 120 675 142 892 SOURCE\001 +4 0 0 50 0 16 10 0.0000 4 120 825 1342 967 COMPILER\001 +4 0 0 50 0 16 10 0.0000 4 120 615 5588 953 OUTPUT\001 diff --git a/attic/latex/figs/compile.pdf b/attic/latex/figs/compile.pdf new file mode 100644 index 0000000..2c888ea Binary files /dev/null and b/attic/latex/figs/compile.pdf differ diff --git a/attic/latex/figs/dict1.eps b/attic/latex/figs/dict1.eps new file mode 100644 index 0000000..7987e4d --- /dev/null +++ b/attic/latex/figs/dict1.eps @@ -0,0 +1,321 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: dict1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Jul 31 12:32:19 2007 +%%For: downey@rocky.olin.edu (Allen Downey) +%%BoundingBox: 0 0 316 134 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 134 moveto 0 0 lineto 316 0 lineto 316 134 lineto closepath clip newpath +-27.0 225.7 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +7.500 slw +n 1125 1725 m 2400 1725 l 2400 3300 l 1125 3300 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 4350 1725 m 5700 1725 l 5700 3000 l 4350 3000 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 3375 1725 m 4050 1725 l 4050 3750 l 3375 3750 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 4350 3375 m 5700 3375 l 5700 3750 l 4350 3750 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +1965 2227 m 1965 2167 l 1813 2167 l 1933 2197 l 1813 2227 l cp +eoclip +n 1575 2197 m + 1950 2197 l gs col0 s gr gr + +% arrowhead +n 1813 2227 m 1933 2197 l 1813 2167 l col0 s +% Polyline +gs clippath +1965 1927 m 1965 1867 l 1813 1867 l 1933 1897 l 1813 1927 l cp +eoclip +n 1575 1897 m + 1950 1897 l gs col0 s gr gr + +% arrowhead +n 1813 1927 m 1933 1897 l 1813 1867 l col0 s +% Polyline +gs clippath +1140 1905 m 1140 1845 l 988 1845 l 1108 1875 l 988 1905 l cp +eoclip +n 750 1875 m + 1125 1875 l gs col0 s gr gr + +% arrowhead +n 988 1905 m 1108 1875 l 988 1845 l col0 s +% Polyline +gs clippath +1965 2827 m 1965 2767 l 1813 2767 l 1933 2797 l 1813 2827 l cp +eoclip +n 1575 2797 m + 1950 2797 l gs col0 s gr gr + +% arrowhead +n 1813 2827 m 1933 2797 l 1813 2767 l col0 s +% Polyline +gs clippath +1965 3127 m 1965 3067 l 1813 3067 l 1933 3097 l 1813 3127 l cp +eoclip +n 1575 3097 m + 1950 3097 l gs col0 s gr gr + +% arrowhead +n 1813 3127 m 1933 3097 l 1813 3067 l col0 s +% Polyline +gs clippath +1965 2527 m 1965 2467 l 1813 2467 l 1933 2497 l 1813 2527 l cp +eoclip +n 1575 2497 m + 1950 2497 l gs col0 s gr gr + +% arrowhead +n 1813 2527 m 1933 2497 l 1813 2467 l col0 s +/Helvetica ff 165.00 scf sf +1500 1950 m +gs 1 -1 sc ('a') dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 1950 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +2025 2250 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +1125 1650 m +gs 1 -1 sc (dict) col0 sh gr +/Helvetica ff 165.00 scf sf +450 1950 m +gs 1 -1 sc (hist) col0 sh gr +/Helvetica ff 165.00 scf sf +1500 2250 m +gs 1 -1 sc ('p') dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 2850 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +1500 3150 m +gs 1 -1 sc ('o') dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 3150 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +1500 2550 m +gs 1 -1 sc ('r') dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 2550 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 165.00 scf sf +1500 2850 m +gs 1 -1 sc ('t') dup sw pop neg 0 rm col0 sh gr +% Polyline +gs clippath +5190 2227 m 5190 2167 l 5038 2167 l 5158 2197 l 5038 2227 l cp +eoclip +n 4800 2197 m + 5175 2197 l gs col0 s gr gr + +% arrowhead +n 5038 2227 m 5158 2197 l 5038 2167 l col0 s +% Polyline +gs clippath +5190 1927 m 5190 1867 l 5038 1867 l 5158 1897 l 5038 1927 l cp +eoclip +n 4800 1897 m + 5175 1897 l gs col0 s gr gr + +% arrowhead +n 5038 1927 m 5158 1897 l 5038 1867 l col0 s +% Polyline +gs clippath +5190 2527 m 5190 2467 l 5038 2467 l 5158 2497 l 5038 2527 l cp +eoclip +n 4800 2497 m + 5175 2497 l gs col0 s gr gr + +% arrowhead +n 5038 2527 m 5158 2497 l 5038 2467 l col0 s +% Polyline +gs clippath +5190 2827 m 5190 2767 l 5038 2767 l 5158 2797 l 5038 2827 l cp +eoclip +n 4800 2797 m + 5175 2797 l gs col0 s gr gr + +% arrowhead +n 5038 2827 m 5158 2797 l 5038 2767 l col0 s +/Helvetica ff 165.00 scf sf +4725 1950 m +gs 1 -1 sc (0) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +4725 2250 m +gs 1 -1 sc (1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +5250 1950 m +gs 1 -1 sc ('a') col0 sh gr +/Helvetica ff 165.00 scf sf +5250 2250 m +gs 1 -1 sc ('p') col0 sh gr +/Helvetica ff 165.00 scf sf +4350 1650 m +gs 1 -1 sc (list) col0 sh gr +/Helvetica ff 165.00 scf sf +4725 2550 m +gs 1 -1 sc (2) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +5250 2550 m +gs 1 -1 sc ('t') col0 sh gr +/Helvetica ff 165.00 scf sf +5250 2850 m +gs 1 -1 sc ('o') col0 sh gr +/Helvetica ff 165.00 scf sf +4725 2850 m +gs 1 -1 sc (3) dup sw pop neg 0 rm col0 sh gr +% Polyline +gs clippath +4365 1919 m 4364 1859 l 4212 1861 l 4333 1890 l 4213 1921 l cp +eoclip +n 3825 1897 m + 4350 1890 l gs col0 s gr gr + +% arrowhead +n 4213 1921 m 4333 1890 l 4212 1861 l col0 s +% Polyline +gs clippath +3390 1905 m 3390 1845 l 3238 1845 l 3358 1875 l 3238 1905 l cp +eoclip +n 3000 1875 m + 3375 1875 l gs col0 s gr gr + +% arrowhead +n 3238 1905 m 3358 1875 l 3238 1845 l col0 s +% Polyline +gs clippath +4365 3551 m 4364 3491 l 4212 3493 l 4333 3522 l 4213 3553 l cp +eoclip +n 3825 3529 m + 4350 3522 l gs col0 s gr gr + +% arrowhead +n 4213 3553 m 4333 3522 l 4212 3493 l col0 s +% Polyline +gs clippath +5190 3577 m 5190 3517 l 5038 3517 l 5158 3547 l 5038 3577 l cp +eoclip +n 4800 3547 m + 5175 3547 l gs col0 s gr gr + +% arrowhead +n 5038 3577 m 5158 3547 l 5038 3517 l col0 s +/Helvetica ff 165.00 scf sf +3750 1950 m +gs 1 -1 sc (1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +3375 1650 m +gs 1 -1 sc (dict) col0 sh gr +/Helvetica ff 165.00 scf sf +2700 1950 m +gs 1 -1 sc (inv) col0 sh gr +/Helvetica ff 165.00 scf sf +3750 3600 m +gs 1 -1 sc (2) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +4725 3600 m +gs 1 -1 sc (0) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +4350 3300 m +gs 1 -1 sc (list) col0 sh gr +/Helvetica ff 165.00 scf sf +5250 3600 m +gs 1 -1 sc ('r') col0 sh gr +% here ends figure; +$F2psEnd +rs +showpage diff --git a/attic/latex/figs/dict1.fig b/attic/latex/figs/dict1.fig new file mode 100644 index 0000000..f1cf02e --- /dev/null +++ b/attic/latex/figs/dict1.fig @@ -0,0 +1,91 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 450 1500 2400 3300 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1575 2197 1950 2197 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1575 1897 1950 1897 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 750 1875 1125 1875 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1575 2797 1950 2797 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1575 3097 1950 3097 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1575 2497 1950 2497 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1125 1725 2400 1725 2400 3300 1125 3300 1125 1725 +4 2 0 50 0 16 11 0.0000 4 120 135 1500 1950 'a'\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2025 1950 1\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2025 2250 1\001 +4 0 0 50 0 16 11 0.0000 4 120 255 1125 1650 dict\001 +4 0 0 50 0 16 11 0.0000 4 120 255 450 1950 hist\001 +4 2 0 50 0 16 11 0.0000 4 150 150 1500 2250 'p'\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2025 2850 1\001 +4 2 0 50 0 16 11 0.0000 4 120 150 1500 3150 'o'\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2025 3150 1\001 +4 2 0 50 0 16 11 0.0000 4 120 120 1500 2550 'r'\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2025 2550 2\001 +4 2 0 50 0 16 11 0.0000 4 120 120 1500 2850 't'\001 +-6 +6 4350 1500 5700 3000 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 2197 5175 2197 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 1897 5175 1897 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 2497 5175 2497 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 2797 5175 2797 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 4350 1725 5700 1725 5700 3000 4350 3000 4350 1725 +4 2 0 50 0 16 11 0.0000 4 120 90 4725 1950 0\001 +4 2 0 50 0 16 11 0.0000 4 120 90 4725 2250 1\001 +4 0 0 50 0 16 11 0.0000 4 120 135 5250 1950 'a'\001 +4 0 0 50 0 16 11 0.0000 4 150 150 5250 2250 'p'\001 +4 0 0 50 0 16 11 0.0000 4 120 195 4350 1650 list\001 +4 2 0 50 0 16 11 0.0000 4 120 90 4725 2550 2\001 +4 0 0 50 0 16 11 0.0000 4 120 120 5250 2550 't'\001 +4 0 0 50 0 16 11 0.0000 4 120 150 5250 2850 'o'\001 +4 2 0 50 0 16 11 0.0000 4 120 90 4725 2850 3\001 +-6 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3825 1897 4350 1890 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3000 1875 3375 1875 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 3375 1725 4050 1725 4050 3750 3375 3750 3375 1725 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3825 3529 4350 3522 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 3547 5175 3547 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 4350 3375 5700 3375 5700 3750 4350 3750 4350 3375 +4 2 0 50 0 16 11 0.0000 4 120 90 3750 1950 1\001 +4 0 0 50 0 16 11 0.0000 4 120 255 3375 1650 dict\001 +4 0 0 50 0 16 11 0.0000 4 120 210 2700 1950 inv\001 +4 2 0 50 0 16 11 0.0000 4 120 90 3750 3600 2\001 +4 2 0 50 0 16 11 0.0000 4 120 90 4725 3600 0\001 +4 0 0 50 0 16 11 0.0000 4 120 195 4350 3300 list\001 +4 0 0 50 0 16 11 0.0000 4 120 120 5250 3600 'r'\001 diff --git a/attic/latex/figs/dict1.pdf b/attic/latex/figs/dict1.pdf new file mode 100644 index 0000000..db7af31 Binary files /dev/null and b/attic/latex/figs/dict1.pdf differ diff --git a/attic/latex/figs/dict2.eps b/attic/latex/figs/dict2.eps new file mode 100644 index 0000000..b1023b7 --- /dev/null +++ b/attic/latex/figs/dict2.eps @@ -0,0 +1,195 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: dict2.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Jul 31 12:39:25 2007 +%%For: downey@rocky.olin.edu (Allen Downey) +%%BoundingBox: 0 0 231 125 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 125 moveto 0 0 lineto 231 0 lineto 231 125 lineto closepath clip newpath +-75.8 194.2 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +7.500 slw +n 1275 1350 m 5100 1350 l 5100 3225 l 1275 3225 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +3690 1852 m 3690 1792 l 3538 1792 l 3658 1822 l 3538 1852 l cp +eoclip +n 3300 1822 m + 3675 1822 l gs col0 s gr gr + +% arrowhead +n 3538 1852 m 3658 1822 l 3538 1792 l col0 s +% Polyline +gs clippath +3690 1552 m 3690 1492 l 3538 1492 l 3658 1522 l 3538 1552 l cp +eoclip +n 3300 1522 m + 3675 1522 l gs col0 s gr gr + +% arrowhead +n 3538 1552 m 3658 1522 l 3538 1492 l col0 s +% Polyline +gs clippath +3690 2452 m 3690 2392 l 3538 2392 l 3658 2422 l 3538 2452 l cp +eoclip +n 3300 2422 m + 3675 2422 l gs col0 s gr gr + +% arrowhead +n 3538 2452 m 3658 2422 l 3538 2392 l col0 s +% Polyline +gs clippath +3690 2752 m 3690 2692 l 3538 2692 l 3658 2722 l 3538 2752 l cp +eoclip +n 3300 2722 m + 3675 2722 l gs col0 s gr gr + +% arrowhead +n 3538 2752 m 3658 2722 l 3538 2692 l col0 s +% Polyline +gs clippath +3690 2152 m 3690 2092 l 3538 2092 l 3658 2122 l 3538 2152 l cp +eoclip +n 3300 2122 m + 3675 2122 l gs col0 s gr gr + +% arrowhead +n 3538 2152 m 3658 2122 l 3538 2092 l col0 s +% Polyline +gs clippath +3690 3030 m 3690 2970 l 3538 2970 l 3658 3000 l 3538 3030 l cp +eoclip +n 3300 3000 m + 3675 3000 l gs col0 s gr gr + +% arrowhead +n 3538 3030 m 3658 3000 l 3538 2970 l col0 s +/Helvetica ff 165.00 scf sf +3225 1575 m +gs 1 -1 sc (\('Cleese', 'John'\)) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +3750 1575 m +gs 1 -1 sc ('08700 100 222') col0 sh gr +/Helvetica ff 165.00 scf sf +3750 1875 m +gs 1 -1 sc ('08700 100 222') col0 sh gr +/Helvetica ff 165.00 scf sf +3750 2175 m +gs 1 -1 sc ('08700 100 222') col0 sh gr +/Helvetica ff 165.00 scf sf +3750 2475 m +gs 1 -1 sc ('08700 100 222') col0 sh gr +/Helvetica ff 165.00 scf sf +3750 2775 m +gs 1 -1 sc ('08700 100 222') col0 sh gr +/Helvetica ff 165.00 scf sf +3225 1875 m +gs 1 -1 sc (\('Chapman', 'Graham'\)) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +3225 2175 m +gs 1 -1 sc (\('Idle', 'Eric'\)) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +3225 2775 m +gs 1 -1 sc (\('Jones', 'Terry'\)) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +3225 2475 m +gs 1 -1 sc (\('Gilliam', 'Terry'\)) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +3225 3075 m +gs 1 -1 sc (\('Palin', 'Michael'\)) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +3750 3075 m +gs 1 -1 sc ('08700 100 222') col0 sh gr +/Helvetica ff 165.00 scf sf +1275 1275 m +gs 1 -1 sc (dict) col0 sh gr +% here ends figure; +$F2psEnd +rs +showpage diff --git a/attic/latex/figs/dict2.fig b/attic/latex/figs/dict2.fig new file mode 100644 index 0000000..d376f55 --- /dev/null +++ b/attic/latex/figs/dict2.fig @@ -0,0 +1,42 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3300 1822 3675 1822 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3300 1522 3675 1522 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3300 2422 3675 2422 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3300 2722 3675 2722 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3300 2122 3675 2122 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3300 3000 3675 3000 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1275 1350 5100 1350 5100 3225 1275 3225 1275 1350 +4 2 0 50 0 16 11 0.0000 4 150 1125 3225 1575 ('Cleese', 'John')\001 +4 0 0 50 0 16 11 0.0000 4 120 1140 3750 1575 '08700 100 222'\001 +4 0 0 50 0 16 11 0.0000 4 120 1140 3750 1875 '08700 100 222'\001 +4 0 0 50 0 16 11 0.0000 4 120 1140 3750 2175 '08700 100 222'\001 +4 0 0 50 0 16 11 0.0000 4 120 1140 3750 2475 '08700 100 222'\001 +4 0 0 50 0 16 11 0.0000 4 120 1140 3750 2775 '08700 100 222'\001 +4 2 0 50 0 16 11 0.0000 4 150 1530 3225 1875 ('Chapman', 'Graham')\001 +4 2 0 50 0 16 11 0.0000 4 150 840 3225 2175 ('Idle', 'Eric')\001 +4 2 0 50 0 16 11 0.0000 4 150 1080 3225 2775 ('Jones', 'Terry')\001 +4 2 0 50 0 16 11 0.0000 4 150 1110 3225 2475 ('Gilliam', 'Terry')\001 +4 2 0 50 0 16 11 0.0000 4 150 1170 3225 3075 ('Palin', 'Michael')\001 +4 0 0 50 0 16 11 0.0000 4 120 1140 3750 3075 '08700 100 222'\001 +4 0 0 50 0 16 11 0.0000 4 120 255 1275 1275 dict\001 diff --git a/attic/latex/figs/dict2.pdf b/attic/latex/figs/dict2.pdf new file mode 100644 index 0000000..114a87a Binary files /dev/null and b/attic/latex/figs/dict2.pdf differ diff --git a/attic/latex/figs/fibonacci.eps b/attic/latex/figs/fibonacci.eps new file mode 100644 index 0000000..ed1a8e3 --- /dev/null +++ b/attic/latex/figs/fibonacci.eps @@ -0,0 +1,356 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: fibonacci.eps +%%Creator: fig2dev Version 3.2 Patchlevel 3c +%%CreationDate: Fri Dec 7 17:25:43 2001 +%%For: downey@rocky.wellesley.edu (Allen B. Downey) +%%BoundingBox: 0 0 308 218 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 218 moveto 0 0 lineto 308 0 lineto 308 218 lineto closepath clip newpath +-62.0 244.0 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +%%Page: 1 1 +10 setmiterlimit + 0.06000 0.06000 sc +% +% Fig objects follow +% +% Polyline +7.500 slw +n 3450 450 m 4350 450 l 4350 1125 l 3450 1125 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 2250 1425 m 3150 1425 l 3150 2100 l 2250 2100 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 4650 1425 m 5550 1425 l 5550 2100 l 4650 2100 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 5250 2400 m 6150 2400 l 6150 3075 l 5250 3075 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 4050 2400 m 4950 2400 l 4950 3075 l 4050 3075 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 2850 2400 m 3750 2400 l 3750 3075 l 2850 3075 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1650 2400 m 2550 2400 l 2550 3075 l 1650 3075 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 2250 3375 m 3150 3375 l 3150 4050 l 2250 4050 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1050 3375 m 1950 3375 l 1950 4050 l 1050 4050 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +4095 929 m 4095 869 l 3943 869 l 4063 899 l 3943 929 l cp +eoclip +n 3705 899 m + 4080 899 l gs col0 s gr gr + +% arrowhead +n 3943 929 m 4063 899 l 3943 869 l col0 s +/Helvetica ff 165.00 scf sf +3555 705 m +gs 1 -1 sc (fibonacci) col0 sh gr +/Helvetica ff 165.00 scf sf +3630 952 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +4155 952 m +gs 1 -1 sc (4) col0 sh gr +% Polyline +gs clippath +3118 1414 m 3160 1456 l 3268 1349 l 3162 1413 l 3225 1306 l cp +eoclip +n 3450 1125 m + 3150 1425 l gs col0 s gr gr + +% arrowhead +n 3225 1306 m 3162 1413 l 3268 1349 l col0 s +% Polyline +gs clippath +2068 2389 m 2110 2431 l 2218 2324 l 2112 2388 l 2175 2281 l cp +eoclip +n 2400 2100 m + 2100 2400 l gs col0 s gr gr + +% arrowhead +n 2175 2281 m 2112 2388 l 2218 2324 l col0 s +% Polyline +gs clippath +1468 3364 m 1510 3406 l 1618 3299 l 1512 3363 l 1575 3256 l cp +eoclip +n 1800 3075 m + 1500 3375 l gs col0 s gr gr + +% arrowhead +n 1575 3256 m 1512 3363 l 1618 3299 l col0 s +% Polyline +gs clippath +4468 2389 m 4510 2431 l 4618 2324 l 4512 2388 l 4575 2281 l cp +eoclip +n 4800 2100 m + 4500 2400 l gs col0 s gr gr + +% arrowhead +n 4575 2281 m 4512 2388 l 4618 2324 l col0 s +% Polyline +gs clippath +4639 1456 m 4681 1414 l 4574 1306 l 4638 1413 l 4531 1349 l cp +eoclip +n 4350 1125 m + 4650 1425 l gs col0 s gr gr + +% arrowhead +n 4531 1349 m 4638 1413 l 4574 1306 l col0 s +% Polyline +gs clippath +3289 2431 m 3331 2389 l 3224 2281 l 3288 2388 l 3181 2324 l cp +eoclip +n 3000 2100 m + 3300 2400 l gs col0 s gr gr + +% arrowhead +n 3181 2324 m 3288 2388 l 3224 2281 l col0 s +% Polyline +gs clippath +2689 3406 m 2731 3364 l 2624 3256 l 2688 3363 l 2581 3299 l cp +eoclip +n 2400 3075 m + 2700 3375 l gs col0 s gr gr + +% arrowhead +n 2581 3299 m 2688 3363 l 2624 3256 l col0 s +% Polyline +gs clippath +5689 2431 m 5731 2389 l 5624 2281 l 5688 2388 l 5581 2324 l cp +eoclip +n 5400 2100 m + 5700 2400 l gs col0 s gr gr + +% arrowhead +n 5581 2324 m 5688 2388 l 5624 2281 l col0 s +% Polyline +gs clippath +2895 1904 m 2895 1844 l 2743 1844 l 2863 1874 l 2743 1904 l cp +eoclip +n 2505 1874 m + 2880 1874 l gs col0 s gr gr + +% arrowhead +n 2743 1904 m 2863 1874 l 2743 1844 l col0 s +% Polyline +gs clippath +5295 1904 m 5295 1844 l 5143 1844 l 5263 1874 l 5143 1904 l cp +eoclip +n 4905 1874 m + 5280 1874 l gs col0 s gr gr + +% arrowhead +n 5143 1904 m 5263 1874 l 5143 1844 l col0 s +% Polyline +gs clippath +5895 2879 m 5895 2819 l 5743 2819 l 5863 2849 l 5743 2879 l cp +eoclip +n 5505 2849 m + 5880 2849 l gs col0 s gr gr + +% arrowhead +n 5743 2879 m 5863 2849 l 5743 2819 l col0 s +% Polyline +gs clippath +4695 2879 m 4695 2819 l 4543 2819 l 4663 2849 l 4543 2879 l cp +eoclip +n 4305 2849 m + 4680 2849 l gs col0 s gr gr + +% arrowhead +n 4543 2879 m 4663 2849 l 4543 2819 l col0 s +% Polyline +gs clippath +3495 2879 m 3495 2819 l 3343 2819 l 3463 2849 l 3343 2879 l cp +eoclip +n 3105 2849 m + 3480 2849 l gs col0 s gr gr + +% arrowhead +n 3343 2879 m 3463 2849 l 3343 2819 l col0 s +% Polyline +gs clippath +2295 2879 m 2295 2819 l 2143 2819 l 2263 2849 l 2143 2879 l cp +eoclip +n 1905 2849 m + 2280 2849 l gs col0 s gr gr + +% arrowhead +n 2143 2879 m 2263 2849 l 2143 2819 l col0 s +% Polyline +gs clippath +2895 3854 m 2895 3794 l 2743 3794 l 2863 3824 l 2743 3854 l cp +eoclip +n 2505 3824 m + 2880 3824 l gs col0 s gr gr + +% arrowhead +n 2743 3854 m 2863 3824 l 2743 3794 l col0 s +% Polyline +gs clippath +1695 3854 m 1695 3794 l 1543 3794 l 1663 3824 l 1543 3854 l cp +eoclip +n 1305 3824 m + 1680 3824 l gs col0 s gr gr + +% arrowhead +n 1543 3854 m 1663 3824 l 1543 3794 l col0 s +/Helvetica ff 165.00 scf sf +2355 1680 m +gs 1 -1 sc (fibonacci) col0 sh gr +/Helvetica ff 165.00 scf sf +2430 1927 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2955 1927 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 165.00 scf sf +4755 1680 m +gs 1 -1 sc (fibonacci) col0 sh gr +/Helvetica ff 165.00 scf sf +4830 1927 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +5355 1927 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 165.00 scf sf +5355 2655 m +gs 1 -1 sc (fibonacci) col0 sh gr +/Helvetica ff 165.00 scf sf +5430 2902 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +5955 2902 m +gs 1 -1 sc (0) col0 sh gr +/Helvetica ff 165.00 scf sf +4155 2655 m +gs 1 -1 sc (fibonacci) col0 sh gr +/Helvetica ff 165.00 scf sf +4230 2902 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +4755 2902 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +2955 2655 m +gs 1 -1 sc (fibonacci) col0 sh gr +/Helvetica ff 165.00 scf sf +3030 2902 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +3555 2902 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +1755 2655 m +gs 1 -1 sc (fibonacci) col0 sh gr +/Helvetica ff 165.00 scf sf +1830 2902 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2355 2902 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 165.00 scf sf +2355 3630 m +gs 1 -1 sc (fibonacci) col0 sh gr +/Helvetica ff 165.00 scf sf +2430 3877 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2955 3877 m +gs 1 -1 sc (0) col0 sh gr +/Helvetica ff 165.00 scf sf +1155 3630 m +gs 1 -1 sc (fibonacci) col0 sh gr +/Helvetica ff 165.00 scf sf +1230 3877 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +1755 3877 m +gs 1 -1 sc (1) col0 sh gr +$F2psEnd +rs diff --git a/attic/latex/figs/fibonacci.fig b/attic/latex/figs/fibonacci.fig new file mode 100644 index 0000000..244cee1 --- /dev/null +++ b/attic/latex/figs/fibonacci.fig @@ -0,0 +1,107 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 3450 450 4350 1125 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 3450 450 4350 450 4350 1125 3450 1125 3450 450 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3705 899 4080 899 +4 0 0 50 0 16 11 0.0000 4 120 615 3555 705 fibonacci\001 +4 2 0 50 0 16 11 0.0000 4 90 90 3630 952 n\001 +4 0 0 50 0 16 11 0.0000 4 120 90 4155 952 4\001 +-6 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3450 1125 3150 1425 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2400 2100 2100 2400 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1800 3075 1500 3375 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 2100 4500 2400 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4350 1125 4650 1425 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3000 2100 3300 2400 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2400 3075 2700 3375 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 5400 2100 5700 2400 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 2250 1425 3150 1425 3150 2100 2250 2100 2250 1425 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2505 1874 2880 1874 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 4650 1425 5550 1425 5550 2100 4650 2100 4650 1425 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4905 1874 5280 1874 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 5250 2400 6150 2400 6150 3075 5250 3075 5250 2400 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 5505 2849 5880 2849 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 4050 2400 4950 2400 4950 3075 4050 3075 4050 2400 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4305 2849 4680 2849 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 2850 2400 3750 2400 3750 3075 2850 3075 2850 2400 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3105 2849 3480 2849 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 2400 2550 2400 2550 3075 1650 3075 1650 2400 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1905 2849 2280 2849 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 2250 3375 3150 3375 3150 4050 2250 4050 2250 3375 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2505 3824 2880 3824 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1050 3375 1950 3375 1950 4050 1050 4050 1050 3375 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1305 3824 1680 3824 +4 0 0 50 0 16 11 0.0000 4 120 615 2355 1680 fibonacci\001 +4 2 0 50 0 16 11 0.0000 4 90 90 2430 1927 n\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2955 1927 3\001 +4 0 0 50 0 16 11 0.0000 4 120 615 4755 1680 fibonacci\001 +4 2 0 50 0 16 11 0.0000 4 90 90 4830 1927 n\001 +4 0 0 50 0 16 11 0.0000 4 120 90 5355 1927 2\001 +4 0 0 50 0 16 11 0.0000 4 120 615 5355 2655 fibonacci\001 +4 2 0 50 0 16 11 0.0000 4 90 90 5430 2902 n\001 +4 0 0 50 0 16 11 0.0000 4 120 90 5955 2902 0\001 +4 0 0 50 0 16 11 0.0000 4 120 615 4155 2655 fibonacci\001 +4 2 0 50 0 16 11 0.0000 4 90 90 4230 2902 n\001 +4 0 0 50 0 16 11 0.0000 4 120 90 4755 2902 1\001 +4 0 0 50 0 16 11 0.0000 4 120 615 2955 2655 fibonacci\001 +4 2 0 50 0 16 11 0.0000 4 90 90 3030 2902 n\001 +4 0 0 50 0 16 11 0.0000 4 120 90 3555 2902 1\001 +4 0 0 50 0 16 11 0.0000 4 120 615 1755 2655 fibonacci\001 +4 2 0 50 0 16 11 0.0000 4 90 90 1830 2902 n\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2355 2902 2\001 +4 0 0 50 0 16 11 0.0000 4 120 615 2355 3630 fibonacci\001 +4 2 0 50 0 16 11 0.0000 4 90 90 2430 3877 n\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2955 3877 0\001 +4 0 0 50 0 16 11 0.0000 4 120 615 1155 3630 fibonacci\001 +4 2 0 50 0 16 11 0.0000 4 90 90 1230 3877 n\001 +4 0 0 50 0 16 11 0.0000 4 120 90 1755 3877 1\001 diff --git a/attic/latex/figs/fibonacci.pdf b/attic/latex/figs/fibonacci.pdf new file mode 100644 index 0000000..ed4dc0d Binary files /dev/null and b/attic/latex/figs/fibonacci.pdf differ diff --git a/attic/latex/figs/flower.test.pdf b/attic/latex/figs/flower.test.pdf new file mode 100644 index 0000000..d48dd61 Binary files /dev/null and b/attic/latex/figs/flower.test.pdf differ diff --git a/attic/latex/figs/flowers.eps b/attic/latex/figs/flowers.eps new file mode 100644 index 0000000..9027094 --- /dev/null +++ b/attic/latex/figs/flowers.eps @@ -0,0 +1,9835 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Tk Canvas Widget +%%For: Allen Downey +%%Title: Window .-1211575348 +%%CreationDate: Mon Jul 2 09:55:23 2007 +%%BoundingBox: 174 345 438 448 +%%Pages: 1 +%%DocumentData: Clean7Bit +%%Orientation: Portrait +%%EndComments + +%%BeginProlog +/CurrentEncoding [ +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quotesingle +/parenleft/parenright/asterisk/plus/comma/hyphen/period/slash +/zero/one/two/three/four/five/six/seven +/eight/nine/colon/semicolon/less/equal/greater/question +/at/A/B/C/D/E/F/G +/H/I/J/K/L/M/N/O +/P/Q/R/S/T/U/V/W +/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore +/grave/a/b/c/d/e/f/g +/h/i/j/k/l/m/n/o +/p/q/r/s/t/u/v/w +/x/y/z/braceleft/bar/braceright/asciitilde/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/exclamdown/cent/sterling/currency/yen/brokenbar/section +/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron +/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered +/cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown +/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla +/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis +/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply +/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls +/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla +/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis +/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide +/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis +] def + +50 dict begin +% This is a standard prolog for Postscript generated by Tk's canvas +% widget. +% RCS: @(#) $Id: mkpsenc.tcl,v 1.3 2002/07/19 14:37:21 drh Exp $ + +% The definitions below just define all of the variables used in +% any of the procedures here. This is needed for obscure reasons +% explained on p. 716 of the Postscript manual (Section H.2.7, +% "Initializing Variables," in the section on Encapsulated Postscript). + +/baseline 0 def +/stipimage 0 def +/height 0 def +/justify 0 def +/lineLength 0 def +/spacing 0 def +/stipple 0 def +/strings 0 def +/xoffset 0 def +/yoffset 0 def +/tmpstip null def + + +/cstringshow { + { + dup type /stringtype eq + { show } { glyphshow } + ifelse + } + forall +} bind def + + + +/cstringwidth { + 0 exch 0 exch + { + dup type /stringtype eq + { stringwidth } { + currentfont /Encoding get exch 1 exch put (\001) stringwidth + } + ifelse + exch 3 1 roll add 3 1 roll add exch + } + forall +} bind def + +% font ISOEncode font +% This procedure changes the encoding of a font from the default +% Postscript encoding to current system encoding. It's typically invoked just +% before invoking "setfont". The body of this procedure comes from +% Section 5.6.1 of the Postscript book. + +/ISOEncode { + dup length dict begin + {1 index /FID ne {def} {pop pop} ifelse} forall + /Encoding CurrentEncoding def + currentdict + end + + % I'm not sure why it's necessary to use "definefont" on this new + % font, but it seems to be important; just use the name "Temporary" + % for the font. + + /Temporary exch definefont +} bind def + +% StrokeClip +% +% This procedure converts the current path into a clip area under +% the assumption of stroking. It's a bit tricky because some Postscript +% interpreters get errors during strokepath for dashed lines. If +% this happens then turn off dashes and try again. + +/StrokeClip { + {strokepath} stopped { + (This Postscript printer gets limitcheck overflows when) = + (stippling dashed lines; lines will be printed solid instead.) = + [] 0 setdash strokepath} if + clip +} bind def + +% desiredSize EvenPixels closestSize +% +% The procedure below is used for stippling. Given the optimal size +% of a dot in a stipple pattern in the current user coordinate system, +% compute the closest size that is an exact multiple of the device's +% pixel size. This allows stipple patterns to be displayed without +% aliasing effects. + +/EvenPixels { + % Compute exact number of device pixels per stipple dot. + dup 0 matrix currentmatrix dtransform + dup mul exch dup mul add sqrt + + % Round to an integer, make sure the number is at least 1, and compute + % user coord distance corresponding to this. + dup round dup 1 lt {pop 1} if + exch div mul +} bind def + +% width height string StippleFill -- +% +% Given a path already set up and a clipping region generated from +% it, this procedure will fill the clipping region with a stipple +% pattern. "String" contains a proper image description of the +% stipple pattern and "width" and "height" give its dimensions. Each +% stipple dot is assumed to be about one unit across in the current +% user coordinate system. This procedure trashes the graphics state. + +/StippleFill { + % The following code is needed to work around a NeWSprint bug. + + /tmpstip 1 index def + + % Change the scaling so that one user unit in user coordinates + % corresponds to the size of one stipple dot. + 1 EvenPixels dup scale + + % Compute the bounding box occupied by the path (which is now + % the clipping region), and round the lower coordinates down + % to the nearest starting point for the stipple pattern. Be + % careful about negative numbers, since the rounding works + % differently on them. + + pathbbox + 4 2 roll + 5 index div dup 0 lt {1 sub} if cvi 5 index mul 4 1 roll + 6 index div dup 0 lt {1 sub} if cvi 6 index mul 3 2 roll + + % Stack now: width height string y1 y2 x1 x2 + % Below is a doubly-nested for loop to iterate across this area + % in units of the stipple pattern size, going up columns then + % across rows, blasting out a stipple-pattern-sized rectangle at + % each position + + 6 index exch { + 2 index 5 index 3 index { + % Stack now: width height string y1 y2 x y + + gsave + 1 index exch translate + 5 index 5 index true matrix tmpstip imagemask + grestore + } for + pop + } for + pop pop pop pop pop +} bind def + +% -- AdjustColor -- +% Given a color value already set for output by the caller, adjusts +% that value to a grayscale or mono value if requested by the CL +% variable. + +/AdjustColor { + CL 2 lt { + currentgray + CL 0 eq { + .5 lt {0} {1} ifelse + } if + setgray + } if +} bind def + +% x y strings spacing xoffset yoffset justify stipple DrawText -- +% This procedure does all of the real work of drawing text. The +% color and font must already have been set by the caller, and the +% following arguments must be on the stack: +% +% x, y - Coordinates at which to draw text. +% strings - An array of strings, one for each line of the text item, +% in order from top to bottom. +% spacing - Spacing between lines. +% xoffset - Horizontal offset for text bbox relative to x and y: 0 for +% nw/w/sw anchor, -0.5 for n/center/s, and -1.0 for ne/e/se. +% yoffset - Vertical offset for text bbox relative to x and y: 0 for +% nw/n/ne anchor, +0.5 for w/center/e, and +1.0 for sw/s/se. +% justify - 0 for left justification, 0.5 for center, 1 for right justify. +% stipple - Boolean value indicating whether or not text is to be +% drawn in stippled fashion. If text is stippled, +% procedure StippleText must have been defined to call +% StippleFill in the right way. +% +% Also, when this procedure is invoked, the color and font must already +% have been set for the text. + +/DrawText { + /stipple exch def + /justify exch def + /yoffset exch def + /xoffset exch def + /spacing exch def + /strings exch def + + % First scan through all of the text to find the widest line. + + /lineLength 0 def + strings { + cstringwidth pop + dup lineLength gt {/lineLength exch def} {pop} ifelse + newpath + } forall + + % Compute the baseline offset and the actual font height. + + 0 0 moveto (TXygqPZ) false charpath + pathbbox dup /baseline exch def + exch pop exch sub /height exch def pop + newpath + + % Translate coordinates first so that the origin is at the upper-left + % corner of the text's bounding box. Remember that x and y for + % positioning are still on the stack. + + translate + lineLength xoffset mul + strings length 1 sub spacing mul height add yoffset mul translate + + % Now use the baseline and justification information to translate so + % that the origin is at the baseline and positioning point for the + % first line of text. + + justify lineLength mul baseline neg translate + + % Iterate over each of the lines to output it. For each line, + % compute its width again so it can be properly justified, then + % display it. + + strings { + dup cstringwidth pop + justify neg mul 0 moveto + stipple { + + + % The text is stippled, so turn it into a path and print + % by calling StippledText, which in turn calls StippleFill. + % Unfortunately, many Postscript interpreters will get + % overflow errors if we try to do the whole string at + % once, so do it a character at a time. + + gsave + /char (X) def + { + dup type /stringtype eq { + % This segment is a string. + { + char 0 3 -1 roll put + currentpoint + gsave + char true charpath clip StippleText + grestore + char stringwidth translate + moveto + } forall + } { + % This segment is glyph name + % Temporary override + currentfont /Encoding get exch 1 exch put + currentpoint + gsave (\001) true charpath clip StippleText + grestore + (\001) stringwidth translate + moveto + } ifelse + } forall + grestore + } {cstringshow} ifelse + 0 spacing neg translate + } forall +} bind def + +%%EndProlog +%%BeginSetup +/CL 2 def +%%EndSetup + +%%Page: 1 1 +save +306.0 396.0 translate +0.846 0.846 scale +-194 -60 translate +38 121 moveto 350 121 lineto 350 0 lineto 38 0 lineto closepath clip newpath +gsave +100 60 moveto +104.188790204786 60 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +104.188790204786 60 moveto +108.367376727162 60.2921952339398 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +108.367376727162 60.2921952339398 moveto +112.515401913619 60.8751621560111 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.515401913619 60.8751621560111 moveto +116.612657002408 61.7460606099691 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.612657002408 61.7460606099691 moveto +120.639180578591 62.9006476660886 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +120.639180578591 62.9006476660886 moveto +124.575355824049 64.3332982922908 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +124.575355824049 64.3332982922908 moveto +128.40200608865 66.0370327587344 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +128.40200608865 66.0370327587344 moveto +132.100488316957 68.0035506423577 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +132.100488316957 68.0035506423577 moveto +135.652783875325 70.2232712657053 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +135.652783875325 70.2232712657053 moveto +139.041586336868 72.685380373026 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +139.041586336868 72.685380373026 moveto +142.250385796636 75.377882816239 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +142.250385796636 75.377882816239 moveto +145.263549306207 78.2876609940905 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +145.263549306207 78.2876609940905 moveto +148.066397035846 81.4005387597879 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +148.066397035846 81.4005387597879 moveto +150.645273793155 84.7013504857621 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150.645273793155 84.7013504857621 moveto +152.987615549799 88.1740149490805 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +152.987615549799 88.1740149490805 moveto +148.798825345013 88.1740149490805 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +148.798825345013 88.1740149490805 moveto +144.620238822637 87.8818197151407 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +144.620238822637 87.8818197151407 moveto +140.47221363618 87.2988527930694 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +140.47221363618 87.2988527930694 moveto +136.374958547391 86.4279543391114 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +136.374958547391 86.4279543391114 moveto +132.348434971208 85.273367282992 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +132.348434971208 85.273367282992 moveto +128.41225972575 83.8407166567898 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +128.41225972575 83.8407166567898 moveto +124.585609461149 82.1369821903461 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +124.585609461149 82.1369821903461 moveto +120.887127232842 80.1704643067229 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +120.887127232842 80.1704643067229 moveto +117.334831674474 77.9507436833752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +117.334831674474 77.9507436833752 moveto +113.946029212931 75.4886345760546 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +113.946029212931 75.4886345760546 moveto +110.737229753163 72.7961321328416 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +110.737229753163 72.7961321328416 moveto +107.724066243592 69.88635395499 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +107.724066243592 69.88635395499 moveto +104.921218513953 66.7734761892926 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +104.921218513953 66.7734761892926 moveto +102.342341756644 63.4726644633185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +102.342341756644 63.4726644633185 moveto +100 60 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +100 60 moveto +102.61166797481 63.2749280555557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +102.61166797481 63.2749280555557 moveto +104.988526624774 66.7240592994786 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +104.988526624774 66.7240592994786 moveto +107.118996133471 70.3305899110537 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +107.118996133471 70.3305899110537 moveto +108.992697067607 74.0769492356688 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +108.992697067607 74.0769492356688 moveto +110.600500944577 77.9448853872768 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +110.600500944577 77.9448853872768 moveto +111.934574705506 81.9155541697508 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +111.934574705506 81.9155541697508 moveto +112.988418877133 85.9696108839129 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.988418877133 85.9696108839129 moveto +113.756899236585 90.0873045729639 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +113.756899236585 90.0873045729639 moveto +114.236271824799 94.24857424716 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.236271824799 94.24857424716 moveto +114.424201186711 98.4331466189377 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.424201186711 98.4331466189377 moveto +114.31977174936 102.620634872334 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.31977174936 102.620634872334 moveto +113.923492282468 106.790637985502 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +113.923492282468 106.790637985502 moveto +113.237293419763 110.922840122443 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +113.237293419763 110.922840122443 moveto +112.264518253129 114.997109609712 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.264518253129 114.997109609712 moveto +111.009906045395 118.993597015913 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +111.009906045395 118.993597015913 moveto +108.398238070585 115.718668960357 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +108.398238070585 115.718668960357 moveto +106.021379420621 112.269537716434 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +106.021379420621 112.269537716434 moveto +103.890909911924 108.663007104859 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +103.890909911924 108.663007104859 moveto +102.017208977787 104.916647780244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +102.017208977787 104.916647780244 moveto +100.409405100818 101.048711628636 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +100.409405100818 101.048711628636 moveto +99.0753313398884 97.0780428461617 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.0753313398884 97.0780428461617 moveto +98.0214871682615 93.0239861319997 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.0214871682615 93.0239861319997 moveto +97.2530068088093 88.9062924429487 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +97.2530068088093 88.9062924429487 moveto +96.7736342205956 84.7450227687526 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.7736342205956 84.7450227687526 moveto +96.585704858684 80.5604503969748 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.585704858684 80.5604503969748 moveto +96.690134296035 76.3729621435789 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.690134296035 76.3729621435789 moveto +97.086413762927 72.2029590304105 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +97.086413762927 72.2029590304105 moveto +97.7726126256313 68.0707568934697 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +97.7726126256313 68.0707568934697 moveto +98.7453877922652 63.9964874062003 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.7453877922652 63.9964874062003 moveto +99.9999999999999 60 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.9999999999999 60 moveto +99.0679064914838 64.0837684889201 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.0679064914838 64.0837684889201 moveto +97.8532142265331 68.0925695666967 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +97.8532142265331 68.0925695666967 moveto +96.3618410637623 72.0068727574424 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.3618410637623 72.0068727574424 moveto +94.6010528233081 75.807607969476 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +94.6010528233081 75.807607969476 moveto +92.579427888484 79.4762584028932 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +92.579427888484 79.4762584028932 moveto +90.3068154127597 82.9949507615538 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +90.3068154127597 82.9949507615538 moveto +87.7942873356745 86.3465423299841 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.7942873356745 86.3465423299841 moveto +85.0540844414617 89.5147044909636 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.0540844414617 89.5147044909636 moveto +82.0995567231776 92.4840022769064 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +82.0995567231776 92.4840022769064 moveto +78.9450983428775 95.2399695674723 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +78.9450983428775 95.2399695674723 moveto +75.6060775047053 97.7691795670505 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +75.6060775047053 97.7691795670505 moveto +72.0987615825474 100.059310218758 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +72.0987615825474 100.059310218758 moveto +68.4402378670222 102.099204236264 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +68.4402378670222 102.099204236264 moveto +64.6483303179184 103.878923460963 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +64.6483303179184 103.878923460963 moveto +60.741512727654 105.38979727969 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +60.741512727654 105.38979727969 moveto +61.6736062361701 101.30602879077 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +61.6736062361701 101.30602879077 moveto +62.8882985011208 97.2972277129933 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +62.8882985011208 97.2972277129933 moveto +64.3796716638916 93.3829245222477 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +64.3796716638916 93.3829245222477 moveto +66.1404599043459 89.5821893102141 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +66.1404599043459 89.5821893102141 moveto +68.1620848391699 85.9135388767969 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +68.1620848391699 85.9135388767969 moveto +70.4346973148942 82.3948465181363 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70.4346973148942 82.3948465181363 moveto +72.9472253919794 79.043254949706 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +72.9472253919794 79.043254949706 moveto +75.6874282861922 75.8750927887265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +75.6874282861922 75.8750927887265 moveto +78.6419560044763 72.9057950027836 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +78.6419560044763 72.9057950027836 moveto +81.7964143847764 70.1498277122177 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +81.7964143847764 70.1498277122177 moveto +85.1354352229486 67.6206177126395 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.1354352229486 67.6206177126395 moveto +88.6427511451065 65.3304870609317 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +88.6427511451065 65.3304870609317 moveto +92.3012748606317 63.2905930434263 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +92.3012748606317 63.2905930434263 moveto +96.0931824097355 61.510873818727 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.0931824097355 61.510873818727 moveto +99.9999999999999 60 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.9999999999999 60 moveto +96.2260304313128 61.8174479564317 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.2260304313128 61.8174479564317 moveto +92.3344753021618 63.3672098918569 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +92.3344753021618 63.3672098918569 moveto +88.3442938779584 64.6417355219078 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +88.3442938779584 64.6417355219078 moveto +84.2749259215097 65.6348154858295 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +84.2749259215097 65.6348154858295 moveto +80.146196984448 66.341611597862 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +80.146196984448 66.341611597862 moveto +75.9782218191364 66.7586804183942 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +75.9782218191364 66.7586804183942 moveto +71.7913063816169 66.8839900300562 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +71.7913063816169 66.8839900300562 moveto +67.6058489030337 66.7169299370161 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +67.6058489030337 66.7169299370161 moveto +63.4422405115018 66.2583140392542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +63.4422405115018 66.2583140392542 moveto +59.3207658885804 65.5103766673246 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +59.3207658885804 65.5103766673246 moveto +55.261504444343 64.4767616969209 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +55.261504444343 64.4767616969209 moveto +51.2842324925106 63.1625047962804 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +51.2842324925106 63.1625047962804 moveto +47.4083269022384 61.5740088929142 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +47.4083269022384 61.5740088929142 moveto +43.6526706959576 59.7190129791886 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +43.6526706959576 59.7190129791886 moveto +40.0355610531879 57.6065544087316 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +40.0355610531879 57.6065544087316 moveto +43.809530621875 55.7891064522999 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +43.809530621875 55.7891064522999 moveto +47.701085751026 54.2393445168747 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +47.701085751026 54.2393445168747 moveto +51.6912671752294 52.9648188868238 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +51.6912671752294 52.9648188868238 moveto +55.7606351316782 51.9717389229021 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +55.7606351316782 51.9717389229021 moveto +59.8893640687398 51.2649428108696 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +59.8893640687398 51.2649428108696 moveto +64.0573392340514 50.8478739903374 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +64.0573392340514 50.8478739903374 moveto +68.244254671571 50.7225643786754 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +68.244254671571 50.7225643786754 moveto +72.4297121501541 50.8896244717155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +72.4297121501541 50.8896244717155 moveto +76.593320541686 51.3482403694774 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +76.593320541686 51.3482403694774 moveto +80.7147951646074 52.096177741407 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +80.7147951646074 52.096177741407 moveto +84.7740566088448 53.1297927118107 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +84.7740566088448 53.1297927118107 moveto +88.7513285606772 54.4440496124512 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +88.7513285606772 54.4440496124512 moveto +92.6272341509494 56.0325455158174 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +92.6272341509494 56.0325455158174 moveto +96.3828903572302 57.887541429543 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.3828903572302 57.887541429543 moveto +99.9999999999999 60 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.9999999999999 60 moveto +96.2260304313128 58.1825520435683 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.2260304313128 58.1825520435683 moveto +92.58803282347 56.1062724898846 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +92.58803282347 56.1062724898846 moveto +89.1037311351269 53.7812767642275 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +89.1037311351269 53.7812767642275 moveto +85.7901005338682 51.2188920120648 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.7901005338682 51.2188920120648 moveto +82.6632846948982 48.4316019143388 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +82.6632846948982 48.4316019143388 moveto +79.738517150678 45.4329858682285 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +79.738517150678 45.4329858682285 moveto +77.0300470746865 42.2376528296904 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +77.0300470746865 42.2376528296904 moveto +74.5510698608794 38.8611701400947 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +74.5510698608794 38.8611701400947 moveto +72.3136628370564 35.3199876837022 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +72.3136628370564 35.3199876837022 moveto +70.3287264253342 31.631357745482 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70.3287264253342 31.631357745482 moveto +68.6059310363858 27.8132509597135 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +68.6059310363858 27.8132509597135 moveto +67.1536699561711 23.8842687588619 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +67.1536699561711 23.8842687588619 moveto +65.9790184546923 19.8635527492701 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +65.9790184546923 19.8635527492701 moveto +65.087699315989 15.7706914551758 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +65.087699315989 15.7706914551758 moveto +64.4840549573098 11.6256248853907 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +64.4840549573098 11.6256248853907 moveto +68.2580245259969 13.4430728418225 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +68.2580245259969 13.4430728418225 moveto +71.8960221338397 15.5193523955062 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +71.8960221338397 15.5193523955062 moveto +75.3803238221828 17.8443481211632 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +75.3803238221828 17.8443481211632 moveto +78.6939544234415 20.406732873326 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +78.6939544234415 20.406732873326 moveto +81.8207702624115 23.1940229710519 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +81.8207702624115 23.1940229710519 moveto +84.7455378066317 26.1926390171623 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +84.7455378066317 26.1926390171623 moveto +87.4540078826232 29.3879720557003 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.4540078826232 29.3879720557003 moveto +89.9329850964304 32.764454745296 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +89.9329850964304 32.764454745296 moveto +92.1703921202534 36.3056372016885 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +92.1703921202534 36.3056372016885 moveto +94.1553285319755 39.9942671399087 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +94.1553285319755 39.9942671399087 moveto +95.878123920924 43.8123739256773 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +95.878123920924 43.8123739256773 moveto +97.3303850011387 47.7413561265288 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +97.3303850011387 47.7413561265288 moveto +98.5050365026175 51.7620721361206 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.5050365026175 51.7620721361206 moveto +99.3963556413208 55.854933430215 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.3963556413208 55.854933430215 moveto +99.9999999999999 60 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.9999999999999 60 moveto +99.0679064914838 55.9162315110799 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.0679064914838 55.9162315110799 moveto +98.4229528052819 51.7773913205955 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.4229528052819 51.7773913205955 moveto +98.0682810909231 47.60364344192 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.0682810909231 47.60364344192 moveto +98.0056192733481 43.4153219551746 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.0056192733481 43.4153219551746 moveto +98.2352726346335 39.2328319416343 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.2352726346335 39.2328319416343 moveto +98.7561223266877 35.0765500722225 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.7561223266877 35.0765500722225 moveto +99.5656308221667 30.966725334419 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.5656308221667 30.966725334419 moveto +100.659854277052 26.9233803812282 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +100.659854277052 26.9233803812282 moveto +102.033461744662 22.9662139828265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +102.033461744662 22.9662139828265 moveto +103.67976114749 19.1145050561339 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +103.67976114749 19.1145050561339 moveto +105.59073188033 15.3870187398689 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +105.59073188033 15.3870187398689 moveto +107.757063885862 11.8019149726786 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +107.757063885862 11.8019149726786 moveto +110.168203012314 8.37666001974347 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +110.168203012314 8.37666001974347 moveto +112.812402432229 5.12794137888881 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.812402432229 5.12794137888881 moveto +115.676779871827 2.07158648077268 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +115.676779871827 2.07158648077268 moveto +116.608873380343 6.15535496969281 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.608873380343 6.15535496969281 moveto +117.253827066545 10.2941951601772 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +117.253827066545 10.2941951601772 moveto +117.608498780904 14.4679430388527 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +117.608498780904 14.4679430388527 moveto +117.671160598478 18.656264525598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +117.671160598478 18.656264525598 moveto +117.441507237193 22.8387545391384 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +117.441507237193 22.8387545391384 moveto +116.920657545139 26.9950364085502 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.920657545139 26.9950364085502 moveto +116.11114904966 31.1048611463537 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.11114904966 31.1048611463537 moveto +115.016925594775 35.1482060995445 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +115.016925594775 35.1482060995445 moveto +113.643318127164 39.1053724979462 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +113.643318127164 39.1053724979462 moveto +111.997018724336 42.9570814246387 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +111.997018724336 42.9570814246387 moveto +110.086047991496 46.6845677409038 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +110.086047991496 46.6845677409038 moveto +107.919715985964 50.269671508094 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +107.919715985964 50.269671508094 moveto +105.508576859512 53.6949264610292 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +105.508576859512 53.6949264610292 moveto +102.864377439598 56.9436451018839 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +102.864377439598 56.9436451018839 moveto +99.9999999999998 59.9999999999999 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.9999999999998 59.9999999999999 moveto +102.61166797481 56.7250719444442 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +102.61166797481 56.7250719444442 moveto +105.445421490617 53.6403021975478 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +105.445421490617 53.6403021975478 moveto +108.487454785139 50.7607194474375 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +108.487454785139 50.7607194474375 moveto +111.72294737795 48.1003527318172 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +111.72294737795 48.1003527318172 moveto +115.136136274368 45.6721630899063 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +115.136136274368 45.6721630899063 moveto +118.710392761182 43.4879804175594 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +118.710392761182 43.4879804175594 moveto +122.428303420072 41.558445833203 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +122.428303420072 41.558445833203 moveto +126.27175496403 39.8929598353758 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +126.27175496403 39.8929598353758 moveto +130.222022483477 38.4996365044453 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +130.222022483477 38.4996365044453 moveto +134.259860672138 37.3852639716233 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +134.259860672138 37.3852639716233 moveto +138.365597588239 36.5552713478735 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +138.365597588239 36.5552713478735 moveto +142.519230494233 36.0137022738281 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +142.519230494233 36.0137022738281 moveto +146.700523308122 35.7631952195776 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +146.700523308122 35.7631952195776 moveto +150.889105191621 35.8049706303094 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150.889105191621 35.8049706303094 moveto +155.064569794827 36.1388249804216 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +155.064569794827 36.1388249804216 moveto +152.452901820017 39.4137530359774 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +152.452901820017 39.4137530359774 moveto +149.61914830421 42.4985227828738 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +149.61914830421 42.4985227828738 moveto +146.577115009688 45.3781055329841 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +146.577115009688 45.3781055329841 moveto +143.341622416877 48.0384722486044 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +143.341622416877 48.0384722486044 moveto +139.928433520459 50.4666618905153 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +139.928433520459 50.4666618905153 moveto +136.354177033645 52.6508445628622 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +136.354177033645 52.6508445628622 moveto +132.636266374755 54.5803791472186 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +132.636266374755 54.5803791472186 moveto +128.792814830796 56.2458651450457 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +128.792814830796 56.2458651450457 moveto +124.842547311349 57.6391884759763 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +124.842547311349 57.6391884759763 moveto +120.804709122689 58.7535610087983 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +120.804709122689 58.7535610087983 moveto +116.698972206587 59.5835536325481 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.698972206587 59.5835536325481 moveto +112.545339300594 60.1251227065935 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.545339300594 60.1251227065935 moveto +108.364046486704 60.375629760844 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +108.364046486704 60.375629760844 moveto +104.175464603206 60.3338543501122 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +104.175464603206 60.3338543501122 moveto +99.9999999999999 60 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200 59.9999999999998 moveto +204.296195081832 59.9999999999998 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +204.296195081832 59.9999999999998 moveto +208.567633936021 60.4605456503816 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +208.567633936021 60.4605456503816 moveto +212.765089415928 61.3763292904158 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.765089415928 61.3763292904158 moveto +216.84018701276 62.7367967679594 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.84018701276 62.7367967679594 moveto +220.745962358347 64.5262690731284 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +220.745962358347 64.5262690731284 moveto +224.437402476444 66.7241230345332 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +224.437402476444 66.7241230345332 moveto +227.871964544784 69.3050289956011 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +227.871964544784 69.3050289956011 moveto +231.010066189291 72.2392427318353 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +231.010066189291 72.2392427318353 moveto +233.815541659945 75.4929482447416 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +233.815541659945 75.4929482447416 moveto +236.256058631014 79.0286474818212 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +236.256058631014 79.0286474818212 moveto +238.303490822124 82.8055924912122 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.303490822124 82.8055924912122 moveto +239.934242145835 86.7802550305195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +239.934242145835 86.7802550305195 moveto +241.129518645993 90.9068282177209 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +241.129518645993 90.9068282177209 moveto +236.833323564161 90.9068282177209 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +236.833323564161 90.9068282177209 moveto +232.561884709972 90.446282567339 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +232.561884709972 90.446282567339 moveto +228.364429230065 89.5304989273048 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +228.364429230065 89.5304989273048 moveto +224.289331633233 88.1700314497612 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +224.289331633233 88.1700314497612 moveto +220.383556287646 86.3805591445921 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +220.383556287646 86.3805591445921 moveto +216.692116169549 84.1827051831874 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.692116169549 84.1827051831874 moveto +213.257554101209 81.6017992221194 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +213.257554101209 81.6017992221194 moveto +210.119452456702 78.6675854858852 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +210.119452456702 78.6675854858852 moveto +207.313976986048 75.4138799729788 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +207.313976986048 75.4138799729788 moveto +204.87346001498 71.8781807358992 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +204.87346001498 71.8781807358992 moveto +202.826027823869 68.1012357265082 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +202.826027823869 68.1012357265082 moveto +201.195276500158 64.1265731872009 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +201.195276500158 64.1265731872009 moveto +200 59.9999999999994 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200 59.9999999999994 moveto +203.475694832352 62.5252401100719 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.475694832352 62.5252401100719 moveto +206.660659514523 65.4085181324775 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +206.660659514523 65.4085181324775 moveto +209.518188212997 68.6166050886796 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +209.518188212997 68.6166050886796 moveto +212.015348703047 72.1125286673771 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.015348703047 72.1125286673771 moveto +214.123361903473 75.8559993201255 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.123361903473 75.8559993201255 moveto +215.817933547525 79.8038745871945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +215.817933547525 79.8038745871945 moveto +217.079534167578 83.9106563024358 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +217.079534167578 83.9106563024358 moveto +217.893624166827 88.1290149470133 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +217.893624166827 88.1290149470133 moveto +218.250821384099 92.4103351089647 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +218.250821384099 92.4103351089647 moveto +218.147009220657 96.7052757623243 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +218.147009220657 96.7052757623243 moveto +217.583384082856 100.964338908745 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +217.583384082856 100.964338908745 moveto +216.566441593894 105.138440028184 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.566441593894 105.138440028184 moveto +215.107901733556 109.179473764366 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +215.107901733556 109.179473764366 moveto +211.632206901204 106.654233654294 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +211.632206901204 106.654233654294 moveto +208.447242219034 103.770955631888 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +208.447242219034 103.770955631888 moveto +205.589713520559 100.562868675686 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +205.589713520559 100.562868675686 moveto +203.092553030509 97.0669450969885 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.092553030509 97.0669450969885 moveto +200.984539830083 93.3234744442401 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200.984539830083 93.3234744442401 moveto +199.289968186032 89.3755991771711 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +199.289968186032 89.3755991771711 moveto +198.028367565978 85.2688174619298 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +198.028367565978 85.2688174619298 moveto +197.214277566729 81.0504588173523 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +197.214277566729 81.0504588173523 moveto +196.857080349457 76.7691386554008 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.857080349457 76.7691386554008 moveto +196.960892512899 72.4741980020412 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.960892512899 72.4741980020412 moveto +197.5245176507 68.2151348556207 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +197.5245176507 68.2151348556207 moveto +198.541460139663 64.0410337361816 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +198.541460139663 64.0410337361816 moveto +200.000000000001 59.9999999999993 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200.000000000001 59.9999999999993 moveto +201.327597291437 64.085924327851 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +201.327597291437 64.085924327851 moveto +202.209539545967 68.290620516737 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +202.209539545967 68.290620516737 moveto +202.63566262402 72.5656306107029 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +202.63566262402 72.5656306107029 moveto +202.601055575452 76.861686305564 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +202.601055575452 76.861686305564 moveto +202.106117236888 81.1292767524296 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +202.106117236888 81.1292767524296 moveto +201.156551635238 85.3192191564876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +201.156551635238 85.3192191564876 moveto +199.763302250372 89.3832255950565 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +199.763302250372 89.3832255950565 moveto +197.942425894552 93.2744595224856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +197.942425894552 93.2744595224856 moveto +195.714907662131 96.9480755483368 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +195.714907662131 96.9480755483368 moveto +193.106419082168 100.361736268057 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +193.106419082168 100.361736268057 moveto +190.147022261181 103.476100189806 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +190.147022261181 103.476100189806 moveto +186.870823425725 106.25527513423 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +186.870823425725 106.25527513423 moveto +183.315579857594 108.667231881857 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.315579857594 108.667231881857 moveto +181.987982566158 104.581307554005 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +181.987982566158 104.581307554005 moveto +181.106040311627 100.376611365119 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +181.106040311627 100.376611365119 moveto +180.679917233575 96.101601271153 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +180.679917233575 96.101601271153 moveto +180.714524282143 91.8055455762919 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +180.714524282143 91.8055455762919 moveto +181.209462620707 87.5379551294263 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +181.209462620707 87.5379551294263 moveto +182.159028222356 83.3480127253684 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +182.159028222356 83.3480127253684 moveto +183.552277607222 79.2840062867994 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.552277607222 79.2840062867994 moveto +185.373153963043 75.3927723593704 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.373153963043 75.3927723593704 moveto +187.600672195464 71.7191563335192 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.600672195464 71.7191563335192 moveto +190.209160775427 68.3054956137994 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +190.209160775427 68.3054956137994 moveto +193.168557596414 65.1911316920499 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +193.168557596414 65.1911316920499 moveto +196.44475643187 62.4119567476259 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.44475643187 62.4119567476259 moveto +200.000000000001 59.9999999999994 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200.000000000001 59.9999999999994 moveto +198.672402708565 64.085924327851 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +198.672402708565 64.085924327851 moveto +196.91445057034 68.00598765143 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.91445057034 68.00598765143 moveto +194.746403495545 71.7150123295136 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +194.746403495545 71.7150123295136 moveto +192.193247624662 75.1702528826639 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +192.193247624662 75.1702528826639 moveto +189.284407370104 78.3318886230083 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +189.284407370104 78.3318886230083 moveto +186.053406308035 81.1634825766093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +186.053406308035 81.1634825766093 moveto +182.537480828464 83.632401409471 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +182.537480828464 83.632401409471 moveto +178.777150996187 85.7101915176505 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +178.777150996187 85.7101915176505 moveto +174.815753568298 87.3729069471427 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +174.815753568298 87.3729069471427 moveto +170.698942550093 88.6013853643503 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +170.698942550093 88.6013853643503 moveto +166.474163045339 89.3814688966571 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +166.474163045339 89.3814688966571 moveto +162.190104464631 89.7041672979784 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.190104464631 89.7041672979784 moveto +157.896139393448 89.5657615588506 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +157.896139393448 89.5657615588506 moveto +159.223736684884 85.4798372309989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +159.223736684884 85.4798372309989 moveto +160.981688823109 81.5597739074198 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160.981688823109 81.5597739074198 moveto +163.149735897904 77.8507492293361 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +163.149735897904 77.8507492293361 moveto +165.702891768787 74.3955086761856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +165.702891768787 74.3955086761856 moveto +168.611732023344 71.2338729358409 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +168.611732023344 71.2338729358409 moveto +171.842733085412 68.4022789822395 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +171.842733085412 68.4022789822395 moveto +175.358658564984 65.9333601493775 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +175.358658564984 65.9333601493775 moveto +179.11898839726 63.8555700411977 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +179.11898839726 63.8555700411977 moveto +183.080385825149 62.1928546117051 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.080385825149 62.1928546117051 moveto +187.197196843354 60.9643761944971 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.197196843354 60.9643761944971 moveto +191.421976348107 60.1842926621899 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +191.421976348107 60.1842926621899 moveto +195.706034928816 59.8615942608683 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +195.706034928816 59.8615942608683 moveto +199.999999999999 59.9999999999956 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +199.999999999999 59.9999999999956 moveto +196.524305167647 62.5252401100684 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.524305167647 62.5252401100684 moveto +192.797936602873 64.6633396167857 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +192.797936602873 64.6633396167857 moveto +188.863839668593 66.3896575170718 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +188.863839668593 66.3896575170718 moveto +184.767353739496 67.6842984765155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +184.767353739496 67.6842984765155 moveto +180.555689678342 68.5323421175744 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +180.555689678342 68.5323421175744 moveto +176.277385743877 68.9240149727826 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +176.277385743877 68.9240149727826 moveto +171.981748200885 68.8548031212494 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +171.981748200885 68.8548031212494 moveto +167.718283079171 68.3255042103438 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +167.718283079171 68.3255042103438 moveto +163.53612563032 67.3422182630307 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +163.53612563032 67.3422182630307 moveto +159.483474057568 65.9162773767991 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +159.483474057568 65.9162773767991 moveto +155.607034044889 64.0641151243866 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +155.607034044889 64.0641151243866 moveto +151.951480486962 61.8070771614163 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.951480486962 61.8070771614163 moveto +148.558942623415 59.1711752236434 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +148.558942623415 59.1711752236434 moveto +152.034637455767 56.6459351135703 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +152.034637455767 56.6459351135703 moveto +155.76100602054 54.5078356068526 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +155.76100602054 54.5078356068526 moveto +159.69510295482 52.7815177065662 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +159.69510295482 52.7815177065662 moveto +163.791588883917 51.4868767471221 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +163.791588883917 51.4868767471221 moveto +168.003252945071 50.6388331060628 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +168.003252945071 50.6388331060628 moveto +172.281556879535 50.2471602508542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +172.281556879535 50.2471602508542 moveto +176.577194422528 50.316372102387 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +176.577194422528 50.316372102387 moveto +180.840659544242 50.8456710132921 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +180.840659544242 50.8456710132921 moveto +185.022816993093 51.8289569606049 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.022816993093 51.8289569606049 moveto +189.075468565845 53.2548978468361 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +189.075468565845 53.2548978468361 moveto +192.951908578524 55.1070600992482 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +192.951908578524 55.1070600992482 moveto +196.607462136451 57.3640980622182 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.607462136451 57.3640980622182 moveto +199.999999999999 59.9999999999907 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +199.999999999999 59.9999999999907 moveto +195.703804918167 59.999999999992 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +195.703804918167 59.999999999992 moveto +191.432366063978 59.5394543496115 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +191.432366063978 59.5394543496115 moveto +187.23491058407 58.6236707095787 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.23491058407 58.6236707095787 moveto +183.159812987238 57.2632032320365 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.159812987238 57.2632032320365 moveto +179.25403764165 55.4737309268687 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +179.25403764165 55.4737309268687 moveto +175.562597523553 53.2758769654652 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +175.562597523553 53.2758769654652 moveto +172.128035455211 50.6949710043985 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +172.128035455211 50.6949710043985 moveto +168.989933810704 47.7607572681655 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +168.989933810704 47.7607572681655 moveto +166.184458340048 44.5070517552601 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +166.184458340048 44.5070517552601 moveto +163.743941368978 40.9713525181814 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +163.743941368978 40.9713525181814 moveto +161.696509177866 37.1944075087913 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.696509177866 37.1944075087913 moveto +160.065757854154 33.2197449694846 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160.065757854154 33.2197449694846 moveto +158.870481353994 29.0931717822836 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +158.870481353994 29.0931717822836 moveto +163.166676435826 29.093171782282 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +163.166676435826 29.093171782282 moveto +167.438115290015 29.553717432662 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +167.438115290015 29.553717432662 moveto +171.635570769923 30.4695010726944 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +171.635570769923 30.4695010726944 moveto +175.710668366756 31.8299685502363 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +175.710668366756 31.8299685502363 moveto +179.616443712343 33.6194408554036 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +179.616443712343 33.6194408554036 moveto +183.307883830441 35.8172948168068 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.307883830441 35.8172948168068 moveto +186.742445898783 38.3982007778732 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +186.742445898783 38.3982007778732 moveto +189.88054754329 41.332414514106 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +189.88054754329 41.332414514106 moveto +192.686023013946 44.586120027011 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +192.686023013946 44.586120027011 moveto +195.126539985016 48.1218192640895 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +195.126539985016 48.1218192640895 moveto +197.173972176129 51.8987642734795 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +197.173972176129 51.8987642734795 moveto +198.804723499842 55.873426812786 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +198.804723499842 55.873426812786 moveto +200.000000000002 59.9999999999868 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200.000000000002 59.9999999999868 moveto +196.524305167648 57.4747598899162 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.524305167648 57.4747598899162 moveto +193.339340485476 54.5914818675122 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +193.339340485476 54.5914818675122 moveto +190.481811787 51.3833949113116 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +190.481811787 51.3833949113116 moveto +187.984651296949 47.8874713326154 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.984651296949 47.8874713326154 moveto +185.87663809652 44.1440006798682 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.87663809652 44.1440006798682 moveto +184.182066452467 40.1961254128001 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +184.182066452467 40.1961254128001 moveto +182.920465832411 36.0893436975595 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +182.920465832411 36.0893436975595 moveto +182.106375833159 31.8709850529825 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +182.106375833159 31.8709850529825 moveto +181.749178615885 27.5896648910312 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +181.749178615885 27.5896648910312 moveto +181.852990779325 23.2947242376715 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +181.852990779325 23.2947242376715 moveto +182.416615917123 19.0356610912507 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +182.416615917123 19.0356610912507 moveto +183.433558406083 14.861559971811 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.433558406083 14.861559971811 moveto +184.892098266418 10.8205262356278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +184.892098266418 10.8205262356278 moveto +188.367793098772 13.3457663456981 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +188.367793098772 13.3457663456981 moveto +191.552757780944 16.2290443681018 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +191.552757780944 16.2290443681018 moveto +194.410286479421 19.4371313243021 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +194.410286479421 19.4371313243021 moveto +196.907446969473 22.9330549029981 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.907446969473 22.9330549029981 moveto +199.015460169901 26.6765255557452 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +199.015460169901 26.6765255557452 moveto +200.710031813955 30.6244008228131 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200.710031813955 30.6244008228131 moveto +201.971632434011 34.7311825380535 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +201.971632434011 34.7311825380535 moveto +202.785722433263 38.9495411826304 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +202.785722433263 38.9495411826304 moveto +203.142919650538 43.2308613445817 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.142919650538 43.2308613445817 moveto +203.039107487099 47.5258019979414 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.039107487099 47.5258019979414 moveto +202.475482349301 51.7848651443623 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +202.475482349301 51.7848651443623 moveto +201.458539860342 55.9589662638021 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +201.458539860342 55.9589662638021 moveto +200.000000000007 59.9999999999855 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200.000000000007 59.9999999999855 moveto +198.672402708567 55.9140756721347 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +198.672402708567 55.9140756721347 moveto +197.790460454034 51.7093794832493 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +197.790460454034 51.7093794832493 moveto +197.364337375978 47.4343693892837 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +197.364337375978 47.4343693892837 moveto +197.398944424543 43.1383136944226 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +197.398944424543 43.1383136944226 moveto +197.893882763104 38.8707232475566 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +197.893882763104 38.8707232475566 moveto +198.84344836475 34.680780843498 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +198.84344836475 34.680780843498 moveto +200.236697749613 30.616774404928 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200.236697749613 30.616774404928 moveto +202.05757410543 26.7255404774975 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +202.05757410543 26.7255404774975 moveto +204.285092337848 23.0519244516445 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +204.285092337848 23.0519244516445 moveto +206.893580917809 19.6382637319227 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +206.893580917809 19.6382637319227 moveto +209.852977738793 16.5238998101708 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +209.852977738793 16.5238998101708 moveto +213.129176574247 13.7447248657442 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +213.129176574247 13.7447248657442 moveto +216.684420142376 11.3327681181148 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.684420142376 11.3327681181148 moveto +218.012017433816 15.4186924459654 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +218.012017433816 15.4186924459654 moveto +218.89395968835 19.6233886348507 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +218.89395968835 19.6233886348507 moveto +219.320082766406 23.8983987288162 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +219.320082766406 23.8983987288162 moveto +219.285475717842 28.1944544236774 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +219.285475717842 28.1944544236774 moveto +218.790537379281 32.4620448705434 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +218.790537379281 32.4620448705434 moveto +217.840971777635 36.6519872746021 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +217.840971777635 36.6519872746021 moveto +216.447722392772 40.7159937131723 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.447722392772 40.7159937131723 moveto +214.626846036956 44.607227640603 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.626846036956 44.607227640603 moveto +212.399327804538 48.2808436664561 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.399327804538 48.2808436664561 moveto +209.790839224577 51.6945043861782 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +209.790839224577 51.6945043861782 moveto +206.831442403594 54.8088683079304 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +206.831442403594 54.8088683079304 moveto +203.55524356814 57.5880432523574 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.55524356814 57.5880432523574 moveto +200.000000000011 59.9999999999871 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200.000000000011 59.9999999999871 moveto +201.327597291444 55.9140756721343 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +201.327597291444 55.9140756721343 moveto +203.085549429665 51.9940123485536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.085549429665 51.9940123485536 moveto +205.253596504456 48.284987670468 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +205.253596504456 48.284987670468 moveto +207.806752375336 44.8297471173154 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +207.806752375336 44.8297471173154 moveto +210.715592629891 41.6681113769682 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +210.715592629891 41.6681113769682 moveto +213.946593691957 38.836517423364 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +213.946593691957 38.836517423364 moveto +217.462519171526 36.3675985904989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +217.462519171526 36.3675985904989 moveto +221.222849003801 34.2898084823159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +221.222849003801 34.2898084823159 moveto +225.184246431689 32.6270930528199 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +225.184246431689 32.6270930528199 moveto +229.301057449893 31.3986146356084 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +229.301057449893 31.3986146356084 moveto +233.525836954645 30.6185311032976 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +233.525836954645 30.6185311032976 moveto +237.809895535353 30.2958327019722 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.809895535353 30.2958327019722 moveto +242.103860606536 30.4342384410959 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +242.103860606536 30.4342384410959 moveto +240.776263315104 34.5201627689489 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +240.776263315104 34.5201627689489 moveto +239.018311176883 38.4402260925298 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +239.018311176883 38.4402260925298 moveto +236.850264102092 42.1492507706155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +236.850264102092 42.1492507706155 moveto +234.297108231212 45.6044913237684 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +234.297108231212 45.6044913237684 moveto +231.388267976658 48.7661270641159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +231.388267976658 48.7661270641159 moveto +228.157266914592 51.5977210177204 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +228.157266914592 51.5977210177204 moveto +224.641341435023 54.0666398505857 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +224.641341435023 54.0666398505857 moveto +220.881011602749 56.1444299587691 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +220.881011602749 56.1444299587691 moveto +216.919614174861 57.8071453882655 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.919614174861 57.8071453882655 moveto +212.802803156657 59.0356238054774 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.802803156657 59.0356238054774 moveto +208.578023651905 59.8157073377886 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +208.578023651905 59.8157073377886 moveto +204.293965071197 60.1384057391143 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +204.293965071197 60.1384057391143 moveto +200.000000000014 59.9999999999911 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200.000000000014 59.9999999999911 moveto +203.475694832364 57.4747598899149 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.475694832364 57.4747598899149 moveto +207.202063397135 55.3366603831941 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +207.202063397135 55.3366603831941 moveto +211.136160331414 53.6103424829043 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +211.136160331414 53.6103424829043 moveto +215.232646260509 52.3157015234566 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +215.232646260509 52.3157015234566 moveto +219.444310321663 51.4676578823937 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +219.444310321663 51.4676578823937 moveto +223.722614256127 51.0759850271814 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +223.722614256127 51.0759850271814 moveto +228.018251799119 51.1451968787105 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +228.018251799119 51.1451968787105 moveto +232.281716920834 51.674495789612 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +232.281716920834 51.674495789612 moveto +236.463874369685 52.6577817369212 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +236.463874369685 52.6577817369212 moveto +240.516525942439 54.0837226231488 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +240.516525942439 54.0837226231488 moveto +244.39296595512 55.9358848755576 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +244.39296595512 55.9358848755576 moveto +248.048519513048 58.1929228385245 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.048519513048 58.1929228385245 moveto +251.441057376599 60.8288247762941 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +251.441057376599 60.8288247762941 moveto +247.965362544249 63.3540648863706 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +247.965362544249 63.3540648863706 moveto +244.238993979478 65.4921643930918 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +244.238993979478 65.4921643930918 moveto +240.3048970452 67.218482293382 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +240.3048970452 67.218482293382 moveto +236.208411116104 68.5131232528301 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +236.208411116104 68.5131232528301 moveto +231.996747054951 69.3611668938934 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +231.996747054951 69.3611668938934 moveto +227.718443120487 69.7528397491061 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +227.718443120487 69.7528397491061 moveto +223.422805577494 69.6836278975773 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +223.422805577494 69.6836278975773 moveto +219.159340455779 69.1543289866763 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +219.159340455779 69.1543289866763 moveto +214.977183006928 68.1710430393675 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.977183006928 68.1710430393675 moveto +210.924531434174 66.7451021531402 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +210.924531434174 66.7451021531402 moveto +207.048091421493 64.8929399007318 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +207.048091421493 64.8929399007318 moveto +203.392537863564 62.6359019377652 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.392537863564 62.6359019377652 moveto +200.000000000014 59.999999999996 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000014 59.9999999998711 moveto +304.072434921334 59.9999999998661 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.072434921334 59.9999999998661 moveto +308.143146999396 60.1184456241472 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +308.143146999396 60.1184456241472 moveto +312.208692005379 60.3552366558913 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.208692005379 60.3552366558913 moveto +316.265630082322 60.7101727462454 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.265630082322 60.7101727462454 moveto +320.310528655585 61.1829535838418 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +320.310528655585 61.1829535838418 moveto +324.339965337151 61.7731791488915 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +324.339965337151 61.7731791488915 moveto +328.350530821306 62.480350051641 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +328.350530821306 62.480350051641 moveto +332.338831769252 63.3038679549057 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +332.338831769252 63.3038679549057 moveto +336.301493680214 64.243036080323 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +336.301493680214 64.243036080323 moveto +340.2351637466 65.2970597978965 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +340.2351637466 65.2970597978965 moveto +344.136513690813 66.4650472983319 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +344.136513690813 66.4650472983319 moveto +348.002242581308 67.7460103475972 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +348.002242581308 67.7460103475972 moveto +343.929807659988 67.7460103476021 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +343.929807659988 67.7460103476021 moveto +339.859095581926 67.6275647233207 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +339.859095581926 67.6275647233207 moveto +335.793550575943 67.3907736915763 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +335.793550575943 67.3907736915763 moveto +331.736612499 67.0358376012219 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +331.736612499 67.0358376012219 moveto +327.691713925737 66.5630567636253 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +327.691713925737 66.5630567636253 moveto +323.662277244171 65.9728311985753 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +323.662277244171 65.9728311985753 moveto +319.651711760016 65.2656602958256 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +319.651711760016 65.2656602958256 moveto +315.66341081207 64.4421423925607 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.66341081207 64.4421423925607 moveto +311.700748901108 63.5029742671431 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.700748901108 63.5029742671431 moveto +307.767078834722 62.4489505495694 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.767078834722 62.4489505495694 moveto +303.865728890509 61.2809630491337 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.865728890509 61.2809630491337 moveto +300.000000000014 59.9999999998682 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000014 59.9999999998682 moveto +303.873115769125 61.2584515990377 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.873115769125 61.2584515990377 moveto +307.707991306115 62.6290192931658 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.707991306115 62.6290192931658 moveto +311.501381923421 64.1105434451516 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.501381923421 64.1105434451516 moveto +315.250078033867 65.701770537654 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.250078033867 65.701770537654 moveto +318.95090786629 67.4013542336914 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +318.95090786629 67.4013542336914 moveto +322.600740149177 69.2078565157781 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +322.600740149177 69.2078565157781 moveto +326.196486760033 71.1197489026301 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +326.196486760033 71.1197489026301 moveto +329.735105338243 73.1354137424134 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +329.735105338243 73.1354137424134 moveto +333.213601859208 75.2531455814382 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +333.213601859208 75.2531455814382 moveto +336.629033167595 77.4711526071437 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +336.629033167595 77.4711526071437 moveto +339.978509467535 79.7875581641502 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +339.978509467535 79.7875581641502 moveto +343.25919676768 82.2004023420968 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +343.25919676768 82.2004023420968 moveto +339.386080998569 80.941950742927 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +339.386080998569 80.941950742927 moveto +335.55120546158 79.5713830487987 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +335.55120546158 79.5713830487987 moveto +331.757814844274 78.0898588968126 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +331.757814844274 78.0898588968126 moveto +328.009118733828 76.49863180431 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +328.009118733828 76.49863180431 moveto +324.308288901405 74.7990481082724 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +324.308288901405 74.7990481082724 moveto +320.658456618518 72.9925458261854 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +320.658456618518 72.9925458261854 moveto +317.062710007662 71.0806534393331 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +317.062710007662 71.0806534393331 moveto +313.524091429452 69.0649885995498 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +313.524091429452 69.0649885995498 moveto +310.045594908487 66.9472567605247 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +310.045594908487 66.9472567605247 moveto +306.630163600101 64.7292497348189 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.630163600101 64.7292497348189 moveto +303.280687300161 62.4128441778121 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.280687300161 62.4128441778121 moveto +300.000000000016 59.9999999998654 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000016 59.9999999998654 moveto +303.294669059852 62.3937171875349 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.294669059852 62.3937171875349 moveto +306.51832371906 64.882246236302 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.51832371906 64.882246236302 moveto +309.668236443961 67.4634816021474 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +309.668236443961 67.4634816021474 moveto +312.741742093918 70.1352393022526 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.741742093918 70.1352393022526 moveto +315.736240176305 72.8952587628669 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.736240176305 72.8952587628669 moveto +318.649197046786 75.7412047319782 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +318.649197046786 75.7412047319782 moveto +321.478148053034 78.67066925517 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +321.478148053034 78.67066925517 moveto +324.220699620065 81.6811737129908 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +324.220699620065 81.6811737129908 moveto +326.874531275452 84.7701709181139 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +326.874531275452 84.7701709181139 moveto +329.437397612665 87.9350472705117 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +329.437397612665 87.9350472705117 moveto +331.907130190918 91.1731249688228 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +331.907130190918 91.1731249688228 moveto +334.281639369884 94.4816642760391 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +334.281639369884 94.4816642760391 moveto +330.986970310048 92.0879470883693 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +330.986970310048 92.0879470883693 moveto +327.763315650841 89.5994180396021 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +327.763315650841 89.5994180396021 moveto +324.613402925939 87.0181826737565 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +324.613402925939 87.0181826737565 moveto +321.539897275983 84.346424973651 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +321.539897275983 84.346424973651 moveto +318.545399193596 81.5864055130366 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +318.545399193596 81.5864055130366 moveto +315.632442323115 78.7404595439251 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.632442323115 78.7404595439251 moveto +312.803491316867 75.8109950207331 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.803491316867 75.8109950207331 moveto +310.060939749836 72.8004905629122 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +310.060939749836 72.8004905629122 moveto +307.40710809445 69.7114933577889 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.40710809445 69.7114933577889 moveto +304.844241757237 66.546617005391 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.844241757237 66.546617005391 moveto +302.374509178983 63.3085393070797 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +302.374509178983 63.3085393070797 moveto +300.000000000018 59.9999999998634 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000018 59.9999999998634 moveto +302.393717187693 63.2946690596953 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +302.393717187693 63.2946690596953 moveto +304.690597190553 66.6575649012063 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.690597190553 66.6575649012063 moveto +306.888696618803 70.0858421787778 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.888696618803 70.0858421787778 moveto +308.986155660879 73.576600227569 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +308.986155660879 73.576600227569 moveto +310.981199657031 77.1268855177685 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +310.981199657031 77.1268855177685 moveto +312.872140600861 80.7336941535761 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.872140600861 80.7336941535761 moveto +314.657378567547 84.3939744147979 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +314.657378567547 84.3939744147979 moveto +316.335403067539 88.1046293389067 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.335403067539 88.1046293389067 moveto +317.904794324584 91.8625193413812 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +317.904794324584 91.8625193413812 moveto +319.364224476997 95.6644648721081 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +319.364224476997 95.6644648721081 moveto +320.712458701167 99.5072491055989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +320.712458701167 99.5072491055989 moveto +321.948356256337 103.387620662745 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +321.948356256337 103.387620662745 moveto +319.554639068662 100.092951602913 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +319.554639068662 100.092951602913 moveto +317.257759065802 96.7300557614023 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +317.257759065802 96.7300557614023 moveto +315.059659637552 93.3017784838305 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.059659637552 93.3017784838305 moveto +312.962200595476 89.8110204350392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.962200595476 89.8110204350392 moveto +310.967156599325 86.2607351448395 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +310.967156599325 86.2607351448395 moveto +309.076215655496 82.6539265090318 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +309.076215655496 82.6539265090318 moveto +307.29097768881 78.9936462478099 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.29097768881 78.9936462478099 moveto +305.612953188818 75.282991323701 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.612953188818 75.282991323701 moveto +304.043561931773 71.5251013212264 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.043561931773 71.5251013212264 moveto +302.58413177936 67.7231557904994 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +302.58413177936 67.7231557904994 moveto +301.235897555191 63.8803715570085 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.235897555191 63.8803715570085 moveto +300.000000000021 59.999999999862 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000021 59.999999999862 moveto +301.258451599197 63.8731157689704 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.258451599197 63.8731157689704 moveto +302.403722327725 67.781194727585 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +302.403722327725 67.781194727585 moveto +303.434843172228 71.7209302507412 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.434843172228 71.7209302507412 moveto +304.350941701529 75.6889889288608 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.350941701529 75.6889889288608 moveto +305.151242804813 79.6820133881485 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.151242804813 79.6820133881485 moveto +305.835069347448 83.6966251312657 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.835069347448 83.6966251312657 moveto +306.40184274391 87.7294273958766 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.40184274391 87.7294273958766 moveto +306.85108344732 91.7770080286481 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.85108344732 91.7770080286481 moveto +307.182411355193 95.8359423722723 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.182411355193 95.8359423722723 moveto +307.395546131041 99.9027961630683 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.395546131041 99.9027961630683 moveto +307.490307441565 103.974128436712 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.490307441565 103.974128436712 moveto +307.466615109236 108.046494439637 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.466615109236 108.046494439637 moveto +306.208163510058 104.173378670529 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.208163510058 104.173378670529 moveto +305.062892781531 100.265299711914 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.062892781531 100.265299711914 moveto +304.031771937027 96.325564188758 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.031771937027 96.325564188758 moveto +303.115673407726 92.3575055106385 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.115673407726 92.3575055106385 moveto +302.315372304441 88.3644810513509 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +302.315372304441 88.3644810513509 moveto +301.631545761805 84.3498693082338 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.631545761805 84.3498693082338 moveto +301.064772365343 80.317067043623 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.064772365343 80.317067043623 moveto +300.615531661933 76.2694864108515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.615531661933 76.2694864108515 moveto +300.284203754059 72.2105520672274 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.284203754059 72.2105520672274 moveto +300.071068978211 68.1436982764314 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.071068978211 68.1436982764314 moveto +299.976307667686 64.0723660027874 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.976307667686 64.0723660027874 moveto +300.000000000015 59.9999999998628 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000015 59.9999999998628 moveto +300.000000000019 64.0724349211829 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000019 64.0724349211829 moveto +299.881554375737 68.1431469992444 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.881554375737 68.1431469992444 moveto +299.644763343992 72.2086920052273 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.644763343992 72.2086920052273 moveto +299.289827253637 76.2656300821704 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.289827253637 76.2656300821704 moveto +298.81704641604 80.3105286554339 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.81704641604 80.3105286554339 moveto +298.22682085099 84.3399653369997 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.22682085099 84.3399653369997 moveto +297.51964994824 88.3505308211542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +297.51964994824 88.3505308211542 moveto +296.696132044975 92.3388317691005 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.696132044975 92.3388317691005 moveto +295.756963919557 96.3014936800622 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.756963919557 96.3014936800622 moveto +294.702940201983 100.235163746448 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.702940201983 100.235163746448 moveto +293.534952701548 104.136513690661 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.534952701548 104.136513690661 moveto +292.253989652282 108.002242581156 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.253989652282 108.002242581156 moveto +292.253989652277 103.929807659836 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.253989652277 103.929807659836 moveto +292.372435276559 99.8590955817741 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.372435276559 99.8590955817741 moveto +292.609226308303 95.7935505757912 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.609226308303 95.7935505757912 moveto +292.964162398658 91.736612498848 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.964162398658 91.736612498848 moveto +293.436943236254 87.6917139255845 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.436943236254 87.6917139255845 moveto +294.027168801304 83.6622772440186 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.027168801304 83.6622772440186 moveto +294.734339704053 79.651711759864 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.734339704053 79.651711759864 moveto +295.557857607318 75.6634108119176 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.557857607318 75.6634108119176 moveto +296.497025732735 71.7007489009558 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.497025732735 71.7007489009558 moveto +297.551049450309 67.7670788345699 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +297.551049450309 67.7670788345699 moveto +298.719036950744 63.8657288903564 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.719036950744 63.8657288903564 moveto +300.000000000009 59.9999999998618 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000009 59.9999999998618 moveto +298.74154840084 63.8731157689728 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.74154840084 63.8731157689728 moveto +297.370980706713 67.7079913059625 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +297.370980706713 67.7079913059625 moveto +295.889456554727 71.5013819232693 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.889456554727 71.5013819232693 moveto +294.298229462226 75.2500780337158 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.298229462226 75.2500780337158 moveto +292.598645766189 78.950907866139 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.598645766189 78.950907866139 moveto +290.792143484103 82.6007401490263 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +290.792143484103 82.6007401490263 moveto +288.880251097252 86.196486759883 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.880251097252 86.196486759883 moveto +286.86458625747 89.735105338093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +286.86458625747 89.735105338093 moveto +284.746854418446 93.2136018590589 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.746854418446 93.2136018590589 moveto +282.528847392741 96.6290331674463 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +282.528847392741 96.6290331674463 moveto +280.212441835736 99.9785094673865 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +280.212441835736 99.9785094673865 moveto +277.79959765779 103.259196767533 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +277.79959765779 103.259196767533 moveto +279.058049256959 99.3860809984217 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +279.058049256959 99.3860809984217 moveto +280.428616951086 95.5512054614319 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +280.428616951086 95.5512054614319 moveto +281.91014110307 91.7578148441248 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +281.91014110307 91.7578148441248 moveto +283.501368195571 88.0091187336782 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.501368195571 88.0091187336782 moveto +285.200951891608 84.3082889012547 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +285.200951891608 84.3082889012547 moveto +287.007454173693 80.6584566183672 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.007454173693 80.6584566183672 moveto +288.919346560544 77.0627100075101 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.919346560544 77.0627100075101 moveto +290.935011400325 73.5240914292999 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +290.935011400325 73.5240914292999 moveto +293.052743239349 70.0455949083336 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.052743239349 70.0455949083336 moveto +295.270750265053 66.630163599946 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.270750265053 66.630163599946 moveto +297.587155822058 63.2806873000054 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +297.587155822058 63.2806873000054 moveto +300.000000000003 59.9999999998587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000003 59.9999999998587 moveto +297.606282812335 63.2946690596963 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +297.606282812335 63.2946690596963 moveto +295.11775376357 66.5183237189052 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.11775376357 66.5183237189052 moveto +292.536518397726 69.668236443808 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.536518397726 69.668236443808 moveto +289.864760697623 72.7417420937662 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +289.864760697623 72.7417420937662 moveto +287.10474123701 75.7362401761546 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.10474123701 75.7362401761546 moveto +284.258795267901 78.649197046638 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.258795267901 78.649197046638 moveto +281.329330744711 81.4781480528872 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +281.329330744711 81.4781480528872 moveto +278.318826286892 84.2206996199208 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +278.318826286892 84.2206996199208 moveto +275.22982908177 86.874531275309 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +275.22982908177 86.874531275309 moveto +272.064952729374 89.4373976125242 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +272.064952729374 89.4373976125242 moveto +268.826875031065 91.9071301907801 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +268.826875031065 91.9071301907801 moveto +265.51833572385 94.2816393697482 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +265.51833572385 94.2816393697482 moveto +267.912052911517 90.9869703099102 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +267.912052911517 90.9869703099102 moveto +270.400581960282 87.7633156507011 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +270.400581960282 87.7633156507011 moveto +272.981817326126 84.6134029257979 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +272.981817326126 84.6134029257979 moveto +275.653575026229 81.5398972758393 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +275.653575026229 81.5398972758393 moveto +278.413594486841 78.5453991934505 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +278.413594486841 78.5453991934505 moveto +281.25954045595 75.6324423229667 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +281.25954045595 75.6324423229667 moveto +284.189004979139 72.803491316717 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.189004979139 72.803491316717 moveto +287.199509436958 70.0609397496829 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.199509436958 70.0609397496829 moveto +290.288506642079 67.4071080942943 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +290.288506642079 67.4071080942943 moveto +293.453382994475 64.8442417570785 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.453382994475 64.8442417570785 moveto +296.691460692784 62.3745091788222 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.691460692784 62.3745091788222 moveto +299.999999999998 59.9999999998537 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.999999999998 59.9999999998537 moveto +296.705330940168 62.3937171875324 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.705330940168 62.3937171875324 moveto +293.34243509866 64.6905971903948 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.34243509866 64.6905971903948 moveto +289.91415782109 66.8886966186483 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +289.91415782109 66.8886966186483 moveto +286.423399772301 68.9861556607278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +286.423399772301 68.9861556607278 moveto +282.873114482103 70.9811996568827 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +282.873114482103 70.9811996568827 moveto +279.266305846298 72.8721406007159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +279.266305846298 72.8721406007159 moveto +275.606025585078 74.6573785674056 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +275.606025585078 74.6573785674056 moveto +271.89537066097 76.3354030674018 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +271.89537066097 76.3354030674018 moveto +268.137480658498 77.9047943244508 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +268.137480658498 77.9047943244508 moveto +264.335535127772 79.3642244768681 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +264.335535127772 79.3642244768681 moveto +260.492750894283 80.7124587010416 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +260.492750894283 80.7124587010416 moveto +256.612379337138 81.948356256216 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +256.612379337138 81.948356256216 moveto +259.907048396967 79.5546390685368 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +259.907048396967 79.5546390685368 moveto +263.269944238476 77.257759065674 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +263.269944238476 77.257759065674 moveto +266.698221516045 75.0596596374201 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +266.698221516045 75.0596596374201 moveto +270.188979564834 72.9622005953402 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +270.188979564834 72.9622005953402 moveto +273.739264855031 70.9671565991848 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +273.739264855031 70.9671565991848 moveto +277.346073490837 69.0762156553512 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +277.346073490837 69.0762156553512 moveto +281.006353752056 67.290977688661 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +281.006353752056 67.290977688661 moveto +284.717008676163 65.6129531886643 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.717008676163 65.6129531886643 moveto +288.474898678636 64.0435619316148 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.474898678636 64.0435619316148 moveto +292.276844209361 62.5841317791969 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.276844209361 62.5841317791969 moveto +296.11962844285 61.2358975550229 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.11962844285 61.2358975550229 moveto +299.999999999995 59.999999999848 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.999999999995 59.999999999848 moveto +296.126884230888 61.2584515990298 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.126884230888 61.2584515990298 moveto +292.218805272275 62.4037223275621 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.218805272275 62.4037223275621 moveto +288.27906974912 63.4348431720697 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.27906974912 63.4348431720697 moveto +284.311011071002 64.3509417013757 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.311011071002 64.3509417013757 moveto +280.317986611715 65.151242804665 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +280.317986611715 65.151242804665 moveto +276.303374868599 65.8350693473056 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +276.303374868599 65.8350693473056 moveto +272.270572603989 66.4018427437722 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +272.270572603989 66.4018427437722 moveto +268.222991971218 66.8510834471874 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +268.222991971218 66.8510834471874 moveto +264.164057627594 67.1824113550657 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +264.164057627594 67.1824113550657 moveto +260.097203836798 67.3955461309188 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +260.097203836798 67.3955461309188 moveto +256.025871563154 67.490307441448 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +256.025871563154 67.490307441448 moveto +251.95350556023 67.4666151091238 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +251.95350556023 67.4666151091238 moveto +255.826621329337 66.2081635099416 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +255.826621329337 66.2081635099416 moveto +259.73470028795 65.0628927814088 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +259.73470028795 65.0628927814088 moveto +263.674435811104 64.0317719369008 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +263.674435811104 64.0317719369008 moveto +267.642494489223 63.1156734075943 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +267.642494489223 63.1156734075943 moveto +271.635518948509 62.3153723043047 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +271.635518948509 62.3153723043047 moveto +275.650130691626 61.6315457616636 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +275.650130691626 61.6315457616636 moveto +279.682932956236 61.0647723651964 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +279.682932956236 61.0647723651964 moveto +283.730513589007 60.6155316617808 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.730513589007 60.6155316617808 moveto +287.78944793263 60.284203753902 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.78944793263 60.284203753902 moveto +291.856301723426 60.0710689780484 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +291.856301723426 60.0710689780484 moveto +295.92763399707 59.9763076675187 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.92763399707 59.9763076675187 moveto +299.999999999994 59.9999999998424 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.999999999994 59.9999999998424 moveto +295.927565078674 59.9999999998518 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.927565078674 59.9999999998518 moveto +291.856853000613 59.881554375575 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +291.856853000613 59.881554375575 moveto +287.79130799463 59.6447633438352 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.79130799463 59.6447633438352 moveto +283.734369917686 59.2898272534855 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.734369917686 59.2898272534855 moveto +279.689471344422 58.8170464158936 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +279.689471344422 58.8170464158936 moveto +275.660034662855 58.2268208508484 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +275.660034662855 58.2268208508484 moveto +271.6494691787 57.5196499481034 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +271.6494691787 57.5196499481034 moveto +267.661168230753 56.6961320448433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +267.661168230753 56.6961320448433 moveto +263.69850631979 55.7569639194306 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +263.69850631979 55.7569639194306 moveto +259.764836253403 54.7029402018619 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +259.764836253403 54.7029402018619 moveto +255.863486309188 53.5349527014311 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +255.863486309188 53.5349527014311 moveto +251.997757418692 52.2539896521704 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +251.997757418692 52.2539896521704 moveto +256.070192340012 52.2539896521606 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +256.070192340012 52.2539896521606 moveto +260.140904418073 52.3724352764369 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +260.140904418073 52.3724352764369 moveto +264.206449424057 52.6092263081761 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +264.206449424057 52.6092263081761 moveto +268.263387501 52.9641623985254 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +268.263387501 52.9641623985254 moveto +272.308286074264 53.4369432361169 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +272.308286074264 53.4369432361169 moveto +276.337722755831 54.0271688011617 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +276.337722755831 54.0271688011617 moveto +280.348288239987 54.734339703906 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +280.348288239987 54.734339703906 moveto +284.336589187934 55.5578576071658 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.336589187934 55.5578576071658 moveto +288.299251098897 56.4970257325781 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.299251098897 56.4970257325781 moveto +292.232921165284 57.5510494501464 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.232921165284 57.5510494501464 moveto +296.134271109499 58.7190369505767 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.134271109499 58.7190369505767 moveto +299.999999999995 59.9999999998369 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.999999999995 59.9999999998369 moveto +296.126884230883 58.7415484006729 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.126884230883 58.7415484006729 moveto +292.292008693891 57.3709807065503 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.292008693891 57.3709807065503 moveto +288.498618076583 55.8894565545699 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.498618076583 55.8894565545699 moveto +284.749921966134 54.2982294620731 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.749921966134 54.2982294620731 moveto +281.049092133709 52.5986457660411 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +281.049092133709 52.5986457660411 moveto +277.399259850819 50.79214348396 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +277.399259850819 50.79214348396 moveto +273.80351323996 48.8802510971134 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +273.80351323996 48.8802510971134 moveto +270.264894661747 46.8645862573356 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +270.264894661747 46.8645862573356 moveto +266.786398140779 44.7468544183161 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +266.786398140779 44.7468544183161 moveto +263.370966832389 42.5288473926159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +263.370966832389 42.5288473926159 moveto +260.021490532445 40.2124418356146 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +260.021490532445 40.2124418356146 moveto +256.740803232296 37.7995976576733 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +256.740803232296 37.7995976576733 moveto +260.613919001409 39.0580492568369 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +260.613919001409 39.0580492568369 moveto +264.4487945384 40.4286169509589 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +264.4487945384 40.4286169509589 moveto +268.242185155709 41.9101411029388 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +268.242185155709 41.9101411029388 moveto +271.990881266158 43.5013681954353 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +271.990881266158 43.5013681954353 moveto +275.691711098583 45.2009518914667 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +275.691711098583 45.2009518914667 moveto +279.341543381473 47.0074541735475 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +279.341543381473 47.0074541735475 moveto +282.937289992333 48.9193465603935 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +282.937289992333 48.9193465603935 moveto +286.475908570546 50.935011400171 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +286.475908570546 50.935011400171 moveto +289.954405091514 53.05274323919 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +289.954405091514 53.05274323919 moveto +293.369836399905 55.2707502648898 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.369836399905 55.2707502648898 moveto +296.719312699848 57.5871558218905 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.719312699848 57.5871558218905 moveto +299.999999999998 59.9999999998315 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.999999999998 59.9999999998315 moveto +296.705330940157 57.606282812168 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.705330940157 57.606282812168 moveto +293.481676280946 55.1177537634068 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.481676280946 55.1177537634068 moveto +290.331763556039 52.5365183975671 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +290.331763556039 52.5365183975671 moveto +287.258257906078 49.8647606974674 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.258257906078 49.8647606974674 moveto +284.263759823686 47.1047412368588 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.263759823686 47.1047412368588 moveto +281.350802953199 44.2587952677529 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +281.350802953199 44.2587952677529 moveto +278.521851946946 41.3293307445665 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +278.521851946946 41.3293307445665 moveto +275.779300379908 38.3188262867509 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +275.779300379908 38.3188262867509 moveto +273.125468724516 35.2298290816329 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +273.125468724516 35.2298290816329 moveto +270.562602387297 32.06495272924 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +270.562602387297 32.06495272924 moveto +268.092869809037 28.8268750309338 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +268.092869809037 28.8268750309338 moveto +265.718360630065 25.5183357237222 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +265.718360630065 25.5183357237222 moveto +269.013029689906 27.9120529113854 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +269.013029689906 27.9120529113854 moveto +272.236684349118 30.4005819601461 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +272.236684349118 30.4005819601461 moveto +275.386597074025 32.9818173259853 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +275.386597074025 32.9818173259853 moveto +278.460102723987 35.6535750260845 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +278.460102723987 35.6535750260845 moveto +281.454600806379 38.4135944866927 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +281.454600806379 38.4135944866927 moveto +284.367557676866 41.2595404557982 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.367557676866 41.2595404557982 moveto +287.19650868312 44.1890049789842 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.19650868312 44.1890049789842 moveto +289.939060250158 47.1995094367995 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +289.939060250158 47.1995094367995 moveto +292.59289190555 50.2885066419171 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.59289190555 50.2885066419171 moveto +295.15575824277 53.4533829943095 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.15575824277 53.4533829943095 moveto +297.62549082103 56.6914606926155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +297.62549082103 56.6914606926155 moveto +300.000000000003 59.9999999998268 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000003 59.9999999998268 moveto +297.60628281232 56.7053309400002 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +297.60628281232 56.7053309400002 moveto +295.309402809453 53.3424350984941 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.309402809453 53.3424350984941 moveto +293.111303381196 49.9141578209273 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.111303381196 49.9141578209273 moveto +291.013844339112 46.4233997721408 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +291.013844339112 46.4233997721408 moveto +289.018800342952 42.8731144819458 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +289.018800342952 42.8731144819458 moveto +287.127859399114 39.2663058461424 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.127859399114 39.2663058461424 moveto +285.34262143242 35.6060255849247 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +285.34262143242 35.6060255849247 moveto +283.664596932419 31.8953706608197 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.664596932419 31.8953706608197 moveto +282.095205675365 28.1374806583489 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +282.095205675365 28.1374806583489 moveto +280.635775522943 24.3355351276254 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +280.635775522943 24.3355351276254 moveto +279.287541298765 20.4927508941377 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +279.287541298765 20.4927508941377 moveto +278.051643743586 16.612379336994 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +278.051643743586 16.612379336994 moveto +280.445360931269 19.9070483968203 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +280.445360931269 19.9070483968203 moveto +282.742240934136 23.269944238326 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +282.742240934136 23.269944238326 moveto +284.940340362394 26.6982215158925 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.940340362394 26.6982215158925 moveto +287.037799404479 30.1889795646786 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.037799404479 30.1889795646786 moveto +289.032843400639 33.7392648548735 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +289.032843400639 33.7392648548735 moveto +290.923784344477 37.3460734906765 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +290.923784344477 37.3460734906765 moveto +292.709022311172 41.0063537518941 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.709022311172 41.0063537518941 moveto +294.387046811173 44.7170086759988 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.387046811173 44.7170086759988 moveto +295.956438068227 48.4748986784695 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.956438068227 48.4748986784695 moveto +297.41586822065 52.2768442091928 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +297.41586822065 52.2768442091928 moveto +298.764102444829 56.1196284426802 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.764102444829 56.1196284426802 moveto +300.000000000009 59.9999999998237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000009 59.9999999998237 moveto +298.741548400822 56.1268842307185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.741548400822 56.1268842307185 moveto +297.596277672285 52.2188052721068 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +297.596277672285 52.2188052721068 moveto +296.565156827772 48.2790697489531 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.565156827772 48.2790697489531 moveto +295.649058298461 44.3110110708359 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.649058298461 44.3110110708359 moveto +294.848757195167 40.3179866115502 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.848757195167 40.3179866115502 moveto +294.164930652521 36.3033748684347 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.164930652521 36.3033748684347 moveto +293.59815725605 32.2705726038253 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.59815725605 32.2705726038253 moveto +293.148916552629 28.2229919710549 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.148916552629 28.2229919710549 moveto +292.817588644746 24.1640576274315 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.817588644746 24.1640576274315 moveto +292.604453868888 20.0972038366361 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.604453868888 20.0972038366361 moveto +292.509692558353 16.0258715629923 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.509692558353 16.0258715629923 moveto +292.533384890672 11.9535055600676 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.533384890672 11.9535055600676 moveto +293.79183648986 15.8266213291727 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.79183648986 15.8266213291727 moveto +294.937107218397 19.7347002877842 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.937107218397 19.7347002877842 moveto +295.968228062911 23.6744358109378 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.968228062911 23.6744358109378 moveto +296.884326592222 27.6424944890549 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.884326592222 27.6424944890549 moveto +297.684627695517 31.6355189483405 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +297.684627695517 31.6355189483405 moveto +298.368454238163 35.6501306914558 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.368454238163 35.6501306914558 moveto +298.935227634635 39.6829329560652 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.935227634635 39.6829329560652 moveto +299.384468338056 43.7305135888356 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.384468338056 43.7305135888356 moveto +299.71579624594 47.7894479324589 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.71579624594 47.7894479324589 moveto +299.928931021799 51.8563017232543 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.928931021799 51.8563017232543 moveto +300.023692332334 55.927633996898 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.023692332334 55.927633996898 moveto +300.000000000015 59.9999999998227 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000015 59.9999999998227 moveto +300.000000000001 55.9275650785026 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000001 55.9275650785026 moveto +300.118445624272 51.8568530004408 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.118445624272 51.8568530004408 moveto +300.355236656007 47.7913079944573 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.355236656007 47.7913079944573 moveto +300.710172746352 43.7343699175133 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.710172746352 43.7343699175133 moveto +301.182953583938 39.6894713442486 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.182953583938 39.6894713442486 moveto +301.773179148978 35.6600346626813 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.773179148978 35.6600346626813 moveto +302.480350051718 31.649469178525 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +302.480350051718 31.649469178525 moveto +303.303867954973 27.6611682305767 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.303867954973 27.6611682305767 moveto +304.243036080381 23.6985063196126 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.243036080381 23.6985063196126 moveto +305.297059797945 19.7648362532242 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.297059797945 19.7648362532242 moveto +306.465047298371 15.8634863090078 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.465047298371 15.8634863090078 moveto +307.746010347626 11.9977574185101 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.746010347626 11.9977574185101 moveto +307.746010347641 16.0701923398302 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.746010347641 16.0701923398302 moveto +307.62756472337 20.140904417892 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.62756472337 20.140904417892 moveto +307.390773691636 24.2064494238756 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.390773691636 24.2064494238756 moveto +307.035837601292 28.2633875008196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.035837601292 28.2633875008196 moveto +306.563056763706 32.3082860740843 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.563056763706 32.3082860740843 moveto +305.972831198666 36.3377227556517 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.972831198666 36.3377227556517 moveto +305.265660295927 40.3482882398081 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.265660295927 40.3482882398081 moveto +304.442142392672 44.3365891877566 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.442142392672 44.3365891877566 moveto +303.502974267265 48.2992510987208 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.502974267265 48.2992510987208 moveto +302.448950549702 52.2329211651094 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +302.448950549702 52.2329211651094 moveto +301.280963049277 56.1342711093258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.280963049277 56.1342711093258 moveto +300.000000000021 59.9999999998237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000021 59.9999999998237 moveto +301.25845159918 56.1268842307095 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.25845159918 56.1268842307095 moveto +302.629019293298 52.2920086937164 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +302.629019293298 52.2920086937164 moveto +304.110543445274 48.4986180764057 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.110543445274 48.4986180764057 moveto +305.701770537766 44.7499219659552 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.701770537766 44.7499219659552 moveto +307.401354233793 41.0490921335276 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.401354233793 41.0490921335276 moveto +309.20785651587 37.3992598506357 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +309.20785651587 37.3992598506357 moveto +311.119748902712 33.8035132397741 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.119748902712 33.8035132397741 moveto +313.135413742485 30.264894661559 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +313.135413742485 30.264894661559 moveto +315.2531455815 26.7863981405876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.2531455815 26.7863981405876 moveto +317.471152607196 23.3709668321947 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +317.471152607196 23.3709668321947 moveto +319.787558164193 20.0214905322485 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +319.787558164193 20.0214905322485 moveto +322.20040234213 16.7408032320959 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +322.20040234213 16.7408032320959 moveto +320.941950742971 20.6139190012103 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +320.941950742971 20.6139190012103 moveto +319.571383048854 24.4487945382036 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +319.571383048854 24.4487945382036 moveto +318.089858896879 28.2421851555144 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +318.089858896879 28.2421851555144 moveto +316.498631804387 31.9908812659651 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.498631804387 31.9908812659651 moveto +314.79904810836 35.6917110983929 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +314.79904810836 35.6917110983929 moveto +312.992545826284 39.341543381285 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.992545826284 39.341543381285 moveto +311.080653439443 42.9372899921469 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.080653439443 42.9372899921469 moveto +309.06498859967 46.4759085703622 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +309.06498859967 46.4759085703622 moveto +306.947256760655 49.9544050913338 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.947256760655 49.9544050913338 moveto +304.72924973496 53.3698363997271 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.72924973496 53.3698363997271 moveto +302.412844177963 56.7193126996735 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +302.412844177963 56.7193126996735 moveto +300.000000000026 59.9999999998263 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000026 59.9999999998263 moveto +302.393717187686 56.7053309399827 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +302.393717187686 56.7053309399827 moveto +304.882246236443 53.4816762807675 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.882246236443 53.4816762807675 moveto +307.463481602279 50.331763555858 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.463481602279 50.331763555858 moveto +310.135239302374 47.2582579058929 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +310.135239302374 47.2582579058929 moveto +312.895258762979 44.2637598234975 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.895258762979 44.2637598234975 moveto +315.741204732081 41.3508029530069 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.741204732081 41.3508029530069 moveto +318.670669255264 38.5218519467502 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +318.670669255264 38.5218519467502 moveto +321.681173713076 35.7793003797088 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +321.681173713076 35.7793003797088 moveto +324.770170918191 33.1254687243128 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +324.770170918191 33.1254687243128 moveto +327.93504727058 30.5626023870895 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +327.93504727058 30.5626023870895 moveto +331.173124968884 28.0928698088253 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +331.173124968884 28.0928698088253 moveto +334.481664276092 25.7183606298488 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +334.481664276092 25.7183606298488 moveto +332.087947088433 29.0130296896928 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +332.087947088433 29.0130296896928 moveto +329.599418039676 32.2366843489083 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +329.599418039676 32.2366843489083 moveto +327.018182673841 35.3865970738181 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +327.018182673841 35.3865970738181 moveto +324.346424973746 38.4601027237834 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +324.346424973746 38.4601027237834 moveto +321.586405513141 41.4546008061793 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +321.586405513141 41.4546008061793 moveto +318.74045954404 44.3675576766703 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +318.74045954404 44.3675576766703 moveto +315.810995020857 47.1965086829273 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.810995020857 47.1965086829273 moveto +312.800490563045 49.939060249969 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.800490563045 49.939060249969 moveto +309.711493357931 52.5928919053654 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +309.711493357931 52.5928919053654 moveto +306.546617005542 55.1557582425893 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.546617005542 55.1557582425893 moveto +303.308539307239 57.6254908208537 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.308539307239 57.6254908208537 moveto +300.000000000031 59.9999999998306 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000031 59.9999999998306 moveto +303.294669059854 57.6062828121435 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.294669059854 57.6062828121435 moveto +306.657564901357 55.3094028092725 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.657564901357 55.3094028092725 moveto +310.085842178921 53.1113033810104 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +310.085842178921 53.1113033810104 moveto +313.576600227705 51.013844338922 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +313.576600227705 51.013844338922 moveto +317.126885517898 49.0188003427581 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +317.126885517898 49.0188003427581 moveto +320.733694153699 47.1278593989157 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +320.733694153699 47.1278593989157 moveto +324.393974414914 45.3426214322166 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +324.393974414914 45.3426214322166 moveto +328.104629339017 43.6645969322109 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +328.104629339017 43.6645969322109 moveto +331.862519341486 42.0952056751524 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +331.862519341486 42.0952056751524 moveto +335.664464872208 40.6357755227255 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +335.664464872208 40.6357755227255 moveto +339.507249105693 39.2875412985421 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +339.507249105693 39.2875412985421 moveto +343.387620662836 38.0516437433578 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +343.387620662836 38.0516437433578 moveto +340.092951603012 40.4453609310454 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +340.092951603012 40.4453609310454 moveto +336.730055761509 42.7422409339167 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +336.730055761509 42.7422409339167 moveto +333.301778483946 44.9403403621793 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +333.301778483946 44.9403403621793 moveto +329.811020435162 47.0377994042681 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +329.811020435162 47.0377994042681 moveto +326.26073514497 49.0328434004326 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +326.26073514497 49.0328434004326 moveto +322.653926509169 50.9237843442753 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +322.653926509169 50.9237843442753 moveto +318.993646247954 52.7090223109747 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +318.993646247954 52.7090223109747 moveto +315.282991323851 54.3870468109808 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.282991323851 54.3870468109808 moveto +311.525101321383 55.9564380680399 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.525101321383 55.9564380680399 moveto +307.723155790661 57.4158682204673 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.723155790661 57.4158682204673 moveto +303.880371557175 58.764102444651 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.880371557175 58.764102444651 moveto +300.000000000033 59.9999999998358 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.000000000033 59.9999999998358 moveto +303.873115769137 58.7415484006441 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.873115769137 58.7415484006441 moveto +307.781194727747 57.596277672102 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.781194727747 57.596277672102 moveto +311.7209302509 56.5651568275843 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.7209302509 56.5651568275843 moveto +315.688988929016 55.6490582982682 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.688988929016 55.6490582982682 moveto +319.6820133883 54.8487571949689 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +319.6820133883 54.8487571949689 moveto +323.696625131415 54.1649306523181 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +323.696625131415 54.1649306523181 moveto +327.729427396024 53.5981572558412 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +327.729427396024 53.5981572558412 moveto +331.777008028794 53.1489165524158 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +331.777008028794 53.1489165524158 moveto +335.835942372417 52.8175886445271 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +335.835942372417 52.8175886445271 moveto +339.902796163212 52.6044538686637 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +339.902796163212 52.6044538686637 moveto +343.974128436855 52.5096925581242 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +343.974128436855 52.5096925581242 moveto +348.04649443978 52.533384890438 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +348.04649443978 52.533384890438 moveto +344.173378670677 53.7918364896302 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +344.173378670677 53.7918364896302 moveto +340.265299712067 54.9371072181729 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +340.265299712067 54.9371072181729 moveto +336.325564188914 55.968228062691 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +336.325564188914 55.968228062691 moveto +332.357505510798 56.8843265920076 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +332.357505510798 56.8843265920076 moveto +328.364481051514 57.6846276953076 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +328.364481051514 57.6846276953076 moveto +324.349869308399 58.3684542379588 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +324.349869308399 58.3684542379588 moveto +320.317067043791 58.9352276344362 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +320.317067043791 58.9352276344362 moveto +316.269486411021 59.3844683378622 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.269486411021 59.3844683378622 moveto +312.210552067398 59.7157962457514 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.210552067398 59.7157962457514 moveto +308.143698276603 59.9289310216153 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +308.143698276603 59.9289310216153 moveto +304.072366002959 60.0236923321552 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.072366002959 60.0236923321552 moveto +300.000000000034 59.999999999842 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +restore showpage + +%%Trailer +end +%%EOF diff --git a/attic/latex/figs/flowers.pdf b/attic/latex/figs/flowers.pdf new file mode 100644 index 0000000..93bf385 Binary files /dev/null and b/attic/latex/figs/flowers.pdf differ diff --git a/attic/latex/figs/interpret.eps b/attic/latex/figs/interpret.eps new file mode 100644 index 0000000..8274779 --- /dev/null +++ b/attic/latex/figs/interpret.eps @@ -0,0 +1,173 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: interpret.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5a +%%CreationDate: Wed May 30 11:13:36 2012 +%%BoundingBox: 0 0 263 61 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 61 moveto 0 0 lineto 263 0 lineto 263 61 lineto closepath clip newpath +-138.2 86.0 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 50 +% Polyline +0 slj +0 slc +7.500 slw +gs clippath +3403 795 m 3615 795 l 3615 705 l 3403 705 l 3403 705 l 3583 750 l 3403 795 l cp +eoclip +n 3225 750 m + 3600 750 l gs col0 s gr gr + +% arrowhead +n 3403 795 m 3583 750 l 3403 705 l col0 s +% Polyline +15.000 slw +n 2325 1350 m 2325 450 l 3000 450 l 3150 600 l 3150 1350 l + 2325 1350 l cp gs col0 s gr +% Polyline +7.500 slw +n 3000 450 m 3000 600 l + 3150 600 l gs col0 s gr +% Polyline +15.000 slw +n 3748 640 m 3652 533 l 3652 900 l + 3748 798 l gs col0 s gr +% Polyline +7.500 slw +gs clippath +5375 1162 m 5587 1162 l 5587 1072 l 5375 1072 l 5375 1072 l 5555 1117 l 5375 1162 l cp +eoclip +n 5197 1117 m + 5572 1117 l gs col0 s gr gr + +% arrowhead +n 5375 1162 m 5555 1117 l 5375 1072 l col0 s +% Polyline +15.000 slw +n 5039 1173 m 5137 1275 l 5137 909 l + 5039 1014 l gs col0 s gr +% Polyline +n 3750 525 m 5047 525 l 5047 1290 l 3750 1290 l + cp gs col0 s gr +% Polyline +n 5919 1296 m 6376 1296 l 6376 1356 l 5919 1356 l + cp gs col0 s gr +% Polyline +n 5823 1357 m 6484 1357 l 6484 1412 l 5823 1412 l + cp gs col0 s gr +% Polyline +n 5638 463 m 6662 463 l 6662 1296 l 5638 1296 l + cp gs col7 1.00 shd ef gr gs col0 s gr +% Polyline +7.500 slw +n 5692 519 m 6606 519 l 6606 1237 l 5692 1237 l + cp gs col7 1.00 shd ef gr gs col0 s gr +/Helvetica ff 166.67 scf sf +2400 900 m +gs 1 -1 sc (SOURCE) col0 sh gr +/Helvetica ff 166.67 scf sf +2400 1125 m +gs 1 -1 sc (CODE) col0 sh gr +/Helvetica ff 166.67 scf sf +3825 975 m +gs 1 -1 sc (INTERPRETER) col0 sh gr +/Helvetica ff 166.67 scf sf +5813 953 m +gs 1 -1 sc (OUTPUT) col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/interpret.fig b/attic/latex/figs/interpret.fig new file mode 100644 index 0000000..f887cfe --- /dev/null +++ b/attic/latex/figs/interpret.fig @@ -0,0 +1,37 @@ +#FIG 3.2 Produced by xfig version 3.2.5b +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 90.00 180.00 + 3225 750 3600 750 +2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 6 + 2325 1350 2325 450 3000 450 3150 600 3150 1350 2325 1350 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 3 + 3000 450 3000 600 3150 600 +2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 4 + 3748 640 3652 533 3652 900 3748 798 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 90.00 180.00 + 5197 1117 5572 1117 +2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 4 + 5039 1173 5137 1275 5137 909 5039 1014 +2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 + 3750 525 5047 525 5047 1290 3750 1290 3750 525 +2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 + 5919 1296 6376 1296 6376 1356 5919 1356 5919 1296 +2 2 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 5 + 5823 1357 6484 1357 6484 1412 5823 1412 5823 1357 +2 2 0 2 0 7 50 0 20 0.000 0 0 -1 0 0 5 + 5638 463 6662 463 6662 1296 5638 1296 5638 463 +2 2 0 1 0 7 50 0 20 0.000 0 0 -1 0 0 5 + 5692 519 6606 519 6606 1237 5692 1237 5692 519 +4 0 0 50 0 16 10 0.0000 4 120 675 2400 900 SOURCE\001 +4 0 0 50 0 16 10 0.0000 4 120 465 2400 1125 CODE\001 +4 0 0 50 0 16 10 0.0000 4 120 1050 3825 975 INTERPRETER\001 +4 0 0 50 0 16 10 0.0000 4 120 615 5813 953 OUTPUT\001 diff --git a/attic/latex/figs/interpret.pdf b/attic/latex/figs/interpret.pdf new file mode 100644 index 0000000..19dbb76 Binary files /dev/null and b/attic/latex/figs/interpret.pdf differ diff --git a/attic/latex/figs/koch.eps b/attic/latex/figs/koch.eps new file mode 100644 index 0000000..37a5b19 --- /dev/null +++ b/attic/latex/figs/koch.eps @@ -0,0 +1,10575 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Tk Canvas Widget +%%For: Allen Downey +%%Title: Window .-1211776788 +%%CreationDate: Tue Jul 3 12:40:49 2007 +%%BoundingBox: 177 357 435 435 +%%Pages: 1 +%%DocumentData: Clean7Bit +%%Orientation: Portrait +%%EndComments + +%%BeginProlog +/CurrentEncoding [ +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quotesingle +/parenleft/parenright/asterisk/plus/comma/hyphen/period/slash +/zero/one/two/three/four/five/six/seven +/eight/nine/colon/semicolon/less/equal/greater/question +/at/A/B/C/D/E/F/G +/H/I/J/K/L/M/N/O +/P/Q/R/S/T/U/V/W +/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore +/grave/a/b/c/d/e/f/g +/h/i/j/k/l/m/n/o +/p/q/r/s/t/u/v/w +/x/y/z/braceleft/bar/braceright/asciitilde/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/exclamdown/cent/sterling/currency/yen/brokenbar/section +/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron +/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered +/cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown +/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla +/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis +/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply +/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls +/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla +/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis +/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide +/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis +] def + +50 dict begin +% This is a standard prolog for Postscript generated by Tk's canvas +% widget. +% RCS: @(#) $Id: mkpsenc.tcl,v 1.3 2002/07/19 14:37:21 drh Exp $ + +% The definitions below just define all of the variables used in +% any of the procedures here. This is needed for obscure reasons +% explained on p. 716 of the Postscript manual (Section H.2.7, +% "Initializing Variables," in the section on Encapsulated Postscript). + +/baseline 0 def +/stipimage 0 def +/height 0 def +/justify 0 def +/lineLength 0 def +/spacing 0 def +/stipple 0 def +/strings 0 def +/xoffset 0 def +/yoffset 0 def +/tmpstip null def + + +/cstringshow { + { + dup type /stringtype eq + { show } { glyphshow } + ifelse + } + forall +} bind def + + + +/cstringwidth { + 0 exch 0 exch + { + dup type /stringtype eq + { stringwidth } { + currentfont /Encoding get exch 1 exch put (\001) stringwidth + } + ifelse + exch 3 1 roll add 3 1 roll add exch + } + forall +} bind def + +% font ISOEncode font +% This procedure changes the encoding of a font from the default +% Postscript encoding to current system encoding. It's typically invoked just +% before invoking "setfont". The body of this procedure comes from +% Section 5.6.1 of the Postscript book. + +/ISOEncode { + dup length dict begin + {1 index /FID ne {def} {pop pop} ifelse} forall + /Encoding CurrentEncoding def + currentdict + end + + % I'm not sure why it's necessary to use "definefont" on this new + % font, but it seems to be important; just use the name "Temporary" + % for the font. + + /Temporary exch definefont +} bind def + +% StrokeClip +% +% This procedure converts the current path into a clip area under +% the assumption of stroking. It's a bit tricky because some Postscript +% interpreters get errors during strokepath for dashed lines. If +% this happens then turn off dashes and try again. + +/StrokeClip { + {strokepath} stopped { + (This Postscript printer gets limitcheck overflows when) = + (stippling dashed lines; lines will be printed solid instead.) = + [] 0 setdash strokepath} if + clip +} bind def + +% desiredSize EvenPixels closestSize +% +% The procedure below is used for stippling. Given the optimal size +% of a dot in a stipple pattern in the current user coordinate system, +% compute the closest size that is an exact multiple of the device's +% pixel size. This allows stipple patterns to be displayed without +% aliasing effects. + +/EvenPixels { + % Compute exact number of device pixels per stipple dot. + dup 0 matrix currentmatrix dtransform + dup mul exch dup mul add sqrt + + % Round to an integer, make sure the number is at least 1, and compute + % user coord distance corresponding to this. + dup round dup 1 lt {pop 1} if + exch div mul +} bind def + +% width height string StippleFill -- +% +% Given a path already set up and a clipping region generated from +% it, this procedure will fill the clipping region with a stipple +% pattern. "String" contains a proper image description of the +% stipple pattern and "width" and "height" give its dimensions. Each +% stipple dot is assumed to be about one unit across in the current +% user coordinate system. This procedure trashes the graphics state. + +/StippleFill { + % The following code is needed to work around a NeWSprint bug. + + /tmpstip 1 index def + + % Change the scaling so that one user unit in user coordinates + % corresponds to the size of one stipple dot. + 1 EvenPixels dup scale + + % Compute the bounding box occupied by the path (which is now + % the clipping region), and round the lower coordinates down + % to the nearest starting point for the stipple pattern. Be + % careful about negative numbers, since the rounding works + % differently on them. + + pathbbox + 4 2 roll + 5 index div dup 0 lt {1 sub} if cvi 5 index mul 4 1 roll + 6 index div dup 0 lt {1 sub} if cvi 6 index mul 3 2 roll + + % Stack now: width height string y1 y2 x1 x2 + % Below is a doubly-nested for loop to iterate across this area + % in units of the stipple pattern size, going up columns then + % across rows, blasting out a stipple-pattern-sized rectangle at + % each position + + 6 index exch { + 2 index 5 index 3 index { + % Stack now: width height string y1 y2 x y + + gsave + 1 index exch translate + 5 index 5 index true matrix tmpstip imagemask + grestore + } for + pop + } for + pop pop pop pop pop +} bind def + +% -- AdjustColor -- +% Given a color value already set for output by the caller, adjusts +% that value to a grayscale or mono value if requested by the CL +% variable. + +/AdjustColor { + CL 2 lt { + currentgray + CL 0 eq { + .5 lt {0} {1} ifelse + } if + setgray + } if +} bind def + +% x y strings spacing xoffset yoffset justify stipple DrawText -- +% This procedure does all of the real work of drawing text. The +% color and font must already have been set by the caller, and the +% following arguments must be on the stack: +% +% x, y - Coordinates at which to draw text. +% strings - An array of strings, one for each line of the text item, +% in order from top to bottom. +% spacing - Spacing between lines. +% xoffset - Horizontal offset for text bbox relative to x and y: 0 for +% nw/w/sw anchor, -0.5 for n/center/s, and -1.0 for ne/e/se. +% yoffset - Vertical offset for text bbox relative to x and y: 0 for +% nw/n/ne anchor, +0.5 for w/center/e, and +1.0 for sw/s/se. +% justify - 0 for left justification, 0.5 for center, 1 for right justify. +% stipple - Boolean value indicating whether or not text is to be +% drawn in stippled fashion. If text is stippled, +% procedure StippleText must have been defined to call +% StippleFill in the right way. +% +% Also, when this procedure is invoked, the color and font must already +% have been set for the text. + +/DrawText { + /stipple exch def + /justify exch def + /yoffset exch def + /xoffset exch def + /spacing exch def + /strings exch def + + % First scan through all of the text to find the widest line. + + /lineLength 0 def + strings { + cstringwidth pop + dup lineLength gt {/lineLength exch def} {pop} ifelse + newpath + } forall + + % Compute the baseline offset and the actual font height. + + 0 0 moveto (TXygqPZ) false charpath + pathbbox dup /baseline exch def + exch pop exch sub /height exch def pop + newpath + + % Translate coordinates first so that the origin is at the upper-left + % corner of the text's bounding box. Remember that x and y for + % positioning are still on the stack. + + translate + lineLength xoffset mul + strings length 1 sub spacing mul height add yoffset mul translate + + % Now use the baseline and justification information to translate so + % that the origin is at the baseline and positioning point for the + % first line of text. + + justify lineLength mul baseline neg translate + + % Iterate over each of the lines to output it. For each line, + % compute its width again so it can be properly justified, then + % display it. + + strings { + dup cstringwidth pop + justify neg mul 0 moveto + stipple { + + + % The text is stippled, so turn it into a path and print + % by calling StippledText, which in turn calls StippleFill. + % Unfortunately, many Postscript interpreters will get + % overflow errors if we try to do the whole string at + % once, so do it a character at a time. + + gsave + /char (X) def + { + dup type /stringtype eq { + % This segment is a string. + { + char 0 3 -1 roll put + currentpoint + gsave + char true charpath clip StippleText + grestore + char stringwidth translate + moveto + } forall + } { + % This segment is glyph name + % Temporary override + currentfont /Encoding get exch 1 exch put + currentpoint + gsave (\001) true charpath clip StippleText + grestore + (\001) stringwidth translate + moveto + } ifelse + } forall + grestore + } {cstringshow} ifelse + 0 spacing neg translate + } forall +} bind def + +%%EndProlog +%%BeginSetup +/CL 2 def +%%EndSetup + +%%Page: 1 1 +save +306.0 396.0 translate +0.846 0.846 scale +-200 -45 translate +48 91 moveto 352 91 lineto 352 0 lineto 48 0 lineto closepath clip newpath +gsave +50 2 moveto +51.2345679012346 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +51.2345679012346 2 moveto +51.8518518518518 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +51.8518518518518 3.06916716516599 moveto +52.4691358024691 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +52.4691358024691 2 moveto +53.7037037037037 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +53.7037037037037 2 moveto +54.320987654321 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +54.320987654321 3.06916716516599 moveto +53.7037037037037 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +53.7037037037037 4.13833433033196 moveto +54.9382716049383 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +54.9382716049383 4.13833433033196 moveto +55.5555555555555 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +55.5555555555555 5.20750149549794 moveto +56.1728395061728 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +56.1728395061728 4.13833433033196 moveto +57.4074074074074 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +57.4074074074074 4.13833433033196 moveto +56.7901234567901 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +56.7901234567901 3.06916716516599 moveto +57.4074074074074 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +57.4074074074074 2 moveto +58.6419753086419 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +58.6419753086419 2 moveto +59.2592592592592 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +59.2592592592592 3.06916716516599 moveto +59.8765432098765 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +59.8765432098765 2 moveto +61.1111111111111 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +61.1111111111111 2 moveto +61.7283950617284 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +61.7283950617284 3.06916716516599 moveto +61.1111111111111 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +61.1111111111111 4.13833433033196 moveto +62.3456790123456 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +62.3456790123456 4.13833433033196 moveto +62.9629629629629 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +62.9629629629629 5.20750149549794 moveto +62.3456790123456 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +62.3456790123456 6.27666866066392 moveto +61.1111111111111 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +61.1111111111111 6.27666866066392 moveto +61.7283950617284 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +61.7283950617284 7.34583582582989 moveto +61.1111111111111 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +61.1111111111111 8.41500299099587 moveto +62.3456790123456 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +62.3456790123456 8.41500299099587 moveto +62.9629629629629 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +62.9629629629629 9.48417015616185 moveto +63.5802469135802 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +63.5802469135802 8.41500299099587 moveto +64.8148148148148 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +64.8148148148148 8.41500299099587 moveto +65.4320987654321 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +65.4320987654321 9.48417015616185 moveto +64.8148148148148 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +64.8148148148148 10.5533373213278 moveto +66.0493827160493 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +66.0493827160493 10.5533373213278 moveto +66.6666666666666 11.6225044864938 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +66.6666666666666 11.6225044864938 moveto +67.2839506172839 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +67.2839506172839 10.5533373213278 moveto +68.5185185185185 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +68.5185185185185 10.5533373213278 moveto +67.9012345679012 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +67.9012345679012 9.48417015616185 moveto +68.5185185185185 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +68.5185185185185 8.41500299099587 moveto +69.753086419753 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +69.753086419753 8.41500299099587 moveto +70.3703703703703 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70.3703703703703 9.48417015616185 moveto +70.9876543209876 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70.9876543209876 8.41500299099587 moveto +72.2222222222222 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +72.2222222222222 8.41500299099587 moveto +71.6049382716049 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +71.6049382716049 7.34583582582989 moveto +72.2222222222222 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +72.2222222222222 6.27666866066392 moveto +70.9876543209876 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70.9876543209876 6.27666866066392 moveto +70.3703703703703 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70.3703703703703 5.20750149549794 moveto +70.9876543209876 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70.9876543209876 4.13833433033196 moveto +72.2222222222222 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +72.2222222222222 4.13833433033196 moveto +71.6049382716049 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +71.6049382716049 3.06916716516599 moveto +72.2222222222222 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +72.2222222222222 2 moveto +73.4567901234568 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +73.4567901234568 2 moveto +74.074074074074 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +74.074074074074 3.06916716516599 moveto +74.6913580246913 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +74.6913580246913 2 moveto +75.9259259259259 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +75.9259259259259 2 moveto +76.5432098765432 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +76.5432098765432 3.06916716516599 moveto +75.9259259259259 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +75.9259259259259 4.13833433033196 moveto +77.1604938271605 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +77.1604938271605 4.13833433033196 moveto +77.7777777777777 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +77.7777777777777 5.20750149549794 moveto +78.395061728395 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +78.395061728395 4.13833433033196 moveto +79.6296296296296 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +79.6296296296296 4.13833433033196 moveto +79.0123456790123 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +79.0123456790123 3.06916716516599 moveto +79.6296296296296 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +79.6296296296296 2 moveto +80.8641975308641 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +80.8641975308641 2 moveto +81.4814814814814 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +81.4814814814814 3.06916716516599 moveto +82.0987654320987 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +82.0987654320987 2 moveto +83.3333333333333 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.3333333333333 2 moveto +83.9506172839505 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.9506172839505 3.06916716516599 moveto +83.3333333333333 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.3333333333333 4.13833433033196 moveto +84.5679012345678 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +84.5679012345678 4.13833433033196 moveto +85.1851851851851 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.1851851851851 5.20750149549794 moveto +84.5679012345678 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +84.5679012345678 6.27666866066392 moveto +83.3333333333333 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.3333333333333 6.27666866066392 moveto +83.9506172839505 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.9506172839505 7.34583582582989 moveto +83.3333333333333 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.3333333333333 8.41500299099587 moveto +84.5679012345678 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +84.5679012345678 8.41500299099587 moveto +85.1851851851851 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.1851851851851 9.48417015616185 moveto +85.8024691358024 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.8024691358024 8.41500299099587 moveto +87.037037037037 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.037037037037 8.41500299099587 moveto +87.6543209876542 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.6543209876542 9.48417015616185 moveto +87.037037037037 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.037037037037 10.5533373213278 moveto +88.2716049382715 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +88.2716049382715 10.5533373213278 moveto +88.8888888888888 11.6225044864938 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +88.8888888888888 11.6225044864938 moveto +88.2716049382715 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +88.2716049382715 12.6916716516598 moveto +87.037037037037 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.037037037037 12.6916716516598 moveto +87.6543209876542 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.6543209876542 13.7608388168258 moveto +87.037037037037 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.037037037037 14.8300059819917 moveto +85.8024691358024 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.8024691358024 14.8300059819917 moveto +85.1851851851851 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.1851851851851 13.7608388168258 moveto +84.5679012345678 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +84.5679012345678 14.8300059819917 moveto +83.3333333333333 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.3333333333333 14.8300059819917 moveto +83.9506172839505 15.8991731471577 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.9506172839505 15.8991731471577 moveto +83.3333333333333 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.3333333333333 16.9683403123237 moveto +84.5679012345678 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +84.5679012345678 16.9683403123237 moveto +85.1851851851851 18.0375074774897 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.1851851851851 18.0375074774897 moveto +84.5679012345678 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +84.5679012345678 19.1066746426557 moveto +83.3333333333333 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.3333333333333 19.1066746426557 moveto +83.9506172839505 20.1758418078216 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.9506172839505 20.1758418078216 moveto +83.3333333333333 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +83.3333333333333 21.2450089729876 moveto +84.5679012345678 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +84.5679012345678 21.2450089729876 moveto +85.1851851851851 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.1851851851851 22.3141761381536 moveto +85.8024691358024 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +85.8024691358024 21.2450089729876 moveto +87.037037037037 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.037037037037 21.2450089729876 moveto +87.6543209876542 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.6543209876542 22.3141761381536 moveto +87.037037037037 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +87.037037037037 23.3833433033196 moveto +88.2716049382715 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +88.2716049382715 23.3833433033196 moveto +88.8888888888888 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +88.8888888888888 24.4525104684856 moveto +89.5061728395061 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +89.5061728395061 23.3833433033196 moveto +90.7407407407407 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +90.7407407407407 23.3833433033196 moveto +90.1234567901234 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +90.1234567901234 22.3141761381536 moveto +90.7407407407407 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +90.7407407407407 21.2450089729876 moveto +91.9753086419752 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +91.9753086419752 21.2450089729876 moveto +92.5925925925925 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +92.5925925925925 22.3141761381536 moveto +93.2098765432098 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +93.2098765432098 21.2450089729876 moveto +94.4444444444444 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +94.4444444444444 21.2450089729876 moveto +95.0617283950616 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +95.0617283950616 22.3141761381536 moveto +94.4444444444444 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +94.4444444444444 23.3833433033196 moveto +95.6790123456789 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +95.6790123456789 23.3833433033196 moveto +96.2962962962962 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.2962962962962 24.4525104684856 moveto +95.6790123456789 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +95.6790123456789 25.5216776336515 moveto +94.4444444444444 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +94.4444444444444 25.5216776336515 moveto +95.0617283950616 26.5908447988175 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +95.0617283950616 26.5908447988175 moveto +94.4444444444444 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +94.4444444444444 27.6600119639835 moveto +95.6790123456789 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +95.6790123456789 27.6600119639835 moveto +96.2962962962962 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.2962962962962 28.7291791291495 moveto +96.9135802469135 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +96.9135802469135 27.6600119639835 moveto +98.1481481481481 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.1481481481481 27.6600119639835 moveto +98.7654320987653 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.7654320987653 28.7291791291495 moveto +98.1481481481481 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +98.1481481481481 29.7983462943155 moveto +99.3827160493826 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.3827160493826 29.7983462943155 moveto +99.9999999999999 30.8675134594814 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +99.9999999999999 30.8675134594814 moveto +100.617283950617 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +100.617283950617 29.7983462943155 moveto +101.851851851852 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +101.851851851852 29.7983462943155 moveto +101.234567901234 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +101.234567901234 28.7291791291495 moveto +101.851851851852 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +101.851851851852 27.6600119639835 moveto +103.086419753086 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +103.086419753086 27.6600119639835 moveto +103.703703703704 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +103.703703703704 28.7291791291495 moveto +104.320987654321 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +104.320987654321 27.6600119639835 moveto +105.555555555555 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +105.555555555555 27.6600119639835 moveto +104.938271604938 26.5908447988175 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +104.938271604938 26.5908447988175 moveto +105.555555555555 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +105.555555555555 25.5216776336515 moveto +104.320987654321 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +104.320987654321 25.5216776336515 moveto +103.703703703704 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +103.703703703704 24.4525104684856 moveto +104.320987654321 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +104.320987654321 23.3833433033196 moveto +105.555555555555 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +105.555555555555 23.3833433033196 moveto +104.938271604938 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +104.938271604938 22.3141761381536 moveto +105.555555555555 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +105.555555555555 21.2450089729876 moveto +106.79012345679 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +106.79012345679 21.2450089729876 moveto +107.407407407407 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +107.407407407407 22.3141761381536 moveto +108.024691358025 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +108.024691358025 21.2450089729876 moveto +109.259259259259 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +109.259259259259 21.2450089729876 moveto +109.876543209876 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +109.876543209876 22.3141761381536 moveto +109.259259259259 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +109.259259259259 23.3833433033196 moveto +110.493827160494 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +110.493827160494 23.3833433033196 moveto +111.111111111111 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +111.111111111111 24.4525104684856 moveto +111.728395061728 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +111.728395061728 23.3833433033196 moveto +112.962962962963 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.962962962963 23.3833433033196 moveto +112.345679012346 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.345679012346 22.3141761381536 moveto +112.962962962963 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.962962962963 21.2450089729876 moveto +114.197530864197 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.197530864197 21.2450089729876 moveto +114.814814814815 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.814814814815 22.3141761381536 moveto +115.432098765432 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +115.432098765432 21.2450089729876 moveto +116.666666666667 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.666666666667 21.2450089729876 moveto +116.049382716049 20.1758418078216 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.049382716049 20.1758418078216 moveto +116.666666666667 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.666666666667 19.1066746426557 moveto +115.432098765432 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +115.432098765432 19.1066746426557 moveto +114.814814814815 18.0375074774897 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.814814814815 18.0375074774897 moveto +115.432098765432 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +115.432098765432 16.9683403123237 moveto +116.666666666667 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.666666666667 16.9683403123237 moveto +116.049382716049 15.8991731471577 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.049382716049 15.8991731471577 moveto +116.666666666667 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.666666666667 14.8300059819917 moveto +115.432098765432 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +115.432098765432 14.8300059819917 moveto +114.814814814815 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.814814814815 13.7608388168258 moveto +114.197530864197 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.197530864197 14.8300059819917 moveto +112.962962962963 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.962962962963 14.8300059819917 moveto +112.345679012346 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.345679012346 13.7608388168258 moveto +112.962962962963 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.962962962963 12.6916716516598 moveto +111.728395061728 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +111.728395061728 12.6916716516598 moveto +111.111111111111 11.6225044864938 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +111.111111111111 11.6225044864938 moveto +111.728395061728 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +111.728395061728 10.5533373213278 moveto +112.962962962963 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.962962962963 10.5533373213278 moveto +112.345679012346 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.345679012346 9.48417015616185 moveto +112.962962962963 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +112.962962962963 8.41500299099587 moveto +114.197530864197 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.197530864197 8.41500299099587 moveto +114.814814814815 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.814814814815 9.48417015616185 moveto +115.432098765432 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +115.432098765432 8.41500299099587 moveto +116.666666666667 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.666666666667 8.41500299099587 moveto +116.049382716049 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.049382716049 7.34583582582989 moveto +116.666666666667 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.666666666667 6.27666866066392 moveto +115.432098765432 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +115.432098765432 6.27666866066392 moveto +114.814814814815 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +114.814814814815 5.20750149549794 moveto +115.432098765432 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +115.432098765432 4.13833433033196 moveto +116.666666666667 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.666666666667 4.13833433033196 moveto +116.049382716049 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.049382716049 3.06916716516599 moveto +116.666666666667 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +116.666666666667 2 moveto +117.901234567901 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +117.901234567901 2 moveto +118.518518518518 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +118.518518518518 3.06916716516599 moveto +119.135802469136 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +119.135802469136 2 moveto +120.37037037037 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +120.37037037037 2 moveto +120.987654320988 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +120.987654320988 3.06916716516599 moveto +120.37037037037 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +120.37037037037 4.13833433033196 moveto +121.604938271605 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +121.604938271605 4.13833433033196 moveto +122.222222222222 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +122.222222222222 5.20750149549794 moveto +122.839506172839 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +122.839506172839 4.13833433033196 moveto +124.074074074074 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +124.074074074074 4.13833433033196 moveto +123.456790123457 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +123.456790123457 3.06916716516599 moveto +124.074074074074 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +124.074074074074 2 moveto +125.308641975308 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +125.308641975308 2 moveto +125.925925925926 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +125.925925925926 3.06916716516599 moveto +126.543209876543 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +126.543209876543 2 moveto +127.777777777778 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +127.777777777778 2 moveto +128.395061728395 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +128.395061728395 3.06916716516599 moveto +127.777777777778 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +127.777777777778 4.13833433033196 moveto +129.012345679012 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +129.012345679012 4.13833433033196 moveto +129.629629629629 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +129.629629629629 5.20750149549794 moveto +129.012345679012 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +129.012345679012 6.27666866066392 moveto +127.777777777778 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +127.777777777778 6.27666866066392 moveto +128.395061728395 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +128.395061728395 7.34583582582989 moveto +127.777777777778 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +127.777777777778 8.41500299099587 moveto +129.012345679012 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +129.012345679012 8.41500299099587 moveto +129.629629629629 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +129.629629629629 9.48417015616185 moveto +130.246913580247 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +130.246913580247 8.41500299099587 moveto +131.481481481481 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +131.481481481481 8.41500299099587 moveto +132.098765432099 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +132.098765432099 9.48417015616185 moveto +131.481481481481 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +131.481481481481 10.5533373213278 moveto +132.716049382716 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +132.716049382716 10.5533373213278 moveto +133.333333333333 11.6225044864938 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +133.333333333333 11.6225044864938 moveto +133.95061728395 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +133.95061728395 10.5533373213278 moveto +135.185185185185 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +135.185185185185 10.5533373213278 moveto +134.567901234568 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +134.567901234568 9.48417015616185 moveto +135.185185185185 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +135.185185185185 8.41500299099587 moveto +136.41975308642 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +136.41975308642 8.41500299099587 moveto +137.037037037037 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +137.037037037037 9.48417015616185 moveto +137.654320987654 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +137.654320987654 8.41500299099587 moveto +138.888888888889 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +138.888888888889 8.41500299099587 moveto +138.271604938271 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +138.271604938271 7.34583582582989 moveto +138.888888888889 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +138.888888888889 6.27666866066392 moveto +137.654320987654 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +137.654320987654 6.27666866066392 moveto +137.037037037037 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +137.037037037037 5.20750149549794 moveto +137.654320987654 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +137.654320987654 4.13833433033196 moveto +138.888888888889 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +138.888888888889 4.13833433033196 moveto +138.271604938271 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +138.271604938271 3.06916716516599 moveto +138.888888888889 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +138.888888888889 2 moveto +140.123456790123 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +140.123456790123 2 moveto +140.740740740741 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +140.740740740741 3.06916716516599 moveto +141.358024691358 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +141.358024691358 2 moveto +142.592592592592 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +142.592592592592 2 moveto +143.20987654321 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +143.20987654321 3.06916716516599 moveto +142.592592592592 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +142.592592592592 4.13833433033196 moveto +143.827160493827 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +143.827160493827 4.13833433033196 moveto +144.444444444444 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +144.444444444444 5.20750149549794 moveto +145.061728395062 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +145.061728395062 4.13833433033196 moveto +146.296296296296 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +146.296296296296 4.13833433033196 moveto +145.679012345679 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +145.679012345679 3.06916716516599 moveto +146.296296296296 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +146.296296296296 2 moveto +147.530864197531 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +147.530864197531 2 moveto +148.148148148148 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +148.148148148148 3.06916716516599 moveto +148.765432098765 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +148.765432098765 2 moveto +150 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 2 moveto +150.617283950617 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150.617283950617 3.06916716516599 moveto +150 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 4.13833433033196 moveto +151.234567901234 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 4.13833433033196 moveto +151.851851851852 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 5.20750149549794 moveto +151.234567901234 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 6.27666866066392 moveto +150 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 6.27666866066392 moveto +150.617283950617 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150.617283950617 7.34583582582989 moveto +150 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 8.41500299099587 moveto +151.234567901234 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 8.41500299099587 moveto +151.851851851852 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 9.48417015616185 moveto +152.469135802469 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +152.469135802469 8.41500299099587 moveto +153.703703703704 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 8.41500299099587 moveto +154.320987654321 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.320987654321 9.48417015616185 moveto +153.703703703704 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 10.5533373213278 moveto +154.938271604938 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.938271604938 10.5533373213278 moveto +155.555555555555 11.6225044864938 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +155.555555555555 11.6225044864938 moveto +154.938271604938 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.938271604938 12.6916716516598 moveto +153.703703703704 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 12.6916716516598 moveto +154.320987654321 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.320987654321 13.7608388168258 moveto +153.703703703704 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 14.8300059819917 moveto +152.469135802469 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +152.469135802469 14.8300059819917 moveto +151.851851851852 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 13.7608388168258 moveto +151.234567901234 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 14.8300059819917 moveto +150 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 14.8300059819917 moveto +150.617283950617 15.8991731471577 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150.617283950617 15.8991731471577 moveto +150 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 16.9683403123237 moveto +151.234567901234 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 16.9683403123237 moveto +151.851851851852 18.0375074774897 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 18.0375074774897 moveto +151.234567901234 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 19.1066746426557 moveto +150 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 19.1066746426557 moveto +150.617283950617 20.1758418078216 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150.617283950617 20.1758418078216 moveto +150 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 21.2450089729876 moveto +151.234567901234 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 21.2450089729876 moveto +151.851851851852 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 22.3141761381536 moveto +152.469135802469 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +152.469135802469 21.2450089729876 moveto +153.703703703704 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 21.2450089729876 moveto +154.320987654321 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.320987654321 22.3141761381536 moveto +153.703703703704 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 23.3833433033196 moveto +154.938271604938 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.938271604938 23.3833433033196 moveto +155.555555555555 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +155.555555555555 24.4525104684856 moveto +156.172839506173 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +156.172839506173 23.3833433033196 moveto +157.407407407407 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +157.407407407407 23.3833433033196 moveto +156.79012345679 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +156.79012345679 22.3141761381536 moveto +157.407407407407 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +157.407407407407 21.2450089729876 moveto +158.641975308642 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +158.641975308642 21.2450089729876 moveto +159.259259259259 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +159.259259259259 22.3141761381536 moveto +159.876543209876 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +159.876543209876 21.2450089729876 moveto +161.111111111111 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 21.2450089729876 moveto +161.728395061728 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.728395061728 22.3141761381536 moveto +161.111111111111 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 23.3833433033196 moveto +162.345679012346 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.345679012346 23.3833433033196 moveto +162.962962962963 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.962962962963 24.4525104684856 moveto +162.345679012346 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.345679012346 25.5216776336515 moveto +161.111111111111 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 25.5216776336515 moveto +161.728395061728 26.5908447988175 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.728395061728 26.5908447988175 moveto +161.111111111111 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 27.6600119639835 moveto +162.345679012346 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.345679012346 27.6600119639835 moveto +162.962962962963 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.962962962963 28.7291791291495 moveto +163.58024691358 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +163.58024691358 27.6600119639835 moveto +164.814814814815 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +164.814814814815 27.6600119639835 moveto +165.432098765432 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +165.432098765432 28.7291791291495 moveto +164.814814814815 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +164.814814814815 29.7983462943155 moveto +166.049382716049 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +166.049382716049 29.7983462943155 moveto +166.666666666667 30.8675134594814 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +166.666666666667 30.8675134594814 moveto +166.049382716049 31.9366806246474 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +166.049382716049 31.9366806246474 moveto +164.814814814815 31.9366806246474 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +164.814814814815 31.9366806246474 moveto +165.432098765432 33.0058477898134 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +165.432098765432 33.0058477898134 moveto +164.814814814815 34.0750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +164.814814814815 34.0750149549794 moveto +163.58024691358 34.0750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +163.58024691358 34.0750149549794 moveto +162.962962962963 33.0058477898134 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.962962962963 33.0058477898134 moveto +162.345679012346 34.0750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.345679012346 34.0750149549794 moveto +161.111111111111 34.0750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 34.0750149549794 moveto +161.728395061728 35.1441821201453 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.728395061728 35.1441821201453 moveto +161.111111111111 36.2133492853113 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 36.2133492853113 moveto +162.345679012346 36.2133492853113 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.345679012346 36.2133492853113 moveto +162.962962962963 37.2825164504773 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.962962962963 37.2825164504773 moveto +162.345679012346 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.345679012346 38.3516836156433 moveto +161.111111111111 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 38.3516836156433 moveto +161.728395061728 39.4208507808093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.728395061728 39.4208507808093 moveto +161.111111111111 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 40.4900179459752 moveto +159.876543209876 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +159.876543209876 40.4900179459752 moveto +159.259259259259 39.4208507808093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +159.259259259259 39.4208507808093 moveto +158.641975308642 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +158.641975308642 40.4900179459752 moveto +157.407407407407 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +157.407407407407 40.4900179459752 moveto +156.79012345679 39.4208507808093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +156.79012345679 39.4208507808093 moveto +157.407407407407 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +157.407407407407 38.3516836156433 moveto +156.172839506173 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +156.172839506173 38.3516836156433 moveto +155.555555555555 37.2825164504773 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +155.555555555555 37.2825164504773 moveto +154.938271604938 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.938271604938 38.3516836156433 moveto +153.703703703704 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 38.3516836156433 moveto +154.320987654321 39.4208507808093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.320987654321 39.4208507808093 moveto +153.703703703704 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 40.4900179459752 moveto +152.469135802469 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +152.469135802469 40.4900179459752 moveto +151.851851851852 39.4208507808093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 39.4208507808093 moveto +151.234567901234 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 40.4900179459752 moveto +150 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 40.4900179459752 moveto +150.617283950617 41.5591851111412 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150.617283950617 41.5591851111412 moveto +150 42.6283522763072 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 42.6283522763072 moveto +151.234567901234 42.6283522763072 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 42.6283522763072 moveto +151.851851851852 43.6975194414731 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 43.6975194414731 moveto +151.234567901234 44.7666866066391 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 44.7666866066391 moveto +150 44.7666866066391 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 44.7666866066391 moveto +150.617283950617 45.8358537718051 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150.617283950617 45.8358537718051 moveto +150 46.905020936971 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 46.905020936971 moveto +151.234567901234 46.905020936971 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 46.905020936971 moveto +151.851851851852 47.974188102137 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 47.974188102137 moveto +152.469135802469 46.905020936971 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +152.469135802469 46.905020936971 moveto +153.703703703704 46.905020936971 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 46.905020936971 moveto +154.320987654321 47.974188102137 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.320987654321 47.974188102137 moveto +153.703703703704 49.043355267303 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 49.043355267303 moveto +154.938271604938 49.043355267303 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.938271604938 49.043355267303 moveto +155.555555555555 50.1125224324689 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +155.555555555555 50.1125224324689 moveto +154.938271604938 51.1816895976349 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.938271604938 51.1816895976349 moveto +153.703703703704 51.1816895976349 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 51.1816895976349 moveto +154.320987654321 52.2508567628009 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.320987654321 52.2508567628009 moveto +153.703703703704 53.3200239279668 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 53.3200239279668 moveto +152.469135802469 53.3200239279668 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +152.469135802469 53.3200239279668 moveto +151.851851851852 52.2508567628009 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 52.2508567628009 moveto +151.234567901234 53.3200239279668 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 53.3200239279668 moveto +150 53.3200239279668 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 53.3200239279668 moveto +150.617283950617 54.3891910931328 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150.617283950617 54.3891910931328 moveto +150 55.4583582582987 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 55.4583582582987 moveto +151.234567901234 55.4583582582987 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 55.4583582582987 moveto +151.851851851852 56.5275254234647 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 56.5275254234647 moveto +151.234567901234 57.5966925886307 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 57.5966925886307 moveto +150 57.5966925886307 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 57.5966925886307 moveto +150.617283950617 58.6658597537966 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150.617283950617 58.6658597537966 moveto +150 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +150 59.7350269189626 moveto +151.234567901234 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.234567901234 59.7350269189626 moveto +151.851851851852 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +151.851851851852 60.8041940841286 moveto +152.469135802469 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +152.469135802469 59.7350269189626 moveto +153.703703703704 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 59.7350269189626 moveto +154.320987654321 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.320987654321 60.8041940841286 moveto +153.703703703704 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +153.703703703704 61.8733612492945 moveto +154.938271604938 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +154.938271604938 61.8733612492945 moveto +155.555555555555 62.9425284144605 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +155.555555555555 62.9425284144605 moveto +156.172839506173 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +156.172839506173 61.8733612492945 moveto +157.407407407407 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +157.407407407407 61.8733612492945 moveto +156.79012345679 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +156.79012345679 60.8041940841286 moveto +157.407407407407 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +157.407407407407 59.7350269189626 moveto +158.641975308642 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +158.641975308642 59.7350269189626 moveto +159.259259259259 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +159.259259259259 60.8041940841286 moveto +159.876543209876 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +159.876543209876 59.7350269189626 moveto +161.111111111111 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 59.7350269189626 moveto +161.728395061728 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.728395061728 60.8041940841286 moveto +161.111111111111 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 61.8733612492945 moveto +162.345679012346 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.345679012346 61.8733612492945 moveto +162.962962962963 62.9425284144605 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.962962962963 62.9425284144605 moveto +162.345679012346 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.345679012346 64.0116955796265 moveto +161.111111111111 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 64.0116955796265 moveto +161.728395061728 65.0808627447924 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.728395061728 65.0808627447924 moveto +161.111111111111 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +161.111111111111 66.1500299099584 moveto +162.345679012346 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.345679012346 66.1500299099584 moveto +162.962962962963 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +162.962962962963 67.2191970751244 moveto +163.58024691358 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +163.58024691358 66.1500299099584 moveto +164.814814814815 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +164.814814814815 66.1500299099584 moveto +165.432098765432 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +165.432098765432 67.2191970751244 moveto +164.814814814815 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +164.814814814815 68.2883642402903 moveto +166.049382716049 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +166.049382716049 68.2883642402903 moveto +166.666666666667 69.3575314054563 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +166.666666666667 69.3575314054563 moveto +167.283950617284 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +167.283950617284 68.2883642402903 moveto +168.518518518518 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +168.518518518518 68.2883642402903 moveto +167.901234567901 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +167.901234567901 67.2191970751244 moveto +168.518518518518 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +168.518518518518 66.1500299099584 moveto +169.753086419753 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +169.753086419753 66.1500299099584 moveto +170.37037037037 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +170.37037037037 67.2191970751244 moveto +170.987654320988 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +170.987654320988 66.1500299099584 moveto +172.222222222222 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +172.222222222222 66.1500299099584 moveto +171.604938271605 65.0808627447924 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +171.604938271605 65.0808627447924 moveto +172.222222222222 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +172.222222222222 64.0116955796265 moveto +170.987654320988 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +170.987654320988 64.0116955796265 moveto +170.37037037037 62.9425284144605 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +170.37037037037 62.9425284144605 moveto +170.987654320988 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +170.987654320988 61.8733612492945 moveto +172.222222222222 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +172.222222222222 61.8733612492945 moveto +171.604938271605 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +171.604938271605 60.8041940841286 moveto +172.222222222222 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +172.222222222222 59.7350269189626 moveto +173.456790123457 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +173.456790123457 59.7350269189626 moveto +174.074074074074 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +174.074074074074 60.8041940841286 moveto +174.691358024691 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +174.691358024691 59.7350269189626 moveto +175.925925925926 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +175.925925925926 59.7350269189626 moveto +176.543209876543 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +176.543209876543 60.8041940841286 moveto +175.925925925926 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +175.925925925926 61.8733612492945 moveto +177.16049382716 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +177.16049382716 61.8733612492945 moveto +177.777777777778 62.9425284144605 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +177.777777777778 62.9425284144605 moveto +178.395061728395 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +178.395061728395 61.8733612492945 moveto +179.62962962963 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +179.62962962963 61.8733612492945 moveto +179.012345679012 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +179.012345679012 60.8041940841286 moveto +179.62962962963 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +179.62962962963 59.7350269189626 moveto +180.864197530864 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +180.864197530864 59.7350269189626 moveto +181.481481481481 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +181.481481481481 60.8041940841286 moveto +182.098765432099 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +182.098765432099 59.7350269189626 moveto +183.333333333333 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.333333333333 59.7350269189626 moveto +183.950617283951 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.950617283951 60.8041940841286 moveto +183.333333333333 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.333333333333 61.8733612492945 moveto +184.567901234568 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +184.567901234568 61.8733612492945 moveto +185.185185185185 62.9425284144605 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.185185185185 62.9425284144605 moveto +184.567901234568 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +184.567901234568 64.0116955796265 moveto +183.333333333333 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.333333333333 64.0116955796265 moveto +183.950617283951 65.0808627447924 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.950617283951 65.0808627447924 moveto +183.333333333333 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.333333333333 66.1500299099584 moveto +184.567901234568 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +184.567901234568 66.1500299099584 moveto +185.185185185185 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.185185185185 67.2191970751244 moveto +185.802469135802 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.802469135802 66.1500299099584 moveto +187.037037037037 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.037037037037 66.1500299099584 moveto +187.654320987654 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.654320987654 67.2191970751244 moveto +187.037037037037 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.037037037037 68.2883642402903 moveto +188.271604938272 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +188.271604938272 68.2883642402903 moveto +188.888888888889 69.3575314054563 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +188.888888888889 69.3575314054563 moveto +188.271604938272 70.4266985706222 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +188.271604938272 70.4266985706222 moveto +187.037037037037 70.4266985706222 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.037037037037 70.4266985706222 moveto +187.654320987654 71.4958657357882 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.654320987654 71.4958657357882 moveto +187.037037037037 72.5650329009542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.037037037037 72.5650329009542 moveto +185.802469135802 72.5650329009542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.802469135802 72.5650329009542 moveto +185.185185185185 71.4958657357882 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.185185185185 71.4958657357882 moveto +184.567901234568 72.5650329009542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +184.567901234568 72.5650329009542 moveto +183.333333333333 72.5650329009542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.333333333333 72.5650329009542 moveto +183.950617283951 73.6342000661201 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.950617283951 73.6342000661201 moveto +183.333333333333 74.7033672312861 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.333333333333 74.7033672312861 moveto +184.567901234568 74.7033672312861 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +184.567901234568 74.7033672312861 moveto +185.185185185185 75.7725343964521 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.185185185185 75.7725343964521 moveto +184.567901234568 76.841701561618 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +184.567901234568 76.841701561618 moveto +183.333333333333 76.841701561618 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.333333333333 76.841701561618 moveto +183.950617283951 77.910868726784 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.950617283951 77.910868726784 moveto +183.333333333333 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +183.333333333333 78.98003589195 moveto +184.567901234568 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +184.567901234568 78.98003589195 moveto +185.185185185185 80.0492030571159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.185185185185 80.0492030571159 moveto +185.802469135802 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +185.802469135802 78.98003589195 moveto +187.037037037037 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.037037037037 78.98003589195 moveto +187.654320987654 80.0492030571159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.654320987654 80.0492030571159 moveto +187.037037037037 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +187.037037037037 81.1183702222819 moveto +188.271604938272 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +188.271604938272 81.1183702222819 moveto +188.888888888889 82.1875373874479 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +188.888888888889 82.1875373874479 moveto +189.506172839506 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +189.506172839506 81.1183702222819 moveto +190.740740740741 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +190.740740740741 81.1183702222819 moveto +190.123456790123 80.0492030571159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +190.123456790123 80.0492030571159 moveto +190.740740740741 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +190.740740740741 78.98003589195 moveto +191.975308641975 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +191.975308641975 78.98003589195 moveto +192.592592592592 80.0492030571159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +192.592592592592 80.0492030571159 moveto +193.20987654321 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +193.20987654321 78.98003589195 moveto +194.444444444444 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +194.444444444444 78.98003589195 moveto +195.061728395062 80.0492030571159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +195.061728395062 80.0492030571159 moveto +194.444444444444 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +194.444444444444 81.1183702222819 moveto +195.679012345679 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +195.679012345679 81.1183702222819 moveto +196.296296296296 82.1875373874479 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.296296296296 82.1875373874479 moveto +195.679012345679 83.2567045526138 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +195.679012345679 83.2567045526138 moveto +194.444444444444 83.2567045526138 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +194.444444444444 83.2567045526138 moveto +195.061728395062 84.3258717177798 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +195.061728395062 84.3258717177798 moveto +194.444444444444 85.3950388829458 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +194.444444444444 85.3950388829458 moveto +195.679012345679 85.3950388829458 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +195.679012345679 85.3950388829458 moveto +196.296296296296 86.4642060481117 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.296296296296 86.4642060481117 moveto +196.913580246913 85.3950388829458 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +196.913580246913 85.3950388829458 moveto +198.148148148148 85.3950388829458 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +198.148148148148 85.3950388829458 moveto +198.765432098765 86.4642060481117 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +198.765432098765 86.4642060481117 moveto +198.148148148148 87.5333732132777 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +198.148148148148 87.5333732132777 moveto +199.382716049383 87.5333732132777 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +199.382716049383 87.5333732132777 moveto +200 88.6025403784436 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200 88.6025403784436 moveto +200.617283950617 87.5333732132777 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +200.617283950617 87.5333732132777 moveto +201.851851851852 87.5333732132777 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +201.851851851852 87.5333732132777 moveto +201.234567901234 86.4642060481117 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +201.234567901234 86.4642060481117 moveto +201.851851851852 85.3950388829458 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +201.851851851852 85.3950388829458 moveto +203.086419753086 85.3950388829458 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.086419753086 85.3950388829458 moveto +203.703703703704 86.4642060481117 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.703703703704 86.4642060481117 moveto +204.320987654321 85.3950388829458 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +204.320987654321 85.3950388829458 moveto +205.555555555555 85.3950388829458 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +205.555555555555 85.3950388829458 moveto +204.938271604938 84.3258717177798 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +204.938271604938 84.3258717177798 moveto +205.555555555555 83.2567045526138 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +205.555555555555 83.2567045526138 moveto +204.320987654321 83.2567045526138 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +204.320987654321 83.2567045526138 moveto +203.703703703704 82.1875373874479 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +203.703703703704 82.1875373874479 moveto +204.320987654321 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +204.320987654321 81.1183702222819 moveto +205.555555555555 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +205.555555555555 81.1183702222819 moveto +204.938271604938 80.0492030571159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +204.938271604938 80.0492030571159 moveto +205.555555555555 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +205.555555555555 78.98003589195 moveto +206.79012345679 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +206.79012345679 78.98003589195 moveto +207.407407407407 80.0492030571159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +207.407407407407 80.0492030571159 moveto +208.024691358025 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +208.024691358025 78.98003589195 moveto +209.259259259259 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +209.259259259259 78.98003589195 moveto +209.876543209876 80.0492030571159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +209.876543209876 80.0492030571159 moveto +209.259259259259 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +209.259259259259 81.1183702222819 moveto +210.493827160494 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +210.493827160494 81.1183702222819 moveto +211.111111111111 82.1875373874479 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +211.111111111111 82.1875373874479 moveto +211.728395061728 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +211.728395061728 81.1183702222819 moveto +212.962962962963 81.1183702222819 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.962962962963 81.1183702222819 moveto +212.345679012346 80.0492030571159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.345679012346 80.0492030571159 moveto +212.962962962963 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.962962962963 78.98003589195 moveto +214.197530864197 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.197530864197 78.98003589195 moveto +214.814814814815 80.0492030571159 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.814814814815 80.0492030571159 moveto +215.432098765432 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +215.432098765432 78.98003589195 moveto +216.666666666667 78.98003589195 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.666666666667 78.98003589195 moveto +216.049382716049 77.910868726784 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.049382716049 77.910868726784 moveto +216.666666666667 76.841701561618 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.666666666667 76.841701561618 moveto +215.432098765432 76.841701561618 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +215.432098765432 76.841701561618 moveto +214.814814814815 75.7725343964521 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.814814814815 75.7725343964521 moveto +215.432098765432 74.7033672312861 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +215.432098765432 74.7033672312861 moveto +216.666666666667 74.7033672312861 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.666666666667 74.7033672312861 moveto +216.049382716049 73.6342000661201 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.049382716049 73.6342000661201 moveto +216.666666666667 72.5650329009542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.666666666667 72.5650329009542 moveto +215.432098765432 72.5650329009542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +215.432098765432 72.5650329009542 moveto +214.814814814815 71.4958657357882 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.814814814815 71.4958657357882 moveto +214.197530864197 72.5650329009542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.197530864197 72.5650329009542 moveto +212.962962962963 72.5650329009542 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.962962962963 72.5650329009542 moveto +212.345679012346 71.4958657357882 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.345679012346 71.4958657357882 moveto +212.962962962963 70.4266985706222 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.962962962963 70.4266985706222 moveto +211.728395061728 70.4266985706222 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +211.728395061728 70.4266985706222 moveto +211.111111111111 69.3575314054563 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +211.111111111111 69.3575314054563 moveto +211.728395061728 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +211.728395061728 68.2883642402903 moveto +212.962962962963 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.962962962963 68.2883642402903 moveto +212.345679012346 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.345679012346 67.2191970751244 moveto +212.962962962963 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +212.962962962963 66.1500299099584 moveto +214.197530864197 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.197530864197 66.1500299099584 moveto +214.814814814815 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.814814814815 67.2191970751244 moveto +215.432098765432 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +215.432098765432 66.1500299099584 moveto +216.666666666667 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.666666666667 66.1500299099584 moveto +216.049382716049 65.0808627447924 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.049382716049 65.0808627447924 moveto +216.666666666667 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.666666666667 64.0116955796265 moveto +215.432098765432 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +215.432098765432 64.0116955796265 moveto +214.814814814815 62.9425284144605 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +214.814814814815 62.9425284144605 moveto +215.432098765432 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +215.432098765432 61.8733612492945 moveto +216.666666666667 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.666666666667 61.8733612492945 moveto +216.049382716049 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.049382716049 60.8041940841286 moveto +216.666666666667 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +216.666666666667 59.7350269189626 moveto +217.901234567901 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +217.901234567901 59.7350269189626 moveto +218.518518518518 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +218.518518518518 60.8041940841286 moveto +219.135802469136 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +219.135802469136 59.7350269189626 moveto +220.37037037037 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +220.37037037037 59.7350269189626 moveto +220.987654320988 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +220.987654320988 60.8041940841286 moveto +220.37037037037 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +220.37037037037 61.8733612492945 moveto +221.604938271605 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +221.604938271605 61.8733612492945 moveto +222.222222222222 62.9425284144605 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +222.222222222222 62.9425284144605 moveto +222.839506172839 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +222.839506172839 61.8733612492945 moveto +224.074074074074 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +224.074074074074 61.8733612492945 moveto +223.456790123457 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +223.456790123457 60.8041940841286 moveto +224.074074074074 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +224.074074074074 59.7350269189626 moveto +225.308641975309 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +225.308641975309 59.7350269189626 moveto +225.925925925926 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +225.925925925926 60.8041940841286 moveto +226.543209876543 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +226.543209876543 59.7350269189626 moveto +227.777777777778 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +227.777777777778 59.7350269189626 moveto +228.395061728395 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +228.395061728395 60.8041940841286 moveto +227.777777777778 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +227.777777777778 61.8733612492945 moveto +229.012345679012 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +229.012345679012 61.8733612492945 moveto +229.62962962963 62.9425284144605 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +229.62962962963 62.9425284144605 moveto +229.012345679012 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +229.012345679012 64.0116955796265 moveto +227.777777777778 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +227.777777777778 64.0116955796265 moveto +228.395061728395 65.0808627447924 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +228.395061728395 65.0808627447924 moveto +227.777777777778 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +227.777777777778 66.1500299099584 moveto +229.012345679012 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +229.012345679012 66.1500299099584 moveto +229.62962962963 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +229.62962962963 67.2191970751244 moveto +230.246913580247 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +230.246913580247 66.1500299099584 moveto +231.481481481481 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +231.481481481481 66.1500299099584 moveto +232.098765432099 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +232.098765432099 67.2191970751244 moveto +231.481481481481 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +231.481481481481 68.2883642402903 moveto +232.716049382716 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +232.716049382716 68.2883642402903 moveto +233.333333333333 69.3575314054563 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +233.333333333333 69.3575314054563 moveto +233.950617283951 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +233.950617283951 68.2883642402903 moveto +235.185185185185 68.2883642402903 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +235.185185185185 68.2883642402903 moveto +234.567901234568 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +234.567901234568 67.2191970751244 moveto +235.185185185185 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +235.185185185185 66.1500299099584 moveto +236.41975308642 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +236.41975308642 66.1500299099584 moveto +237.037037037037 67.2191970751244 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.037037037037 67.2191970751244 moveto +237.654320987654 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.654320987654 66.1500299099584 moveto +238.888888888889 66.1500299099584 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 66.1500299099584 moveto +238.271604938272 65.0808627447924 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.271604938272 65.0808627447924 moveto +238.888888888889 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 64.0116955796265 moveto +237.654320987654 64.0116955796265 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.654320987654 64.0116955796265 moveto +237.037037037037 62.9425284144605 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.037037037037 62.9425284144605 moveto +237.654320987654 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.654320987654 61.8733612492945 moveto +238.888888888889 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 61.8733612492945 moveto +238.271604938272 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.271604938272 60.8041940841286 moveto +238.888888888889 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 59.7350269189626 moveto +240.123456790123 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +240.123456790123 59.7350269189626 moveto +240.740740740741 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +240.740740740741 60.8041940841286 moveto +241.358024691358 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +241.358024691358 59.7350269189626 moveto +242.592592592593 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +242.592592592593 59.7350269189626 moveto +243.20987654321 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +243.20987654321 60.8041940841286 moveto +242.592592592593 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +242.592592592593 61.8733612492945 moveto +243.827160493827 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +243.827160493827 61.8733612492945 moveto +244.444444444444 62.9425284144605 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +244.444444444444 62.9425284144605 moveto +245.061728395062 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.061728395062 61.8733612492945 moveto +246.296296296296 61.8733612492945 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 61.8733612492945 moveto +245.679012345679 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.679012345679 60.8041940841286 moveto +246.296296296296 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 59.7350269189626 moveto +247.530864197531 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +247.530864197531 59.7350269189626 moveto +248.148148148148 60.8041940841286 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 60.8041940841286 moveto +248.765432098765 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 59.7350269189626 moveto +250 59.7350269189626 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 59.7350269189626 moveto +249.382716049383 58.6658597537966 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.382716049383 58.6658597537966 moveto +250 57.5966925886307 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 57.5966925886307 moveto +248.765432098765 57.5966925886307 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 57.5966925886307 moveto +248.148148148148 56.5275254234647 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 56.5275254234647 moveto +248.765432098765 55.4583582582987 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 55.4583582582987 moveto +250 55.4583582582987 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 55.4583582582987 moveto +249.382716049383 54.3891910931328 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.382716049383 54.3891910931328 moveto +250 53.3200239279668 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 53.3200239279668 moveto +248.765432098765 53.3200239279668 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 53.3200239279668 moveto +248.148148148148 52.2508567628009 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 52.2508567628009 moveto +247.530864197531 53.3200239279668 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +247.530864197531 53.3200239279668 moveto +246.296296296296 53.3200239279668 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 53.3200239279668 moveto +245.679012345679 52.2508567628009 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.679012345679 52.2508567628009 moveto +246.296296296296 51.1816895976349 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 51.1816895976349 moveto +245.061728395062 51.1816895976349 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.061728395062 51.1816895976349 moveto +244.444444444444 50.1125224324689 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +244.444444444444 50.1125224324689 moveto +245.061728395062 49.043355267303 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.061728395062 49.043355267303 moveto +246.296296296296 49.043355267303 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 49.043355267303 moveto +245.679012345679 47.974188102137 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.679012345679 47.974188102137 moveto +246.296296296296 46.905020936971 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 46.905020936971 moveto +247.530864197531 46.905020936971 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +247.530864197531 46.905020936971 moveto +248.148148148148 47.974188102137 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 47.974188102137 moveto +248.765432098765 46.905020936971 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 46.905020936971 moveto +250 46.905020936971 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 46.905020936971 moveto +249.382716049383 45.8358537718051 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.382716049383 45.8358537718051 moveto +250 44.7666866066391 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 44.7666866066391 moveto +248.765432098765 44.7666866066391 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 44.7666866066391 moveto +248.148148148148 43.6975194414731 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 43.6975194414731 moveto +248.765432098765 42.6283522763072 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 42.6283522763072 moveto +250 42.6283522763072 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 42.6283522763072 moveto +249.382716049383 41.5591851111412 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.382716049383 41.5591851111412 moveto +250 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 40.4900179459752 moveto +248.765432098765 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 40.4900179459752 moveto +248.148148148148 39.4208507808093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 39.4208507808093 moveto +247.530864197531 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +247.530864197531 40.4900179459752 moveto +246.296296296296 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 40.4900179459752 moveto +245.679012345679 39.4208507808093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.679012345679 39.4208507808093 moveto +246.296296296296 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 38.3516836156433 moveto +245.061728395062 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.061728395062 38.3516836156433 moveto +244.444444444444 37.2825164504773 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +244.444444444444 37.2825164504773 moveto +243.827160493827 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +243.827160493827 38.3516836156433 moveto +242.592592592593 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +242.592592592593 38.3516836156433 moveto +243.20987654321 39.4208507808093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +243.20987654321 39.4208507808093 moveto +242.592592592593 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +242.592592592593 40.4900179459752 moveto +241.358024691358 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +241.358024691358 40.4900179459752 moveto +240.740740740741 39.4208507808093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +240.740740740741 39.4208507808093 moveto +240.123456790123 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +240.123456790123 40.4900179459752 moveto +238.888888888889 40.4900179459752 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 40.4900179459752 moveto +238.271604938272 39.4208507808093 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.271604938272 39.4208507808093 moveto +238.888888888889 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 38.3516836156433 moveto +237.654320987654 38.3516836156433 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.654320987654 38.3516836156433 moveto +237.037037037037 37.2825164504773 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.037037037037 37.2825164504773 moveto +237.654320987654 36.2133492853113 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.654320987654 36.2133492853113 moveto +238.888888888889 36.2133492853113 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 36.2133492853113 moveto +238.271604938272 35.1441821201453 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.271604938272 35.1441821201453 moveto +238.888888888889 34.0750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 34.0750149549794 moveto +237.654320987654 34.0750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.654320987654 34.0750149549794 moveto +237.037037037037 33.0058477898134 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.037037037037 33.0058477898134 moveto +236.41975308642 34.0750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +236.41975308642 34.0750149549794 moveto +235.185185185185 34.0750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +235.185185185185 34.0750149549794 moveto +234.567901234568 33.0058477898134 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +234.567901234568 33.0058477898134 moveto +235.185185185185 31.9366806246474 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +235.185185185185 31.9366806246474 moveto +233.950617283951 31.9366806246474 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +233.950617283951 31.9366806246474 moveto +233.333333333333 30.8675134594814 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +233.333333333333 30.8675134594814 moveto +233.950617283951 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +233.950617283951 29.7983462943155 moveto +235.185185185185 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +235.185185185185 29.7983462943155 moveto +234.567901234568 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +234.567901234568 28.7291791291495 moveto +235.185185185185 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +235.185185185185 27.6600119639835 moveto +236.41975308642 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +236.41975308642 27.6600119639835 moveto +237.037037037037 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.037037037037 28.7291791291495 moveto +237.654320987654 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.654320987654 27.6600119639835 moveto +238.888888888889 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 27.6600119639835 moveto +238.271604938272 26.5908447988175 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.271604938272 26.5908447988175 moveto +238.888888888889 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 25.5216776336515 moveto +237.654320987654 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.654320987654 25.5216776336515 moveto +237.037037037037 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.037037037037 24.4525104684856 moveto +237.654320987654 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +237.654320987654 23.3833433033196 moveto +238.888888888889 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 23.3833433033196 moveto +238.271604938272 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.271604938272 22.3141761381536 moveto +238.888888888889 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +238.888888888889 21.2450089729876 moveto +240.123456790123 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +240.123456790123 21.2450089729876 moveto +240.740740740741 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +240.740740740741 22.3141761381536 moveto +241.358024691358 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +241.358024691358 21.2450089729876 moveto +242.592592592593 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +242.592592592593 21.2450089729876 moveto +243.20987654321 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +243.20987654321 22.3141761381536 moveto +242.592592592593 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +242.592592592593 23.3833433033196 moveto +243.827160493827 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +243.827160493827 23.3833433033196 moveto +244.444444444444 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +244.444444444444 24.4525104684856 moveto +245.061728395062 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.061728395062 23.3833433033196 moveto +246.296296296296 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 23.3833433033196 moveto +245.679012345679 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.679012345679 22.3141761381536 moveto +246.296296296296 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 21.2450089729876 moveto +247.530864197531 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +247.530864197531 21.2450089729876 moveto +248.148148148148 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 22.3141761381536 moveto +248.765432098765 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 21.2450089729876 moveto +250 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 21.2450089729876 moveto +249.382716049383 20.1758418078216 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.382716049383 20.1758418078216 moveto +250 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 19.1066746426557 moveto +248.765432098765 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 19.1066746426557 moveto +248.148148148148 18.0375074774897 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 18.0375074774897 moveto +248.765432098765 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 16.9683403123237 moveto +250 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 16.9683403123237 moveto +249.382716049383 15.8991731471577 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.382716049383 15.8991731471577 moveto +250 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 14.8300059819917 moveto +248.765432098765 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 14.8300059819917 moveto +248.148148148148 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 13.7608388168258 moveto +247.530864197531 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +247.530864197531 14.8300059819917 moveto +246.296296296296 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 14.8300059819917 moveto +245.679012345679 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.679012345679 13.7608388168258 moveto +246.296296296296 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 12.6916716516598 moveto +245.061728395062 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.061728395062 12.6916716516598 moveto +244.444444444444 11.6225044864938 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +244.444444444444 11.6225044864938 moveto +245.061728395062 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.061728395062 10.5533373213278 moveto +246.296296296296 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 10.5533373213278 moveto +245.679012345679 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +245.679012345679 9.48417015616185 moveto +246.296296296296 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +246.296296296296 8.41500299099587 moveto +247.530864197531 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +247.530864197531 8.41500299099587 moveto +248.148148148148 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 9.48417015616185 moveto +248.765432098765 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 8.41500299099587 moveto +250 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 8.41500299099587 moveto +249.382716049383 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.382716049383 7.34583582582989 moveto +250 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 6.27666866066392 moveto +248.765432098765 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 6.27666866066392 moveto +248.148148148148 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.148148148148 5.20750149549794 moveto +248.765432098765 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +248.765432098765 4.13833433033196 moveto +250 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 4.13833433033196 moveto +249.382716049383 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.382716049383 3.06916716516599 moveto +250 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 2 moveto +251.234567901235 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +251.234567901235 2 moveto +251.851851851852 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +251.851851851852 3.06916716516599 moveto +252.469135802469 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +252.469135802469 2 moveto +253.703703703704 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +253.703703703704 2 moveto +254.320987654321 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +254.320987654321 3.06916716516599 moveto +253.703703703704 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +253.703703703704 4.13833433033196 moveto +254.938271604938 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +254.938271604938 4.13833433033196 moveto +255.555555555556 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +255.555555555556 5.20750149549794 moveto +256.172839506173 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +256.172839506173 4.13833433033196 moveto +257.407407407407 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +257.407407407407 4.13833433033196 moveto +256.79012345679 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +256.79012345679 3.06916716516599 moveto +257.407407407407 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +257.407407407407 2 moveto +258.641975308642 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +258.641975308642 2 moveto +259.259259259259 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +259.259259259259 3.06916716516599 moveto +259.876543209877 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +259.876543209877 2 moveto +261.111111111111 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +261.111111111111 2 moveto +261.728395061728 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +261.728395061728 3.06916716516599 moveto +261.111111111111 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +261.111111111111 4.13833433033196 moveto +262.345679012346 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +262.345679012346 4.13833433033196 moveto +262.962962962963 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +262.962962962963 5.20750149549794 moveto +262.345679012346 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +262.345679012346 6.27666866066392 moveto +261.111111111111 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +261.111111111111 6.27666866066392 moveto +261.728395061728 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +261.728395061728 7.34583582582989 moveto +261.111111111111 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +261.111111111111 8.41500299099587 moveto +262.345679012346 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +262.345679012346 8.41500299099587 moveto +262.962962962963 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +262.962962962963 9.48417015616185 moveto +263.58024691358 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +263.58024691358 8.41500299099587 moveto +264.814814814815 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +264.814814814815 8.41500299099587 moveto +265.432098765432 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +265.432098765432 9.48417015616185 moveto +264.814814814815 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +264.814814814815 10.5533373213278 moveto +266.049382716049 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +266.049382716049 10.5533373213278 moveto +266.666666666667 11.6225044864938 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +266.666666666667 11.6225044864938 moveto +267.283950617284 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +267.283950617284 10.5533373213278 moveto +268.518518518519 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +268.518518518519 10.5533373213278 moveto +267.901234567901 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +267.901234567901 9.48417015616185 moveto +268.518518518519 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +268.518518518519 8.41500299099587 moveto +269.753086419753 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +269.753086419753 8.41500299099587 moveto +270.37037037037 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +270.37037037037 9.48417015616185 moveto +270.987654320988 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +270.987654320988 8.41500299099587 moveto +272.222222222222 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +272.222222222222 8.41500299099587 moveto +271.604938271605 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +271.604938271605 7.34583582582989 moveto +272.222222222222 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +272.222222222222 6.27666866066392 moveto +270.987654320988 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +270.987654320988 6.27666866066392 moveto +270.37037037037 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +270.37037037037 5.20750149549794 moveto +270.987654320988 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +270.987654320988 4.13833433033196 moveto +272.222222222222 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +272.222222222222 4.13833433033196 moveto +271.604938271605 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +271.604938271605 3.06916716516599 moveto +272.222222222222 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +272.222222222222 2 moveto +273.456790123457 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +273.456790123457 2 moveto +274.074074074074 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +274.074074074074 3.06916716516599 moveto +274.691358024691 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +274.691358024691 2 moveto +275.925925925926 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +275.925925925926 2 moveto +276.543209876543 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +276.543209876543 3.06916716516599 moveto +275.925925925926 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +275.925925925926 4.13833433033196 moveto +277.160493827161 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +277.160493827161 4.13833433033196 moveto +277.777777777778 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +277.777777777778 5.20750149549794 moveto +278.395061728395 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +278.395061728395 4.13833433033196 moveto +279.62962962963 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +279.62962962963 4.13833433033196 moveto +279.012345679012 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +279.012345679012 3.06916716516599 moveto +279.62962962963 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +279.62962962963 2 moveto +280.864197530864 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +280.864197530864 2 moveto +281.481481481481 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +281.481481481481 3.06916716516599 moveto +282.098765432099 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +282.098765432099 2 moveto +283.333333333333 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.333333333333 2 moveto +283.950617283951 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.950617283951 3.06916716516599 moveto +283.333333333333 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.333333333333 4.13833433033196 moveto +284.567901234568 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.567901234568 4.13833433033196 moveto +285.185185185185 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +285.185185185185 5.20750149549794 moveto +284.567901234568 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.567901234568 6.27666866066392 moveto +283.333333333333 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.333333333333 6.27666866066392 moveto +283.950617283951 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.950617283951 7.34583582582989 moveto +283.333333333333 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.333333333333 8.41500299099587 moveto +284.567901234568 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.567901234568 8.41500299099587 moveto +285.185185185185 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +285.185185185185 9.48417015616185 moveto +285.802469135802 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +285.802469135802 8.41500299099587 moveto +287.037037037037 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.037037037037 8.41500299099587 moveto +287.654320987654 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.654320987654 9.48417015616185 moveto +287.037037037037 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.037037037037 10.5533373213278 moveto +288.271604938272 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.271604938272 10.5533373213278 moveto +288.888888888889 11.6225044864938 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.888888888889 11.6225044864938 moveto +288.271604938272 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.271604938272 12.6916716516598 moveto +287.037037037037 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.037037037037 12.6916716516598 moveto +287.654320987654 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.654320987654 13.7608388168258 moveto +287.037037037037 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.037037037037 14.8300059819917 moveto +285.802469135802 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +285.802469135802 14.8300059819917 moveto +285.185185185185 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +285.185185185185 13.7608388168258 moveto +284.567901234568 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.567901234568 14.8300059819917 moveto +283.333333333333 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.333333333333 14.8300059819917 moveto +283.950617283951 15.8991731471577 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.950617283951 15.8991731471577 moveto +283.333333333333 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.333333333333 16.9683403123237 moveto +284.567901234568 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.567901234568 16.9683403123237 moveto +285.185185185185 18.0375074774897 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +285.185185185185 18.0375074774897 moveto +284.567901234568 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.567901234568 19.1066746426557 moveto +283.333333333333 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.333333333333 19.1066746426557 moveto +283.950617283951 20.1758418078216 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.950617283951 20.1758418078216 moveto +283.333333333333 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +283.333333333333 21.2450089729876 moveto +284.567901234568 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +284.567901234568 21.2450089729876 moveto +285.185185185185 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +285.185185185185 22.3141761381536 moveto +285.802469135802 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +285.802469135802 21.2450089729876 moveto +287.037037037037 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.037037037037 21.2450089729876 moveto +287.654320987654 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.654320987654 22.3141761381536 moveto +287.037037037037 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +287.037037037037 23.3833433033196 moveto +288.271604938272 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.271604938272 23.3833433033196 moveto +288.888888888889 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +288.888888888889 24.4525104684856 moveto +289.506172839506 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +289.506172839506 23.3833433033196 moveto +290.740740740741 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +290.740740740741 23.3833433033196 moveto +290.123456790123 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +290.123456790123 22.3141761381536 moveto +290.740740740741 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +290.740740740741 21.2450089729876 moveto +291.975308641975 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +291.975308641975 21.2450089729876 moveto +292.592592592593 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +292.592592592593 22.3141761381536 moveto +293.20987654321 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +293.20987654321 21.2450089729876 moveto +294.444444444444 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.444444444444 21.2450089729876 moveto +295.061728395062 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.061728395062 22.3141761381536 moveto +294.444444444444 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.444444444444 23.3833433033196 moveto +295.679012345679 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.679012345679 23.3833433033196 moveto +296.296296296296 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.296296296296 24.4525104684856 moveto +295.679012345679 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.679012345679 25.5216776336515 moveto +294.444444444444 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.444444444444 25.5216776336515 moveto +295.061728395062 26.5908447988175 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.061728395062 26.5908447988175 moveto +294.444444444444 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +294.444444444444 27.6600119639835 moveto +295.679012345679 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +295.679012345679 27.6600119639835 moveto +296.296296296296 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.296296296296 28.7291791291495 moveto +296.913580246914 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +296.913580246914 27.6600119639835 moveto +298.148148148148 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.148148148148 27.6600119639835 moveto +298.765432098765 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.765432098765 28.7291791291495 moveto +298.148148148148 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +298.148148148148 29.7983462943155 moveto +299.382716049383 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +299.382716049383 29.7983462943155 moveto +300 30.8675134594814 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300 30.8675134594814 moveto +300.617283950617 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +300.617283950617 29.7983462943155 moveto +301.851851851852 29.7983462943155 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.851851851852 29.7983462943155 moveto +301.234567901235 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.234567901235 28.7291791291495 moveto +301.851851851852 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +301.851851851852 27.6600119639835 moveto +303.086419753086 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.086419753086 27.6600119639835 moveto +303.703703703704 28.7291791291495 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.703703703704 28.7291791291495 moveto +304.320987654321 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.320987654321 27.6600119639835 moveto +305.555555555555 27.6600119639835 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.555555555555 27.6600119639835 moveto +304.938271604938 26.5908447988175 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.938271604938 26.5908447988175 moveto +305.555555555555 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.555555555555 25.5216776336515 moveto +304.320987654321 25.5216776336515 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.320987654321 25.5216776336515 moveto +303.703703703704 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +303.703703703704 24.4525104684856 moveto +304.320987654321 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.320987654321 23.3833433033196 moveto +305.555555555555 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.555555555555 23.3833433033196 moveto +304.938271604938 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +304.938271604938 22.3141761381536 moveto +305.555555555555 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +305.555555555555 21.2450089729876 moveto +306.79012345679 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +306.79012345679 21.2450089729876 moveto +307.407407407407 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +307.407407407407 22.3141761381536 moveto +308.024691358025 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +308.024691358025 21.2450089729876 moveto +309.259259259259 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +309.259259259259 21.2450089729876 moveto +309.876543209876 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +309.876543209876 22.3141761381536 moveto +309.259259259259 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +309.259259259259 23.3833433033196 moveto +310.493827160494 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +310.493827160494 23.3833433033196 moveto +311.111111111111 24.4525104684856 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.111111111111 24.4525104684856 moveto +311.728395061728 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.728395061728 23.3833433033196 moveto +312.962962962963 23.3833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.962962962963 23.3833433033196 moveto +312.345679012346 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.345679012346 22.3141761381536 moveto +312.962962962963 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.962962962963 21.2450089729876 moveto +314.197530864197 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +314.197530864197 21.2450089729876 moveto +314.814814814815 22.3141761381536 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +314.814814814815 22.3141761381536 moveto +315.432098765432 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.432098765432 21.2450089729876 moveto +316.666666666667 21.2450089729876 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.666666666667 21.2450089729876 moveto +316.049382716049 20.1758418078216 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.049382716049 20.1758418078216 moveto +316.666666666667 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.666666666667 19.1066746426557 moveto +315.432098765432 19.1066746426557 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.432098765432 19.1066746426557 moveto +314.814814814815 18.0375074774897 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +314.814814814815 18.0375074774897 moveto +315.432098765432 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.432098765432 16.9683403123237 moveto +316.666666666667 16.9683403123237 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.666666666667 16.9683403123237 moveto +316.049382716049 15.8991731471577 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.049382716049 15.8991731471577 moveto +316.666666666667 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.666666666667 14.8300059819917 moveto +315.432098765432 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.432098765432 14.8300059819917 moveto +314.814814814815 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +314.814814814815 13.7608388168258 moveto +314.197530864197 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +314.197530864197 14.8300059819917 moveto +312.962962962963 14.8300059819917 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.962962962963 14.8300059819917 moveto +312.345679012346 13.7608388168258 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.345679012346 13.7608388168258 moveto +312.962962962963 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.962962962963 12.6916716516598 moveto +311.728395061728 12.6916716516598 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.728395061728 12.6916716516598 moveto +311.111111111111 11.6225044864938 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.111111111111 11.6225044864938 moveto +311.728395061728 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +311.728395061728 10.5533373213278 moveto +312.962962962963 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.962962962963 10.5533373213278 moveto +312.345679012346 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.345679012346 9.48417015616185 moveto +312.962962962963 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +312.962962962963 8.41500299099587 moveto +314.197530864197 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +314.197530864197 8.41500299099587 moveto +314.814814814815 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +314.814814814815 9.48417015616185 moveto +315.432098765432 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.432098765432 8.41500299099587 moveto +316.666666666667 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.666666666667 8.41500299099587 moveto +316.049382716049 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.049382716049 7.34583582582989 moveto +316.666666666667 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.666666666667 6.27666866066392 moveto +315.432098765432 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.432098765432 6.27666866066392 moveto +314.814814814815 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +314.814814814815 5.20750149549794 moveto +315.432098765432 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +315.432098765432 4.13833433033196 moveto +316.666666666667 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.666666666667 4.13833433033196 moveto +316.049382716049 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.049382716049 3.06916716516599 moveto +316.666666666667 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +316.666666666667 2 moveto +317.901234567901 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +317.901234567901 2 moveto +318.518518518518 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +318.518518518518 3.06916716516599 moveto +319.135802469136 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +319.135802469136 2 moveto +320.37037037037 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +320.37037037037 2 moveto +320.987654320988 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +320.987654320988 3.06916716516599 moveto +320.37037037037 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +320.37037037037 4.13833433033196 moveto +321.604938271605 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +321.604938271605 4.13833433033196 moveto +322.222222222222 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +322.222222222222 5.20750149549794 moveto +322.839506172839 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +322.839506172839 4.13833433033196 moveto +324.074074074074 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +324.074074074074 4.13833433033196 moveto +323.456790123457 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +323.456790123457 3.06916716516599 moveto +324.074074074074 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +324.074074074074 2 moveto +325.308641975309 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +325.308641975309 2 moveto +325.925925925926 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +325.925925925926 3.06916716516599 moveto +326.543209876543 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +326.543209876543 2 moveto +327.777777777778 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +327.777777777778 2 moveto +328.395061728395 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +328.395061728395 3.06916716516599 moveto +327.777777777778 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +327.777777777778 4.13833433033196 moveto +329.012345679012 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +329.012345679012 4.13833433033196 moveto +329.62962962963 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +329.62962962963 5.20750149549794 moveto +329.012345679012 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +329.012345679012 6.27666866066392 moveto +327.777777777778 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +327.777777777778 6.27666866066392 moveto +328.395061728395 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +328.395061728395 7.34583582582989 moveto +327.777777777778 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +327.777777777778 8.41500299099587 moveto +329.012345679012 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +329.012345679012 8.41500299099587 moveto +329.62962962963 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +329.62962962963 9.48417015616185 moveto +330.246913580247 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +330.246913580247 8.41500299099587 moveto +331.481481481481 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +331.481481481481 8.41500299099587 moveto +332.098765432099 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +332.098765432099 9.48417015616185 moveto +331.481481481481 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +331.481481481481 10.5533373213278 moveto +332.716049382716 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +332.716049382716 10.5533373213278 moveto +333.333333333333 11.6225044864938 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +333.333333333333 11.6225044864938 moveto +333.95061728395 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +333.95061728395 10.5533373213278 moveto +335.185185185185 10.5533373213278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +335.185185185185 10.5533373213278 moveto +334.567901234568 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +334.567901234568 9.48417015616185 moveto +335.185185185185 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +335.185185185185 8.41500299099587 moveto +336.41975308642 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +336.41975308642 8.41500299099587 moveto +337.037037037037 9.48417015616185 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +337.037037037037 9.48417015616185 moveto +337.654320987654 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +337.654320987654 8.41500299099587 moveto +338.888888888889 8.41500299099587 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +338.888888888889 8.41500299099587 moveto +338.271604938271 7.34583582582989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +338.271604938271 7.34583582582989 moveto +338.888888888889 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +338.888888888889 6.27666866066392 moveto +337.654320987654 6.27666866066392 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +337.654320987654 6.27666866066392 moveto +337.037037037037 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +337.037037037037 5.20750149549794 moveto +337.654320987654 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +337.654320987654 4.13833433033196 moveto +338.888888888889 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +338.888888888889 4.13833433033196 moveto +338.271604938271 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +338.271604938271 3.06916716516599 moveto +338.888888888889 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +338.888888888889 2 moveto +340.123456790123 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +340.123456790123 2 moveto +340.740740740741 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +340.740740740741 3.06916716516599 moveto +341.358024691358 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +341.358024691358 2 moveto +342.592592592592 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +342.592592592592 2 moveto +343.20987654321 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +343.20987654321 3.06916716516599 moveto +342.592592592592 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +342.592592592592 4.13833433033196 moveto +343.827160493827 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +343.827160493827 4.13833433033196 moveto +344.444444444444 5.20750149549794 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +344.444444444444 5.20750149549794 moveto +345.061728395062 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +345.061728395062 4.13833433033196 moveto +346.296296296296 4.13833433033196 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +346.296296296296 4.13833433033196 moveto +345.679012345679 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +345.679012345679 3.06916716516599 moveto +346.296296296296 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +346.296296296296 2 moveto +347.530864197531 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +347.530864197531 2 moveto +348.148148148148 3.06916716516599 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +348.148148148148 3.06916716516599 moveto +348.765432098765 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +348.765432098765 2 moveto +350 2 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +restore showpage + +%%Trailer +end +%%EOF diff --git a/attic/latex/figs/koch.pdf b/attic/latex/figs/koch.pdf new file mode 100644 index 0000000..4c8ad6d Binary files /dev/null and b/attic/latex/figs/koch.pdf differ diff --git a/attic/latex/figs/list1.eps b/attic/latex/figs/list1.eps new file mode 100644 index 0000000..c3a3e7d --- /dev/null +++ b/attic/latex/figs/list1.eps @@ -0,0 +1,166 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: list1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5-alpha7 +%%CreationDate: Thu Jan 3 09:32:30 2008 +%%For: downey@rocky (Allen Downey,,,) +%%BoundingBox: 0 0 218 42 +%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 42 moveto 0 0 lineto 218 0 lineto 218 42 lineto closepath clip newpath +-107.3 99.7 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 3825 975 m 5400 975 l 5400 1650 l 3825 1650 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1800 975 m 3375 975 l 3375 1650 l 1800 1650 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +4375 1413 m 4522 1375 l 4507 1317 l 4360 1355 l 4360 1355 l 4484 1354 l 4375 1413 l cp +eoclip +n 4125 1447 m + 4500 1350 l gs col0 s gr gr + +% arrowhead +n 4375 1413 m 4484 1354 l 4360 1355 l col0 s +% Polyline +gs clippath +4360 1259 m 4504 1308 l 4523 1251 l 4380 1202 l 4380 1202 l 4484 1270 l 4360 1259 l cp +eoclip +n 4125 1147 m + 4500 1275 l gs col0 s gr gr + +% arrowhead +n 4360 1259 m 4484 1270 l 4380 1202 l col0 s +% Polyline +gs clippath +2338 1477 m 2490 1477 l 2490 1417 l 2338 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +2338 1177 m 2490 1177 l 2490 1117 l 2338 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +/Helvetica ff 183.33 scf sf +4050 1200 m +gs 1 -1 sc (a) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +4050 1500 m +gs 1 -1 sc (b) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +4575 1350 m +gs 1 -1 sc ('banana') col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1200 m +gs 1 -1 sc (a) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1500 m +gs 1 -1 sc (b) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1200 m +gs 1 -1 sc ('banana') col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1500 m +gs 1 -1 sc ('banana') col0 sh gr +% here ends figure; +$F2psEnd +rs +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/list1.fig b/attic/latex/figs/list1.fig new file mode 100644 index 0000000..57f0e00 --- /dev/null +++ b/attic/latex/figs/list1.fig @@ -0,0 +1,32 @@ +#FIG 3.2 Produced by xfig version 3.2.5-alpha5 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4125 1447 4500 1350 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4125 1147 4500 1275 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 3825 975 5400 975 5400 1650 3825 1650 3825 975 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 975 3375 975 3375 1650 1800 1650 1800 975 +4 2 0 50 0 16 11 0.0000 4 105 105 4050 1200 a\001 +4 2 0 50 0 16 11 0.0000 4 135 105 4050 1500 b\001 +4 0 0 50 0 16 11 0.0000 4 135 720 4575 1350 'banana'\001 +4 2 0 50 0 16 11 0.0000 4 105 105 2025 1200 a\001 +4 2 0 50 0 16 11 0.0000 4 135 105 2025 1500 b\001 +4 0 0 50 0 16 11 0.0000 4 135 720 2550 1200 'banana'\001 +4 0 0 50 0 16 11 0.0000 4 135 720 2550 1500 'banana'\001 diff --git a/attic/latex/figs/list1.pdf b/attic/latex/figs/list1.pdf new file mode 100644 index 0000000..fea00a3 Binary files /dev/null and b/attic/latex/figs/list1.pdf differ diff --git a/attic/latex/figs/list2.eps b/attic/latex/figs/list2.eps new file mode 100644 index 0000000..ebe15aa --- /dev/null +++ b/attic/latex/figs/list2.eps @@ -0,0 +1,128 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: list2.eps +%%Creator: fig2dev Version 3.2 Patchlevel 3c +%%CreationDate: Thu Dec 6 09:32:48 2001 +%%For: downey@rocky.wellesley.edu (Allen B. Downey) +%%BoundingBox: 0 0 97 43 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 43 moveto 0 0 lineto 97 0 lineto 97 43 lineto closepath clip newpath +-107.0 100.0 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +%%Page: 1 1 +10 setmiterlimit + 0.06000 0.06000 sc +% +% Fig objects follow +% +% Polyline +7.500 slw +n 1800 975 m 3375 975 l 3375 1650 l 1800 1650 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2490 1477 m 2490 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +2490 1177 m 2490 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +/Helvetica ff 165.00 scf sf +2025 1200 m +gs 1 -1 sc (a) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 1500 m +gs 1 -1 sc (b) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1200 m +gs 1 -1 sc ([ 1, 2, 3 ]) col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1500 m +gs 1 -1 sc ([ 1, 2, 3 ]) col0 sh gr +$F2psEnd +rs diff --git a/attic/latex/figs/list2.fig b/attic/latex/figs/list2.fig new file mode 100644 index 0000000..73d6dd0 --- /dev/null +++ b/attic/latex/figs/list2.fig @@ -0,0 +1,21 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 975 3375 975 3375 1650 1800 1650 1800 975 +4 2 0 50 0 16 11 0.0000 4 90 75 2025 1200 a\001 +4 2 0 50 0 16 11 0.0000 4 120 90 2025 1500 b\001 +4 0 0 50 0 16 11 0.0000 4 150 630 2550 1200 [ 1, 2, 3 ]\001 +4 0 0 50 0 16 11 0.0000 4 150 630 2550 1500 [ 1, 2, 3 ]\001 diff --git a/attic/latex/figs/list2.pdf b/attic/latex/figs/list2.pdf new file mode 100644 index 0000000..0d3d7e1 Binary files /dev/null and b/attic/latex/figs/list2.pdf differ diff --git a/attic/latex/figs/list3.eps b/attic/latex/figs/list3.eps new file mode 100644 index 0000000..dfec837 --- /dev/null +++ b/attic/latex/figs/list3.eps @@ -0,0 +1,140 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: list3.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5a +%%CreationDate: Tue May 22 16:12:59 2012 +%%BoundingBox: 0 0 96 42 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 42 moveto 0 0 lineto 96 0 lineto 96 42 lineto closepath clip newpath +-107.3 99.7 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 1800 975 m 3375 975 l 3375 1650 l 1800 1650 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2350 1413 m 2497 1375 l 2482 1317 l 2335 1355 l 2335 1355 l 2459 1354 l 2350 1413 l cp +eoclip +n 2100 1447 m + 2475 1350 l gs col0 s gr gr + +% arrowhead +n 2350 1413 m 2459 1354 l 2335 1355 l col0 s +% Polyline +gs clippath +2335 1259 m 2479 1308 l 2498 1251 l 2355 1202 l 2355 1202 l 2459 1270 l 2335 1259 l cp +eoclip +n 2100 1147 m + 2475 1275 l gs col0 s gr gr + +% arrowhead +n 2335 1259 m 2459 1270 l 2355 1202 l col0 s +/Helvetica ff 183.33 scf sf +2025 1200 m +gs 1 -1 sc (a) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1500 m +gs 1 -1 sc (b) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1350 m +gs 1 -1 sc ([ 1, 2, 3 ]) col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/list3.fig b/attic/latex/figs/list3.fig new file mode 100644 index 0000000..ae60d05 --- /dev/null +++ b/attic/latex/figs/list3.fig @@ -0,0 +1,20 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1350 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1275 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 975 3375 975 3375 1650 1800 1650 1800 975 +4 2 0 50 0 16 11 0.0000 4 90 75 2025 1200 a\001 +4 2 0 50 0 16 11 0.0000 4 120 90 2025 1500 b\001 +4 0 0 50 0 16 11 0.0000 4 150 630 2550 1350 [ 1, 2, 3 ]\001 diff --git a/attic/latex/figs/list3.pdf b/attic/latex/figs/list3.pdf new file mode 100644 index 0000000..edc5f89 Binary files /dev/null and b/attic/latex/figs/list3.pdf differ diff --git a/attic/latex/figs/liststate.eps b/attic/latex/figs/liststate.eps new file mode 100644 index 0000000..56544ee --- /dev/null +++ b/attic/latex/figs/liststate.eps @@ -0,0 +1,255 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: liststate.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5d +%%CreationDate: Mon Oct 19 10:23:07 2015 +%%BoundingBox: 0 0 218 204 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 204 moveto 0 0 lineto 218 0 lineto 218 204 lineto closepath clip newpath +-12.8 243.7 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 1650 3675 m 1950 3675 l 1950 3975 l 1650 3975 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1650 975 m 3675 975 l 3675 1950 l 1650 1950 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1650 2325 m 3225 2325 l 3225 3300 l 1650 3300 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2338 2527 m 2490 2527 l 2490 2467 l 2338 2467 l 2338 2467 l 2458 2497 l 2338 2527 l cp +eoclip +n 2100 2497 m + 2475 2497 l gs col0 s gr gr + +% arrowhead +n 2338 2527 m 2458 2497 l 2338 2467 l col0 s +% Polyline +gs clippath +1438 2505 m 1590 2505 l 1590 2445 l 1438 2445 l 1438 2445 l 1558 2475 l 1438 2505 l cp +eoclip +n 1200 2475 m + 1575 2475 l gs col0 s gr gr + +% arrowhead +n 1438 2505 m 1558 2475 l 1438 2445 l col0 s +% Polyline +gs clippath +2342 3029 m 2472 3108 l 2503 3056 l 2373 2978 l 2373 2978 l 2461 3066 l 2342 3029 l cp +eoclip +n 2100 2850 m + 2475 3075 l gs col0 s gr gr + +% arrowhead +n 2342 3029 m 2461 3066 l 2373 2978 l col0 s +% Polyline + [15 60] 60 sd +n 2100 2797 m + 2475 2797 l gs col0 s gr [] 0 sd +% Polyline +n 2550 2700 m + 2850 2850 l gs col0 s gr +% Polyline +n 2850 2700 m + 2550 2850 l gs col0 s gr +% Polyline +gs clippath +1438 3855 m 1590 3855 l 1590 3795 l 1438 3795 l 1438 3795 l 1558 3825 l 1438 3855 l cp +eoclip +n 1200 3825 m + 1575 3825 l gs col0 s gr gr + +% arrowhead +n 1438 3855 m 1558 3825 l 1438 3795 l col0 s +% Polyline +gs clippath +2338 1477 m 2490 1477 l 2490 1417 l 2338 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +2338 1777 m 2490 1777 l 2490 1717 l 2338 1717 l 2338 1717 l 2458 1747 l 2338 1777 l cp +eoclip +n 2100 1747 m + 2475 1747 l gs col0 s gr gr + +% arrowhead +n 2338 1777 m 2458 1747 l 2338 1717 l col0 s +% Polyline +gs clippath +2338 1177 m 2490 1177 l 2490 1117 l 2338 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +% Polyline +gs clippath +1438 1155 m 1590 1155 l 1590 1095 l 1438 1095 l 1438 1095 l 1558 1125 l 1438 1155 l cp +eoclip +n 1200 1125 m + 1575 1125 l gs col0 s gr gr + +% arrowhead +n 1438 1155 m 1558 1125 l 1438 1095 l col0 s +% Polyline +n 225 675 m 3825 675 l 3825 4050 l 225 4050 l + cp gs col7 s gr +/Helvetica ff 183.33 scf sf +2025 2550 m +gs 1 -1 sc (0) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 2850 m +gs 1 -1 sc (1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1650 2250 m +gs 1 -1 sc (list) col0 sh gr +/Helvetica ff 183.33 scf sf +1125 2550 m +gs 1 -1 sc (numbers) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 2850 m +gs 1 -1 sc (123) col0 sh gr +/Helvetica ff 183.33 scf sf +2550 3150 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 183.33 scf sf +1650 3600 m +gs 1 -1 sc (list) col0 sh gr +/Helvetica ff 183.33 scf sf +1125 3900 m +gs 1 -1 sc (empty) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1200 m +gs 1 -1 sc (0) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1500 m +gs 1 -1 sc (1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1800 m +gs 1 -1 sc (2) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1200 m +gs 1 -1 sc ('Cheddar') col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1500 m +gs 1 -1 sc ('Edam') col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1800 m +gs 1 -1 sc ('Gouda') col0 sh gr +/Helvetica ff 183.33 scf sf +1650 900 m +gs 1 -1 sc (list) col0 sh gr +/Helvetica ff 183.33 scf sf +1125 1200 m +gs 1 -1 sc (cheeses) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 2550 m +gs 1 -1 sc (42) col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/liststate.fig b/attic/latex/figs/liststate.fig new file mode 100644 index 0000000..79bb4cb --- /dev/null +++ b/attic/latex/figs/liststate.fig @@ -0,0 +1,64 @@ +#FIG 3.2 Produced by xfig version 3.2.5b +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 2497 2475 2497 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1200 2475 1575 2475 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 2850 2475 3075 +2 1 2 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 + 2100 2797 2475 2797 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 2550 2700 2850 2850 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 2850 2700 2550 2850 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1200 3825 1575 3825 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 3675 1950 3675 1950 3975 1650 3975 1650 3675 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 975 3675 975 3675 1950 1650 1950 1650 975 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1747 2475 1747 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1200 1125 1575 1125 +2 2 0 1 7 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 225 675 3825 675 3825 4050 225 4050 225 675 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 2325 3225 2325 3225 3300 1650 3300 1650 2325 +4 2 0 50 0 16 11 0.0000 4 120 105 2025 2550 0\001 +4 2 0 50 0 16 11 0.0000 4 120 105 2025 2850 1\001 +4 0 0 50 0 16 11 0.0000 4 135 225 1650 2250 list\001 +4 2 0 50 0 16 11 0.0000 4 135 720 1125 2550 numbers\001 +4 0 0 50 0 16 11 0.0000 4 120 315 2550 2850 123\001 +4 0 0 50 0 16 11 0.0000 4 120 105 2550 3150 5\001 +4 0 0 50 0 16 11 0.0000 4 135 225 1650 3600 list\001 +4 2 0 50 0 16 11 0.0000 4 165 495 1125 3900 empty\001 +4 2 0 50 0 16 11 0.0000 4 120 105 2025 1200 0\001 +4 2 0 50 0 16 11 0.0000 4 120 105 2025 1500 1\001 +4 2 0 50 0 16 11 0.0000 4 120 105 2025 1800 2\001 +4 0 0 50 0 16 11 0.0000 4 135 780 2550 1200 'Cheddar'\001 +4 0 0 50 0 16 11 0.0000 4 135 540 2550 1500 'Edam'\001 +4 0 0 50 0 16 11 0.0000 4 135 615 2550 1800 'Gouda'\001 +4 0 0 50 0 16 11 0.0000 4 135 225 1650 900 list\001 +4 2 0 50 0 16 11 0.0000 4 135 690 1125 1200 cheeses\001 +4 0 0 50 0 16 11 0.0000 4 120 210 2550 2550 42\001 diff --git a/attic/latex/figs/liststate.fig.bak b/attic/latex/figs/liststate.fig.bak new file mode 100644 index 0000000..55fcf23 --- /dev/null +++ b/attic/latex/figs/liststate.fig.bak @@ -0,0 +1,64 @@ +#FIG 3.2 Produced by xfig version 3.2.5 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 2497 2475 2497 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1200 2475 1575 2475 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 2850 2475 3075 +2 1 2 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 + 2100 2797 2475 2797 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 2550 2700 2850 2850 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 2850 2700 2550 2850 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 2325 3225 2325 3225 3300 1650 3300 1650 2325 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1200 3825 1575 3825 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 3675 1950 3675 1950 3975 1650 3975 1650 3675 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 975 3675 975 3675 1950 1650 1950 1650 975 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1747 2475 1747 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1200 1125 1575 1125 +2 2 0 1 7 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 225 675 3825 675 3825 4050 225 4050 225 675 +4 2 0 50 0 16 11 0.0000 4 135 105 2025 2550 0\001 +4 2 0 50 0 16 11 0.0000 4 135 105 2025 2850 1\001 +4 0 0 50 0 16 11 0.0000 4 135 225 1650 2250 list\001 +4 2 0 50 0 16 11 0.0000 4 135 705 1125 2550 numbers\001 +4 0 0 50 0 16 11 0.0000 4 135 210 2550 2550 17\001 +4 0 0 50 0 16 11 0.0000 4 135 315 2550 2850 123\001 +4 0 0 50 0 16 11 0.0000 4 135 105 2550 3150 5\001 +4 0 0 50 0 16 11 0.0000 4 135 225 1650 3600 list\001 +4 2 0 50 0 16 11 0.0000 4 180 495 1125 3900 empty\001 +4 2 0 50 0 16 11 0.0000 4 135 105 2025 1200 0\001 +4 2 0 50 0 16 11 0.0000 4 135 105 2025 1500 1\001 +4 2 0 50 0 16 11 0.0000 4 135 105 2025 1800 2\001 +4 0 0 50 0 16 11 0.0000 4 135 810 2550 1200 'Cheddar'\001 +4 0 0 50 0 16 11 0.0000 4 135 555 2550 1500 'Edam'\001 +4 0 0 50 0 16 11 0.0000 4 135 645 2550 1800 'Gouda'\001 +4 0 0 50 0 16 11 0.0000 4 135 225 1650 900 list\001 +4 2 0 50 0 16 11 0.0000 4 135 705 1125 1200 cheeses\001 diff --git a/attic/latex/figs/liststate.pdf b/attic/latex/figs/liststate.pdf new file mode 100644 index 0000000..0c4d6f5 Binary files /dev/null and b/attic/latex/figs/liststate.pdf differ diff --git a/attic/latex/figs/listsum1.eps b/attic/latex/figs/listsum1.eps new file mode 100644 index 0000000..27870ec --- /dev/null +++ b/attic/latex/figs/listsum1.eps @@ -0,0 +1,1740 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: listsum1.eps +%%Creator: matplotlib version 0.99.1.1, http://matplotlib.sourceforge.net/ +%%CreationDate: Fri Aug 5 16:02:46 2011 +%%Orientation: portrait +%%BoundingBox: 18 180 594 612 +%%EndComments +%%BeginProlog +/mpldict 8 dict def +mpldict begin +/m { moveto } bind def +/l { lineto } bind def +/r { rlineto } bind def +/c { curveto } bind def +/cl { closepath } bind def +/box { +m +1 index 0 r +0 exch r +neg 0 r +cl +} bind def +/clipbox { +box +clip +newpath +} bind def +%!PS-Adobe-3.0 Resource-Font +%%Title: DejaVu Sans +%%Copyright: Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. DejaVu changes are in public domain +%%Creator: Converted from TrueType by PPR +25 dict begin +/_d{bind def}bind def +/_m{moveto}_d +/_l{lineto}_d +/_cl{closepath eofill}_d +/_c{curveto}_d +/_sc{7 -1 roll{setcachedevice}{pop pop pop pop pop pop}ifelse}_d +/_e{exec}_d +/FontName /DejaVuSans def +/PaintType 0 def +/FontMatrix[.001 0 0 .001 0 0]def +/FontBBox[-1020 -349 1681 1167]def +/FontType 3 def +/Encoding StandardEncoding def +/FontInfo 10 dict dup begin +/FamilyName (DejaVu Sans) def +/FullName (DejaVu Sans) def +/Notice (Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. DejaVu changes are in public domain ) def +/Weight (Book) def +/Version (Version 2.30) def +/ItalicAngle 0.0 def +/isFixedPitch false def +/UnderlinePosition -130 def +/UnderlineThickness 90 def +end readonly def +/CharStrings 23 dict dup begin +/space{318 0 0 0 0 0 _sc +}_d +/parenleft{390 0 86 -131 310 759 _sc +310 759 _m +266 683 234 609 213 536 _c +191 463 181 389 181 314 _c +181 238 191 164 213 91 _c +234 17 266 -56 310 -131 _c +232 -131 _l +183 -54 146 20 122 94 _c +98 168 86 241 86 314 _c +86 386 98 459 122 533 _c +146 607 182 682 232 759 _c +310 759 _l +_cl}_d +/parenright{390 0 80 -131 304 759 _sc +80 759 _m +158 759 _l +206 682 243 607 267 533 _c +291 459 304 386 304 314 _c +304 241 291 168 267 94 _c +243 20 206 -54 158 -131 _c +80 -131 _l +123 -56 155 17 177 91 _c +198 164 209 238 209 314 _c +209 389 198 463 177 536 _c +155 609 123 683 80 759 _c +_cl}_d +/hyphen{361 0 49 234 312 314 _sc +49 314 _m +312 314 _l +312 234 _l +49 234 _l +49 314 _l +_cl}_d +/zero{636 0 66 -13 570 742 _sc +318 664 _m +267 664 229 639 203 589 _c +177 539 165 464 165 364 _c +165 264 177 189 203 139 _c +229 89 267 64 318 64 _c +369 64 407 89 433 139 _c +458 189 471 264 471 364 _c +471 464 458 539 433 589 _c +407 639 369 664 318 664 _c +318 742 _m +399 742 461 709 505 645 _c +548 580 570 486 570 364 _c +570 241 548 147 505 83 _c +461 19 399 -13 318 -13 _c +236 -13 173 19 130 83 _c +87 147 66 241 66 364 _c +66 486 87 580 130 645 _c +173 709 236 742 318 742 _c +_cl}_d +/one{636 0 110 0 544 729 _sc +124 83 _m +285 83 _l +285 639 _l +110 604 _l +110 694 _l +284 729 _l +383 729 _l +383 83 _l +544 83 _l +544 0 _l +124 0 _l +124 83 _l +_cl}_d +/two{{636 0 73 0 536 742 _sc +192 83 _m +536 83 _l +536 0 _l +73 0 _l +73 83 _l +110 121 161 173 226 239 _c +290 304 331 346 348 365 _c +380 400 402 430 414 455 _c +426 479 433 504 433 528 _c +433 566 419 598 392 622 _c +365 646 330 659 286 659 _c +255 659 222 653 188 643 _c +154 632 117 616 78 594 _c +78 694 _l +118 710 155 722 189 730 _c +223 738 255 742 284 742 _c +359 742 419 723 464 685 _c +509 647 532 597 532 534 _c +532 504 526 475 515 449 _c +504 422 484 390 454 354 _c +446 344 420 317 376 272 _c +332 227 271 164 192 83 _c +_cl}_e}_d +/five{{636 0 77 -13 549 729 _sc +108 729 _m +495 729 _l +495 646 _l +198 646 _l +198 467 _l +212 472 227 476 241 478 _c +255 480 270 482 284 482 _c +365 482 429 459 477 415 _c +525 370 549 310 549 234 _c +549 155 524 94 475 51 _c +426 8 357 -13 269 -13 _c +238 -13 207 -10 175 -6 _c +143 -1 111 6 77 17 _c +77 116 _l +106 100 136 88 168 80 _c +199 72 232 69 267 69 _c +323 69 368 83 401 113 _c +433 143 450 183 450 234 _c +450 284 433 324 401 354 _c +368 384 323 399 267 399 _c +241 399 214 396 188 390 _c +162 384 135 375 108 363 _c +108 729 _l +_cl}_e}_d +/six{{636 0 70 -13 573 742 _sc +330 404 _m +286 404 251 388 225 358 _c +199 328 186 286 186 234 _c +186 181 199 139 225 109 _c +251 79 286 64 330 64 _c +374 64 409 79 435 109 _c +461 139 474 181 474 234 _c +474 286 461 328 435 358 _c +409 388 374 404 330 404 _c +526 713 _m +526 623 _l +501 635 476 644 451 650 _c +425 656 400 659 376 659 _c +310 659 260 637 226 593 _c +192 549 172 482 168 394 _c +187 422 211 444 240 459 _c +269 474 301 482 336 482 _c +409 482 467 459 509 415 _c +551 371 573 310 573 234 _c +573 159 550 99 506 54 _c +462 9 403 -13 330 -13 _c +246 -13 181 19 137 83 _c +92 147 70 241 70 364 _c +70 479 97 571 152 639 _c +206 707 280 742 372 742 _c +}_e{396 742 421 739 447 735 _c +472 730 498 723 526 713 _c +_cl}_e}_d +/seven{636 0 82 0 551 729 _sc +82 729 _m +551 729 _l +551 687 _l +286 0 _l +183 0 _l +432 646 _l +82 646 _l +82 729 _l +_cl}_d +/underscore{500 0 -9 -235 510 -165 _sc +510 -165 _m +510 -235 _l +-9 -235 _l +-9 -165 _l +510 -165 _l +_cl}_d +/d{{635 0 55 -13 544 760 _sc +454 464 _m +454 760 _l +544 760 _l +544 0 _l +454 0 _l +454 82 _l +435 49 411 25 382 10 _c +353 -5 319 -13 279 -13 _c +213 -13 159 13 117 65 _c +75 117 55 187 55 273 _c +55 359 75 428 117 481 _c +159 533 213 560 279 560 _c +319 560 353 552 382 536 _c +411 520 435 496 454 464 _c +148 273 _m +148 207 161 155 188 117 _c +215 79 253 61 301 61 _c +348 61 385 79 413 117 _c +440 155 454 207 454 273 _c +454 339 440 390 413 428 _c +385 466 348 485 301 485 _c +253 485 215 466 188 428 _c +161 390 148 339 148 273 _c +_cl}_e}_d +/e{{615 0 55 -13 562 560 _sc +562 296 _m +562 252 _l +149 252 _l +153 190 171 142 205 110 _c +238 78 284 62 344 62 _c +378 62 412 66 444 74 _c +476 82 509 95 541 113 _c +541 28 _l +509 14 476 3 442 -3 _c +408 -9 373 -13 339 -13 _c +251 -13 182 12 131 62 _c +80 112 55 181 55 268 _c +55 357 79 428 127 481 _c +175 533 241 560 323 560 _c +397 560 455 536 498 489 _c +540 441 562 377 562 296 _c +472 322 _m +471 371 457 410 431 440 _c +404 469 368 484 324 484 _c +274 484 234 469 204 441 _c +174 413 156 373 152 322 _c +472 322 _l +_cl}_e}_d +/i{278 0 94 0 184 760 _sc +94 547 _m +184 547 _l +184 0 _l +94 0 _l +94 547 _l +94 760 _m +184 760 _l +184 646 _l +94 646 _l +94 760 _l +_cl}_d +/l{278 0 94 0 184 760 _sc +94 760 _m +184 760 _l +184 0 _l +94 0 _l +94 760 _l +_cl}_d +/m{{974 0 91 0 889 560 _sc +520 442 _m +542 482 569 511 600 531 _c +631 550 668 560 711 560 _c +767 560 811 540 842 500 _c +873 460 889 403 889 330 _c +889 0 _l +799 0 _l +799 327 _l +799 379 789 418 771 444 _c +752 469 724 482 686 482 _c +639 482 602 466 575 435 _c +548 404 535 362 535 309 _c +535 0 _l +445 0 _l +445 327 _l +445 379 435 418 417 444 _c +398 469 369 482 331 482 _c +285 482 248 466 221 435 _c +194 404 181 362 181 309 _c +181 0 _l +91 0 _l +91 547 _l +181 547 _l +181 462 _l +201 495 226 520 255 536 _c +283 552 317 560 357 560 _c +397 560 430 550 458 530 _c +486 510 506 480 520 442 _c +}_e{_cl}_e}_d +/n{634 0 91 0 549 560 _sc +549 330 _m +549 0 _l +459 0 _l +459 327 _l +459 379 448 417 428 443 _c +408 469 378 482 338 482 _c +289 482 251 466 223 435 _c +195 404 181 362 181 309 _c +181 0 _l +91 0 _l +91 547 _l +181 547 _l +181 462 _l +202 494 227 519 257 535 _c +286 551 320 560 358 560 _c +420 560 468 540 500 501 _c +532 462 549 405 549 330 _c +_cl}_d +/p{{635 0 91 -207 580 560 _sc +181 82 _m +181 -207 _l +91 -207 _l +91 547 _l +181 547 _l +181 464 _l +199 496 223 520 252 536 _c +281 552 316 560 356 560 _c +422 560 476 533 518 481 _c +559 428 580 359 580 273 _c +580 187 559 117 518 65 _c +476 13 422 -13 356 -13 _c +316 -13 281 -5 252 10 _c +223 25 199 49 181 82 _c +487 273 _m +487 339 473 390 446 428 _c +418 466 381 485 334 485 _c +286 485 249 466 222 428 _c +194 390 181 339 181 273 _c +181 207 194 155 222 117 _c +249 79 286 61 334 61 _c +381 61 418 79 446 117 _c +473 155 487 207 487 273 _c +_cl}_e}_d +/r{411 0 91 0 411 560 _sc +411 463 _m +401 469 390 473 378 476 _c +366 478 353 480 339 480 _c +288 480 249 463 222 430 _c +194 397 181 350 181 288 _c +181 0 _l +91 0 _l +91 547 _l +181 547 _l +181 462 _l +199 495 224 520 254 536 _c +284 552 321 560 365 560 _c +371 560 378 559 386 559 _c +393 558 401 557 411 555 _c +411 463 _l +_cl}_d +/s{{521 0 54 -13 472 560 _sc +443 531 _m +443 446 _l +417 458 391 468 364 475 _c +336 481 308 485 279 485 _c +234 485 200 478 178 464 _c +156 450 145 430 145 403 _c +145 382 153 366 169 354 _c +185 342 217 330 265 320 _c +296 313 _l +360 299 405 279 432 255 _c +458 230 472 195 472 151 _c +472 100 452 60 412 31 _c +372 1 316 -13 246 -13 _c +216 -13 186 -10 154 -5 _c +122 0 89 8 54 20 _c +54 113 _l +87 95 120 82 152 74 _c +184 65 216 61 248 61 _c +290 61 323 68 346 82 _c +368 96 380 117 380 144 _c +380 168 371 187 355 200 _c +339 213 303 226 247 238 _c +216 245 _l +160 257 119 275 95 299 _c +70 323 58 356 58 399 _c +58 450 76 490 112 518 _c +148 546 200 560 268 560 _c +}_e{301 560 332 557 362 552 _c +391 547 418 540 443 531 _c +_cl}_e}_d +/t{392 0 27 0 368 702 _sc +183 702 _m +183 547 _l +368 547 _l +368 477 _l +183 477 _l +183 180 _l +183 135 189 106 201 94 _c +213 81 238 75 276 75 _c +368 75 _l +368 0 _l +276 0 _l +206 0 158 13 132 39 _c +106 65 93 112 93 180 _c +93 477 _l +27 477 _l +27 547 _l +93 547 _l +93 702 _l +183 702 _l +_cl}_d +/u{634 0 85 -13 543 560 _sc +85 216 _m +85 547 _l +175 547 _l +175 219 _l +175 167 185 129 205 103 _c +225 77 255 64 296 64 _c +344 64 383 79 411 110 _c +439 141 453 183 453 237 _c +453 547 _l +543 547 _l +543 0 _l +453 0 _l +453 84 _l +431 50 405 26 377 10 _c +348 -5 315 -13 277 -13 _c +214 -13 166 6 134 45 _c +101 83 85 140 85 216 _c +_cl}_d +/x{592 0 29 0 559 547 _sc +549 547 _m +351 281 _l +559 0 _l +453 0 _l +294 215 _l +135 0 _l +29 0 _l +241 286 _l +47 547 _l +153 547 _l +298 352 _l +443 547 _l +549 547 _l +_cl}_d +end readonly def + +/BuildGlyph + {exch begin + CharStrings exch + 2 copy known not{pop /.notdef}if + true 3 1 roll get exec + end}_d + +/BuildChar { + 1 index /Encoding get exch get + 1 index /BuildGlyph get exec +}_d + +FontName currentdict end definefont pop +end +%%EndProlog +mpldict begin +18 180 translate +576 432 0 0 clipbox +1.000 setlinewidth +1 setlinejoin +2 setlinecap +[] 0 setdash +1.000 setgray +gsave +0 0 m +576 0 l +576 432 l +0 432 l +0 0 l +gsave +fill +grestore +stroke +grestore +gsave +72 43.2 m +518.4 43.2 l +518.4 388.8 l +72 388.8 l +72 43.2 l +fill +grestore +2.000 setlinewidth +0.700 setgray +gsave +446.4 345.6 72 43.2 clipbox +139.19 187.425 m +178.493 217.853 l +206.38 239.442 l +228.01 256.189 l +245.683 269.871 l +260.626 281.439 l +273.57 291.46 l +284.987 300.3 l +295.2 308.207 l +304.439 315.359 l +312.873 321.889 l +320.632 327.896 l +327.816 333.457 l +334.504 338.635 l +340.76 343.478 l +346.636 348.028 l +352.177 352.318 l +357.418 356.375 l +362.39 360.225 l +367.119 363.886 l +371.629 367.377 l +375.938 370.713 l +380.063 373.907 l +stroke +grestore +3.000 setlinewidth +0.000 0.000 1.000 setrgbcolor +gsave +446.4 345.6 72 43.2 clipbox +139.19 177.665 m +178.493 223.153 l +206.38 235.689 l +228.01 255.822 l +245.683 268.018 l +260.626 275.171 l +273.57 284.764 l +284.987 293.269 l +295.2 300.907 l +304.439 310.015 l +312.873 320.036 l +320.632 321.889 l +327.816 327.189 l +334.504 336.782 l +340.76 338.268 l +346.636 342.558 l +352.177 350.465 l +357.418 349.203 l +362.39 356.471 l +367.119 367.211 l +371.629 364.147 l +375.938 363.097 l +380.063 373.907 l +stroke +grestore +2.000 setlinewidth +0.700 setgray +gsave +446.4 345.6 72 43.2 clipbox +139.19 153.243 m +178.493 183.671 l +206.38 205.261 l +228.01 222.007 l +245.683 235.689 l +260.626 247.258 l +273.57 257.279 l +284.987 266.118 l +295.2 274.025 l +304.439 281.178 l +312.873 287.707 l +320.632 293.714 l +327.816 299.276 l +334.504 304.453 l +340.76 309.297 l +346.636 313.846 l +352.177 318.136 l +357.418 322.193 l +362.39 326.043 l +367.119 329.704 l +371.629 333.196 l +375.938 336.531 l +380.063 339.725 l +stroke +grestore +3.000 setlinewidth +0.000 0.502 0.000 setrgbcolor +gsave +446.4 345.6 72 43.2 clipbox +139.19 147.236 m +178.493 177.665 l +206.38 216 l +228.01 216 l +245.683 235.689 l +260.626 241.251 l +273.57 251.272 l +284.987 271.679 l +295.2 281.701 l +304.439 287.707 l +312.873 290.54 l +320.632 293.269 l +327.816 303.29 l +334.504 303.29 l +340.76 310.015 l +346.636 312.129 l +352.177 316.187 l +357.418 328.875 l +362.39 327.189 l +367.119 330.525 l +371.629 333.718 l +375.938 336.782 l +380.063 339.725 l +stroke +grestore +0.500 setlinewidth +0 setlinecap +0.000 setgray +gsave +/o { +gsave +newpath +translate +0 0 m +0 4 l +stroke +grestore +} bind def +72 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -4 l +stroke +grestore +} bind def +72 388.8 o +grestore +gsave +61.000000 24.200000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.937500 moveto +/one glyphshow + +7.634766 1.937500 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.875000 moveto +/five glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 4 l +stroke +grestore +} bind def +295.2 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -4 l +stroke +grestore +} bind def +295.2 388.8 o +grestore +gsave +284.200000 24.200000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.828125 moveto +/one glyphshow + +7.634766 1.828125 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.765625 moveto +/six glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 4 l +stroke +grestore +} bind def +518.4 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -4 l +stroke +grestore +} bind def +518.4 388.8 o +grestore +gsave +507.400000 24.200000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.937500 moveto +/one glyphshow + +7.634766 1.937500 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.875000 moveto +/seven glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +139.19 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +139.19 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +178.493 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +178.493 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +206.38 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +206.38 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +228.01 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +228.01 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +245.683 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +245.683 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +260.626 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +260.626 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +273.57 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +273.57 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +284.987 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +284.987 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +362.39 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +362.39 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +401.693 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +401.693 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +429.58 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +429.58 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +451.21 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +451.21 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +468.883 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +468.883 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +483.826 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +483.826 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +496.77 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +496.77 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +508.187 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +508.187 388.8 o +grestore +/DejaVuSans findfont +12.000 scalefont +setfont +292.45 12.481 m +(n) show +gsave +/o { +gsave +newpath +translate +0 0 m +4 0 l +stroke +grestore +} bind def +72 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-4 0 l +stroke +grestore +} bind def +518.4 43.2 o +grestore +gsave +43.000000 35.700000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.828125 moveto +/one glyphshow + +7.634766 1.828125 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.765625 moveto +/hyphen glyphshow + +18.300586 8.765625 moveto +/two glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +4 0 l +stroke +grestore +} bind def +72 216 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-4 0 l +stroke +grestore +} bind def +518.4 216 o +grestore +gsave +43.000000 208.500000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.937500 moveto +/one glyphshow + +7.634766 1.937500 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.875000 moveto +/hyphen glyphshow + +18.300586 8.875000 moveto +/one glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +4 0 l +stroke +grestore +} bind def +72 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-4 0 l +stroke +grestore +} bind def +518.4 388.8 o +grestore +gsave +46.000000 381.300000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.828125 moveto +/one glyphshow + +7.634766 1.828125 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.765625 moveto +/zero glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 95.218 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 95.218 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 125.647 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 125.647 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 147.236 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 147.236 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 163.982 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 163.982 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 177.665 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 177.665 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 189.233 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 189.233 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 199.254 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 199.254 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 208.093 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 208.093 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 268.018 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 268.018 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 298.447 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 298.447 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 320.036 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 320.036 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 336.782 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 336.782 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 350.465 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 350.465 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 362.033 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 362.033 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 372.054 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 372.054 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 380.893 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 380.893 o +grestore +38 181.258 m +gsave +90 rotate +0 1.578 rmoveto +(run time \(s\)) show +grestore +1.000 setlinewidth +2 setlinecap +gsave +72 388.8 m +518.4 388.8 l +stroke +grestore +gsave +518.4 43.2 m +518.4 388.8 l +stroke +grestore +gsave +72 43.2 m +518.4 43.2 l +stroke +grestore +gsave +72 43.2 m +72 388.8 l +stroke +grestore +gsave +373.844 50.4 m +511.2 50.4 l +511.2 96.995 l +373.844 96.995 l +373.844 50.4 l +cl +gsave +1.000 setgray +fill +grestore +stroke +grestore +3.000 setlinewidth +0.000 0.000 1.000 setrgbcolor +gsave +383.924 85.6344 m +404.084 85.6344 l +stroke +grestore +0.000 setgray +/DejaVuSans findfont +14.400 scalefont +setfont +419.924 77.297 m +0 3.297 rmoveto +(sum_extend) show +0.000 0.502 0.000 setrgbcolor +gsave +383.924 64.4969 m +404.084 64.4969 l +stroke +grestore +0.000 setgray +419.924 56.16 m +0 3.297 rmoveto +(sum_plus) show + +end +showpage diff --git a/attic/latex/figs/listsum1.pdf b/attic/latex/figs/listsum1.pdf new file mode 100644 index 0000000..103db19 Binary files /dev/null and b/attic/latex/figs/listsum1.pdf differ diff --git a/attic/latex/figs/listsum2.eps b/attic/latex/figs/listsum2.eps new file mode 100644 index 0000000..f771ec9 --- /dev/null +++ b/attic/latex/figs/listsum2.eps @@ -0,0 +1,2086 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: listsum2.eps +%%Creator: matplotlib version 0.99.1.1, http://matplotlib.sourceforge.net/ +%%CreationDate: Wed Aug 3 16:20:28 2011 +%%Orientation: portrait +%%BoundingBox: 18 180 594 612 +%%EndComments +%%BeginProlog +/mpldict 8 dict def +mpldict begin +/m { moveto } bind def +/l { lineto } bind def +/r { rlineto } bind def +/c { curveto } bind def +/cl { closepath } bind def +/box { +m +1 index 0 r +0 exch r +neg 0 r +cl +} bind def +/clipbox { +box +clip +newpath +} bind def +%!PS-Adobe-3.0 Resource-Font +%%Title: DejaVu Sans +%%Copyright: Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. DejaVu changes are in public domain +%%Creator: Converted from TrueType by PPR +25 dict begin +/_d{bind def}bind def +/_m{moveto}_d +/_l{lineto}_d +/_cl{closepath eofill}_d +/_c{curveto}_d +/_sc{7 -1 roll{setcachedevice}{pop pop pop pop pop pop}ifelse}_d +/_e{exec}_d +/FontName /DejaVuSans def +/PaintType 0 def +/FontMatrix[.001 0 0 .001 0 0]def +/FontBBox[-1020 -349 1681 1167]def +/FontType 3 def +/Encoding StandardEncoding def +/FontInfo 10 dict dup begin +/FamilyName (DejaVu Sans) def +/FullName (DejaVu Sans) def +/Notice (Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. DejaVu changes are in public domain ) def +/Weight (Book) def +/Version (Version 2.30) def +/ItalicAngle 0.0 def +/isFixedPitch false def +/UnderlinePosition -130 def +/UnderlineThickness 90 def +end readonly def +/CharStrings 19 dict dup begin +/space{318 0 0 0 0 0 _sc +}_d +/parenleft{390 0 86 -131 310 759 _sc +310 759 _m +266 683 234 609 213 536 _c +191 463 181 389 181 314 _c +181 238 191 164 213 91 _c +234 17 266 -56 310 -131 _c +232 -131 _l +183 -54 146 20 122 94 _c +98 168 86 241 86 314 _c +86 386 98 459 122 533 _c +146 607 182 682 232 759 _c +310 759 _l +_cl}_d +/parenright{390 0 80 -131 304 759 _sc +80 759 _m +158 759 _l +206 682 243 607 267 533 _c +291 459 304 386 304 314 _c +304 241 291 168 267 94 _c +243 20 206 -54 158 -131 _c +80 -131 _l +123 -56 155 17 177 91 _c +198 164 209 238 209 314 _c +209 389 198 463 177 536 _c +155 609 123 683 80 759 _c +_cl}_d +/hyphen{361 0 49 234 312 314 _sc +49 314 _m +312 314 _l +312 234 _l +49 234 _l +49 314 _l +_cl}_d +/zero{636 0 66 -13 570 742 _sc +318 664 _m +267 664 229 639 203 589 _c +177 539 165 464 165 364 _c +165 264 177 189 203 139 _c +229 89 267 64 318 64 _c +369 64 407 89 433 139 _c +458 189 471 264 471 364 _c +471 464 458 539 433 589 _c +407 639 369 664 318 664 _c +318 742 _m +399 742 461 709 505 645 _c +548 580 570 486 570 364 _c +570 241 548 147 505 83 _c +461 19 399 -13 318 -13 _c +236 -13 173 19 130 83 _c +87 147 66 241 66 364 _c +66 486 87 580 130 645 _c +173 709 236 742 318 742 _c +_cl}_d +/one{636 0 110 0 544 729 _sc +124 83 _m +285 83 _l +285 639 _l +110 604 _l +110 694 _l +284 729 _l +383 729 _l +383 83 _l +544 83 _l +544 0 _l +124 0 _l +124 83 _l +_cl}_d +/two{{636 0 73 0 536 742 _sc +192 83 _m +536 83 _l +536 0 _l +73 0 _l +73 83 _l +110 121 161 173 226 239 _c +290 304 331 346 348 365 _c +380 400 402 430 414 455 _c +426 479 433 504 433 528 _c +433 566 419 598 392 622 _c +365 646 330 659 286 659 _c +255 659 222 653 188 643 _c +154 632 117 616 78 594 _c +78 694 _l +118 710 155 722 189 730 _c +223 738 255 742 284 742 _c +359 742 419 723 464 685 _c +509 647 532 597 532 534 _c +532 504 526 475 515 449 _c +504 422 484 390 454 354 _c +446 344 420 317 376 272 _c +332 227 271 164 192 83 _c +_cl}_e}_d +/three{{636 0 76 -13 556 742 _sc +406 393 _m +453 383 490 362 516 330 _c +542 298 556 258 556 212 _c +556 140 531 84 482 45 _c +432 6 362 -13 271 -13 _c +240 -13 208 -10 176 -4 _c +144 1 110 10 76 22 _c +76 117 _l +103 101 133 89 166 81 _c +198 73 232 69 268 69 _c +330 69 377 81 409 105 _c +441 129 458 165 458 212 _c +458 254 443 288 413 312 _c +383 336 341 349 287 349 _c +202 349 _l +202 430 _l +291 430 _l +339 430 376 439 402 459 _c +428 478 441 506 441 543 _c +441 580 427 609 401 629 _c +374 649 336 659 287 659 _c +260 659 231 656 200 650 _c +169 644 135 635 98 623 _c +98 711 _l +135 721 170 729 203 734 _c +235 739 266 742 296 742 _c +}_e{370 742 429 725 473 691 _c +517 657 539 611 539 553 _c +539 513 527 479 504 451 _c +481 423 448 403 406 393 _c +_cl}_e}_d +/four{636 0 49 0 580 729 _sc +378 643 _m +129 254 _l +378 254 _l +378 643 _l +352 729 _m +476 729 _l +476 254 _l +580 254 _l +580 172 _l +476 172 _l +476 0 _l +378 0 _l +378 172 _l +49 172 _l +49 267 _l +352 729 _l +_cl}_d +/five{{636 0 77 -13 549 729 _sc +108 729 _m +495 729 _l +495 646 _l +198 646 _l +198 467 _l +212 472 227 476 241 478 _c +255 480 270 482 284 482 _c +365 482 429 459 477 415 _c +525 370 549 310 549 234 _c +549 155 524 94 475 51 _c +426 8 357 -13 269 -13 _c +238 -13 207 -10 175 -6 _c +143 -1 111 6 77 17 _c +77 116 _l +106 100 136 88 168 80 _c +199 72 232 69 267 69 _c +323 69 368 83 401 113 _c +433 143 450 183 450 234 _c +450 284 433 324 401 354 _c +368 384 323 399 267 399 _c +241 399 214 396 188 390 _c +162 384 135 375 108 363 _c +108 729 _l +_cl}_e}_d +/underscore{500 0 -9 -235 510 -165 _sc +510 -165 _m +510 -235 _l +-9 -235 _l +-9 -165 _l +510 -165 _l +_cl}_d +/e{{615 0 55 -13 562 560 _sc +562 296 _m +562 252 _l +149 252 _l +153 190 171 142 205 110 _c +238 78 284 62 344 62 _c +378 62 412 66 444 74 _c +476 82 509 95 541 113 _c +541 28 _l +509 14 476 3 442 -3 _c +408 -9 373 -13 339 -13 _c +251 -13 182 12 131 62 _c +80 112 55 181 55 268 _c +55 357 79 428 127 481 _c +175 533 241 560 323 560 _c +397 560 455 536 498 489 _c +540 441 562 377 562 296 _c +472 322 _m +471 371 457 410 431 440 _c +404 469 368 484 324 484 _c +274 484 234 469 204 441 _c +174 413 156 373 152 322 _c +472 322 _l +_cl}_e}_d +/i{278 0 94 0 184 760 _sc +94 547 _m +184 547 _l +184 0 _l +94 0 _l +94 547 _l +94 760 _m +184 760 _l +184 646 _l +94 646 _l +94 760 _l +_cl}_d +/m{{974 0 91 0 889 560 _sc +520 442 _m +542 482 569 511 600 531 _c +631 550 668 560 711 560 _c +767 560 811 540 842 500 _c +873 460 889 403 889 330 _c +889 0 _l +799 0 _l +799 327 _l +799 379 789 418 771 444 _c +752 469 724 482 686 482 _c +639 482 602 466 575 435 _c +548 404 535 362 535 309 _c +535 0 _l +445 0 _l +445 327 _l +445 379 435 418 417 444 _c +398 469 369 482 331 482 _c +285 482 248 466 221 435 _c +194 404 181 362 181 309 _c +181 0 _l +91 0 _l +91 547 _l +181 547 _l +181 462 _l +201 495 226 520 255 536 _c +283 552 317 560 357 560 _c +397 560 430 550 458 530 _c +486 510 506 480 520 442 _c +}_e{_cl}_e}_d +/n{634 0 91 0 549 560 _sc +549 330 _m +549 0 _l +459 0 _l +459 327 _l +459 379 448 417 428 443 _c +408 469 378 482 338 482 _c +289 482 251 466 223 435 _c +195 404 181 362 181 309 _c +181 0 _l +91 0 _l +91 547 _l +181 547 _l +181 462 _l +202 494 227 519 257 535 _c +286 551 320 560 358 560 _c +420 560 468 540 500 501 _c +532 462 549 405 549 330 _c +_cl}_d +/r{411 0 91 0 411 560 _sc +411 463 _m +401 469 390 473 378 476 _c +366 478 353 480 339 480 _c +288 480 249 463 222 430 _c +194 397 181 350 181 288 _c +181 0 _l +91 0 _l +91 547 _l +181 547 _l +181 462 _l +199 495 224 520 254 536 _c +284 552 321 560 365 560 _c +371 560 378 559 386 559 _c +393 558 401 557 411 555 _c +411 463 _l +_cl}_d +/s{{521 0 54 -13 472 560 _sc +443 531 _m +443 446 _l +417 458 391 468 364 475 _c +336 481 308 485 279 485 _c +234 485 200 478 178 464 _c +156 450 145 430 145 403 _c +145 382 153 366 169 354 _c +185 342 217 330 265 320 _c +296 313 _l +360 299 405 279 432 255 _c +458 230 472 195 472 151 _c +472 100 452 60 412 31 _c +372 1 316 -13 246 -13 _c +216 -13 186 -10 154 -5 _c +122 0 89 8 54 20 _c +54 113 _l +87 95 120 82 152 74 _c +184 65 216 61 248 61 _c +290 61 323 68 346 82 _c +368 96 380 117 380 144 _c +380 168 371 187 355 200 _c +339 213 303 226 247 238 _c +216 245 _l +160 257 119 275 95 299 _c +70 323 58 356 58 399 _c +58 450 76 490 112 518 _c +148 546 200 560 268 560 _c +}_e{301 560 332 557 362 552 _c +391 547 418 540 443 531 _c +_cl}_e}_d +/t{392 0 27 0 368 702 _sc +183 702 _m +183 547 _l +368 547 _l +368 477 _l +183 477 _l +183 180 _l +183 135 189 106 201 94 _c +213 81 238 75 276 75 _c +368 75 _l +368 0 _l +276 0 _l +206 0 158 13 132 39 _c +106 65 93 112 93 180 _c +93 477 _l +27 477 _l +27 547 _l +93 547 _l +93 702 _l +183 702 _l +_cl}_d +/u{634 0 85 -13 543 560 _sc +85 216 _m +85 547 _l +175 547 _l +175 219 _l +175 167 185 129 205 103 _c +225 77 255 64 296 64 _c +344 64 383 79 411 110 _c +439 141 453 183 453 237 _c +453 547 _l +543 547 _l +543 0 _l +453 0 _l +453 84 _l +431 50 405 26 377 10 _c +348 -5 315 -13 277 -13 _c +214 -13 166 6 134 45 _c +101 83 85 140 85 216 _c +_cl}_d +end readonly def + +/BuildGlyph + {exch begin + CharStrings exch + 2 copy known not{pop /.notdef}if + true 3 1 roll get exec + end}_d + +/BuildChar { + 1 index /Encoding get exch get + 1 index /BuildGlyph get exec +}_d + +FontName currentdict end definefont pop +end +%%EndProlog +mpldict begin +18 180 translate +576 432 0 0 clipbox +1.000 setlinewidth +1 setlinejoin +2 setlinecap +[] 0 setdash +1.000 setgray +gsave +0 0 m +576 0 l +576 432 l +0 432 l +0 0 l +gsave +fill +grestore +stroke +grestore +gsave +72 43.2 m +518.4 43.2 l +518.4 388.8 l +72 388.8 l +72 43.2 l +fill +grestore +2.000 setlinewidth +0.700 setgray +gsave +446.4 345.6 72 43.2 clipbox +139.19 144.289 m +178.493 174.718 l +206.38 196.307 l +228.01 213.054 l +245.683 226.736 l +260.626 238.304 l +273.57 248.325 l +284.987 257.165 l +295.2 265.071 l +304.439 272.224 l +312.873 278.754 l +320.632 284.761 l +327.816 290.322 l +334.504 295.5 l +340.76 300.343 l +346.636 304.893 l +352.177 309.183 l +357.418 313.24 l +362.39 317.089 l +367.119 320.751 l +371.629 324.242 l +375.938 327.578 l +380.063 330.772 l +stroke +grestore +3.000 setlinewidth +0.000 0.000 1.000 setrgbcolor +gsave +446.4 345.6 72 43.2 clipbox +139.19 129.6 m +178.493 181.618 l +206.38 189.991 l +228.01 212.047 l +245.683 225.845 l +260.626 235.911 l +273.57 248.85 l +284.987 257.223 l +295.2 264.065 l +304.439 271.594 l +312.873 279.279 l +320.632 285.654 l +327.816 291.102 l +334.504 295.408 l +340.76 299.677 l +346.636 306.316 l +352.177 310.472 l +357.418 313.661 l +362.39 317.111 l +367.119 320.502 l +371.629 324.036 l +375.938 328.221 l +380.063 330.772 l +stroke +grestore +0.500 setlinewidth +0 setlinecap +0.000 setgray +gsave +/o { +gsave +newpath +translate +0 0 m +0 4 l +stroke +grestore +} bind def +72 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -4 l +stroke +grestore +} bind def +72 388.8 o +grestore +gsave +61.000000 24.200000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.828125 moveto +/one glyphshow + +7.634766 1.828125 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.765625 moveto +/three glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 4 l +stroke +grestore +} bind def +295.2 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -4 l +stroke +grestore +} bind def +295.2 388.8 o +grestore +gsave +284.200000 24.200000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.937500 moveto +/one glyphshow + +7.634766 1.937500 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.875000 moveto +/four glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 4 l +stroke +grestore +} bind def +518.4 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -4 l +stroke +grestore +} bind def +518.4 388.8 o +grestore +gsave +507.400000 24.200000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.937500 moveto +/one glyphshow + +7.634766 1.937500 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.875000 moveto +/five glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +139.19 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +139.19 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +178.493 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +178.493 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +206.38 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +206.38 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +228.01 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +228.01 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +245.683 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +245.683 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +260.626 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +260.626 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +273.57 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +273.57 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +284.987 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +284.987 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +362.39 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +362.39 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +401.693 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +401.693 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +429.58 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +429.58 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +451.21 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +451.21 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +468.883 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +468.883 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +483.826 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +483.826 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +496.77 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +496.77 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 2 l +stroke +grestore +} bind def +508.187 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +0 -2 l +stroke +grestore +} bind def +508.187 388.8 o +grestore +/DejaVuSans findfont +12.000 scalefont +setfont +292.45 12.481 m +(n) show +gsave +/o { +gsave +newpath +translate +0 0 m +4 0 l +stroke +grestore +} bind def +72 43.2 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-4 0 l +stroke +grestore +} bind def +518.4 43.2 o +grestore +gsave +43.000000 35.700000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.828125 moveto +/one glyphshow + +7.634766 1.828125 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.765625 moveto +/hyphen glyphshow + +18.300586 8.765625 moveto +/three glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +4 0 l +stroke +grestore +} bind def +72 129.6 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-4 0 l +stroke +grestore +} bind def +518.4 129.6 o +grestore +gsave +43.000000 122.100000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.828125 moveto +/one glyphshow + +7.634766 1.828125 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.765625 moveto +/hyphen glyphshow + +18.300586 8.765625 moveto +/two glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +4 0 l +stroke +grestore +} bind def +72 216 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-4 0 l +stroke +grestore +} bind def +518.4 216 o +grestore +gsave +43.000000 208.500000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.937500 moveto +/one glyphshow + +7.634766 1.937500 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.875000 moveto +/hyphen glyphshow + +18.300586 8.875000 moveto +/one glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +4 0 l +stroke +grestore +} bind def +72 302.4 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-4 0 l +stroke +grestore +} bind def +518.4 302.4 o +grestore +gsave +46.000000 294.900000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.828125 moveto +/one glyphshow + +7.634766 1.828125 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.765625 moveto +/zero glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +4 0 l +stroke +grestore +} bind def +72 388.8 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-4 0 l +stroke +grestore +} bind def +518.4 388.8 o +grestore +gsave +46.000000 381.300000 translate +0.000000 rotate +/DejaVuSans findfont +12.0 scalefont +setfont +0.000000 1.937500 moveto +/one glyphshow + +7.634766 1.937500 moveto +/zero glyphshow + +/DejaVuSans findfont +8.4 scalefont +setfont +15.269531 8.875000 moveto +/one glyphshow + + +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 69.209 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 69.209 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 84.4233 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 84.4233 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 95.218 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 95.218 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 103.591 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 103.591 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 110.432 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 110.432 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 116.216 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 116.216 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 121.227 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 121.227 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 125.647 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 125.647 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 155.609 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 155.609 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 170.823 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 170.823 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 181.618 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 181.618 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 189.991 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 189.991 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 196.832 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 196.832 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 202.616 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 202.616 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 207.627 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 207.627 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 212.047 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 212.047 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 242.009 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 242.009 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 257.223 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 257.223 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 268.018 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 268.018 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 276.391 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 276.391 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 283.232 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 283.232 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 289.016 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 289.016 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 294.027 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 294.027 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 298.447 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 298.447 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 328.409 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 328.409 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 343.623 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 343.623 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 354.418 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 354.418 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 362.791 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 362.791 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 369.632 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 369.632 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 375.416 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 375.416 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 380.427 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 380.427 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +2 0 l +stroke +grestore +} bind def +72 384.847 o +grestore +gsave +/o { +gsave +newpath +translate +0 0 m +-2 0 l +stroke +grestore +} bind def +518.4 384.847 o +grestore +38 181.258 m +gsave +90 rotate +0 1.578 rmoveto +(run time \(s\)) show +grestore +1.000 setlinewidth +2 setlinecap +gsave +72 388.8 m +518.4 388.8 l +stroke +grestore +gsave +518.4 43.2 m +518.4 388.8 l +stroke +grestore +gsave +72 43.2 m +518.4 43.2 l +stroke +grestore +gsave +72 43.2 m +72 388.8 l +stroke +grestore +gsave +392.985 50.4 m +511.2 50.4 l +511.2 75.8575 l +392.985 75.8575 l +392.985 50.4 l +cl +gsave +1.000 setgray +fill +grestore +stroke +grestore +3.000 setlinewidth +0.000 0.000 1.000 setrgbcolor +gsave +403.065 64.4969 m +423.225 64.4969 l +stroke +grestore +0.000 setgray +/DejaVuSans findfont +14.400 scalefont +setfont +439.065 56.16 m +0 3.297 rmoveto +(sum_sum) show + +end +showpage diff --git a/attic/latex/figs/listsum2.pdf b/attic/latex/figs/listsum2.pdf new file mode 100644 index 0000000..1b5e77d Binary files /dev/null and b/attic/latex/figs/listsum2.pdf differ diff --git a/attic/latex/figs/loop.py b/attic/latex/figs/loop.py new file mode 100644 index 0000000..1e4dea2 --- /dev/null +++ b/attic/latex/figs/loop.py @@ -0,0 +1,20 @@ +import sys, os +from glob import glob + +def pipe(cmd): + fp = os.popen(cmd) + res = fp.read() + stat = fp.close() + return res, stat + +def main(script, files='*.eps'): + for filename in sorted(glob(files)): + destination = '.'.join(filename.split('.')[:-1]) + '.pdf' + cmd = 'convert %s %s' % (filename, destination) + print cmd + + res, stat = pipe(cmd) + print res, stat + +if __name__ == '__main__': + main(*sys.argv) diff --git a/book/figs/loop.py~ b/attic/latex/figs/loop.py~ similarity index 100% rename from book/figs/loop.py~ rename to attic/latex/figs/loop.py~ diff --git a/attic/latex/figs/pies.eps b/attic/latex/figs/pies.eps new file mode 100644 index 0000000..486986f --- /dev/null +++ b/attic/latex/figs/pies.eps @@ -0,0 +1,875 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: Tk Canvas Widget +%%For: Allen Downey +%%Title: Window .-1211895540 +%%CreationDate: Mon Jul 2 10:01:49 2007 +%%BoundingBox: 196 360 416 432 +%%Pages: 1 +%%DocumentData: Clean7Bit +%%Orientation: Portrait +%%EndComments + +%%BeginProlog +/CurrentEncoding [ +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quotesingle +/parenleft/parenright/asterisk/plus/comma/hyphen/period/slash +/zero/one/two/three/four/five/six/seven +/eight/nine/colon/semicolon/less/equal/greater/question +/at/A/B/C/D/E/F/G +/H/I/J/K/L/M/N/O +/P/Q/R/S/T/U/V/W +/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore +/grave/a/b/c/d/e/f/g +/h/i/j/k/l/m/n/o +/p/q/r/s/t/u/v/w +/x/y/z/braceleft/bar/braceright/asciitilde/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/space/space/space/space/space/space/space +/space/exclamdown/cent/sterling/currency/yen/brokenbar/section +/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron +/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered +/cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown +/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla +/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis +/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply +/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls +/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla +/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis +/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide +/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis +] def + +50 dict begin +% This is a standard prolog for Postscript generated by Tk's canvas +% widget. +% RCS: @(#) $Id: mkpsenc.tcl,v 1.3 2002/07/19 14:37:21 drh Exp $ + +% The definitions below just define all of the variables used in +% any of the procedures here. This is needed for obscure reasons +% explained on p. 716 of the Postscript manual (Section H.2.7, +% "Initializing Variables," in the section on Encapsulated Postscript). + +/baseline 0 def +/stipimage 0 def +/height 0 def +/justify 0 def +/lineLength 0 def +/spacing 0 def +/stipple 0 def +/strings 0 def +/xoffset 0 def +/yoffset 0 def +/tmpstip null def + + +/cstringshow { + { + dup type /stringtype eq + { show } { glyphshow } + ifelse + } + forall +} bind def + + + +/cstringwidth { + 0 exch 0 exch + { + dup type /stringtype eq + { stringwidth } { + currentfont /Encoding get exch 1 exch put (\001) stringwidth + } + ifelse + exch 3 1 roll add 3 1 roll add exch + } + forall +} bind def + +% font ISOEncode font +% This procedure changes the encoding of a font from the default +% Postscript encoding to current system encoding. It's typically invoked just +% before invoking "setfont". The body of this procedure comes from +% Section 5.6.1 of the Postscript book. + +/ISOEncode { + dup length dict begin + {1 index /FID ne {def} {pop pop} ifelse} forall + /Encoding CurrentEncoding def + currentdict + end + + % I'm not sure why it's necessary to use "definefont" on this new + % font, but it seems to be important; just use the name "Temporary" + % for the font. + + /Temporary exch definefont +} bind def + +% StrokeClip +% +% This procedure converts the current path into a clip area under +% the assumption of stroking. It's a bit tricky because some Postscript +% interpreters get errors during strokepath for dashed lines. If +% this happens then turn off dashes and try again. + +/StrokeClip { + {strokepath} stopped { + (This Postscript printer gets limitcheck overflows when) = + (stippling dashed lines; lines will be printed solid instead.) = + [] 0 setdash strokepath} if + clip +} bind def + +% desiredSize EvenPixels closestSize +% +% The procedure below is used for stippling. Given the optimal size +% of a dot in a stipple pattern in the current user coordinate system, +% compute the closest size that is an exact multiple of the device's +% pixel size. This allows stipple patterns to be displayed without +% aliasing effects. + +/EvenPixels { + % Compute exact number of device pixels per stipple dot. + dup 0 matrix currentmatrix dtransform + dup mul exch dup mul add sqrt + + % Round to an integer, make sure the number is at least 1, and compute + % user coord distance corresponding to this. + dup round dup 1 lt {pop 1} if + exch div mul +} bind def + +% width height string StippleFill -- +% +% Given a path already set up and a clipping region generated from +% it, this procedure will fill the clipping region with a stipple +% pattern. "String" contains a proper image description of the +% stipple pattern and "width" and "height" give its dimensions. Each +% stipple dot is assumed to be about one unit across in the current +% user coordinate system. This procedure trashes the graphics state. + +/StippleFill { + % The following code is needed to work around a NeWSprint bug. + + /tmpstip 1 index def + + % Change the scaling so that one user unit in user coordinates + % corresponds to the size of one stipple dot. + 1 EvenPixels dup scale + + % Compute the bounding box occupied by the path (which is now + % the clipping region), and round the lower coordinates down + % to the nearest starting point for the stipple pattern. Be + % careful about negative numbers, since the rounding works + % differently on them. + + pathbbox + 4 2 roll + 5 index div dup 0 lt {1 sub} if cvi 5 index mul 4 1 roll + 6 index div dup 0 lt {1 sub} if cvi 6 index mul 3 2 roll + + % Stack now: width height string y1 y2 x1 x2 + % Below is a doubly-nested for loop to iterate across this area + % in units of the stipple pattern size, going up columns then + % across rows, blasting out a stipple-pattern-sized rectangle at + % each position + + 6 index exch { + 2 index 5 index 3 index { + % Stack now: width height string y1 y2 x y + + gsave + 1 index exch translate + 5 index 5 index true matrix tmpstip imagemask + grestore + } for + pop + } for + pop pop pop pop pop +} bind def + +% -- AdjustColor -- +% Given a color value already set for output by the caller, adjusts +% that value to a grayscale or mono value if requested by the CL +% variable. + +/AdjustColor { + CL 2 lt { + currentgray + CL 0 eq { + .5 lt {0} {1} ifelse + } if + setgray + } if +} bind def + +% x y strings spacing xoffset yoffset justify stipple DrawText -- +% This procedure does all of the real work of drawing text. The +% color and font must already have been set by the caller, and the +% following arguments must be on the stack: +% +% x, y - Coordinates at which to draw text. +% strings - An array of strings, one for each line of the text item, +% in order from top to bottom. +% spacing - Spacing between lines. +% xoffset - Horizontal offset for text bbox relative to x and y: 0 for +% nw/w/sw anchor, -0.5 for n/center/s, and -1.0 for ne/e/se. +% yoffset - Vertical offset for text bbox relative to x and y: 0 for +% nw/n/ne anchor, +0.5 for w/center/e, and +1.0 for sw/s/se. +% justify - 0 for left justification, 0.5 for center, 1 for right justify. +% stipple - Boolean value indicating whether or not text is to be +% drawn in stippled fashion. If text is stippled, +% procedure StippleText must have been defined to call +% StippleFill in the right way. +% +% Also, when this procedure is invoked, the color and font must already +% have been set for the text. + +/DrawText { + /stipple exch def + /justify exch def + /yoffset exch def + /xoffset exch def + /spacing exch def + /strings exch def + + % First scan through all of the text to find the widest line. + + /lineLength 0 def + strings { + cstringwidth pop + dup lineLength gt {/lineLength exch def} {pop} ifelse + newpath + } forall + + % Compute the baseline offset and the actual font height. + + 0 0 moveto (TXygqPZ) false charpath + pathbbox dup /baseline exch def + exch pop exch sub /height exch def pop + newpath + + % Translate coordinates first so that the origin is at the upper-left + % corner of the text's bounding box. Remember that x and y for + % positioning are still on the stack. + + translate + lineLength xoffset mul + strings length 1 sub spacing mul height add yoffset mul translate + + % Now use the baseline and justification information to translate so + % that the origin is at the baseline and positioning point for the + % first line of text. + + justify lineLength mul baseline neg translate + + % Iterate over each of the lines to output it. For each line, + % compute its width again so it can be properly justified, then + % display it. + + strings { + dup cstringwidth pop + justify neg mul 0 moveto + stipple { + + + % The text is stippled, so turn it into a path and print + % by calling StippledText, which in turn calls StippleFill. + % Unfortunately, many Postscript interpreters will get + % overflow errors if we try to do the whole string at + % once, so do it a character at a time. + + gsave + /char (X) def + { + dup type /stringtype eq { + % This segment is a string. + { + char 0 3 -1 roll put + currentpoint + gsave + char true charpath clip StippleText + grestore + char stringwidth translate + moveto + } forall + } { + % This segment is glyph name + % Temporary override + currentfont /Encoding get exch 1 exch put + currentpoint + gsave (\001) true charpath clip StippleText + grestore + (\001) stringwidth translate + moveto + } ifelse + } forall + grestore + } {cstringshow} ifelse + 0 spacing neg translate + } forall +} bind def + +%%EndProlog +%%BeginSetup +/CL 2 def +%%EndSetup + +%%Page: 1 1 +save +306.0 396.0 translate +0.846 0.846 scale +-158 -42 translate +28 84 moveto 288 84 lineto 288 0 lineto 28 0 lineto closepath clip newpath +gsave +70 42 moveto +102.360679774998 18.4885899083011 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +102.360679774998 18.4885899083011 moveto +102.360679774998 65.5114100916989 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +102.360679774998 65.5114100916989 moveto +70 42 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70 42 moveto +102.360679774998 65.511410091699 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +102.360679774998 65.511410091699 moveto +57.6393202250021 80.0422606518062 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +57.6393202250021 80.0422606518062 moveto +70 42 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70 42 moveto +57.6393202250022 80.0422606518062 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +57.6393202250022 80.0422606518062 moveto +30.0000000000001 42 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +30.0000000000001 42 moveto +70.0000000000001 42 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70.0000000000001 42 moveto +30.0000000000001 42 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +30.0000000000001 42 moveto +57.6393202250021 3.95773934819377 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +57.6393202250021 3.95773934819377 moveto +70.0000000000001 41.9999999999999 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +70.0000000000001 41.9999999999999 moveto +57.6393202250021 3.95773934819377 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +57.6393202250021 3.95773934819377 moveto +102.360679774998 18.4885899083011 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +102.360679774998 18.4885899083011 moveto +70 42 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160 41.9999999999999 moveto +194.641016151377 21.9999999999998 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +194.641016151377 21.9999999999998 moveto +194.641016151377 61.9999999999997 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +194.641016151377 61.9999999999997 moveto +160 41.9999999999998 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160 41.9999999999998 moveto +194.641016151377 61.9999999999999 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +194.641016151377 61.9999999999999 moveto +160 81.9999999999999 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160 81.9999999999999 moveto +160 41.9999999999999 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160 41.9999999999999 moveto +160 81.9999999999999 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160 81.9999999999999 moveto +125.358983848622 62 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +125.358983848622 62 moveto +160 42.0000000000001 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160 42.0000000000001 moveto +125.358983848622 62.0000000000001 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +125.358983848622 62.0000000000001 moveto +125.358983848622 22.0000000000001 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +125.358983848622 22.0000000000001 moveto +160 42.0000000000001 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160 42.0000000000001 moveto +125.358983848622 22 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +125.358983848622 22 moveto +160 2.00000000000006 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160 2.00000000000006 moveto +160 42.0000000000001 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160 42.0000000000001 moveto +160 2.00000000000006 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +160 2.00000000000006 moveto +194.641016151377 22.0000000000001 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +194.641016151377 22.0000000000001 moveto +160 42.0000000000001 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 42.0000000000005 moveto +286.038754716097 24.6446504352984 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +286.038754716097 24.6446504352984 moveto +286.038754716097 59.3553495647031 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +286.038754716097 59.3553495647031 moveto +250 42.0000000000011 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +250 42.0000000000011 moveto +286.038754716096 59.3553495647037 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +286.038754716096 59.3553495647037 moveto +258.900837358252 80.9971164872744 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +258.900837358252 80.9971164872744 moveto +249.999999999999 42.0000000000015 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.999999999999 42.0000000000015 moveto +258.900837358252 80.9971164872746 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +258.900837358252 80.9971164872746 moveto +225.06040792565 73.2732592987229 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +225.06040792565 73.2732592987229 moveto +249.999999999999 42.0000000000014 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.999999999999 42.0000000000014 moveto +225.060407925649 73.2732592987224 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +225.060407925649 73.2732592987224 moveto +209.999999999998 42.0000000000013 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +209.999999999998 42.0000000000013 moveto +249.999999999998 42.0000000000008 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.999999999998 42.0000000000008 moveto +209.999999999998 42 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +209.999999999998 42 moveto +225.060407925649 10.7267407012788 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +225.060407925649 10.7267407012788 moveto +249.999999999999 41.9999999999997 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.999999999999 41.9999999999997 moveto +225.06040792565 10.726740701278 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +225.06040792565 10.726740701278 moveto +258.900837358252 3.00288351272661 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +258.900837358252 3.00288351272661 moveto +249.999999999999 41.9999999999995 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +249.999999999999 41.9999999999995 moveto +258.900837358253 3.00288351272675 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +258.900837358253 3.00288351272675 moveto +286.038754716097 24.6446504352977 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +gsave +286.038754716097 24.6446504352977 moveto +250 41.9999999999999 lineto +0 setlinecap +1 setlinejoin +1 setlinewidth +[] 0 setdash +0.000 0.000 0.000 setrgbcolor AdjustColor +stroke +grestore +restore showpage + +%%Trailer +end +%%EOF diff --git a/attic/latex/figs/pies.pdf b/attic/latex/figs/pies.pdf new file mode 100644 index 0000000..b3a18a4 Binary files /dev/null and b/attic/latex/figs/pies.pdf differ diff --git a/attic/latex/figs/point.eps b/attic/latex/figs/point.eps new file mode 100644 index 0000000..8356ba9 --- /dev/null +++ b/attic/latex/figs/point.eps @@ -0,0 +1,147 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: point.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Wed Jul 25 13:34:31 2007 +%%For: downey@rocky.olin.edu (Allen Downey) +%%BoundingBox: 0 0 118 53 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 53 moveto 0 0 lineto 118 0 lineto 118 53 lineto closepath clip newpath +-58.8 99.7 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +7.500 slw +n 1800 975 m 2925 975 l 2925 1650 l 1800 1650 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2490 1477 m 2490 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +2490 1177 m 2490 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +% Polyline +gs clippath +1815 1147 m 1815 1087 l 1663 1087 l 1783 1117 l 1663 1147 l cp +eoclip +n 1425 1117 m + 1800 1117 l gs col0 s gr gr + +% arrowhead +n 1663 1147 m 1783 1117 l 1663 1087 l col0 s +/Helvetica ff 165.00 scf sf +2025 1200 m +gs 1 -1 sc (x) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 1500 m +gs 1 -1 sc (y) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1200 m +gs 1 -1 sc (3.0) col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1500 m +gs 1 -1 sc (4.0) col0 sh gr +/Helvetica ff 165.00 scf sf +1350 1170 m +gs 1 -1 sc (blank) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +1800 900 m +gs 1 -1 sc (Point) col0 sh gr +% here ends figure; +$F2psEnd +rs +showpage diff --git a/attic/latex/figs/point.fig b/attic/latex/figs/point.fig new file mode 100644 index 0000000..30afbce --- /dev/null +++ b/attic/latex/figs/point.fig @@ -0,0 +1,26 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 975 2925 975 2925 1650 1800 1650 1800 975 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1425 1117 1800 1117 +4 2 0 50 0 16 11 0.0000 4 90 90 2025 1200 x\001 +4 2 0 50 0 16 11 0.0000 4 120 75 2025 1500 y\001 +4 0 0 50 0 16 11 0.0000 4 120 225 2550 1200 3.0\001 +4 0 0 50 0 16 11 0.0000 4 120 225 2550 1500 4.0\001 +4 2 0 50 0 16 11 0.0000 4 120 360 1350 1170 blank\001 +4 0 0 50 0 16 11 0.0000 4 120 375 1800 900 Point\001 diff --git a/attic/latex/figs/point.pdf b/attic/latex/figs/point.pdf new file mode 100644 index 0000000..36952d7 Binary files /dev/null and b/attic/latex/figs/point.pdf differ diff --git a/attic/latex/figs/rectangle.eps b/attic/latex/figs/rectangle.eps new file mode 100644 index 0000000..26ad4a9 --- /dev/null +++ b/attic/latex/figs/rectangle.eps @@ -0,0 +1,206 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: rectangle.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5a +%%CreationDate: Wed May 30 11:35:27 2012 +%%BoundingBox: 0 0 219 74 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 74 moveto 0 0 lineto 219 0 lineto 219 74 lineto closepath clip newpath +-39.1 117.7 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 3300 1350 m 4275 1350 l 4275 1950 l 3300 1950 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1425 975 m 3075 975 l 3075 1950 l 1425 1950 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +3763 1852 m 3915 1852 l 3915 1792 l 3763 1792 l 3763 1792 l 3883 1822 l 3763 1852 l cp +eoclip +n 3525 1822 m + 3900 1822 l gs col0 s gr gr + +% arrowhead +n 3763 1852 m 3883 1822 l 3763 1792 l col0 s +% Polyline +gs clippath +3763 1552 m 3915 1552 l 3915 1492 l 3763 1492 l 3763 1492 l 3883 1522 l 3763 1552 l cp +eoclip +n 3525 1522 m + 3900 1522 l gs col0 s gr gr + +% arrowhead +n 3763 1552 m 3883 1522 l 3763 1492 l col0 s +% Polyline +gs clippath +2338 1477 m 2490 1477 l 2490 1417 l 2338 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +3158 1775 m 3310 1774 l 3309 1714 l 3157 1715 l 3157 1715 l 3278 1745 l 3158 1775 l cp +eoclip +n 2100 1747 m + 3295 1745 l gs col0 s gr gr + +% arrowhead +n 3158 1775 m 3278 1745 l 3157 1715 l col0 s +% Polyline +gs clippath +2338 1177 m 2490 1177 l 2490 1117 l 2338 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +% Polyline +gs clippath +1276 1170 m 1428 1170 l 1428 1110 l 1276 1110 l 1276 1110 l 1396 1140 l 1276 1170 l cp +eoclip +n 1028 1140 m + 1413 1140 l gs col0 s gr gr + +% arrowhead +n 1276 1170 m 1396 1140 l 1276 1110 l col0 s +/Helvetica ff 183.33 scf sf +3450 1875 m +gs 1 -1 sc (y) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +3975 1575 m +gs 1 -1 sc (0.0) col0 sh gr +/Helvetica ff 183.33 scf sf +3450 1575 m +gs 1 -1 sc (x) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +3975 1875 m +gs 1 -1 sc (0.0) col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1200 m +gs 1 -1 sc (width) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1200 m +gs 1 -1 sc (100.0) col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1800 m +gs 1 -1 sc (corner) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1500 m +gs 1 -1 sc (200.0) col0 sh gr +/Helvetica ff 183.33 scf sf +3300 1275 m +gs 1 -1 sc (Point) col0 sh gr +/Helvetica ff 183.33 scf sf +1500 900 m +gs 1 -1 sc (Rectangle) col0 sh gr +/Helvetica ff 183.33 scf sf +975 1200 m +gs 1 -1 sc (box) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1500 m +gs 1 -1 sc (height) dup sw pop neg 0 rm col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/rectangle.fig b/attic/latex/figs/rectangle.fig new file mode 100644 index 0000000..6ce860c --- /dev/null +++ b/attic/latex/figs/rectangle.fig @@ -0,0 +1,45 @@ +#FIG 3.2 Produced by xfig version 3.2.5b +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 3300 1350 4275 1950 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3525 1822 3900 1822 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3525 1522 3900 1522 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 3300 1350 4275 1350 4275 1950 3300 1950 3300 1350 +4 2 0 50 0 16 11 0.0000 4 150 105 3450 1875 y\001 +4 0 0 50 0 16 11 0.0000 4 135 255 3975 1575 0.0\001 +4 2 0 50 0 16 11 0.0000 4 105 90 3450 1575 x\001 +4 0 0 50 0 16 11 0.0000 4 135 255 3975 1875 0.0\001 +-6 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1747 3295 1745 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1028 1140 1413 1140 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1425 975 3075 975 3075 1950 1425 1950 1425 975 +4 2 0 50 0 16 11 0.0000 4 135 435 2025 1200 width\001 +4 0 0 50 0 16 11 0.0000 4 135 465 2550 1200 100.0\001 +4 2 0 50 0 16 11 0.0000 4 105 540 2025 1800 corner\001 +4 0 0 50 0 16 11 0.0000 4 135 465 2550 1500 200.0\001 +4 0 0 50 0 16 11 0.0000 4 135 420 3300 1275 Point\001 +4 0 0 50 0 16 11 0.0000 4 180 840 1500 900 Rectangle\001 +4 2 0 50 0 16 11 0.0000 4 135 300 975 1200 box\001 +4 2 0 50 0 16 11 0.0000 4 180 510 2025 1500 height\001 diff --git a/attic/latex/figs/rectangle.pdf b/attic/latex/figs/rectangle.pdf new file mode 100644 index 0000000..79bc921 Binary files /dev/null and b/attic/latex/figs/rectangle.pdf differ diff --git a/attic/latex/figs/rectangle2.eps b/attic/latex/figs/rectangle2.eps new file mode 100644 index 0000000..2819cf2 --- /dev/null +++ b/attic/latex/figs/rectangle2.eps @@ -0,0 +1,257 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: rectangle2.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5a +%%CreationDate: Wed May 30 11:38:48 2012 +%%BoundingBox: 0 0 370 60 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 60 moveto 0 0 lineto 370 0 lineto 370 60 lineto closepath clip newpath +-43.6 117.7 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 3300 1350 m 4275 1350 l 4275 1950 l 3300 1950 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1425 975 m 3075 975 l 3075 1950 l 1425 1950 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 4500 975 m 6075 975 l 6075 1950 l 4500 1950 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +3763 1852 m 3915 1852 l 3915 1792 l 3763 1792 l 3763 1792 l 3883 1822 l 3763 1852 l cp +eoclip +n 3525 1822 m + 3900 1822 l gs col0 s gr gr + +% arrowhead +n 3763 1852 m 3883 1822 l 3763 1792 l col0 s +% Polyline +gs clippath +3763 1552 m 3915 1552 l 3915 1492 l 3763 1492 l 3763 1492 l 3883 1522 l 3763 1552 l cp +eoclip +n 3525 1522 m + 3900 1522 l gs col0 s gr gr + +% arrowhead +n 3763 1552 m 3883 1522 l 3763 1492 l col0 s +% Polyline +gs clippath +2338 1477 m 2490 1477 l 2490 1417 l 2338 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +2338 1177 m 2490 1177 l 2490 1117 l 2338 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +% Polyline +gs clippath +5162 1417 m 5010 1417 l 5010 1477 l 5162 1477 l 5162 1477 l 5042 1447 l 5162 1417 l cp +eoclip +n 5400 1447 m + 5025 1447 l gs col0 s gr gr + +% arrowhead +n 5162 1417 m 5042 1447 l 5162 1477 l col0 s +% Polyline +gs clippath +5162 1117 m 5010 1117 l 5010 1177 l 5162 1177 l 5162 1177 l 5042 1147 l 5162 1117 l cp +eoclip +n 5400 1147 m + 5025 1147 l gs col0 s gr gr + +% arrowhead +n 5162 1117 m 5042 1147 l 5162 1177 l col0 s +% Polyline +gs clippath +3158 1775 m 3310 1774 l 3309 1714 l 3157 1715 l 3157 1715 l 3278 1745 l 3158 1775 l cp +eoclip +n 2100 1747 m + 3295 1745 l gs col0 s gr gr + +% arrowhead +n 3158 1775 m 3278 1745 l 3157 1715 l col0 s +% Polyline +gs clippath +4409 1725 m 4257 1724 l 4256 1784 l 4408 1785 l 4408 1785 l 4289 1755 l 4409 1725 l cp +eoclip +n 5467 1757 m + 4272 1755 l gs col0 s gr gr + +% arrowhead +n 4409 1725 m 4289 1755 l 4408 1785 l col0 s +% Polyline +gs clippath +1303 1177 m 1455 1177 l 1455 1117 l 1303 1117 l 1303 1117 l 1423 1147 l 1303 1177 l cp +eoclip +n 1080 1147 m + 1440 1147 l gs col0 s gr gr + +% arrowhead +n 1303 1177 m 1423 1147 l 1303 1117 l col0 s +% Polyline +gs clippath +6227 1117 m 6075 1117 l 6075 1177 l 6227 1177 l 6227 1177 l 6107 1147 l 6227 1117 l cp +eoclip +n 6435 1147 m + 6090 1147 l gs col0 s gr gr + +% arrowhead +n 6227 1117 m 6107 1147 l 6227 1177 l col0 s +/Helvetica ff 183.33 scf sf +3450 1875 m +gs 1 -1 sc (y) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +3975 1575 m +gs 1 -1 sc (0.0) col0 sh gr +/Helvetica ff 183.33 scf sf +3450 1575 m +gs 1 -1 sc (x) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +3975 1875 m +gs 1 -1 sc (0.0) col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1200 m +gs 1 -1 sc (width) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1500 m +gs 1 -1 sc (height) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1200 m +gs 1 -1 sc (100.0) col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1800 m +gs 1 -1 sc (corner) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1500 m +gs 1 -1 sc (200.0) col0 sh gr +/Helvetica ff 183.33 scf sf +1050 1200 m +gs 1 -1 sc (box) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +4575 1200 m +gs 1 -1 sc (100.0) col0 sh gr +/Helvetica ff 183.33 scf sf +4575 1500 m +gs 1 -1 sc (200.0) col0 sh gr +/Helvetica ff 183.33 scf sf +5475 1200 m +gs 1 -1 sc (width) col0 sh gr +/Helvetica ff 183.33 scf sf +5475 1500 m +gs 1 -1 sc (height) col0 sh gr +/Helvetica ff 183.33 scf sf +5475 1800 m +gs 1 -1 sc (corner) col0 sh gr +/Helvetica ff 183.33 scf sf +6450 1200 m +gs 1 -1 sc (box2) col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/rectangle2.fig b/attic/latex/figs/rectangle2.fig new file mode 100644 index 0000000..8eb0f4a --- /dev/null +++ b/attic/latex/figs/rectangle2.fig @@ -0,0 +1,67 @@ +#FIG 3.2 Produced by xfig version 3.2.5b +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 3300 1350 4275 1950 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3525 1822 3900 1822 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3525 1522 3900 1522 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 3300 1350 4275 1350 4275 1950 3300 1950 3300 1350 +4 2 0 50 0 16 11 0.0000 4 150 105 3450 1875 y\001 +4 0 0 50 0 16 11 0.0000 4 135 255 3975 1575 0.0\001 +4 2 0 50 0 16 11 0.0000 4 105 90 3450 1575 x\001 +4 0 0 50 0 16 11 0.0000 4 135 255 3975 1875 0.0\001 +-6 +6 2100 1050 2475 1500 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +-6 +6 5025 1050 5400 1500 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 5400 1447 5025 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 5400 1147 5025 1147 +-6 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1747 3295 1745 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 5467 1757 4272 1755 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1080 1147 1440 1147 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1425 975 3075 975 3075 1950 1425 1950 1425 975 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 6435 1147 6090 1147 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 4500 975 6075 975 6075 1950 4500 1950 4500 975 +4 2 0 50 0 16 11 0.0000 4 135 435 2025 1200 width\001 +4 2 0 50 0 16 11 0.0000 4 180 510 2025 1500 height\001 +4 0 0 50 0 16 11 0.0000 4 135 465 2550 1200 100.0\001 +4 2 0 50 0 16 11 0.0000 4 105 540 2025 1800 corner\001 +4 0 0 50 0 16 11 0.0000 4 135 465 2550 1500 200.0\001 +4 2 0 50 0 16 11 0.0000 4 135 300 1050 1200 box\001 +4 0 0 50 0 16 11 0.0000 4 135 465 4575 1200 100.0\001 +4 0 0 50 0 16 11 0.0000 4 135 465 4575 1500 200.0\001 +4 0 0 50 0 16 11 0.0000 4 135 435 5475 1200 width\001 +4 0 0 50 0 16 11 0.0000 4 180 510 5475 1500 height\001 +4 0 0 50 0 16 11 0.0000 4 105 540 5475 1800 corner\001 +4 0 0 50 0 16 11 0.0000 4 135 405 6450 1200 box2\001 diff --git a/attic/latex/figs/rectangle2.pdf b/attic/latex/figs/rectangle2.pdf new file mode 100644 index 0000000..3197c5c Binary files /dev/null and b/attic/latex/figs/rectangle2.pdf differ diff --git a/attic/latex/figs/stack.eps b/attic/latex/figs/stack.eps new file mode 100644 index 0000000..c377a9b --- /dev/null +++ b/attic/latex/figs/stack.eps @@ -0,0 +1,219 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: stack.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5e +%%CreationDate: Mon Jul 27 11:38:05 2015 +%%BoundingBox: 0 0 284 141 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 141 moveto 0 0 lineto 284 0 lineto 284 141 lineto closepath clip newpath +-14.6 198.7 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 1424 2925 m 4950 2925 l 4950 3300 l 1424 3300 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1425 1800 m 4950 1800 l 4950 2775 l 1425 2775 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1425 975 m 4950 975 l 4950 1650 l 1425 1650 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2338 2302 m 2490 2302 l 2490 2242 l 2338 2242 l 2338 2242 l 2458 2272 l 2338 2302 l cp +eoclip +n 2100 2272 m + 2475 2272 l gs col0 s gr gr + +% arrowhead +n 2338 2302 m 2458 2272 l 2338 2242 l col0 s +% Polyline +gs clippath +2338 2602 m 2490 2602 l 2490 2542 l 2338 2542 l 2338 2542 l 2458 2572 l 2338 2602 l cp +eoclip +n 2100 2572 m + 2475 2572 l gs col0 s gr gr + +% arrowhead +n 2338 2602 m 2458 2572 l 2338 2542 l col0 s +% Polyline +gs clippath +2338 2002 m 2490 2002 l 2490 1942 l 2338 1942 l 2338 1942 l 2458 1972 l 2338 2002 l cp +eoclip +n 2100 1972 m + 2475 1972 l gs col0 s gr gr + +% arrowhead +n 2338 2002 m 2458 1972 l 2338 1942 l col0 s +% Polyline +gs clippath +2338 1477 m 2490 1477 l 2490 1417 l 2338 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +2338 1177 m 2490 1177 l 2490 1117 l 2338 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +% Polyline +gs clippath +2330 3127 m 2482 3127 l 2482 3067 l 2330 3067 l 2330 3067 l 2450 3097 l 2330 3127 l cp +eoclip +n 2092 3097 m + 2467 3097 l gs col0 s gr gr + +% arrowhead +n 2330 3127 m 2450 3097 l 2330 3067 l col0 s +/Helvetica ff 183.33 scf sf +2025 1200 m +gs 1 -1 sc (line1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1500 m +gs 1 -1 sc (line2) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1500 m +gs 1 -1 sc ('tiddle bang.') col0 sh gr +/Helvetica ff 183.33 scf sf +2025 2025 m +gs 1 -1 sc (part1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 2325 m +gs 1 -1 sc (part2) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 2625 m +gs 1 -1 sc (cat) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2017 3150 m +gs 1 -1 sc (bruce) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1200 m +gs 1 -1 sc ('Bing tiddle ') col0 sh gr +/Helvetica ff 183.33 scf sf +2550 2025 m +gs 1 -1 sc ('Bing tiddle ') col0 sh gr +/Helvetica ff 183.33 scf sf +2550 2325 m +gs 1 -1 sc ('tiddle bang.') col0 sh gr +/Helvetica ff 183.33 scf sf +2550 2625 m +gs 1 -1 sc ('Bing tiddle tiddle bang.') col0 sh gr +/Helvetica ff 183.33 scf sf +2550 3150 m +gs 1 -1 sc ('Bing tiddle tiddle bang.') col0 sh gr +/Helvetica ff 183.33 scf sf +1275 2325 m +gs 1 -1 sc (cat_twice) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1275 3150 m +gs 1 -1 sc (print_twice) dup sw pop neg 0 rm col0 sh gr +% __main__ +/Helvetica ff 183.33 scf sf +1275 1350 m +gs 1 -1 sc (__main__) dup sw pop neg 0 rm col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/stack.fig b/attic/latex/figs/stack.fig new file mode 100644 index 0000000..a8e4b9e --- /dev/null +++ b/attic/latex/figs/stack.fig @@ -0,0 +1,51 @@ +#FIG 3.2 Produced by xfig version 3.2.5c +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 2100 1897 2475 2647 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 2272 2475 2272 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 2572 2475 2572 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1972 2475 1972 +-6 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2092 3097 2467 3097 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1424 2925 4950 2925 4950 3300 1424 3300 1424 2925 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1425 1800 4950 1800 4950 2775 1425 2775 1425 1800 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1425 975 4950 975 4950 1650 1425 1650 1425 975 +4 2 0 50 0 16 11 0.0000 4 135 450 2025 1200 line1\001 +4 2 0 50 0 16 11 0.0000 4 135 450 2025 1500 line2\001 +4 0 0 50 0 16 11 0.0000 4 165 1260 2550 1500 'tiddle bang.'\001 +4 2 0 50 0 16 11 0.0000 4 165 450 2025 2025 part1\001 +4 2 0 50 0 16 11 0.0000 4 165 450 2025 2325 part2\001 +4 2 0 50 0 16 11 0.0000 4 120 270 2025 2625 cat\001 +4 2 0 50 0 16 11 0.0000 4 135 450 2017 3150 bruce\001 +4 0 0 50 0 16 11 0.0000 4 165 1260 2550 1200 'Bing tiddle '\001 +4 0 0 50 0 16 11 0.0000 4 165 1260 2550 2025 'Bing tiddle '\001 +4 0 0 50 0 16 11 0.0000 4 165 1260 2550 2325 'tiddle bang.'\001 +4 0 0 50 0 16 11 0.0000 4 165 2340 2550 2625 'Bing tiddle tiddle bang.'\001 +4 0 0 50 0 16 11 0.0000 4 165 2340 2550 3150 'Bing tiddle tiddle bang.'\001 +4 2 0 50 0 16 11 0.0000 4 135 810 1275 2325 cat_twice\001 +4 2 0 50 0 16 11 0.0000 4 150 990 1275 3150 print_twice\001 +# __main__ +4 2 0 50 0 16 11 0.0000 4 135 720 1275 1350 __main__\001 diff --git a/attic/latex/figs/stack.pdf b/attic/latex/figs/stack.pdf new file mode 100644 index 0000000..f402410 Binary files /dev/null and b/attic/latex/figs/stack.pdf differ diff --git a/attic/latex/figs/stack2.eps b/attic/latex/figs/stack2.eps new file mode 100644 index 0000000..0e82547 --- /dev/null +++ b/attic/latex/figs/stack2.eps @@ -0,0 +1,200 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: stack2.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5d +%%CreationDate: Mon Oct 19 10:20:09 2015 +%%BoundingBox: 0 0 139 150 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 150 moveto 0 0 lineto 139 0 lineto 139 150 lineto closepath clip newpath +-42.7 176.2 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 1800 450 m 3000 450 l 3000 825 l 1800 825 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1800 975 m 3000 975 l 3000 1350 l 1800 1350 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1800 1500 m 3000 1500 l 3000 1875 l 1800 1875 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1800 2025 m 3000 2025 l 3000 2400 l 1800 2400 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1800 2550 m 3000 2550 l 3000 2925 l 1800 2925 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2413 1177 m 2565 1177 l 2565 1117 l 2413 1117 l 2413 1117 l 2533 1147 l 2413 1177 l cp +eoclip +n 2175 1147 m + 2550 1147 l gs col0 s gr gr + +% arrowhead +n 2413 1177 m 2533 1147 l 2413 1117 l col0 s +% Polyline +gs clippath +2413 1702 m 2565 1702 l 2565 1642 l 2413 1642 l 2413 1642 l 2533 1672 l 2413 1702 l cp +eoclip +n 2175 1672 m + 2550 1672 l gs col0 s gr gr + +% arrowhead +n 2413 1702 m 2533 1672 l 2413 1642 l col0 s +% Polyline +gs clippath +2413 2227 m 2565 2227 l 2565 2167 l 2413 2167 l 2413 2167 l 2533 2197 l 2413 2227 l cp +eoclip +n 2175 2197 m + 2550 2197 l gs col0 s gr gr + +% arrowhead +n 2413 2227 m 2533 2197 l 2413 2167 l col0 s +% Polyline +gs clippath +2413 2752 m 2565 2752 l 2565 2692 l 2413 2692 l 2413 2692 l 2533 2722 l 2413 2752 l cp +eoclip +n 2175 2722 m + 2550 2722 l gs col0 s gr gr + +% arrowhead +n 2413 2752 m 2533 2722 l 2413 2692 l col0 s +/Helvetica ff 183.33 scf sf +1650 675 m +gs 1 -1 sc (__main__) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1650 1200 m +gs 1 -1 sc (countdown) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1650 1725 m +gs 1 -1 sc (countdown) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1650 2250 m +gs 1 -1 sc (countdown) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1650 2775 m +gs 1 -1 sc (countdown) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2100 1200 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2625 1200 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 183.33 scf sf +2100 1725 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2625 1725 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 183.33 scf sf +2100 2250 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2625 2250 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 183.33 scf sf +2100 2775 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2625 2775 m +gs 1 -1 sc (0) col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/stack2.fig b/attic/latex/figs/stack2.fig new file mode 100644 index 0000000..4826deb --- /dev/null +++ b/attic/latex/figs/stack2.fig @@ -0,0 +1,44 @@ +#FIG 3.2 Produced by xfig version 3.2.5c +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 450 3000 450 3000 825 1800 825 1800 450 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 975 3000 975 3000 1350 1800 1350 1800 975 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 1500 3000 1500 3000 1875 1800 1875 1800 1500 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 2025 3000 2025 3000 2400 1800 2400 1800 2025 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 2550 3000 2550 3000 2925 1800 2925 1800 2550 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 1147 2550 1147 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 1672 2550 1672 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 2197 2550 2197 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 2722 2550 2722 +4 2 0 50 0 16 11 0.0000 4 135 720 1650 675 __main__\001 +4 2 0 50 0 16 11 0.0000 4 135 810 1650 1200 countdown\001 +4 2 0 50 0 16 11 0.0000 4 135 810 1650 1725 countdown\001 +4 2 0 50 0 16 11 0.0000 4 135 810 1650 2250 countdown\001 +4 2 0 50 0 16 11 0.0000 4 135 810 1650 2775 countdown\001 +4 2 0 50 0 16 11 0.0000 4 90 90 2100 1200 n\001 +4 0 0 50 0 16 11 0.0000 4 135 90 2625 1200 3\001 +4 2 0 50 0 16 11 0.0000 4 90 90 2100 1725 n\001 +4 0 0 50 0 16 11 0.0000 4 135 90 2625 1725 2\001 +4 2 0 50 0 16 11 0.0000 4 90 90 2100 2250 n\001 +4 0 0 50 0 16 11 0.0000 4 135 90 2625 2250 1\001 +4 2 0 50 0 16 11 0.0000 4 90 90 2100 2775 n\001 +4 0 0 50 0 16 11 0.0000 4 135 90 2625 2775 0\001 diff --git a/attic/latex/figs/stack2.pdf b/attic/latex/figs/stack2.pdf new file mode 100644 index 0000000..8625e86 Binary files /dev/null and b/attic/latex/figs/stack2.pdf differ diff --git a/attic/latex/figs/stack3.eps b/attic/latex/figs/stack3.eps new file mode 100644 index 0000000..b894ef6 --- /dev/null +++ b/attic/latex/figs/stack3.eps @@ -0,0 +1,342 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: stack3.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5e +%%CreationDate: Mon Jul 27 11:39:42 2015 +%%BoundingBox: 0 0 319 150 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 150 moveto 0 0 lineto 319 0 lineto 319 150 lineto closepath clip newpath +-48.2 176.2 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 1800 975 m 5700 975 l 5700 1350 l 1800 1350 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1800 1500 m 5700 1500 l 5700 1875 l 1800 1875 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1800 2025 m 5700 2025 l 5700 2400 l 1800 2400 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1800 2550 m 5700 2550 l 5700 2925 l 1800 2925 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1800 450 m 5700 450 l 5700 825 l 1800 825 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2413 1177 m 2565 1177 l 2565 1117 l 2413 1117 l 2413 1117 l 2533 1147 l 2413 1177 l cp +eoclip +n 2175 1147 m + 2550 1147 l gs col0 s gr gr + +% arrowhead +n 2413 1177 m 2533 1147 l 2413 1117 l col0 s +% Polyline +gs clippath +3913 1177 m 4065 1177 l 4065 1117 l 3913 1117 l 3913 1117 l 4033 1147 l 3913 1177 l cp +eoclip +n 3675 1147 m + 4050 1147 l gs col0 s gr gr + +% arrowhead +n 3913 1177 m 4033 1147 l 3913 1117 l col0 s +% Polyline +gs clippath +3913 1702 m 4065 1702 l 4065 1642 l 3913 1642 l 3913 1642 l 4033 1672 l 3913 1702 l cp +eoclip +n 3675 1672 m + 4050 1672 l gs col0 s gr gr + +% arrowhead +n 3913 1702 m 4033 1672 l 3913 1642 l col0 s +% Polyline +gs clippath +3913 2227 m 4065 2227 l 4065 2167 l 3913 2167 l 3913 2167 l 4033 2197 l 3913 2227 l cp +eoclip +n 3675 2197 m + 4050 2197 l gs col0 s gr gr + +% arrowhead +n 3913 2227 m 4033 2197 l 3913 2167 l col0 s +% Arc +gs clippath +5839 2262 m 5694 2216 l 5676 2274 l 5821 2319 l 5821 2319 l 5716 2255 l 5839 2262 l cp +eoclip +n 5700.0 2475.0 225.0 90.0000 -90.0000 arcn +gs col0 s gr + gr + +% arrowhead +n 5839 2262 m 5716 2255 l 5821 2319 l col0 s +% Arc +gs clippath +5839 1737 m 5694 1691 l 5676 1749 l 5821 1794 l 5821 1794 l 5716 1730 l 5839 1737 l cp +eoclip +n 5700.0 1950.0 225.0 90.0000 -90.0000 arcn +gs col0 s gr + gr + +% arrowhead +n 5839 1737 m 5716 1730 l 5821 1794 l col0 s +% Arc +gs clippath +5839 687 m 5694 641 l 5676 699 l 5821 744 l 5821 744 l 5716 680 l 5839 687 l cp +eoclip +n 5700.0 900.0 225.0 90.0000 -90.0000 arcn +gs col0 s gr + gr + +% arrowhead +n 5839 687 m 5716 680 l 5821 744 l col0 s +% Arc +gs clippath +5839 1212 m 5694 1166 l 5676 1224 l 5821 1269 l 5821 1269 l 5716 1205 l 5839 1212 l cp +eoclip +n 5700.0 1425.0 225.0 90.0000 -90.0000 arcn +gs col0 s gr + gr + +% arrowhead +n 5839 1212 m 5716 1205 l 5821 1269 l col0 s +% Polyline +gs clippath +2413 1702 m 2565 1702 l 2565 1642 l 2413 1642 l 2413 1642 l 2533 1672 l 2413 1702 l cp +eoclip +n 2175 1672 m + 2550 1672 l gs col0 s gr gr + +% arrowhead +n 2413 1702 m 2533 1672 l 2413 1642 l col0 s +% Polyline +gs clippath +2413 2227 m 2565 2227 l 2565 2167 l 2413 2167 l 2413 2167 l 2533 2197 l 2413 2227 l cp +eoclip +n 2175 2197 m + 2550 2197 l gs col0 s gr gr + +% arrowhead +n 2413 2227 m 2533 2197 l 2413 2167 l col0 s +% Polyline +gs clippath +2413 2752 m 2565 2752 l 2565 2692 l 2413 2692 l 2413 2692 l 2533 2722 l 2413 2752 l cp +eoclip +n 2175 2722 m + 2550 2722 l gs col0 s gr gr + +% arrowhead +n 2413 2752 m 2533 2722 l 2413 2692 l col0 s +% Polyline +gs clippath +5263 2227 m 5415 2227 l 5415 2167 l 5263 2167 l 5263 2167 l 5383 2197 l 5263 2227 l cp +eoclip +n 5025 2197 m + 5400 2197 l gs col0 s gr gr + +% arrowhead +n 5263 2227 m 5383 2197 l 5263 2167 l col0 s +% Polyline +gs clippath +5263 1702 m 5415 1702 l 5415 1642 l 5263 1642 l 5263 1642 l 5383 1672 l 5263 1702 l cp +eoclip +n 5025 1672 m + 5400 1672 l gs col0 s gr gr + +% arrowhead +n 5263 1702 m 5383 1672 l 5263 1642 l col0 s +% Polyline +gs clippath +5263 1177 m 5415 1177 l 5415 1117 l 5263 1117 l 5263 1117 l 5383 1147 l 5263 1177 l cp +eoclip +n 5025 1147 m + 5400 1147 l gs col0 s gr gr + +% arrowhead +n 5263 1177 m 5383 1147 l 5263 1117 l col0 s +/Helvetica ff 183.33 scf sf +2100 1200 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2625 1200 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 183.33 scf sf +3600 1200 m +gs 1 -1 sc (recurse) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +4125 1200 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 183.33 scf sf +3600 1725 m +gs 1 -1 sc (recurse) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +4125 1725 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 183.33 scf sf +3600 2250 m +gs 1 -1 sc (recurse) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +4125 2250 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 183.33 scf sf +1650 675 m +gs 1 -1 sc (__main__) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1650 1200 m +gs 1 -1 sc (factorial) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2100 1725 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2625 1725 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 183.33 scf sf +2100 2250 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2625 2250 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 183.33 scf sf +2100 2775 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2625 2775 m +gs 1 -1 sc (0) col0 sh gr +/Helvetica ff 183.33 scf sf +1650 1725 m +gs 1 -1 sc (factorial) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1650 2250 m +gs 1 -1 sc (factorial) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +1650 2775 m +gs 1 -1 sc (factorial) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +6000 2550 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 183.33 scf sf +6000 2025 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 183.33 scf sf +6000 1500 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 183.33 scf sf +6000 975 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 183.33 scf sf +5475 2250 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 183.33 scf sf +4950 2250 m +gs 1 -1 sc (result) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +5475 1725 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 183.33 scf sf +5475 1200 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 183.33 scf sf +4950 1200 m +gs 1 -1 sc (result) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +4950 1725 m +gs 1 -1 sc (result) dup sw pop neg 0 rm col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/stack3.fig b/attic/latex/figs/stack3.fig new file mode 100644 index 0000000..623fa28 --- /dev/null +++ b/attic/latex/figs/stack3.fig @@ -0,0 +1,96 @@ +#FIG 3.2 Produced by xfig version 3.2.5c +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +5 1 0 1 0 7 50 0 -1 0.000 0 1 1 0 5700.000 2475.000 5700 2700 5925 2475 5700 2250 + 0 0 1.00 60.00 120.00 +5 1 0 1 0 7 50 0 -1 0.000 0 1 1 0 5700.000 1950.000 5700 2175 5925 1950 5700 1725 + 0 0 1.00 60.00 120.00 +5 1 0 1 0 7 50 0 -1 0.000 0 1 1 0 5700.000 900.000 5700 1125 5925 900 5700 675 + 0 0 1.00 60.00 120.00 +5 1 0 1 0 7 50 0 -1 0.000 0 1 1 0 5700.000 1425.000 5700 1650 5925 1425 5700 1200 + 0 0 1.00 60.00 120.00 +6 1950 1050 2775 1200 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 1147 2550 1147 +4 2 0 50 0 16 11 0.0000 4 90 90 2100 1200 n\001 +4 0 0 50 0 16 11 0.0000 4 135 90 2625 1200 3\001 +-6 +6 3075 1050 4275 2250 +6 3075 1050 4275 1200 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3675 1147 4050 1147 +4 2 0 50 0 16 11 0.0000 4 90 630 3600 1200 recurse\001 +4 0 0 50 0 16 11 0.0000 4 135 90 4125 1200 2\001 +-6 +6 3075 1575 4275 1725 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3675 1672 4050 1672 +4 2 0 50 0 16 11 0.0000 4 90 630 3600 1725 recurse\001 +4 0 0 50 0 16 11 0.0000 4 135 90 4125 1725 1\001 +-6 +6 3075 2100 4275 2250 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3675 2197 4050 2197 +4 2 0 50 0 16 11 0.0000 4 90 630 3600 2250 recurse\001 +4 0 0 50 0 16 11 0.0000 4 135 90 4125 2250 1\001 +-6 +-6 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 1672 2550 1672 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 2197 2550 2197 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 2722 2550 2722 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 975 5700 975 5700 1350 1800 1350 1800 975 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 1500 5700 1500 5700 1875 1800 1875 1800 1500 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 2025 5700 2025 5700 2400 1800 2400 1800 2025 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 2550 5700 2550 5700 2925 1800 2925 1800 2550 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 450 5700 450 5700 825 1800 825 1800 450 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 5025 2197 5400 2197 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 5025 1672 5400 1672 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 5025 1147 5400 1147 +4 2 0 50 0 16 11 0.0000 4 135 720 1650 675 __main__\001 +4 2 0 50 0 16 11 0.0000 4 135 810 1650 1200 factorial\001 +4 2 0 50 0 16 11 0.0000 4 90 90 2100 1725 n\001 +4 0 0 50 0 16 11 0.0000 4 135 90 2625 1725 2\001 +4 2 0 50 0 16 11 0.0000 4 90 90 2100 2250 n\001 +4 0 0 50 0 16 11 0.0000 4 135 90 2625 2250 1\001 +4 2 0 50 0 16 11 0.0000 4 90 90 2100 2775 n\001 +4 0 0 50 0 16 11 0.0000 4 135 90 2625 2775 0\001 +4 2 0 50 0 16 11 0.0000 4 135 810 1650 1725 factorial\001 +4 2 0 50 0 16 11 0.0000 4 135 810 1650 2250 factorial\001 +4 2 0 50 0 16 11 0.0000 4 135 810 1650 2775 factorial\001 +4 0 0 50 0 16 11 0.0000 4 135 90 6000 2550 1\001 +4 0 0 50 0 16 11 0.0000 4 135 90 6000 2025 1\001 +4 0 0 50 0 16 11 0.0000 4 135 90 6000 1500 2\001 +4 0 0 50 0 16 11 0.0000 4 135 90 6000 975 6\001 +4 0 0 50 0 16 11 0.0000 4 135 90 5475 2250 1\001 +4 2 0 50 0 16 11 0.0000 4 135 540 4950 2250 result\001 +4 0 0 50 0 16 11 0.0000 4 135 90 5475 1725 2\001 +4 0 0 50 0 16 11 0.0000 4 135 90 5475 1200 6\001 +4 2 0 50 0 16 11 0.0000 4 135 540 4950 1200 result\001 +4 2 0 50 0 16 11 0.0000 4 135 540 4950 1725 result\001 diff --git a/attic/latex/figs/stack3.pdf b/attic/latex/figs/stack3.pdf new file mode 100644 index 0000000..456bd93 Binary files /dev/null and b/attic/latex/figs/stack3.pdf differ diff --git a/attic/latex/figs/stack4.eps b/attic/latex/figs/stack4.eps new file mode 100644 index 0000000..430a3d4 --- /dev/null +++ b/attic/latex/figs/stack4.eps @@ -0,0 +1,173 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: stack4.eps +%%Creator: fig2dev Version 3.2 Patchlevel 3c +%%CreationDate: Fri Dec 14 14:02:13 2001 +%%For: downey@rocky.wellesley.edu (Allen B. Downey) +%%BoundingBox: 0 0 222 101 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 101 moveto 0 0 lineto 222 0 lineto 222 101 lineto closepath clip newpath +-40.0 145.0 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +%%Page: 1 1 +10 setmiterlimit + 0.06000 0.06000 sc +% +% Fig objects follow +% +% Polyline +7.500 slw +n 1800 1725 m 4350 1725 l 4350 2400 l 1800 2400 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 1800 750 m 4350 750 l 4350 1575 l 1800 1575 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline + [15 45] 45 sd +n 2175 1125 m + 2550 1125 l gs col0 s gr [] 0 sd +% Polyline + [15 45] 45 sd +n 2175 1125 m + 2550 900 l gs col0 s gr [] 0 sd +% Polyline +gs clippath +2547 1383 m 2578 1331 l 2448 1253 l 2536 1341 l 2417 1304 l cp +eoclip +n 2175 1125 m + 2550 1350 l gs col0 s gr gr + +% arrowhead +n 2417 1304 m 2536 1341 l 2448 1253 l col0 s +/Helvetica ff 165.00 scf sf +2100 1200 m +gs 1 -1 sc (i) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2625 1200 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 165.00 scf sf +2625 975 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +2625 1425 m +gs 1 -1 sc (3) col0 sh gr +% Polyline +gs clippath +2565 2130 m 2565 2070 l 2413 2070 l 2533 2100 l 2413 2130 l cp +eoclip +n 2175 2100 m + 2550 2100 l gs col0 s gr gr + +% arrowhead +n 2413 2130 m 2533 2100 l 2413 2070 l col0 s +% Polyline + [15 45] 45 sd +n 3300 2100 m + 3675 1875 l gs col0 s gr [] 0 sd +% Polyline +gs clippath +3690 2130 m 3690 2070 l 3538 2070 l 3658 2100 l 3538 2130 l cp +eoclip +n 3300 2100 m + 3675 2100 l gs col0 s gr gr + +% arrowhead +n 3538 2130 m 3658 2100 l 3538 2070 l col0 s +/Helvetica ff 165.00 scf sf +2100 2175 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2625 2175 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 165.00 scf sf +3225 2175 m +gs 1 -1 sc (i) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +3750 2175 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 165.00 scf sf +3750 1950 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +675 975 m +gs 1 -1 sc (printMultTable) col0 sh gr +/Helvetica ff 165.00 scf sf +750 1950 m +gs 1 -1 sc (printMultiples) col0 sh gr +$F2psEnd +rs diff --git a/attic/latex/figs/stack4.fig b/attic/latex/figs/stack4.fig new file mode 100644 index 0000000..d79f4c7 --- /dev/null +++ b/attic/latex/figs/stack4.fig @@ -0,0 +1,41 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 2025 825 2775 1425 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 2175 1125 2550 1125 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 2175 1125 2550 900 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 1125 2550 1350 +4 2 0 50 0 16 11 0.0000 4 120 30 2100 1200 i\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2625 1200 2\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2625 975 1\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2625 1425 3\001 +-6 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 2100 2550 2100 +2 1 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 + 3300 2100 3675 1875 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3300 2100 3675 2100 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 1725 4350 1725 4350 2400 1800 2400 1800 1725 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1800 750 4350 750 4350 1575 1800 1575 1800 750 +4 2 0 50 0 16 11 0.0000 4 90 90 2100 2175 n\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2625 2175 3\001 +4 2 0 50 0 16 11 0.0000 4 120 30 3225 2175 i\001 +4 0 0 50 0 16 11 0.0000 4 120 90 3750 2175 2\001 +4 0 0 50 0 16 11 0.0000 4 120 90 3750 1950 1\001 +4 0 0 50 0 16 11 0.0000 4 150 975 675 975 printMultTable\001 +4 0 0 50 0 16 11 0.0000 4 150 930 750 1950 printMultiples\001 diff --git a/attic/latex/figs/stack4.pdf b/attic/latex/figs/stack4.pdf new file mode 100644 index 0000000..0797d08 Binary files /dev/null and b/attic/latex/figs/stack4.pdf differ diff --git a/attic/latex/figs/stack5.eps b/attic/latex/figs/stack5.eps new file mode 100644 index 0000000..92a8a36 --- /dev/null +++ b/attic/latex/figs/stack5.eps @@ -0,0 +1,197 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Title: stack5.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5e +%%CreationDate: Mon Jul 27 11:40:36 2015 +%%BoundingBox: 0 0 238 74 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 74 moveto 0 0 lineto 238 0 lineto 238 74 lineto closepath clip newpath +-96.1 162.7 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 2700 1500 m 3675 1500 l 3675 1950 l 2700 1950 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 2700 2100 m 3675 2100 l 3675 2550 l 2700 2550 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 4125 1725 m 5550 1725 l 5550 2700 l 4125 2700 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +4813 2227 m 4965 2227 l 4965 2167 l 4813 2167 l 4813 2167 l 4933 2197 l 4813 2227 l cp +eoclip +n 4575 2197 m + 4950 2197 l gs col0 s gr gr + +% arrowhead +n 4813 2227 m 4933 2197 l 4813 2167 l col0 s +% Polyline +gs clippath +4813 2527 m 4965 2527 l 4965 2467 l 4813 2467 l 4813 2467 l 4933 2497 l 4813 2527 l cp +eoclip +n 4575 2497 m + 4950 2497 l gs col0 s gr gr + +% arrowhead +n 4813 2527 m 4933 2497 l 4813 2467 l col0 s +% Polyline +gs clippath +4813 1927 m 4965 1927 l 4965 1867 l 4813 1867 l 4813 1867 l 4933 1897 l 4813 1927 l cp +eoclip +n 4575 1897 m + 4950 1897 l gs col0 s gr gr + +% arrowhead +n 4813 1927 m 4933 1897 l 4813 1867 l col0 s +% Polyline +gs clippath +3953 2051 m 4079 1966 l 4045 1916 l 3919 2001 l 3919 2001 l 4036 1959 l 3953 2051 l cp +eoclip +n 3507 2318 m + 4050 1950 l gs col0 s gr gr + +% arrowhead +n 3953 2051 m 4036 1959 l 3919 2001 l col0 s +% Polyline +gs clippath +3910 1867 m 4056 1907 l 4072 1850 l 3926 1809 l 3926 1809 l 4034 1871 l 3910 1867 l cp +eoclip +n 3510 1725 m + 4050 1875 l gs col0 s gr gr + +% arrowhead +n 3910 1867 m 4034 1871 l 3926 1809 l col0 s +/Helvetica ff 183.33 scf sf +4500 1950 m +gs 1 -1 sc (0) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +4500 2250 m +gs 1 -1 sc (1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +4500 2550 m +gs 1 -1 sc (2) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +5025 1950 m +gs 1 -1 sc ('a') col0 sh gr +/Helvetica ff 183.33 scf sf +5025 2250 m +gs 1 -1 sc ('b') col0 sh gr +/Helvetica ff 183.33 scf sf +5025 2550 m +gs 1 -1 sc ('c') col0 sh gr +/Helvetica ff 183.33 scf sf +4125 1650 m +gs 1 -1 sc (list) col0 sh gr +/Helvetica ff 183.33 scf sf +3450 2377 m +gs 1 -1 sc (t) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +3465 1770 m +gs 1 -1 sc (letters) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2632 2377 m +gs 1 -1 sc (delete_head) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2617 1770 m +gs 1 -1 sc (__main__) dup sw pop neg 0 rm col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/stack5.fig b/attic/latex/figs/stack5.fig new file mode 100644 index 0000000..6db872a --- /dev/null +++ b/attic/latex/figs/stack5.fig @@ -0,0 +1,41 @@ +#FIG 3.2 Produced by xfig version 3.2.5c +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4575 2197 4950 2197 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4575 2497 4950 2497 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4575 1897 4950 1897 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 2700 1500 3675 1500 3675 1950 2700 1950 2700 1500 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 2700 2100 3675 2100 3675 2550 2700 2550 2700 2100 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3507 2318 4050 1950 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3510 1725 4050 1875 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 4125 1725 5550 1725 5550 2700 4125 2700 4125 1725 +4 2 0 50 0 16 11 0.0000 4 135 90 4500 1950 0\001 +4 2 0 50 0 16 11 0.0000 4 135 90 4500 2250 1\001 +4 2 0 50 0 16 11 0.0000 4 135 90 4500 2550 2\001 +4 0 0 50 0 16 11 0.0000 4 135 270 5025 1950 'a'\001 +4 0 0 50 0 16 11 0.0000 4 135 270 5025 2250 'b'\001 +4 0 0 50 0 16 11 0.0000 4 135 270 5025 2550 'c'\001 +4 0 0 50 0 16 11 0.0000 4 135 360 4125 1650 list\001 +4 2 0 50 0 16 11 0.0000 4 120 90 3450 2377 t\001 +4 2 0 50 0 16 11 0.0000 4 135 630 3465 1770 letters\001 +4 2 0 50 0 16 11 0.0000 4 150 990 2632 2377 delete_head\001 +4 2 0 50 0 16 11 0.0000 4 135 720 2617 1770 __main__\001 diff --git a/attic/latex/figs/stack5.pdf b/attic/latex/figs/stack5.pdf new file mode 100644 index 0000000..b2b781b Binary files /dev/null and b/attic/latex/figs/stack5.pdf differ diff --git a/attic/latex/figs/state.eps b/attic/latex/figs/state.eps new file mode 100644 index 0000000..eec6614 --- /dev/null +++ b/attic/latex/figs/state.eps @@ -0,0 +1,143 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: state.eps +%%Creator: fig2dev Version 3.2 Patchlevel 3c +%%CreationDate: Thu Dec 6 11:03:45 2001 +%%For: downey@rocky.wellesley.edu (Allen B. Downey) +%%BoundingBox: 0 0 173 61 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 61 moveto 0 0 lineto 173 0 lineto 173 61 lineto closepath clip newpath +-71.0 118.0 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +%%Page: 1 1 +10 setmiterlimit + 0.06000 0.06000 sc +% +% Fig objects follow +% +% Polyline +7.500 slw +n 1200 975 m 4050 975 l 4050 1950 l 1200 1950 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2490 1477 m 2490 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +2490 1777 m 2490 1717 l 2338 1717 l 2458 1747 l 2338 1777 l cp +eoclip +n 2100 1747 m + 2475 1747 l gs col0 s gr gr + +% arrowhead +n 2338 1777 m 2458 1747 l 2338 1717 l col0 s +% Polyline +gs clippath +2490 1177 m 2490 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +/Helvetica ff 165.00 scf sf +2025 1200 m +gs 1 -1 sc (message) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 1500 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 1800 m +gs 1 -1 sc (pi) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1200 m +gs 1 -1 sc ("What's up, Doc?") col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1500 m +gs 1 -1 sc (17) col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1800 m +gs 1 -1 sc (3.14159) col0 sh gr +$F2psEnd +rs diff --git a/attic/latex/figs/state.fig b/attic/latex/figs/state.fig new file mode 100644 index 0000000..512fe95 --- /dev/null +++ b/attic/latex/figs/state.fig @@ -0,0 +1,60 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 525 750 3675 1950 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 975 3675 975 3675 1950 1650 1950 1650 975 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1747 2475 1747 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1200 1125 1575 1125 +4 2 0 50 0 16 11 0.0000 4 120 90 2025 1200 0\001 +4 2 0 50 0 16 11 0.0000 4 120 90 2025 1500 1\001 +4 2 0 50 0 16 11 0.0000 4 120 90 2025 1800 2\001 +4 0 0 50 0 16 11 0.0000 4 120 615 2550 1200 'cheddar'\001 +4 0 0 50 0 16 11 0.0000 4 120 420 2550 1500 'edam'\001 +4 0 0 50 0 16 11 0.0000 4 150 480 2550 1800 'gouda'\001 +4 0 0 50 0 16 11 0.0000 4 120 195 1650 900 list\001 +4 2 0 50 0 16 11 0.0000 4 120 540 1125 1200 cheeses\001 +-6 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 2325 3675 2325 3675 3300 1650 3300 1650 2325 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 2497 2475 2497 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1200 2475 1575 2475 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 3675 3675 3675 3675 4650 1650 4650 1650 3675 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1200 3825 1575 3825 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 2850 2475 3075 +2 1 2 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2 + 2100 2797 2475 2797 +4 2 0 50 0 16 11 0.0000 4 120 90 2025 2550 0\001 +4 2 0 50 0 16 11 0.0000 4 120 90 2025 2850 1\001 +4 0 0 50 0 16 11 0.0000 4 120 195 1650 2250 list\001 +4 0 0 50 0 16 11 0.0000 4 120 195 1650 3600 list\001 +4 2 0 50 0 16 11 0.0000 4 120 585 1125 2550 numbers\001 +4 2 0 50 0 16 11 0.0000 4 150 420 1125 3900 empty\001 +4 0 0 50 0 16 11 0.0000 4 120 180 2550 2550 17\001 +4 0 0 50 0 16 11 0.0000 4 120 270 2550 2850 123\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2550 3150 5\001 diff --git a/attic/latex/figs/state.pdf b/attic/latex/figs/state.pdf new file mode 100644 index 0000000..d820979 Binary files /dev/null and b/attic/latex/figs/state.pdf differ diff --git a/attic/latex/figs/state2.eps b/attic/latex/figs/state2.eps new file mode 100644 index 0000000..b0b1931 --- /dev/null +++ b/attic/latex/figs/state2.eps @@ -0,0 +1,158 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: state2.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5a +%%CreationDate: Thu May 10 10:30:01 2012 +%%BoundingBox: 0 0 312 60 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 60 moveto 0 0 lineto 312 0 lineto 312 60 lineto closepath clip newpath +-71.3 117.7 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 1200 975 m 6375 975 l 6375 1950 l 1200 1950 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2338 1477 m 2490 1477 l 2490 1417 l 2338 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +2338 1777 m 2490 1777 l 2490 1717 l 2338 1717 l 2338 1717 l 2458 1747 l 2338 1777 l cp +eoclip +n 2100 1747 m + 2475 1747 l gs col0 s gr gr + +% arrowhead +n 2338 1777 m 2458 1747 l 2338 1717 l col0 s +% Polyline +gs clippath +2338 1177 m 2490 1177 l 2490 1117 l 2338 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +/Helvetica ff 183.33 scf sf +2025 1200 m +gs 1 -1 sc (message) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1500 m +gs 1 -1 sc (n) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2025 1800 m +gs 1 -1 sc (pi) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1500 m +gs 1 -1 sc (17) col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1200 m +gs 1 -1 sc ('And now for something completely different') col0 sh gr +/Helvetica ff 183.33 scf sf +2550 1800 m +gs 1 -1 sc (3.1415926535897932) col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/state2.fig b/attic/latex/figs/state2.fig new file mode 100644 index 0000000..d18e62f --- /dev/null +++ b/attic/latex/figs/state2.fig @@ -0,0 +1,28 @@ +#FIG 3.2 Produced by xfig version 3.2.5b +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 2100 1072 2475 1822 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1747 2475 1747 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +-6 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1200 975 6375 975 6375 1950 1200 1950 1200 975 +4 2 0 50 0 16 11 0.0000 4 150 735 2025 1200 message\001 +4 2 0 50 0 16 11 0.0000 4 105 105 2025 1500 n\001 +4 2 0 50 0 16 11 0.0000 4 180 150 2025 1800 pi\001 +4 0 0 50 0 16 11 0.0000 4 135 210 2550 1500 17\001 +4 0 0 50 0 16 11 0.0000 4 180 3690 2550 1200 'And now for something completely different'\001 +4 0 0 50 0 16 11 0.0000 4 135 1830 2550 1800 3.1415926535897932\001 diff --git a/attic/latex/figs/state2.pdf b/attic/latex/figs/state2.pdf new file mode 100644 index 0000000..dedfcf4 Binary files /dev/null and b/attic/latex/figs/state2.pdf differ diff --git a/attic/latex/figs/state3.eps b/attic/latex/figs/state3.eps new file mode 100644 index 0000000..9f499f6 --- /dev/null +++ b/attic/latex/figs/state3.eps @@ -0,0 +1,162 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: state3.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Jul 10 08:51:50 2007 +%%For: downey@rocky.olin.edu (Allen Downey) +%%BoundingBox: 0 0 132 78 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 78 moveto 0 0 lineto 132 0 lineto 132 78 lineto closepath clip newpath +-71.3 135.7 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +7.500 slw +n 1200 975 m 3375 975 l 3375 2250 l 1200 2250 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2490 1477 m 2490 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +2490 1777 m 2490 1717 l 2338 1717 l 2458 1747 l 2338 1777 l cp +eoclip +n 2100 1747 m + 2475 1747 l gs col0 s gr gr + +% arrowhead +n 2338 1777 m 2458 1747 l 2338 1717 l col0 s +% Polyline +gs clippath +2490 1177 m 2490 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +% Polyline +gs clippath +2490 2055 m 2490 1995 l 2338 1995 l 2458 2025 l 2338 2055 l cp +eoclip +n 2100 2025 m + 2475 2025 l gs col0 s gr gr + +% arrowhead +n 2338 2055 m 2458 2025 l 2338 1995 l col0 s +/Helvetica ff 165.00 scf sf +2025 1200 m +gs 1 -1 sc (word1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 1500 m +gs 1 -1 sc (word2) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1200 m +gs 1 -1 sc ('pots') col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1500 m +gs 1 -1 sc ('stop') col0 sh gr +/Helvetica ff 165.00 scf sf +2025 1800 m +gs 1 -1 sc (i) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1800 m +gs 1 -1 sc (0) col0 sh gr +/Helvetica ff 165.00 scf sf +2025 2100 m +gs 1 -1 sc (j) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2550 2100 m +gs 1 -1 sc (3) col0 sh gr +% here ends figure; +$F2psEnd +rs +showpage diff --git a/attic/latex/figs/state3.fig b/attic/latex/figs/state3.fig new file mode 100644 index 0000000..076e294 --- /dev/null +++ b/attic/latex/figs/state3.fig @@ -0,0 +1,31 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1747 2475 1747 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 2025 2475 2025 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1200 975 3375 975 3375 2250 1200 2250 1200 975 +4 2 0 50 0 16 11 0.0000 4 120 450 2025 1200 word1\001 +4 2 0 50 0 16 11 0.0000 4 120 450 2025 1500 word2\001 +4 0 0 50 0 16 11 0.0000 4 150 375 2550 1200 'pots'\001 +4 0 0 50 0 16 11 0.0000 4 150 375 2550 1500 'stop'\001 +4 2 0 50 0 16 11 0.0000 4 120 30 2025 1800 i\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2550 1800 0\001 +4 2 0 50 0 16 11 0.0000 4 150 30 2025 2100 j\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2550 2100 3\001 diff --git a/attic/latex/figs/state3.pdf b/attic/latex/figs/state3.pdf new file mode 100644 index 0000000..f41407d Binary files /dev/null and b/attic/latex/figs/state3.pdf differ diff --git a/attic/latex/figs/state4.eps b/attic/latex/figs/state4.eps new file mode 100644 index 0000000..1e34b6e --- /dev/null +++ b/attic/latex/figs/state4.eps @@ -0,0 +1,170 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: state4.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Jul 10 08:59:59 2007 +%%For: downey@rocky.olin.edu (Allen Downey) +%%BoundingBox: 0 0 245 56 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 56 moveto 0 0 lineto 245 0 lineto 245 56 lineto closepath clip newpath +-62.3 221.2 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +7.500 slw +n 1050 2775 m 5100 2775 l 5100 3675 l 1050 3675 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2340 3502 m 2340 3442 l 2188 3442 l 2308 3472 l 2188 3502 l cp +eoclip +n 1950 3472 m + 2325 3472 l gs col0 s gr gr + +% arrowhead +n 2188 3502 m 2308 3472 l 2188 3442 l col0 s +/Helvetica ff 165.00 scf sf +1875 3525 m +gs 1 -1 sc (i) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2400 3525 m +gs 1 -1 sc (0) col0 sh gr +% Polyline +gs clippath +4440 3480 m 4440 3420 l 4288 3420 l 4408 3450 l 4288 3480 l cp +eoclip +n 4050 3450 m + 4425 3450 l gs col0 s gr gr + +% arrowhead +n 4288 3480 m 4408 3450 l 4288 3420 l col0 s +/Helvetica ff 165.00 scf sf +3975 3525 m +gs 1 -1 sc (j) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +4500 3525 m +gs 1 -1 sc (3) col0 sh gr +% Polyline +gs clippath +2340 2977 m 2340 2917 l 2188 2917 l 2308 2947 l 2188 2977 l cp +eoclip +n 1950 2947 m + 2325 2947 l gs col0 s gr gr + +% arrowhead +n 2188 2977 m 2308 2947 l 2188 2917 l col0 s +% Polyline +gs clippath +4140 2977 m 4140 2917 l 3988 2917 l 4108 2947 l 3988 2977 l cp +eoclip +n 3750 2947 m + 4125 2947 l gs col0 s gr gr + +% arrowhead +n 3988 2977 m 4108 2947 l 3988 2917 l col0 s +% Polyline + [15 45] 45 sd +n 2475 3300 m + 2475 3075 l gs col0 s gr [] 0 sd +% Polyline + [15 45] 45 sd +n 4537 3307 m + 4537 3082 l gs col0 s gr [] 0 sd +/Helvetica ff 165.00 scf sf +1875 3000 m +gs 1 -1 sc (word1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2400 3000 m +gs 1 -1 sc ('pots') col0 sh gr +/Helvetica ff 165.00 scf sf +3675 3000 m +gs 1 -1 sc (word2) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +4200 3000 m +gs 1 -1 sc ('stop') col0 sh gr +% here ends figure; +$F2psEnd +rs +showpage diff --git a/attic/latex/figs/state4.fig b/attic/latex/figs/state4.fig new file mode 100644 index 0000000..c6c35d2 --- /dev/null +++ b/attic/latex/figs/state4.fig @@ -0,0 +1,39 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 1800 3375 2550 3525 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1950 3472 2325 3472 +4 2 0 50 0 16 11 0.0000 4 120 30 1875 3525 i\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2400 3525 0\001 +-6 +6 3900 3375 4650 3600 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4050 3450 4425 3450 +4 2 0 50 0 16 11 0.0000 4 150 30 3975 3525 j\001 +4 0 0 50 0 16 11 0.0000 4 120 90 4500 3525 3\001 +-6 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1950 2947 2325 2947 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3750 2947 4125 2947 +2 1 2 1 0 7 50 -1 -1 3.000 0 0 -1 0 0 2 + 2475 3300 2475 3075 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1050 2775 5100 2775 5100 3675 1050 3675 1050 2775 +2 1 2 1 0 7 50 -1 -1 3.000 0 0 -1 0 0 2 + 4537 3307 4537 3082 +4 2 0 50 0 16 11 0.0000 4 120 450 1875 3000 word1\001 +4 0 0 50 0 16 11 0.0000 4 150 375 2400 3000 'pots'\001 +4 2 0 50 0 16 11 0.0000 4 120 450 3675 3000 word2\001 +4 0 0 50 0 16 11 0.0000 4 150 375 4200 3000 'stop'\001 diff --git a/attic/latex/figs/state4.pdf b/attic/latex/figs/state4.pdf new file mode 100644 index 0000000..455a16e Binary files /dev/null and b/attic/latex/figs/state4.pdf differ diff --git a/attic/latex/figs/state5.eps b/attic/latex/figs/state5.eps new file mode 100644 index 0000000..d1e3ee5 --- /dev/null +++ b/attic/latex/figs/state5.eps @@ -0,0 +1,321 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: state5.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Jul 17 12:07:18 2007 +%%For: downey@rocky.olin.edu (Allen Downey) +%%BoundingBox: 0 0 316 134 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 134 moveto 0 0 lineto 316 0 lineto 316 134 lineto closepath clip newpath +-27.0 225.7 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +7.500 slw +n 1125 1725 m 2400 1725 l 2400 3300 l 1125 3300 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 4350 1725 m 5700 1725 l 5700 3000 l 4350 3000 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 3375 1725 m 4050 1725 l 4050 3750 l 3375 3750 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +n 4350 3375 m 5700 3375 l 5700 3750 l 4350 3750 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +1965 2227 m 1965 2167 l 1813 2167 l 1933 2197 l 1813 2227 l cp +eoclip +n 1575 2197 m + 1950 2197 l gs col0 s gr gr + +% arrowhead +n 1813 2227 m 1933 2197 l 1813 2167 l col0 s +% Polyline +gs clippath +1965 1927 m 1965 1867 l 1813 1867 l 1933 1897 l 1813 1927 l cp +eoclip +n 1575 1897 m + 1950 1897 l gs col0 s gr gr + +% arrowhead +n 1813 1927 m 1933 1897 l 1813 1867 l col0 s +% Polyline +gs clippath +1140 1905 m 1140 1845 l 988 1845 l 1108 1875 l 988 1905 l cp +eoclip +n 750 1875 m + 1125 1875 l gs col0 s gr gr + +% arrowhead +n 988 1905 m 1108 1875 l 988 1845 l col0 s +% Polyline +gs clippath +1965 2827 m 1965 2767 l 1813 2767 l 1933 2797 l 1813 2827 l cp +eoclip +n 1575 2797 m + 1950 2797 l gs col0 s gr gr + +% arrowhead +n 1813 2827 m 1933 2797 l 1813 2767 l col0 s +% Polyline +gs clippath +1965 3127 m 1965 3067 l 1813 3067 l 1933 3097 l 1813 3127 l cp +eoclip +n 1575 3097 m + 1950 3097 l gs col0 s gr gr + +% arrowhead +n 1813 3127 m 1933 3097 l 1813 3067 l col0 s +% Polyline +gs clippath +1965 2527 m 1965 2467 l 1813 2467 l 1933 2497 l 1813 2527 l cp +eoclip +n 1575 2497 m + 1950 2497 l gs col0 s gr gr + +% arrowhead +n 1813 2527 m 1933 2497 l 1813 2467 l col0 s +/Helvetica ff 165.00 scf sf +1500 1950 m +gs 1 -1 sc ('a') dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 1950 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +2025 2250 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +1125 1650 m +gs 1 -1 sc (dict) col0 sh gr +/Helvetica ff 165.00 scf sf +450 1950 m +gs 1 -1 sc (hist) col0 sh gr +/Helvetica ff 165.00 scf sf +1500 2250 m +gs 1 -1 sc ('p') dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 2850 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +1500 3150 m +gs 1 -1 sc ('o') dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 3150 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 165.00 scf sf +1500 2550 m +gs 1 -1 sc ('r') dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 2550 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 165.00 scf sf +1500 2850 m +gs 1 -1 sc ('t') dup sw pop neg 0 rm col0 sh gr +% Polyline +gs clippath +5190 2227 m 5190 2167 l 5038 2167 l 5158 2197 l 5038 2227 l cp +eoclip +n 4800 2197 m + 5175 2197 l gs col0 s gr gr + +% arrowhead +n 5038 2227 m 5158 2197 l 5038 2167 l col0 s +% Polyline +gs clippath +5190 1927 m 5190 1867 l 5038 1867 l 5158 1897 l 5038 1927 l cp +eoclip +n 4800 1897 m + 5175 1897 l gs col0 s gr gr + +% arrowhead +n 5038 1927 m 5158 1897 l 5038 1867 l col0 s +% Polyline +gs clippath +5190 2527 m 5190 2467 l 5038 2467 l 5158 2497 l 5038 2527 l cp +eoclip +n 4800 2497 m + 5175 2497 l gs col0 s gr gr + +% arrowhead +n 5038 2527 m 5158 2497 l 5038 2467 l col0 s +% Polyline +gs clippath +5190 2827 m 5190 2767 l 5038 2767 l 5158 2797 l 5038 2827 l cp +eoclip +n 4800 2797 m + 5175 2797 l gs col0 s gr gr + +% arrowhead +n 5038 2827 m 5158 2797 l 5038 2767 l col0 s +/Helvetica ff 165.00 scf sf +4725 1950 m +gs 1 -1 sc (0) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +4725 2250 m +gs 1 -1 sc (1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +5250 1950 m +gs 1 -1 sc ('a') col0 sh gr +/Helvetica ff 165.00 scf sf +5250 2250 m +gs 1 -1 sc ('p') col0 sh gr +/Helvetica ff 165.00 scf sf +4350 1650 m +gs 1 -1 sc (list) col0 sh gr +/Helvetica ff 165.00 scf sf +4725 2550 m +gs 1 -1 sc (2) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +5250 2550 m +gs 1 -1 sc ('t') col0 sh gr +/Helvetica ff 165.00 scf sf +5250 2850 m +gs 1 -1 sc ('o') col0 sh gr +/Helvetica ff 165.00 scf sf +4725 2850 m +gs 1 -1 sc (3) dup sw pop neg 0 rm col0 sh gr +% Polyline +gs clippath +4365 1919 m 4364 1859 l 4212 1861 l 4333 1890 l 4213 1921 l cp +eoclip +n 3825 1897 m + 4350 1890 l gs col0 s gr gr + +% arrowhead +n 4213 1921 m 4333 1890 l 4212 1861 l col0 s +% Polyline +gs clippath +3390 1905 m 3390 1845 l 3238 1845 l 3358 1875 l 3238 1905 l cp +eoclip +n 3000 1875 m + 3375 1875 l gs col0 s gr gr + +% arrowhead +n 3238 1905 m 3358 1875 l 3238 1845 l col0 s +% Polyline +gs clippath +4365 3551 m 4364 3491 l 4212 3493 l 4333 3522 l 4213 3553 l cp +eoclip +n 3825 3529 m + 4350 3522 l gs col0 s gr gr + +% arrowhead +n 4213 3553 m 4333 3522 l 4212 3493 l col0 s +% Polyline +gs clippath +5190 3577 m 5190 3517 l 5038 3517 l 5158 3547 l 5038 3577 l cp +eoclip +n 4800 3547 m + 5175 3547 l gs col0 s gr gr + +% arrowhead +n 5038 3577 m 5158 3547 l 5038 3517 l col0 s +/Helvetica ff 165.00 scf sf +3750 1950 m +gs 1 -1 sc (1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +3375 1650 m +gs 1 -1 sc (dict) col0 sh gr +/Helvetica ff 165.00 scf sf +2700 1950 m +gs 1 -1 sc (inv) col0 sh gr +/Helvetica ff 165.00 scf sf +3750 3600 m +gs 1 -1 sc (2) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +4725 3600 m +gs 1 -1 sc (0) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +4350 3300 m +gs 1 -1 sc (list) col0 sh gr +/Helvetica ff 165.00 scf sf +5250 3600 m +gs 1 -1 sc ('r') col0 sh gr +% here ends figure; +$F2psEnd +rs +showpage diff --git a/attic/latex/figs/state5.fig b/attic/latex/figs/state5.fig new file mode 100644 index 0000000..f1cf02e --- /dev/null +++ b/attic/latex/figs/state5.fig @@ -0,0 +1,91 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 450 1500 2400 3300 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1575 2197 1950 2197 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1575 1897 1950 1897 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 750 1875 1125 1875 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1575 2797 1950 2797 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1575 3097 1950 3097 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1575 2497 1950 2497 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1125 1725 2400 1725 2400 3300 1125 3300 1125 1725 +4 2 0 50 0 16 11 0.0000 4 120 135 1500 1950 'a'\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2025 1950 1\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2025 2250 1\001 +4 0 0 50 0 16 11 0.0000 4 120 255 1125 1650 dict\001 +4 0 0 50 0 16 11 0.0000 4 120 255 450 1950 hist\001 +4 2 0 50 0 16 11 0.0000 4 150 150 1500 2250 'p'\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2025 2850 1\001 +4 2 0 50 0 16 11 0.0000 4 120 150 1500 3150 'o'\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2025 3150 1\001 +4 2 0 50 0 16 11 0.0000 4 120 120 1500 2550 'r'\001 +4 0 0 50 0 16 11 0.0000 4 120 90 2025 2550 2\001 +4 2 0 50 0 16 11 0.0000 4 120 120 1500 2850 't'\001 +-6 +6 4350 1500 5700 3000 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 2197 5175 2197 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 1897 5175 1897 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 2497 5175 2497 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 2797 5175 2797 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 4350 1725 5700 1725 5700 3000 4350 3000 4350 1725 +4 2 0 50 0 16 11 0.0000 4 120 90 4725 1950 0\001 +4 2 0 50 0 16 11 0.0000 4 120 90 4725 2250 1\001 +4 0 0 50 0 16 11 0.0000 4 120 135 5250 1950 'a'\001 +4 0 0 50 0 16 11 0.0000 4 150 150 5250 2250 'p'\001 +4 0 0 50 0 16 11 0.0000 4 120 195 4350 1650 list\001 +4 2 0 50 0 16 11 0.0000 4 120 90 4725 2550 2\001 +4 0 0 50 0 16 11 0.0000 4 120 120 5250 2550 't'\001 +4 0 0 50 0 16 11 0.0000 4 120 150 5250 2850 'o'\001 +4 2 0 50 0 16 11 0.0000 4 120 90 4725 2850 3\001 +-6 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3825 1897 4350 1890 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3000 1875 3375 1875 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 3375 1725 4050 1725 4050 3750 3375 3750 3375 1725 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3825 3529 4350 3522 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4800 3547 5175 3547 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 4350 3375 5700 3375 5700 3750 4350 3750 4350 3375 +4 2 0 50 0 16 11 0.0000 4 120 90 3750 1950 1\001 +4 0 0 50 0 16 11 0.0000 4 120 255 3375 1650 dict\001 +4 0 0 50 0 16 11 0.0000 4 120 210 2700 1950 inv\001 +4 2 0 50 0 16 11 0.0000 4 120 90 3750 3600 2\001 +4 2 0 50 0 16 11 0.0000 4 120 90 4725 3600 0\001 +4 0 0 50 0 16 11 0.0000 4 120 195 4350 3300 list\001 +4 0 0 50 0 16 11 0.0000 4 120 120 5250 3600 'r'\001 diff --git a/attic/latex/figs/state5.pdf b/attic/latex/figs/state5.pdf new file mode 100644 index 0000000..59a7dc8 Binary files /dev/null and b/attic/latex/figs/state5.pdf differ diff --git a/attic/latex/figs/time.eps b/attic/latex/figs/time.eps new file mode 100644 index 0000000..4ba15b2 --- /dev/null +++ b/attic/latex/figs/time.eps @@ -0,0 +1,173 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: time.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5a +%%CreationDate: Wed May 23 14:46:23 2012 +%%BoundingBox: 0 0 139 73 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 73 moveto 0 0 lineto 139 0 lineto 139 73 lineto closepath clip newpath +-37.3 117.7 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +0 slj +0 slc +7.500 slw +n 1425 975 m 2925 975 l 2925 1950 l 1425 1950 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2413 1477 m 2565 1477 l 2565 1417 l 2413 1417 l 2413 1417 l 2533 1447 l 2413 1477 l cp +eoclip +n 2175 1447 m + 2550 1447 l gs col0 s gr gr + +% arrowhead +n 2413 1477 m 2533 1447 l 2413 1417 l col0 s +% Polyline +gs clippath +2405 1777 m 2557 1777 l 2557 1717 l 2405 1717 l 2405 1717 l 2525 1747 l 2405 1777 l cp +eoclip +n 2175 1747 m + 2542 1747 l gs col0 s gr gr + +% arrowhead +n 2405 1777 m 2525 1747 l 2405 1717 l col0 s +% Polyline +gs clippath +2413 1177 m 2565 1177 l 2565 1117 l 2413 1117 l 2413 1117 l 2533 1147 l 2413 1177 l cp +eoclip +n 2175 1147 m + 2550 1147 l gs col0 s gr gr + +% arrowhead +n 2413 1177 m 2533 1147 l 2413 1117 l col0 s +% Polyline +gs clippath +1275 1177 m 1427 1177 l 1427 1117 l 1275 1117 l 1275 1117 l 1395 1147 l 1275 1177 l cp +eoclip +n 1027 1147 m + 1412 1147 l gs col0 s gr gr + +% arrowhead +n 1275 1177 m 1395 1147 l 1275 1117 l col0 s +/Helvetica ff 183.33 scf sf +2625 1500 m +gs 1 -1 sc (59) col0 sh gr +/Helvetica ff 183.33 scf sf +2625 1800 m +gs 1 -1 sc (30) col0 sh gr +/Helvetica ff 183.33 scf sf +2100 1200 m +gs 1 -1 sc (hour) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2100 1500 m +gs 1 -1 sc (minute) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2100 1800 m +gs 1 -1 sc (second) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 183.33 scf sf +2625 1200 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 183.33 scf sf +1425 900 m +gs 1 -1 sc (Time) col0 sh gr +/Helvetica ff 183.33 scf sf +975 1200 m +gs 1 -1 sc (time) dup sw pop neg 0 rm col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/time.fig b/attic/latex/figs/time.fig new file mode 100644 index 0000000..d829e6b --- /dev/null +++ b/attic/latex/figs/time.fig @@ -0,0 +1,31 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 1447 2550 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 1747 2542 1747 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2175 1147 2550 1147 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1425 975 2925 975 2925 1950 1425 1950 1425 975 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1027 1147 1412 1147 +4 0 0 50 0 16 11 0.0000 4 120 180 2625 1500 59\001 +4 0 0 50 0 16 11 0.0000 4 120 180 2625 1800 30\001 +4 2 0 50 0 16 11 0.0000 4 120 315 2100 1200 hour\001 +4 2 0 50 0 16 11 0.0000 4 120 450 2100 1500 minute\001 +4 2 0 50 0 16 11 0.0000 4 120 495 2100 1800 second\001 +4 0 0 50 0 16 11 0.0000 4 120 180 2625 1200 11\001 +4 0 0 50 0 16 11 0.0000 4 120 300 1425 900 Time\001 +4 2 0 50 0 16 11 0.0000 4 120 285 975 1200 time\001 diff --git a/attic/latex/figs/time.pdf b/attic/latex/figs/time.pdf new file mode 100644 index 0000000..c2053de Binary files /dev/null and b/attic/latex/figs/time.pdf differ diff --git a/attic/latex/figs/towers.eps b/attic/latex/figs/towers.eps new file mode 100644 index 0000000..f1fcd2a --- /dev/null +++ b/attic/latex/figs/towers.eps @@ -0,0 +1,317 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: towers.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5a +%%CreationDate: Wed May 23 14:46:36 2012 +%%BoundingBox: 0 0 657 158 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 158 moveto 0 0 lineto 657 0 lineto 657 158 lineto closepath clip newpath +-64.4 176.5 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06299 0.06299 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 50 +% Polyline +0 slj +0 slc +7.500 slw +n 1035 2520 m 1305 2520 l 1305 2790 l 1035 2790 l + cp gs col0 s gr +% Polyline +n 1305 2520 m 1575 2520 l 1575 2790 l 1305 2790 l + cp gs col0 s gr +% Polyline +n 1620 2520 m 1890 2520 l 1890 2790 l 1620 2790 l + cp gs col0 s gr +% Polyline +n 1890 2520 m 2160 2520 l 2160 2790 l 1890 2790 l + cp gs col0 s gr +% Polyline +n 2205 2520 m 2475 2520 l 2475 2790 l 2205 2790 l + cp gs col0 s gr +% Polyline +n 2475 2520 m 2745 2520 l 2745 2790 l 2475 2790 l + cp gs col0 s gr +% Polyline +n 2745 2520 m 3015 2520 l 3015 2790 l 2745 2790 l + cp gs col0 s gr +% Polyline +n 3015 2520 m 3285 2520 l 3285 2790 l 3015 2790 l + cp gs col0 s gr +% Polyline +n 3330 2520 m 3600 2520 l 3600 2790 l 3330 2790 l + cp gs col0 s gr +% Polyline +n 3600 2520 m 3870 2520 l 3870 2790 l 3600 2790 l + cp gs col0 s gr +% Polyline +n 3870 2520 m 4140 2520 l 4140 2790 l 3870 2790 l + cp gs col0 s gr +% Polyline +n 4140 2520 m 4410 2520 l 4410 2790 l 4140 2790 l + cp gs col0 s gr +% Polyline +n 4410 2520 m 4680 2520 l 4680 2790 l 4410 2790 l + cp gs col0 s gr +% Polyline +n 4680 2520 m 4950 2520 l 4950 2790 l 4680 2790 l + cp gs col0 s gr +% Polyline +n 4950 2520 m 5220 2520 l 5220 2790 l 4950 2790 l + cp gs col0 s gr +% Polyline +n 5220 2520 m 5490 2520 l 5490 2790 l 5220 2790 l + cp gs col0 s gr +% Polyline +n 6975 2520 m 7245 2520 l 7245 2790 l 6975 2790 l + cp gs col0 s gr +% Polyline +n 7245 2520 m 7515 2520 l 7515 2790 l 7245 2790 l + cp gs col0 s gr +% Polyline +n 7560 2520 m 7830 2520 l 7830 2790 l 7560 2790 l + cp gs col0 s gr +% Polyline +n 7830 2520 m 8100 2520 l 8100 2790 l 7830 2790 l + cp gs col0 s gr +% Polyline +n 8145 2520 m 8415 2520 l 8415 2790 l 8145 2790 l + cp gs col0 s gr +% Polyline +n 8415 2520 m 8685 2520 l 8685 2790 l 8415 2790 l + cp gs col0 s gr +% Polyline +n 8685 2520 m 8955 2520 l 8955 2790 l 8685 2790 l + cp gs col0 s gr +% Polyline +n 8955 2520 m 9225 2520 l 9225 2790 l 8955 2790 l + cp gs col0 s gr +% Polyline +n 9270 2520 m 9540 2520 l 9540 2790 l 9270 2790 l + cp gs col0 s gr +% Polyline +n 9540 2520 m 9810 2520 l 9810 2790 l 9540 2790 l + cp gs col0 s gr +% Polyline +n 9810 2520 m 10080 2520 l 10080 2790 l 9810 2790 l + cp gs col0 s gr +% Polyline +n 10080 2520 m 10350 2520 l 10350 2790 l 10080 2790 l + cp gs col0 s gr +% Polyline +n 10350 2520 m 10620 2520 l 10620 2790 l 10350 2790 l + cp gs col0 s gr +% Polyline +n 10620 2520 m 10890 2520 l 10890 2790 l 10620 2790 l + cp gs col0 s gr +% Polyline +n 10890 2520 m 11160 2520 l 11160 2790 l 10890 2790 l + cp gs col0 s gr +% Polyline +n 11160 2520 m 11430 2520 l 11430 2790 l 11160 2790 l + cp gs col0 s gr +% Polyline +n 1620 2205 m 1890 2205 l 1890 2475 l 1620 2475 l + cp gs col0 s gr +% Polyline +n 1620 1935 m 1890 1935 l 1890 2205 l 1620 2205 l + cp gs col0 s gr +% Polyline +n 2205 2205 m 2475 2205 l 2475 2475 l 2205 2475 l + cp gs col0 s gr +% Polyline +n 2205 1935 m 2475 1935 l 2475 2205 l 2205 2205 l + cp gs col0 s gr +% Polyline +n 2205 1665 m 2475 1665 l 2475 1935 l 2205 1935 l + cp gs col0 s gr +% Polyline +n 2205 1395 m 2475 1395 l 2475 1665 l 2205 1665 l + cp gs col0 s gr +% Polyline +n 3330 2205 m 3600 2205 l 3600 2475 l 3330 2475 l + cp gs col0 s gr +% Polyline +n 3330 1935 m 3600 1935 l 3600 2205 l 3330 2205 l + cp gs col0 s gr +% Polyline +n 3330 1665 m 3600 1665 l 3600 1935 l 3330 1935 l + cp gs col0 s gr +% Polyline +n 3330 1395 m 3600 1395 l 3600 1665 l 3330 1665 l + cp gs col0 s gr +% Polyline +n 3330 1125 m 3600 1125 l 3600 1395 l 3330 1395 l + cp gs col0 s gr +% Polyline +n 3330 855 m 3600 855 l 3600 1125 l 3330 1125 l + cp gs col0 s gr +% Polyline +n 3330 585 m 3600 585 l 3600 855 l 3330 855 l + cp gs col0 s gr +% Polyline +n 3330 315 m 3600 315 l 3600 585 l 3330 585 l + cp gs col0 s gr +% Polyline +n 9540 2205 m 9540 2475 l 9270 2475 l 9270 2205 l + cp gs col0 s gr +% Polyline +n 9810 2205 m 9810 2475 l 9540 2475 l 9540 2205 l + cp gs col0 s gr +% Polyline +n 10080 2205 m 10080 2475 l 9810 2475 l 9810 2205 l + cp gs col0 s gr +% Polyline +n 10350 2205 m 10350 2475 l 10080 2475 l 10080 2205 l + cp gs col0 s gr +% Polyline +n 10620 2205 m 10620 2475 l 10350 2475 l 10350 2205 l + cp gs col0 s gr +% Polyline +n 10890 2205 m 10890 2475 l 10620 2475 l 10620 2205 l + cp gs col0 s gr +% Polyline +n 11160 2205 m 11160 2475 l 10890 2475 l 10890 2205 l + cp gs col0 s gr +% Polyline +n 11430 2205 m 11430 2475 l 11160 2475 l 11160 2205 l + cp gs col0 s gr +% Polyline +n 8415 2205 m 8415 2475 l 8145 2475 l 8145 2205 l + cp gs col0 s gr +% Polyline +n 8685 2205 m 8685 2475 l 8415 2475 l 8415 2205 l + cp gs col0 s gr +% Polyline +n 8955 2205 m 8955 2475 l 8685 2475 l 8685 2205 l + cp gs col0 s gr +% Polyline +n 9225 2205 m 9225 2475 l 8955 2475 l 8955 2205 l + cp gs col0 s gr +% Polyline +n 7830 2205 m 7830 2475 l 7560 2475 l 7560 2205 l + cp gs col0 s gr +% Polyline +n 8100 2205 m 8100 2475 l 7830 2475 l 7830 2205 l + cp gs col0 s gr +% Polyline +gs clippath +1933 2100 m 2085 2100 l 2085 2040 l 1933 2040 l 1933 2040 l 2053 2070 l 1933 2100 l cp +eoclip +n 1800 2070 m + 2070 2070 l gs col0 s gr gr + +% arrowhead +n 1933 2100 m 2053 2070 l 1933 2040 l col0 s +% Polyline +gs clippath +3643 480 m 3795 480 l 3795 420 l 3643 420 l 3643 420 l 3763 450 l 3643 480 l cp +eoclip +n 3510 450 m + 3780 450 l gs col0 s gr gr + +% arrowhead +n 3643 480 m 3763 450 l 3643 420 l col0 s +% Polyline +gs clippath +2518 1560 m 2670 1560 l 2670 1500 l 2518 1500 l 2518 1500 l 2638 1530 l 2518 1560 l cp +eoclip +n 2385 1530 m + 2655 1530 l gs col0 s gr gr + +% arrowhead +n 2518 1560 m 2638 1530 l 2518 1500 l col0 s +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/attic/latex/figs/towers.fig b/attic/latex/figs/towers.fig new file mode 100644 index 0000000..8760390 --- /dev/null +++ b/attic/latex/figs/towers.fig @@ -0,0 +1,178 @@ +#FIG 3.2 Produced by xfig version 3.2.5 +Landscape +Center +Metric +A4 +100.00 +Single +-2 +1200 2 +6 1035 2520 5490 2790 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 1035 2520 1305 2520 1305 2790 1035 2790 1035 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 1305 2520 1575 2520 1575 2790 1305 2790 1305 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 1620 2520 1890 2520 1890 2790 1620 2790 1620 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 1890 2520 2160 2520 2160 2790 1890 2790 1890 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 2205 2520 2475 2520 2475 2790 2205 2790 2205 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 2475 2520 2745 2520 2745 2790 2475 2790 2475 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 2745 2520 3015 2520 3015 2790 2745 2790 2745 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3015 2520 3285 2520 3285 2790 3015 2790 3015 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3330 2520 3600 2520 3600 2790 3330 2790 3330 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3600 2520 3870 2520 3870 2790 3600 2790 3600 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3870 2520 4140 2520 4140 2790 3870 2790 3870 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 4140 2520 4410 2520 4410 2790 4140 2790 4140 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 4410 2520 4680 2520 4680 2790 4410 2790 4410 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 4680 2520 4950 2520 4950 2790 4680 2790 4680 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 4950 2520 5220 2520 5220 2790 4950 2790 4950 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 5220 2520 5490 2520 5490 2790 5220 2790 5220 2520 +-6 +6 6975 2520 11430 2790 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 6975 2520 7245 2520 7245 2790 6975 2790 6975 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 7245 2520 7515 2520 7515 2790 7245 2790 7245 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 7560 2520 7830 2520 7830 2790 7560 2790 7560 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 7830 2520 8100 2520 8100 2790 7830 2790 7830 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 8145 2520 8415 2520 8415 2790 8145 2790 8145 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 8415 2520 8685 2520 8685 2790 8415 2790 8415 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 8685 2520 8955 2520 8955 2790 8685 2790 8685 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 8955 2520 9225 2520 9225 2790 8955 2790 8955 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 9270 2520 9540 2520 9540 2790 9270 2790 9270 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 9540 2520 9810 2520 9810 2790 9540 2790 9540 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 9810 2520 10080 2520 10080 2790 9810 2790 9810 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 10080 2520 10350 2520 10350 2790 10080 2790 10080 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 10350 2520 10620 2520 10620 2790 10350 2790 10350 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 10620 2520 10890 2520 10890 2790 10620 2790 10620 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 10890 2520 11160 2520 11160 2790 10890 2790 10890 2520 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 11160 2520 11430 2520 11430 2790 11160 2790 11160 2520 +-6 +6 1620 1935 1890 2475 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 1620 2205 1890 2205 1890 2475 1620 2475 1620 2205 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 1620 1935 1890 1935 1890 2205 1620 2205 1620 1935 +-6 +6 2205 1395 2475 2475 +6 2205 1935 2475 2475 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 2205 2205 2475 2205 2475 2475 2205 2475 2205 2205 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 2205 1935 2475 1935 2475 2205 2205 2205 2205 1935 +-6 +6 2205 1395 2475 1935 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 2205 1665 2475 1665 2475 1935 2205 1935 2205 1665 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 2205 1395 2475 1395 2475 1665 2205 1665 2205 1395 +-6 +-6 +6 3330 315 3600 2475 +6 3330 1935 3600 2475 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3330 2205 3600 2205 3600 2475 3330 2475 3330 2205 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3330 1935 3600 1935 3600 2205 3330 2205 3330 1935 +-6 +6 3330 1395 3600 1935 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3330 1665 3600 1665 3600 1935 3330 1935 3330 1665 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3330 1395 3600 1395 3600 1665 3330 1665 3330 1395 +-6 +6 3330 855 3600 1395 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3330 1125 3600 1125 3600 1395 3330 1395 3330 1125 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3330 855 3600 855 3600 1125 3330 1125 3330 855 +-6 +6 3330 315 3600 855 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3330 585 3600 585 3600 855 3330 855 3330 585 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 3330 315 3600 315 3600 585 3330 585 3330 315 +-6 +-6 +6 9270 2205 11430 2475 +6 9270 2205 9810 2475 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 9540 2205 9540 2475 9270 2475 9270 2205 9540 2205 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 9810 2205 9810 2475 9540 2475 9540 2205 9810 2205 +-6 +6 9810 2205 10350 2475 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 10080 2205 10080 2475 9810 2475 9810 2205 10080 2205 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 10350 2205 10350 2475 10080 2475 10080 2205 10350 2205 +-6 +6 10350 2205 10890 2475 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 10620 2205 10620 2475 10350 2475 10350 2205 10620 2205 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 10890 2205 10890 2475 10620 2475 10620 2205 10890 2205 +-6 +6 10890 2205 11430 2475 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 11160 2205 11160 2475 10890 2475 10890 2205 11160 2205 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 11430 2205 11430 2475 11160 2475 11160 2205 11430 2205 +-6 +-6 +6 8145 2205 9225 2475 +6 8145 2205 8685 2475 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 8415 2205 8415 2475 8145 2475 8145 2205 8415 2205 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 8685 2205 8685 2475 8415 2475 8415 2205 8685 2205 +-6 +6 8685 2205 9225 2475 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 8955 2205 8955 2475 8685 2475 8685 2205 8955 2205 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 9225 2205 9225 2475 8955 2475 8955 2205 9225 2205 +-6 +-6 +6 7560 2205 8100 2475 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 7830 2205 7830 2475 7560 2475 7560 2205 7830 2205 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 8100 2205 8100 2475 7830 2475 7830 2205 8100 2205 +-6 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 1800 2070 2070 2070 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3510 450 3780 450 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2385 1530 2655 1530 diff --git a/attic/latex/figs/towers.pdf b/attic/latex/figs/towers.pdf new file mode 100644 index 0000000..8e49809 Binary files /dev/null and b/attic/latex/figs/towers.pdf differ diff --git a/attic/latex/figs/tuple1.eps b/attic/latex/figs/tuple1.eps new file mode 100644 index 0000000..7949bda --- /dev/null +++ b/attic/latex/figs/tuple1.eps @@ -0,0 +1,135 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: tuple1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Jul 31 12:27:49 2007 +%%For: downey@rocky.olin.edu (Allen Downey) +%%BoundingBox: 0 0 123 53 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +newpath 0 53 moveto 0 0 lineto 123 0 lineto 123 53 lineto closepath clip newpath +-98.3 99.7 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06000 0.06000 sc +% +% Fig objects follow +% +% +% here starts figure with depth 51 +% Polyline +7.500 slw +n 1650 975 m 3675 975 l 3675 1650 l 1650 1650 l + cp gs col7 0.90 shd ef gr gs col0 s gr +% Polyline +gs clippath +2490 1477 m 2490 1417 l 2338 1417 l 2458 1447 l 2338 1477 l cp +eoclip +n 2100 1447 m + 2475 1447 l gs col0 s gr gr + +% arrowhead +n 2338 1477 m 2458 1447 l 2338 1417 l col0 s +% Polyline +gs clippath +2490 1177 m 2490 1117 l 2338 1117 l 2458 1147 l 2338 1177 l cp +eoclip +n 2100 1147 m + 2475 1147 l gs col0 s gr gr + +% arrowhead +n 2338 1177 m 2458 1147 l 2338 1117 l col0 s +/Helvetica ff 165.00 scf sf +2025 1200 m +gs 1 -1 sc (0) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2025 1500 m +gs 1 -1 sc (1) dup sw pop neg 0 rm col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1200 m +gs 1 -1 sc ('Cleese') col0 sh gr +/Helvetica ff 165.00 scf sf +2550 1500 m +gs 1 -1 sc ('John') col0 sh gr +/Helvetica ff 165.00 scf sf +1650 900 m +gs 1 -1 sc (tuple) col0 sh gr +% here ends figure; +$F2psEnd +rs +showpage diff --git a/attic/latex/figs/tuple1.fig b/attic/latex/figs/tuple1.fig new file mode 100644 index 0000000..fad2c3d --- /dev/null +++ b/attic/latex/figs/tuple1.fig @@ -0,0 +1,22 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1447 2475 1447 +2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 2100 1147 2475 1147 +2 2 0 1 0 7 51 0 18 0.000 0 0 -1 0 0 5 + 1650 975 3675 975 3675 1650 1650 1650 1650 975 +4 2 0 50 0 16 11 0.0000 4 120 90 2025 1200 0\001 +4 2 0 50 0 16 11 0.0000 4 120 90 2025 1500 1\001 +4 0 0 50 0 16 11 0.0000 4 120 510 2550 1200 'Cleese'\001 +4 0 0 50 0 16 11 0.0000 4 120 405 2550 1500 'John'\001 +4 0 0 50 0 16 11 0.0000 4 150 330 1650 900 tuple\001 diff --git a/attic/latex/figs/tuple1.pdf b/attic/latex/figs/tuple1.pdf new file mode 100644 index 0000000..df15839 Binary files /dev/null and b/attic/latex/figs/tuple1.pdf differ diff --git a/book/footer.html b/attic/latex/footer.html similarity index 100% rename from book/footer.html rename to attic/latex/footer.html diff --git a/book/header.html b/attic/latex/header.html similarity index 100% rename from book/header.html rename to attic/latex/header.html diff --git a/book/htmlonly b/attic/latex/htmlonly similarity index 100% rename from book/htmlonly rename to attic/latex/htmlonly diff --git a/book/latexonly b/attic/latex/latexonly similarity index 100% rename from book/latexonly rename to attic/latex/latexonly diff --git a/book/localdef.py b/attic/latex/localdef.py similarity index 100% rename from book/localdef.py rename to attic/latex/localdef.py diff --git a/book/next.png b/attic/latex/next.png similarity index 100% rename from book/next.png rename to attic/latex/next.png diff --git a/book/up.png b/attic/latex/up.png similarity index 100% rename from book/up.png rename to attic/latex/up.png diff --git a/book/.gitignore b/book/.gitignore new file mode 100644 index 0000000..69fa449 --- /dev/null +++ b/book/.gitignore @@ -0,0 +1 @@ +_build/ diff --git a/book/00-front-matter.rst b/book/00-front-matter.rst new file mode 100644 index 0000000..64254f6 --- /dev/null +++ b/book/00-front-matter.rst @@ -0,0 +1,526 @@ +[chapter] + +| 3 Think Python +| How to Think Like a Computer Scientist + +2nd Edition, Version 2.2.14 + +| 3 Think Python +| How to Think Like a Computer Scientist + +2nd Edition, Version 2.2.14 + +Allen Downey + +Green Tea Press + +Needham, Massachusetts + +Copyright © 2015 Allen Downey. + +| Green Tea Press +| 9 Washburn Ave +| Needham MA 02492 + +Permission is granted to copy, distribute, and/or modify this document +under the terms of the Creative Commons Attribution-NonCommercial 3.0 +Unported License, which is available at +http://creativecommons.org/licenses/by-nc/3.0/. + +The original form of this book is LaTeX source code. Compiling this +LaTeX source has the effect of generating a device-independent +representation of a textbook, which can be converted to other formats +and printed. + +The LaTeX source for this book is available from +http://www.thinkpython2.com + +Think Python: How to Think Like a Computer Scientist + +Allen B. Downey + +2nd Edition, Version 2.2.14 + +Preface +======= + +The strange history of this book +-------------------------------- + +In January 1999 I was preparing to teach an introductory programming +class in Java. I had taught it three times and I was getting frustrated. +The failure rate in the class was too high and, even for students who +succeeded, the overall level of achievement was too low. + +One of the problems I saw was the books. They were too big, with too +much unnecessary detail about Java, and not enough high-level guidance +about how to program. And they all suffered from the trap door effect: +they would start out easy, proceed gradually, and then somewhere around +Chapter 5 the bottom would fall out. The students would get too much new +material, too fast, and I would spend the rest of the semester picking +up the pieces. + +Two weeks before the first day of classes, I decided to write my own +book. My goals were: + +- Keep it short. It is better for students to read 10 pages than not + read 50 pages. + +- Be careful with vocabulary. I tried to minimize jargon and define + each term at first use. + +- Build gradually. To avoid trap doors, I took the most difficult + topics and split them into a series of small steps. + +- Focus on programming, not the programming language. I included the + minimum useful subset of Java and left out the rest. + +I needed a title, so on a whim I chose *How to Think Like a Computer +Scientist*. + +My first version was rough, but it worked. Students did the reading, and +they understood enough that I could spend class time on the hard topics, +the interesting topics and (most important) letting the students +practice. + +I released the book under the GNU Free Documentation License, which +allows users to copy, modify, and distribute the book. + +What happened next is the cool part. Jeff Elkner, a high school teacher +in Virginia, adopted my book and translated it into Python. He sent me a +copy of his translation, and I had the unusual experience of learning +Python by reading my own book. As Green Tea Press, I published the first +Python version in 2001. + +In 2003 I started teaching at Olin College and I got to teach Python for +the first time. The contrast with Java was striking. Students struggled +less, learned more, worked on more interesting projects, and generally +had a lot more fun. + +Since then I’ve continued to develop the book, correcting errors, +improving some of the examples and adding material, especially +exercises. + +The result is this book, now with the less grandiose title *Think +Python*. Some of the changes are: + +- I added a section about debugging at the end of each chapter. These + sections present general techniques for finding and avoiding bugs, + and warnings about Python pitfalls. + +- I added more exercises, ranging from short tests of understanding to + a few substantial projects. Most exercises include a link to my + solution. + +- I added a series of case studies—longer examples with exercises, + solutions, and discussion. + +- I expanded the discussion of program development plans and basic + design patterns. + +- I added appendices about debugging and analysis of algorithms. + +The second edition of *Think Python* has these new features: + +- The book and all supporting code have been updated to Python 3. + +- I added a few sections, and more details on the web, to help + beginners get started running Python in a browser, so you don’t have + to deal with installing Python until you want to. + +- For Chapter [turtle] I switched from my own turtle graphics package, + called Swampy, to a more standard Python module, turtle, which is + easier to install and more powerful. + +- I added a new chapter called “The Goodies”, which introduces some + additional Python features that are not strictly necessary, but + sometimes handy. + +I hope you enjoy working with this book, and that it helps you learn to +program and think like a computer scientist, at least a little bit. + +| Allen B. Downey +| Olin College + +Acknowledgments +--------------- + +Many thanks to Jeff Elkner, who translated my Java book into Python, +which got this project started and introduced me to what has turned out +to be my favorite language. + +Thanks also to Chris Meyers, who contributed several sections to *How to +Think Like a Computer Scientist*. + +Thanks to the Free Software Foundation for developing the GNU Free +Documentation License, which helped make my collaboration with Jeff and +Chris possible, and Creative Commons for the license I am using now. + +Thanks to the editors at Lulu who worked on *How to Think Like a +Computer Scientist*. + +Thanks to the editors at O’Reilly Media who worked on *Think Python*. + +Thanks to all the students who worked with earlier versions of this book +and all the contributors (listed below) who sent in corrections and +suggestions. + +Contributor List +---------------- + +More than 100 sharp-eyed and thoughtful readers have sent in suggestions +and corrections over the past few years. Their contributions, and +enthusiasm for this project, have been a huge help. + +If you have a suggestion or correction, please send email to +feedback@thinkpython.com. If I make a change based on your feedback, I +will add you to the contributor list (unless you ask to be omitted). + +If you include at least part of the sentence the error appears in, that +makes it easy for me to search. Page and section numbers are fine, too, +but not quite as easy to work with. Thanks! + +- Lloyd Hugh Allen sent in a correction to Section 8.4. + +- Yvon Boulianne sent in a correction of a semantic error in Chapter 5. + +- Fred Bremmer submitted a correction in Section 2.1. + +- Jonah Cohen wrote the Perl scripts to convert the LaTeX source for + this book into beautiful HTML. + +- Michael Conlon sent in a grammar correction in Chapter 2 and an + improvement in style in Chapter 1, and he initiated discussion on the + technical aspects of interpreters. + +- Benoit Girard sent in a correction to a humorous mistake in Section + 5.6. + +- Courtney Gleason and Katherine Smith wrote horsebet.py, which was + used as a case study in an earlier version of the book. Their program + can now be found on the website. + +- Lee Harr submitted more corrections than we have room to list here, + and indeed he should be listed as one of the principal editors of the + text. + +- James Kaylin is a student using the text. He has submitted numerous + corrections. + +- David Kershaw fixed the broken catTwice function in Section 3.10. + +- Eddie Lam has sent in numerous corrections to Chapters 1, 2, and 3. + He also fixed the Makefile so that it creates an index the first time + it is run and helped us set up a versioning scheme. + +- Man-Yong Lee sent in a correction to the example code in Section 2.4. + +- David Mayo pointed out that the word \`\`unconsciously“ in Chapter 1 + needed to be changed to \`\`subconsciously”. + +- Chris McAloon sent in several corrections to Sections 3.9 and 3.10. + +- Matthew J. Moelter has been a long-time contributor who sent in + numerous corrections and suggestions to the book. + +- Simon Dicon Montford reported a missing function definition and + several typos in Chapter 3. He also found errors in the increment + function in Chapter 13. + +- John Ouzts corrected the definition of \`\`return value" in Chapter + 3. + +- Kevin Parks sent in valuable comments and suggestions as to how to + improve the distribution of the book. + +- David Pool sent in a typo in the glossary of Chapter 1, as well as + kind words of encouragement. + +- Michael Schmitt sent in a correction to the chapter on files and + exceptions. + +- Robin Shaw pointed out an error in Section 13.1, where the printTime + function was used in an example without being defined. + +- Paul Sleigh found an error in Chapter 7 and a bug in Jonah Cohen’s + Perl script that generates HTML from LaTeX. + +- Craig T. Snydal is testing the text in a course at Drew University. + He has contributed several valuable suggestions and corrections. + +- Ian Thomas and his students are using the text in a programming + course. They are the first ones to test the chapters in the latter + half of the book, and they have made numerous corrections and + suggestions. + +- Keith Verheyden sent in a correction in Chapter 3. + +- Peter Winstanley let us know about a longstanding error in our Latin + in Chapter 3. + +- Chris Wrobel made corrections to the code in the chapter on file I/O + and exceptions. + +- Moshe Zadka has made invaluable contributions to this project. In + addition to writing the first draft of the chapter on Dictionaries, + he provided continual guidance in the early stages of the book. + +- Christoph Zwerschke sent several corrections and pedagogic + suggestions, and explained the difference between *gleich* and + *selbe*. + +- James Mayer sent us a whole slew of spelling and typographical + errors, including two in the contributor list. + +- Hayden McAfee caught a potentially confusing inconsistency between + two examples. + +- Angel Arnal is part of an international team of translators working + on the Spanish version of the text. He has also found several errors + in the English version. + +- Tauhidul Hoque and Lex Berezhny created the illustrations in Chapter + 1 and improved many of the other illustrations. + +- Dr. Michele Alzetta caught an error in Chapter 8 and sent some + interesting pedagogic comments and suggestions about Fibonacci and + Old Maid. + +- Andy Mitchell caught a typo in Chapter 1 and a broken example in + Chapter 2. + +- Kalin Harvey suggested a clarification in Chapter 7 and caught some + typos. + +- Christopher P. Smith caught several typos and helped us update the + book for Python 2.2. + +- David Hutchins caught a typo in the Foreword. + +- Gregor Lingl is teaching Python at a high school in Vienna, Austria. + He is working on a German translation of the book, and he caught a + couple of bad errors in Chapter 5. + +- Julie Peters caught a typo in the Preface. + +- Florin Oprina sent in an improvement in makeTime, a correction in + printTime, and a nice typo. + +- D. J. Webre suggested a clarification in Chapter 3. + +- Ken found a fistful of errors in Chapters 8, 9 and 11. + +- Ivo Wever caught a typo in Chapter 5 and suggested a clarification in + Chapter 3. + +- Curtis Yanko suggested a clarification in Chapter 2. + +- Ben Logan sent in a number of typos and problems with translating the + book into HTML. + +- Jason Armstrong saw the missing word in Chapter 2. + +- Louis Cordier noticed a spot in Chapter 16 where the code didn’t + match the text. + +- Brian Cain suggested several clarifications in Chapters 2 and 3. + +- Rob Black sent in a passel of corrections, including some changes for + Python 2.2. + +- Jean-Philippe Rey at Ecole Centrale Paris sent a number of patches, + including some updates for Python 2.2 and other thoughtful + improvements. + +- Jason Mader at George Washington University made a number of useful + suggestions and corrections. + +- Jan Gundtofte-Bruun reminded us that “a error” is an error. + +- Abel David and Alexis Dinno reminded us that the plural of “matrix” + is “matrices”, not “matrixes”. This error was in the book for years, + but two readers with the same initials reported it on the same day. + Weird. + +- Charles Thayer encouraged us to get rid of the semi-colons we had put + at the ends of some statements and to clean up our use of “argument” + and “parameter”. + +- Roger Sperberg pointed out a twisted piece of logic in Chapter 3. + +- Sam Bull pointed out a confusing paragraph in Chapter 2. + +- Andrew Cheung pointed out two instances of “use before def”. + +- C. Corey Capel spotted the missing word in the Third Theorem of + Debugging and a typo in Chapter 4. + +- Alessandra helped clear up some Turtle confusion. + +- Wim Champagne found a brain-o in a dictionary example. + +- Douglas Wright pointed out a problem with floor division in arc. + +- Jared Spindor found some jetsam at the end of a sentence. + +- Lin Peiheng sent a number of very helpful suggestions. + +- Ray Hagtvedt sent in two errors and a not-quite-error. + +- Torsten Hübsch pointed out an inconsistency in Swampy. + +- Inga Petuhhov corrected an example in Chapter 14. + +- Arne Babenhauserheide sent several helpful corrections. + +- Mark E. Casida is is good at spotting repeated words. + +- Scott Tyler filled in a that was missing. And then sent in a heap of + corrections. + +- Gordon Shephard sent in several corrections, all in separate emails. + +- Andrew Turner spotted an error in Chapter 8. + +- Adam Hobart fixed a problem with floor division in arc. + +- Daryl Hammond and Sarah Zimmerman pointed out that I served up + math.pi too early. And Zim spotted a typo. + +- George Sass found a bug in a Debugging section. + +- Brian Bingham suggested Exercise [exrotatepairs]. + +- Leah Engelbert-Fenton pointed out that I used tuple as a variable + name, contrary to my own advice. And then found a bunch of typos and + a “use before def”. + +- Joe Funke spotted a typo. + +- Chao-chao Chen found an inconsistency in the Fibonacci example. + +- Jeff Paine knows the difference between space and spam. + +- Lubos Pintes sent in a typo. + +- Gregg Lind and Abigail Heithoff suggested Exercise [checksum]. + +- Max Hailperin has sent in a number of corrections and suggestions. + Max is one of the authors of the extraordinary *Concrete + Abstractions*, which you might want to read when you are done with + this book. + +- Chotipat Pornavalai found an error in an error message. + +- Stanislaw Antol sent a list of very helpful suggestions. + +- Eric Pashman sent a number of corrections for Chapters 4–11. + +- Miguel Azevedo found some typos. + +- Jianhua Liu sent in a long list of corrections. + +- Nick King found a missing word. + +- Martin Zuther sent a long list of suggestions. + +- Adam Zimmerman found an inconsistency in my instance of an “instance” + and several other errors. + +- Ratnakar Tiwari suggested a footnote explaining degenerate triangles. + +- Anurag Goel suggested another solution for ``is_abecedarian`` and + sent some additional corrections. And he knows how to spell Jane + Austen. + +- Kelli Kratzer spotted one of the typos. + +- Mark Griffiths pointed out a confusing example in Chapter 3. + +- Roydan Ongie found an error in my Newton’s method. + +- Patryk Wolowiec helped me with a problem in the HTML version. + +- Mark Chonofsky told me about a new keyword in Python 3. + +- Russell Coleman helped me with my geometry. + +- Wei Huang spotted several typographical errors. + +- Karen Barber spotted the the oldest typo in the book. + +- Nam Nguyen found a typo and pointed out that I used the Decorator + pattern but didn’t mention it by name. + +- Stéphane Morin sent in several corrections and suggestions. + +- Paul Stoop corrected a typo in ``uses_only``. + +- Eric Bronner pointed out a confusion in the discussion of the order + of operations. + +- Alexandros Gezerlis set a new standard for the number and quality of + suggestions he submitted. We are deeply grateful! + +- Gray Thomas knows his right from his left. + +- Giovanni Escobar Sosa sent a long list of corrections and + suggestions. + +- Alix Etienne fixed one of the URLs. + +- Kuang He found a typo. + +- Daniel Neilson corrected an error about the order of operations. + +- Will McGinnis pointed out that polyline was defined differently in + two places. + +- Swarup Sahoo spotted a missing semi-colon. + +- Frank Hecker pointed out an exercise that was under-specified, and + some broken links. + +- Animesh B helped me clean up a confusing example. + +- Martin Caspersen found two round-off errors. + +- Gregor Ulm sent several corrections and suggestions. + +- Dimitrios Tsirigkas suggested I clarify an exercise. + +- Carlos Tafur sent a page of corrections and suggestions. + +- Martin Nordsletten found a bug in an exercise solution. + +- Lars O.D. Christensen found a broken reference. + +- Victor Simeone found a typo. + +- Sven Hoexter pointed out that a variable named input shadows a + build-in function. + +- Viet Le found a typo. + +- Stephen Gregory pointed out the problem with cmp in Python 3. + +- Matthew Shultz let me know about a broken link. + +- Lokesh Kumar Makani let me know about some broken links and some + changes in error messages. + +- Ishwar Bhat corrected my statement of Fermat’s last theorem. + +- Brian McGhie suggested a clarification. + +- Andrea Zanella translated the book into Italian, and sent a number of + corrections along the way. + +- Many, many thanks to Melissa Lewis and Luciano Ramalho for excellent + comments and suggestions on the second edition. + +- Thanks to Harry Percival from PythonAnywhere for his help getting + people started running Python in a browser. + +- Xavier Van Aubel made several useful corrections in the second + edition. diff --git a/book/01-the-way.rst b/book/01-the-way.rst new file mode 100644 index 0000000..961a2d5 --- /dev/null +++ b/book/01-the-way.rst @@ -0,0 +1,423 @@ +The way of the program +====================== + +The goal of this book is to teach you to think like a computer +scientist. This way of thinking combines some of the best features of +mathematics, engineering, and natural science. Like mathematicians, +computer scientists use formal languages to denote ideas (specifically +computations). Like engineers, they design things, assembling components +into systems and evaluating tradeoffs among alternatives. Like +scientists, they observe the behavior of complex systems, form +hypotheses, and test predictions. + +The single most important skill for a computer scientist is **problem +solving**. Problem solving means the ability to formulate problems, +think creatively about solutions, and express a solution clearly and +accurately. As it turns out, the process of learning to program is an +excellent opportunity to practice problem-solving skills. That’s why +this chapter is called, “The way of the program”. + +On one level, you will be learning to program, a useful skill by itself. +On another level, you will use programming as a means to an end. As we +go along, that end will become clearer. + +What is a program? +------------------ + +A **program** is a sequence of instructions that specifies how to +perform a computation. The computation might be something mathematical, +such as solving a system of equations or finding the roots of a +polynomial, but it can also be a symbolic computation, such as searching +and replacing text in a document or something graphical, like processing +an image or playing a video. + +The details look different in different languages, but a few basic +instructions appear in just about every language: + +input: + Get data from the keyboard, a file, the network, or some other + device. + +output: + Display data on the screen, save it in a file, send it over the + network, etc. + +math: + Perform basic mathematical operations like addition and + multiplication. + +conditional execution: + Check for certain conditions and run the appropriate code. + +repetition: + Perform some action repeatedly, usually with some variation. + +Believe it or not, that’s pretty much all there is to it. Every program +you’ve ever used, no matter how complicated, is made up of instructions +that look pretty much like these. So you can think of programming as the +process of breaking a large, complex task into smaller and smaller +subtasks until the subtasks are simple enough to be performed with one +of these basic instructions. + +Running Python +-------------- + +One of the challenges of getting started with Python is that you might +have to install Python and related software on your computer. If you are +familiar with your operating system, and especially if you are +comfortable with the command-line interface, you will have no trouble +installing Python. But for beginners, it can be painful to learn about +system administration and programming at the same time. + +To avoid that problem, I recommend that you start out running Python in +a browser. Later, when you are comfortable with Python, I’ll make +suggestions for installing Python on your computer. + +There are a number of web pages you can use to run Python. If you +already have a favorite, go ahead and use it. Otherwise I recommend +PythonAnywhere. I provide detailed instructions for getting started at +http://tinyurl.com/thinkpython2e. + +There are two versions of Python, called Python 2 and Python 3. They are +very similar, so if you learn one, it is easy to switch to the other. In +fact, there are only a few differences you will encounter as a beginner. +This book is written for Python 3, but I include some notes about Python +2. + +The Python **interpreter** is a program that reads and executes Python +code. Depending on your environment, you might start the interpreter by +clicking on an icon, or by typing python on a command line. When it +starts, you should see output like this: + +:: + + Python 3.4.0 (default, Jun 19 2015, 14:20:21) + [GCC 4.8.2] on linux + Type "help", "copyright", "credits" or "license" for more information. + >>> + +The first three lines contain information about the interpreter and the +operating system it’s running on, so it might be different for you. But +you should check that the version number, which is 3.4.0 in this +example, begins with 3, which indicates that you are running Python 3. +If it begins with 2, you are running (you guessed it) Python 2. + +The last line is a **prompt** that indicates that the interpreter is +ready for you to enter code. If you type a line of code and hit Enter, +the interpreter displays the result: + +:: + + >>> 1 + 1 + 2 + +Now you’re ready to get started. From here on, I assume that you know +how to start the Python interpreter and run code. + +The first program +----------------- + +Traditionally, the first program you write in a new language is called +“Hello, World!” because all it does is display the words “Hello, +World!”. In Python, it looks like this: + +:: + + >>> print('Hello, World!') + +This is an example of a **print statement**, although it doesn’t +actually print anything on paper. It displays a result on the screen. In +this case, the result is the words + +:: + + Hello, World! + +The quotation marks in the program mark the beginning and end of the +text to be displayed; they don’t appear in the result. + +The parentheses indicate that print is a function. We’ll get to +functions in Chapter [funcchap]. + +In Python 2, the print statement is slightly different; it is not a +function, so it doesn’t use parentheses. + +:: + + >>> print 'Hello, World!' + +This distinction will make more sense soon, but that’s enough to get +started. + +Arithmetic operators +-------------------- + +After “Hello, World”, the next step is arithmetic. Python provides +**operators**, which are special symbols that represent computations +like addition and multiplication. + +The operators +, -, and perform addition, subtraction, and +multiplication, as in the following examples: + +:: + + >>> 40 + 2 + 42 + >>> 43 - 1 + 42 + >>> 6 * 7 + 42 + +The operator / performs division: + +:: + + >>> 84 / 2 + 42.0 + +You might wonder why the result is 42.0 instead of 42. I’ll explain in +the next section. + +Finally, the operator \* performs exponentiation; that is, it raises a +number to a power: + +:: + + >>> 6**2 + 6 + 42 + +In some other languages, ``^`` is used for exponentiation, but in Python +it is a bitwise operator called XOR. If you are not familiar with +bitwise operators, the result will surprise you: + +:: + + >>> 6 ^ 2 + 4 + +I won’t cover bitwise operators in this book, but you can read about +them at http://wiki.python.org/moin/BitwiseOperators. + +Values and types +---------------- + +A **value** is one of the basic things a program works with, like a +letter or a number. Some values we have seen so far are 2, 42.0, and +``'Hello, World!'``. + +These values belong to different **types**: 2 is an **integer**, 42.0 is +a **floating-point number**, and ``'Hello, World!'`` is a **string**, +so-called because the letters it contains are strung together. + +If you are not sure what type a value has, the interpreter can tell you: + +:: + + >>> type(2) + + >>> type(42.0) + + >>> type('Hello, World!') + + +In these results, the word “class” is used in the sense of a category; a +type is a category of values. + +Not surprisingly, integers belong to the type int, strings belong to str +and floating-point numbers belong to float. + +What about values like ``'2'`` and ``'42.0'``? They look like numbers, +but they are in quotation marks like strings. + +:: + + >>> type('2') + + >>> type('42.0') + + +They’re strings. + +When you type a large integer, you might be tempted to use commas +between groups of digits, as in 1,000,000. This is not a legal *integer* +in Python, but it is legal: + +:: + + >>> 1,000,000 + (1, 0, 0) + +That’s not what we expected at all! Python interprets 1,000,000 as a +comma-separated sequence of integers. We’ll learn more about this kind +of sequence later. + +Formal and natural languages +---------------------------- + +**Natural languages** are the languages people speak, such as English, +Spanish, and French. They were not designed by people (although people +try to impose some order on them); they evolved naturally. + +**Formal languages** are languages that are designed by people for +specific applications. For example, the notation that mathematicians use +is a formal language that is particularly good at denoting relationships +among numbers and symbols. Chemists use a formal language to represent +the chemical structure of molecules. And most importantly: + + **Programming languages are formal languages that have been designed + to express computations.** + +Formal languages tend to have strict **syntax** rules that govern the +structure of statements. For example, in mathematics the statement +:math:`3 + 3 = 6` has correct syntax, but :math:`3 + = 3 \$ 6` does not. +In chemistry :math:`H_2O` is a syntactically correct formula, but +:math:`_2Zz` is not. + +Syntax rules come in two flavors, pertaining to **tokens** and +structure. Tokens are the basic elements of the language, such as words, +numbers, and chemical elements. One of the problems with +:math:`3 += 3 \$ 6` is that :math:` \$ ` is not a legal token in +mathematics (at least as far as I know). Similarly, :math:`_2Zz` is not +legal because there is no element with the abbreviation :math:`Zz`. + +The second type of syntax rule pertains to the way tokens are combined. +The equation :math:`3 += 3` is illegal because even though :math:`+` and +:math:`=` are legal tokens, you can’t have one right after the other. +Similarly, in a chemical formula the subscript comes after the element +name, not before. + +This is @ well-structured Engli$h sentence with invalid t\*kens in it. +This sentence all valid tokens has, but invalid structure with. + +When you read a sentence in English or a statement in a formal language, +you have to figure out the structure (although in a natural language you +do this subconsciously). This process is called **parsing**. + +Although formal and natural languages have many features in +common—tokens, structure, and syntax—there are some differences: + +ambiguity: + Natural languages are full of ambiguity, which people deal with by + using contextual clues and other information. Formal languages are + designed to be nearly or completely unambiguous, which means that + any statement has exactly one meaning, regardless of context. + +redundancy: + In order to make up for ambiguity and reduce misunderstandings, + natural languages employ lots of redundancy. As a result, they are + often verbose. Formal languages are less redundant and more concise. + +literalness: + Natural languages are full of idiom and metaphor. If I say, “The + penny dropped”, there is probably no penny and nothing dropping + (this idiom means that someone understood something after a period + of confusion). Formal languages mean exactly what they say. + +Because we all grow up speaking natural languages, it is sometimes hard +to adjust to formal languages. The difference between formal and natural +language is like the difference between poetry and prose, but more so: + +Poetry: + Words are used for their sounds as well as for their meaning, and + the whole poem together creates an effect or emotional response. + Ambiguity is not only common but often deliberate. + +Prose: + The literal meaning of words is more important, and the structure + contributes more meaning. Prose is more amenable to analysis than + poetry but still often ambiguous. + +Programs: + The meaning of a computer program is unambiguous and literal, and + can be understood entirely by analysis of the tokens and structure. + +Formal languages are more dense than natural languages, so it takes +longer to read them. Also, the structure is important, so it is not +always best to read from top to bottom, left to right. Instead, learn to +parse the program in your head, identifying the tokens and interpreting +the structure. Finally, the details matter. Small errors in spelling and +punctuation, which you can get away with in natural languages, can make +a big difference in a formal language. + +Debugging +--------- + +Programmers make mistakes. For whimsical reasons, programming errors are +called **bugs** and the process of tracking them down is called +**debugging**. + +Programming, and especially debugging, sometimes brings out strong +emotions. If you are struggling with a difficult bug, you might feel +angry, despondent, or embarrassed. + +There is evidence that people naturally respond to computers as if they +were people. When they work well, we think of them as teammates, and +when they are obstinate or rude, we respond to them the same way we +respond to rude, obstinate people (Reeves and Nass, *The Media Equation: +How People Treat Computers, Television, and New Media Like Real People +and Places*). + +Preparing for these reactions might help you deal with them. One +approach is to think of the computer as an employee with certain +strengths, like speed and precision, and particular weaknesses, like +lack of empathy and inability to grasp the big picture. + +Your job is to be a good manager: find ways to take advantage of the +strengths and mitigate the weaknesses. And find ways to use your +emotions to engage with the problem, without letting your reactions +interfere with your ability to work effectively. + +Learning to debug can be frustrating, but it is a valuable skill that is +useful for many activities beyond programming. At the end of each +chapter there is a section, like this one, with my suggestions for +debugging. I hope they help! + + +.. _glossary01: + +Glossary +-------- + +.. include:: glossary/01.txt + + +Exercises +--------- + +It is a good idea to read this book in front of a computer so you can +try out the examples as you go. + +Whenever you are experimenting with a new feature, you should try to +make mistakes. For example, in the “Hello, world!” program, what happens +if you leave out one of the quotation marks? What if you leave out both? +What if you spell print wrong? + +This kind of experiment helps you remember what you read; it also helps +when you are programming, because you get to know what the error +messages mean. It is better to make mistakes now and on purpose than +later and accidentally. + +#. In a print statement, what happens if you leave out one of the + parentheses, or both? + +#. If you are trying to print a string, what happens if you leave out + one of the quotation marks, or both? + +#. You can use a minus sign to make a negative number like -2. What + happens if you put a plus sign before a number? What about 2++2? + +#. In math notation, leading zeros are ok, as in 02. What happens if you + try this in Python? + +#. What happens if you have two values with no operator between them? + +Start the Python interpreter and use it as a calculator. + +#. How many seconds are there in 42 minutes 42 seconds? + +#. How many miles are there in 10 kilometers? Hint: there are 1.61 + kilometers in a mile. + +#. If you run a 10 kilometer race in 42 minutes 42 seconds, what is your + average pace (time per mile in minutes and seconds)? What is your + average speed in miles per hour? diff --git a/book/02-statement.rst b/book/02-statement.rst new file mode 100644 index 0000000..ea8e93f --- /dev/null +++ b/book/02-statement.rst @@ -0,0 +1,388 @@ +Variables, expressions and statements +===================================== + +One of the most powerful features of a programming language is the +ability to manipulate **variables**. A variable is a name that refers to +a value. + +Assignment statements +--------------------- + +An **assignment statement** creates a new variable and gives it a value: + +:: + + >>> message = 'And now for something completely different' + >>> n = 17 + >>> pi = 3.141592653589793 + +This example makes three assignments. The first assigns a string to a +new variable named message; the second gives the integer 17 to n; the +third assigns the (approximate) value of :math:`\pi` to pi. + +A common way to represent variables on paper is to write the name with +an arrow pointing to its value. This kind of figure is called a **state +diagram** because it shows what state each of the variables is in (think +of it as the variable’s state of mind). Figure [fig.state2] shows the +result of the previous example. + +.. figure:: figs/state2.pdf + :alt: State diagram. + + State diagram. + +Variable names +-------------- + +Programmers generally choose names for their variables that are +meaningful—they document what the variable is used for. + +Variable names can be as long as you like. They can contain both letters +and numbers, but they can’t begin with a number. It is legal to use +uppercase letters, but it is conventional to use only lower case for +variables names. + +The underscore character, ``_``, can appear in a name. It is often used +in names with multiple words, such as ``your_name`` or +``airspeed_of_unladen_swallow``. + +If you give a variable an illegal name, you get a syntax error: + +:: + + >>> 76trombones = 'big parade' + SyntaxError: invalid syntax + >>> more@ = 1000000 + SyntaxError: invalid syntax + >>> class = 'Advanced Theoretical Zymurgy' + SyntaxError: invalid syntax + +76trombones is illegal because it begins with a number. more@ is illegal +because it contains an illegal character, @. But what’s wrong with +class? + +It turns out that class is one of Python’s **keywords**. The interpreter +uses keywords to recognize the structure of the program, and they cannot +be used as variable names. + +Python 3 has these keywords: + +:: + + False class finally is return + None continue for lambda try + True def from nonlocal while + and del global not with + as elif if or yield + assert else import pass + break except in raise + +You don’t have to memorize this list. In most development environments, +keywords are displayed in a different color; if you try to use one as a +variable name, you’ll know. + +Expressions and statements +-------------------------- + +An **expression** is a combination of values, variables, and operators. +A value all by itself is considered an expression, and so is a variable, +so the following are all legal expressions: + +:: + + >>> 42 + 42 + >>> n + 17 + >>> n + 25 + 42 + +When you type an expression at the prompt, the interpreter **evaluates** +it, which means that it finds the value of the expression. In this +example, n has the value 17 and n + 25 has the value 42. + +A **statement** is a unit of code that has an effect, like creating a +variable or displaying a value. + +:: + + >>> n = 17 + >>> print(n) + +The first line is an assignment statement that gives a value to n. The +second line is a print statement that displays the value of n. + +When you type a statement, the interpreter **executes** it, which means +that it does whatever the statement says. In general, statements don’t +have values. + +Script mode +----------- + +So far we have run Python in **interactive mode**, which means that you +interact directly with the interpreter. Interactive mode is a good way +to get started, but if you are working with more than a few lines of +code, it can be clumsy. + +The alternative is to save code in a file called a **script** and then +run the interpreter in **script mode** to execute the script. By +convention, Python scripts have names that end with .py. + +If you know how to create and run a script on your computer, you are +ready to go. Otherwise I recommend using PythonAnywhere again. I have +posted instructions for running in script mode at +http://tinyurl.com/thinkpython2e. + +Because Python provides both modes, you can test bits of code in +interactive mode before you put them in a script. But there are +differences between interactive mode and script mode that can be +confusing. + +For example, if you are using Python as a calculator, you might type + +:: + + >>> miles = 26.2 + >>> miles * 1.61 + 42.182 + +The first line assigns a value to miles, but it has no visible effect. +The second line is an expression, so the interpreter evaluates it and +displays the result. It turns out that a marathon is about 42 +kilometers. + +But if you type the same code into a script and run it, you get no +output at all. In script mode an expression, all by itself, has no +visible effect. Python actually evaluates the expression, but it doesn’t +display the value unless you tell it to: + +:: + + miles = 26.2 + print(miles * 1.61) + +This behavior can be confusing at first. + +A script usually contains a sequence of statements. If there is more +than one statement, the results appear one at a time as the statements +execute. + +For example, the script + +:: + + print(1) + x = 2 + print(x) + +produces the output + +:: + + 1 + 2 + +The assignment statement produces no output. + +To check your understanding, type the following statements in the Python +interpreter and see what they do: + +:: + + 5 + x = 5 + x + 1 + +Now put the same statements in a script and run it. What is the output? +Modify the script by transforming each expression into a print statement +and then run it again. + +Order of operations +------------------- + +When an expression contains more than one operator, the order of +evaluation depends on the **order of operations**. For mathematical +operators, Python follows mathematical convention. The acronym +**PEMDAS** is a useful way to remember the rules: + +- **P**\ arentheses have the highest precedence and can be used to + force an expression to evaluate in the order you want. Since + expressions in parentheses are evaluated first, 2 \* (3-1) is 4, and + (1+1)\*\*(5-2) is 8. You can also use parentheses to make an + expression easier to read, as in (minute \* 100) / 60, even if it + doesn’t change the result. + +- **E**\ xponentiation has the next highest precedence, so 1 + 2\*\*3 + is 9, not 27, and 2 \* 3\*\*2 is 18, not 36. + +- **M**\ ultiplication and **D**\ ivision have higher precedence than + **A**\ ddition and **S**\ ubtraction. So 2\*3-1 is 5, not 4, and + 6+4/2 is 8, not 5. + +- Operators with the same precedence are evaluated from left to right + (except exponentiation). So in the expression degrees / 2 \* pi, the + division happens first and the result is multiplied by pi. To divide + by :math:`2 \pi`, you can use parentheses or write degrees / 2 / pi. + +I don’t work very hard to remember the precedence of operators. If I +can’t tell by looking at the expression, I use parentheses to make it +obvious. + +String operations +----------------- + +In general, you can’t perform mathematical operations on strings, even +if the strings look like numbers, so the following are illegal: + +:: + + '2'-'1' 'eggs'/'easy' 'third'*'a charm' + +But there are two exceptions, + and . + +The + operator performs **string concatenation**, which means it joins +the strings by linking them end-to-end. For example: + +:: + + >>> first = 'throat' + >>> second = 'warbler' + >>> first + second + throatwarbler + +The operator also works on strings; it performs repetition. For example, +``'Spam'*3`` is ``'SpamSpamSpam'``. If one of the values is a string, +the other has to be an integer. + +This use of + and makes sense by analogy with addition and +multiplication. Just as 4\*3 is equivalent to 4+4+4, we expect +``'Spam'*3`` to be the same as ``'Spam'+'Spam'+'Spam'``, and it is. On +the other hand, there is a significant way in which string concatenation +and repetition are different from integer addition and multiplication. +Can you think of a property that addition has that string concatenation +does not? + +Comments +-------- + +As programs get bigger and more complicated, they get more difficult to +read. Formal languages are dense, and it is often difficult to look at a +piece of code and figure out what it is doing, or why. + +For this reason, it is a good idea to add notes to your programs to +explain in natural language what the program is doing. These notes are +called **comments**, and they start with the ``#`` symbol: + +:: + + # compute the percentage of the hour that has elapsed + percentage = (minute * 100) / 60 + +In this case, the comment appears on a line by itself. You can also put +comments at the end of a line: + +:: + + percentage = (minute * 100) / 60 # percentage of an hour + +Everything from the # to the end of the line is ignored—it has no effect +on the execution of the program. + +Comments are most useful when they document non-obvious features of the +code. It is reasonable to assume that the reader can figure out *what* +the code does; it is more useful to explain *why*. + +This comment is redundant with the code and useless: + +:: + + v = 5 # assign 5 to v + +This comment contains useful information that is not in the code: + +:: + + v = 5 # velocity in meters/second. + +Good variable names can reduce the need for comments, but long names can +make complex expressions hard to read, so there is a tradeoff. + +Debugging +--------- + +Three kinds of errors can occur in a program: syntax errors, runtime +errors, and semantic errors. It is useful to distinguish between them in +order to track them down more quickly. + +Syntax error: + “Syntax” refers to the structure of a program and the rules about + that structure. For example, parentheses have to come in matching + pairs, so (1 + 2) is legal, but 8) is a **syntax error**. + + If there is a syntax error anywhere in your program, Python displays + an error message and quits, and you will not be able to run the + program. During the first few weeks of your programming career, you + might spend a lot of time tracking down syntax errors. As you gain + experience, you will make fewer errors and find them faster. + +Runtime error: + The second type of error is a runtime error, so called because the + error does not appear until after the program has started running. + These errors are also called **exceptions** because they usually + indicate that something exceptional (and bad) has happened. + + Runtime errors are rare in the simple programs you will see in the + first few chapters, so it might be a while before you encounter one. + +Semantic error: + The third type of error is “semantic”, which means related to + meaning. If there is a semantic error in your program, it will run + without generating error messages, but it will not do the right + thing. It will do something else. Specifically, it will do what you + told it to do. + + Identifying semantic errors can be tricky because it requires you to + work backward by looking at the output of the program and trying to + figure out what it is doing. + + +.. _glossary02: + +Glossary +-------- + +.. include:: glossary/02.txt + + +Exercises +--------- + +Repeating my advice from the previous chapter, whenever you learn a new +feature, you should try it out in interactive mode and make errors on +purpose to see what goes wrong. + +- We’ve seen that n = 42 is legal. What about 42 = n? + +- How about x = y = 1? + +- In some languages every statement ends with a semi-colon, ;. What + happens if you put a semi-colon at the end of a Python statement? + +- What if you put a period at the end of a statement? + +- In math notation you can multiply :math:`x` and :math:`y` like this: + :math:`x y`. What happens if you try that in Python? + +Practice using the Python interpreter as a calculator: + +#. The volume of a sphere with radius :math:`r` is + :math:`\frac{4}{3} \pi r^3`. What is the volume of a sphere with + radius 5? + +#. Suppose the cover price of a book is $24.95, but bookstores get a 40% + discount. Shipping costs $3 for the first copy and 75 cents for each + additional copy. What is the total wholesale cost for 60 copies? + +#. If I leave my house at 6:52 am and run 1 mile at an easy pace (8:15 + per mile), then 3 miles at tempo (7:12 per mile) and 1 mile at easy + pace again, what time do I get home for breakfast? diff --git a/book/03-function.rst b/book/03-function.rst new file mode 100644 index 0000000..453baa1 --- /dev/null +++ b/book/03-function.rst @@ -0,0 +1,695 @@ +Functions +========= + +In the context of programming, a **function** is a named sequence of +statements that performs a computation. When you define a function, you +specify the name and the sequence of statements. Later, you can “call” +the function by name. + +Function calls +-------------- + +We have already seen one example of a **function call**: + +:: + + >>> type(42) + + +The name of the function is type. The expression in parentheses is +called the **argument** of the function. The result, for this function, +is the type of the argument. + +It is common to say that a function “takes” an argument and “returns” a +result. The result is also called the **return value**. + +Python provides functions that convert values from one type to another. +The int function takes any value and converts it to an integer, if it +can, or complains otherwise: + +:: + + >>> int('32') + 32 + >>> int('Hello') + ValueError: invalid literal for int(): Hello + +int can convert floating-point values to integers, but it doesn’t round +off; it chops off the fraction part: + +:: + + >>> int(3.99999) + 3 + >>> int(-2.3) + -2 + +float converts integers and strings to floating-point numbers: + +:: + + >>> float(32) + 32.0 + >>> float('3.14159') + 3.14159 + +Finally, str converts its argument to a string: + +:: + + >>> str(32) + '32' + >>> str(3.14159) + '3.14159' + +Math functions +-------------- + +Python has a math module that provides most of the familiar mathematical +functions. A **module** is a file that contains a collection of related +functions. + +Before we can use the functions in a module, we have to import it with +an **import statement**: + +:: + + >>> import math + +This statement creates a **module object** named math. If you display +the module object, you get some information about it: + +:: + + >>> math + + +The module object contains the functions and variables defined in the +module. To access one of the functions, you have to specify the name of +the module and the name of the function, separated by a dot (also known +as a period). This format is called **dot notation**. + +:: + + >>> ratio = signal_power / noise_power + >>> decibels = 10 * math.log10(ratio) + + >>> radians = 0.7 + >>> height = math.sin(radians) + +The first example uses ``math.log10`` to compute a signal-to-noise ratio +in decibels (assuming that ``signal_power`` and ``noise_power`` are +defined). The math module also provides log, which computes logarithms +base e. + +The second example finds the sine of radians. The name of the variable +is a hint that sin and the other trigonometric functions (cos, tan, +etc.) take arguments in radians. To convert from degrees to radians, +divide by 180 and multiply by :math:`\pi`: + +:: + + >>> degrees = 45 + >>> radians = degrees / 180.0 * math.pi + >>> math.sin(radians) + 0.707106781187 + +The expression math.pi gets the variable pi from the math module. Its +value is a floating-point approximation of :math:`\pi`, accurate to +about 15 digits. + +If you know trigonometry, you can check the previous result by comparing +it to the square root of two divided by two: + +:: + + >>> math.sqrt(2) / 2.0 + 0.707106781187 + +Composition +----------- + +So far, we have looked at the elements of a program—variables, +expressions, and statements—in isolation, without talking about how to +combine them. + +One of the most useful features of programming languages is their +ability to take small building blocks and **compose** them. For example, +the argument of a function can be any kind of expression, including +arithmetic operators: + +:: + + x = math.sin(degrees / 360.0 * 2 * math.pi) + +And even function calls: + +:: + + x = math.exp(math.log(x+1)) + +Almost anywhere you can put a value, you can put an arbitrary +expression, with one exception: the left side of an assignment statement +has to be a variable name. Any other expression on the left side is a +syntax error (we will see exceptions to this rule later). + +:: + + >>> minutes = hours * 60 # right + >>> hours * 60 = minutes # wrong! + SyntaxError: can't assign to operator + +Adding new functions +-------------------- + +So far, we have only been using the functions that come with Python, but +it is also possible to add new functions. A **function definition** +specifies the name of a new function and the sequence of statements that +run when the function is called. + +Here is an example: + +:: + + def print_lyrics(): + print("I'm a lumberjack, and I'm okay.") + print("I sleep all night and I work all day.") + +def is a keyword that indicates that this is a function definition. The +name of the function is ``print_lyrics``. The rules for function names +are the same as for variable names: letters, numbers and underscore are +legal, but the first character can’t be a number. You can’t use a +keyword as the name of a function, and you should avoid having a +variable and a function with the same name. + +The empty parentheses after the name indicate that this function doesn’t +take any arguments. + +The first line of the function definition is called the **header**; the +rest is called the **body**. The header has to end with a colon and the +body has to be indented. By convention, indentation is always four +spaces. The body can contain any number of statements. + +The strings in the print statements are enclosed in double quotes. +Single quotes and double quotes do the same thing; most people use +single quotes except in cases like this where a single quote (which is +also an apostrophe) appears in the string. + +All quotation marks (single and double) must be “straight quotes”, +usually located next to Enter on the keyboard. “Curly quotes”, like the +ones in this sentence, are not legal in Python. + +If you type a function definition in interactive mode, the interpreter +prints dots (...) to let you know that the definition isn’t complete: + +:: + + >>> def print_lyrics(): + ... print("I'm a lumberjack, and I'm okay.") + ... print("I sleep all night and I work all day.") + ... + +To end the function, you have to enter an empty line. + +Defining a function creates a **function object**, which has type +``function``: + +:: + + >>> print(print_lyrics) + + >>> type(print_lyrics) + + +The syntax for calling the new function is the same as for built-in +functions: + +:: + + >>> print_lyrics() + I'm a lumberjack, and I'm okay. + I sleep all night and I work all day. + +Once you have defined a function, you can use it inside another +function. For example, to repeat the previous refrain, we could write a +function called ``repeat_lyrics``: + +:: + + def repeat_lyrics(): + print_lyrics() + print_lyrics() + +And then call ``repeat_lyrics``: + +:: + + >>> repeat_lyrics() + I'm a lumberjack, and I'm okay. + I sleep all night and I work all day. + I'm a lumberjack, and I'm okay. + I sleep all night and I work all day. + +But that’s not really how the song goes. + +Definitions and uses +-------------------- + +Pulling together the code fragments from the previous section, the whole +program looks like this: + +:: + + def print_lyrics(): + print("I'm a lumberjack, and I'm okay.") + print("I sleep all night and I work all day.") + + def repeat_lyrics(): + print_lyrics() + print_lyrics() + + repeat_lyrics() + +This program contains two function definitions: ``print_lyrics`` and +``repeat_lyrics``. Function definitions get executed just like other +statements, but the effect is to create function objects. The statements +inside the function do not run until the function is called, and the +function definition generates no output. + +As you might expect, you have to create a function before you can run +it. In other words, the function definition has to run before the +function gets called. + +As an exercise, move the last line of this program to the top, so the +function call appears before the definitions. Run the program and see +what error message you get. + +Now move the function call back to the bottom and move the definition of +``print_lyrics`` after the definition of ``repeat_lyrics``. What happens +when you run this program? + +Flow of execution +----------------- + +To ensure that a function is defined before its first use, you have to +know the order statements run in, which is called the **flow of +execution**. + +Execution always begins at the first statement of the program. +Statements are run one at a time, in order from top to bottom. + +Function definitions do not alter the flow of execution of the program, +but remember that statements inside the function don’t run until the +function is called. + +A function call is like a detour in the flow of execution. Instead of +going to the next statement, the flow jumps to the body of the function, +runs the statements there, and then comes back to pick up where it left +off. + +That sounds simple enough, until you remember that one function can call +another. While in the middle of one function, the program might have to +run the statements in another function. Then, while running that new +function, the program might have to run yet another function! + +Fortunately, Python is good at keeping track of where it is, so each +time a function completes, the program picks up where it left off in the +function that called it. When it gets to the end of the program, it +terminates. + +In summary, when you read a program, you don’t always want to read from +top to bottom. Sometimes it makes more sense if you follow the flow of +execution. + +Parameters and arguments +------------------------ + +Some of the functions we have seen require arguments. For example, when +you call math.sin you pass a number as an argument. Some functions take +more than one argument: math.pow takes two, the base and the exponent. + +Inside the function, the arguments are assigned to variables called +**parameters**. Here is a definition for a function that takes an +argument: + +:: + + def print_twice(bruce): + print(bruce) + print(bruce) + +This function assigns the argument to a parameter named bruce. When the +function is called, it prints the value of the parameter (whatever it +is) twice. + +This function works with any value that can be printed. + +:: + + >>> print_twice('Spam') + Spam + Spam + >>> print_twice(42) + 42 + 42 + >>> print_twice(math.pi) + 3.14159265359 + 3.14159265359 + +The same rules of composition that apply to built-in functions also +apply to programmer-defined functions, so we can use any kind of +expression as an argument for ``print_twice``: + +:: + + >>> print_twice('Spam '*4) + Spam Spam Spam Spam + Spam Spam Spam Spam + >>> print_twice(math.cos(math.pi)) + -1.0 + -1.0 + +The argument is evaluated before the function is called, so in the +examples the expressions ``'Spam '*4`` and math.cos(math.pi) are only +evaluated once. + +You can also use a variable as an argument: + +:: + + >>> michael = 'Eric, the half a bee.' + >>> print_twice(michael) + Eric, the half a bee. + Eric, the half a bee. + +The name of the variable we pass as an argument (michael) has nothing to +do with the name of the parameter (bruce). It doesn’t matter what the +value was called back home (in the caller); here in ``print_twice``, we +call everybody bruce. + +Variables and parameters are local +---------------------------------- + +When you create a variable inside a function, it is **local**, which +means that it only exists inside the function. For example: + +:: + + def cat_twice(part1, part2): + cat = part1 + part2 + print_twice(cat) + +This function takes two arguments, concatenates them, and prints the +result twice. Here is an example that uses it: + +:: + + >>> line1 = 'Bing tiddle ' + >>> line2 = 'tiddle bang.' + >>> cat_twice(line1, line2) + Bing tiddle tiddle bang. + Bing tiddle tiddle bang. + +When ``cat_twice`` terminates, the variable cat is destroyed. If we try +to print it, we get an exception: + +:: + + >>> print(cat) + NameError: name 'cat' is not defined + +Parameters are also local. For example, outside ``print_twice``, there +is no such thing as bruce. + +Stack diagrams +-------------- + +To keep track of which variables can be used where, it is sometimes +useful to draw a **stack diagram**. Like state diagrams, stack diagrams +show the value of each variable, but they also show the function each +variable belongs to. + +Each function is represented by a **frame**. A frame is a box with the +name of a function beside it and the parameters and variables of the +function inside it. The stack diagram for the previous example is shown +in Figure [fig.stack]. + +.. figure:: figs/stack.pdf + :alt: Stack diagram. + + Stack diagram. + +The frames are arranged in a stack that indicates which function called +which, and so on. In this example, ``print_twice`` was called by +``cat_twice``, and ``cat_twice`` was called by ``__main__``, which is a +special name for the topmost frame. When you create a variable outside +of any function, it belongs to ``__main__``. + +Each parameter refers to the same value as its corresponding argument. +So, part1 has the same value as line1, part2 has the same value as +line2, and bruce has the same value as cat. + +If an error occurs during a function call, Python prints the name of the +function, the name of the function that called it, and the name of the +function that called *that*, all the way back to ``__main__``. + +For example, if you try to access cat from within ``print_twice``, you +get a NameError: + +:: + + Traceback (innermost last): + File "test.py", line 13, in __main__ + cat_twice(line1, line2) + File "test.py", line 5, in cat_twice + print_twice(cat) + File "test.py", line 9, in print_twice + print(cat) + NameError: name 'cat' is not defined + +This list of functions is called a **traceback**. It tells you what +program file the error occurred in, and what line, and what functions +were executing at the time. It also shows the line of code that caused +the error. + +The order of the functions in the traceback is the same as the order of +the frames in the stack diagram. The function that is currently running +is at the bottom. + +Fruitful functions and void functions +------------------------------------- + +Some of the functions we have used, such as the math functions, return +results; for lack of a better name, I call them **fruitful functions**. +Other functions, like ``print_twice``, perform an action but don’t +return a value. They are called **void functions**. + +When you call a fruitful function, you almost always want to do +something with the result; for example, you might assign it to a +variable or use it as part of an expression: + +:: + + x = math.cos(radians) + golden = (math.sqrt(5) + 1) / 2 + +When you call a function in interactive mode, Python displays the +result: + +:: + + >>> math.sqrt(5) + 2.2360679774997898 + +But in a script, if you call a fruitful function all by itself, the +return value is lost forever! + +:: + + math.sqrt(5) + +This script computes the square root of 5, but since it doesn’t store or +display the result, it is not very useful. + +Void functions might display something on the screen or have some other +effect, but they don’t have a return value. If you assign the result to +a variable, you get a special value called None. + +:: + + >>> result = print_twice('Bing') + Bing + Bing + >>> print(result) + None + +The value None is not the same as the string ``'None'``. It is a special +value that has its own type: + +:: + + >>> print(type(None)) + + +The functions we have written so far are all void. We will start writing +fruitful functions in a few chapters. + +Why functions? +-------------- + +It may not be clear why it is worth the trouble to divide a program into +functions. There are several reasons: + +- Creating a new function gives you an opportunity to name a group of + statements, which makes your program easier to read and debug. + +- Functions can make a program smaller by eliminating repetitive code. + Later, if you make a change, you only have to make it in one place. + +- Dividing a long program into functions allows you to debug the parts + one at a time and then assemble them into a working whole. + +- Well-designed functions are often useful for many programs. Once you + write and debug one, you can reuse it. + +Debugging +--------- + +One of the most important skills you will acquire is debugging. Although +it can be frustrating, debugging is one of the most intellectually rich, +challenging, and interesting parts of programming. + +In some ways debugging is like detective work. You are confronted with +clues and you have to infer the processes and events that led to the +results you see. + +Debugging is also like an experimental science. Once you have an idea +about what is going wrong, you modify your program and try again. If +your hypothesis was correct, you can predict the result of the +modification, and you take a step closer to a working program. If your +hypothesis was wrong, you have to come up with a new one. As Sherlock +Holmes pointed out, “When you have eliminated the impossible, whatever +remains, however improbable, must be the truth.” (A. Conan Doyle, *The +Sign of Four*) + +For some people, programming and debugging are the same thing. That is, +programming is the process of gradually debugging a program until it +does what you want. The idea is that you should start with a working +program and make small modifications, debugging them as you go. + +For example, Linux is an operating system that contains millions of +lines of code, but it started out as a simple program Linus Torvalds +used to explore the Intel 80386 chip. According to Larry Greenfield, +“One of Linus’s earlier projects was a program that would switch between +printing AAAA and BBBB. This later evolved to Linux.” (*The Linux Users’ +Guide* Beta Version 1). + + +.. _glossary03: + +Glossary +-------- + +.. include:: glossary/03.txt + + +Exercises +--------- + +Write a function named ``right_justify`` that takes a string named s as +a parameter and prints the string with enough leading spaces so that the +last letter of the string is in column 70 of the display. + +:: + + >>> right_justify('monty') + monty + +Hint: Use string concatenation and repetition. Also, Python provides a +built-in function called len that returns the length of a string, so the +value of ``len('monty')`` is 5. + +A function object is a value you can assign to a variable or pass as an +argument. For example, ``do_twice`` is a function that takes a function +object as an argument and calls it twice: + +:: + + def do_twice(f): + f() + f() + +Here’s an example that uses ``do_twice`` to call a function named +``print_spam`` twice. + +:: + + def print_spam(): + print('spam') + + do_twice(print_spam) + +#. Type this example into a script and test it. + +#. Modify ``do_twice`` so that it takes two arguments, a function object + and a value, and calls the function twice, passing the value as an + argument. + +#. Copy the definition of ``print_twice`` from earlier in this chapter + to your script. + +#. Use the modified version of ``do_twice`` to call ``print_twice`` + twice, passing ``'spam'`` as an argument. + +#. Define a new function called ``do_four`` that takes a function object + and a value and calls the function four times, passing the value as a + parameter. There should be only two statements in the body of this + function, not four. + +Solution: http://thinkpython2.com/code/do_four.py. + +Note: This exercise should be done using only the statements and other +features we have learned so far. + +#. Write a function that draws a grid like the following: + + :: + + + - - - - + - - - - + + | | | + | | | + | | | + | | | + + - - - - + - - - - + + | | | + | | | + | | | + | | | + + - - - - + - - - - + + + Hint: to print more than one value on a line, you can print a + comma-separated sequence of values: + + :: + + print('+', '-') + + By default, print advances to the next line, but you can override + that behavior and put a space at the end, like this: + + :: + + print('+', end=' ') + print('-') + + The output of these statements is ``'+ -'``. + + A print statement with no argument ends the current line and goes to + the next line. + +#. Write a function that draws a similar grid with four rows and four + columns. + +Solution: http://thinkpython2.com/code/grid.py. Credit: This exercise is +based on an exercise in Oualline, *Practical C Programming, Third +Edition*, O’Reilly Media, 1997. diff --git a/book/04-case-ui.rst b/book/04-case-ui.rst new file mode 100644 index 0000000..e908d07 --- /dev/null +++ b/book/04-case-ui.rst @@ -0,0 +1,561 @@ +Case study: interface design +============================ + +This chapter presents a case study that demonstrates a process for +designing functions that work together. + +It introduces the turtle module, which allows you to create images using +turtle graphics. The turtle module is included in most Python +installations, but if you are running Python using PythonAnywhere, you +won’t be able to run the turtle examples (at least you couldn’t when I +wrote this). + +If you have already installed Python on your computer, you should be +able to run the examples. Otherwise, now is a good time to install. I +have posted instructions at http://tinyurl.com/thinkpython2e. + +Code examples from this chapter are available from +http://thinkpython2.com/code/polygon.py. + +The turtle module +----------------- + +To check whether you have the turtle module, open the Python interpreter +and type + +:: + + >>> import turtle + >>> bob = turtle.Turtle() + +When you run this code, it should create a new window with small arrow +that represents the turtle. Close the window. + +Create a file named mypolygon.py and type in the following code: + +:: + + import turtle + bob = turtle.Turtle() + print(bob) + turtle.mainloop() + +The turtle module (with a lowercase ’t’) provides a function called +Turtle (with an uppercase ’T’) that creates a Turtle object, which we +assign to a variable named bob. Printing bob displays something like: + +:: + + + +This means that bob refers to an object with type Turtle as defined in +module turtle. + +``mainloop`` tells the window to wait for the user to do something, +although in this case there’s not much for the user to do except close +the window. + +Once you create a Turtle, you can call a **method** to move it around +the window. A method is similar to a function, but it uses slightly +different syntax. For example, to move the turtle forward: + +:: + + bob.fd(100) + +The method, fd, is associated with the turtle object we’re calling bob. +Calling a method is like making a request: you are asking bob to move +forward. + +The argument of fd is a distance in pixels, so the actual size depends +on your display. + +Other methods you can call on a Turtle are bk to move backward, lt for +left turn, and rt right turn. The argument for lt and rt is an angle in +degrees. + +Also, each Turtle is holding a pen, which is either down or up; if the +pen is down, the Turtle leaves a trail when it moves. The methods pu and +pd stand for “pen up” and “pen down”. + +To draw a right angle, add these lines to the program (after creating +bob and before calling ``mainloop``): + +:: + + bob.fd(100) + bob.lt(90) + bob.fd(100) + +When you run this program, you should see bob move east and then north, +leaving two line segments behind. + +Now modify the program to draw a square. Don’t go on until you’ve got it +working! + +Simple repetition +----------------- + +Chances are you wrote something like this: + +:: + + bob.fd(100) + bob.lt(90) + + bob.fd(100) + bob.lt(90) + + bob.fd(100) + bob.lt(90) + + bob.fd(100) + +We can do the same thing more concisely with a for statement. Add this +example to mypolygon.py and run it again: + +:: + + for i in range(4): + print('Hello!') + +You should see something like this: + +:: + + Hello! + Hello! + Hello! + Hello! + +This is the simplest use of the for statement; we will see more later. +But that should be enough to let you rewrite your square-drawing +program. Don’t go on until you do. + +Here is a for statement that draws a square: + +:: + + for i in range(4): + bob.fd(100) + bob.lt(90) + +The syntax of a for statement is similar to a function definition. It +has a header that ends with a colon and an indented body. The body can +contain any number of statements. + +A for statement is also called a **loop** because the flow of execution +runs through the body and then loops back to the top. In this case, it +runs the body four times. + +This version is actually a little different from the previous +square-drawing code because it makes another turn after drawing the last +side of the square. The extra turn takes more time, but it simplifies +the code if we do the same thing every time through the loop. This +version also has the effect of leaving the turtle back in the starting +position, facing in the starting direction. + +Exercises +--------- + +The following is a series of exercises using TurtleWorld. They are meant +to be fun, but they have a point, too. While you are working on them, +think about what the point is. + +The following sections have solutions to the exercises, so don’t look +until you have finished (or at least tried). + +#. Write a function called square that takes a parameter named t, which + is a turtle. It should use the turtle to draw a square. + + Write a function call that passes bob as an argument to square, and + then run the program again. + +#. Add another parameter, named length, to square. Modify the body so + length of the sides is length, and then modify the function call to + provide a second argument. Run the program again. Test your program + with a range of values for length. + +#. Make a copy of square and change the name to polygon. Add another + parameter named n and modify the body so it draws an n-sided regular + polygon. Hint: The exterior angles of an n-sided regular polygon are + :math:`360/n` degrees. + +#. Write a function called circle that takes a turtle, t, and radius, r, + as parameters and that draws an approximate circle by calling polygon + with an appropriate length and number of sides. Test your function + with a range of values of r. + + Hint: figure out the circumference of the circle and make sure that + length \* n = circumference. + +#. Make a more general version of circle called arc that takes an + additional parameter angle, which determines what fraction of a + circle to draw. angle is in units of degrees, so when angle=360, arc + should draw a complete circle. + +Encapsulation +------------- + +The first exercise asks you to put your square-drawing code into a +function definition and then call the function, passing the turtle as a +parameter. Here is a solution: + +:: + + def square(t): + for i in range(4): + t.fd(100) + t.lt(90) + + square(bob) + +The innermost statements, fd and lt are indented twice to show that they +are inside the for loop, which is inside the function definition. The +next line, square(bob), is flush with the left margin, which indicates +the end of both the for loop and the function definition. + +Inside the function, t refers to the same turtle bob, so t.lt(90) has +the same effect as bob.lt(90). In that case, why not call the parameter +bob? The idea is that t can be any turtle, not just bob, so you could +create a second turtle and pass it as an argument to square: + +:: + + alice = Turtle() + square(alice) + +Wrapping a piece of code up in a function is called **encapsulation**. +One of the benefits of encapsulation is that it attaches a name to the +code, which serves as a kind of documentation. Another advantage is that +if you re-use the code, it is more concise to call a function twice than +to copy and paste the body! + +Generalization +-------------- + +The next step is to add a length parameter to square. Here is a +solution: + +:: + + def square(t, length): + for i in range(4): + t.fd(length) + t.lt(90) + + square(bob, 100) + +Adding a parameter to a function is called **generalization** because it +makes the function more general: in the previous version, the square is +always the same size; in this version it can be any size. + +The next step is also a generalization. Instead of drawing squares, +polygon draws regular polygons with any number of sides. Here is a +solution: + +:: + + def polygon(t, n, length): + angle = 360 / n + for i in range(n): + t.fd(length) + t.lt(angle) + + polygon(bob, 7, 70) + +This example draws a 7-sided polygon with side length 70. + +If you are using Python 2, the value of angle might be off because of +integer division. A simple solution is to compute angle = 360.0 / n. +Because the numerator is a floating-point number, the result is floating +point. + +When a function has more than a few numeric arguments, it is easy to +forget what they are, or what order they should be in. In that case it +is often a good idea to include the names of the parameters in the +argument list: + +:: + + polygon(bob, n=7, length=70) + +These are called **keyword arguments** because they include the +parameter names as “keywords” (not to be confused with Python keywords +like while and def). + +This syntax makes the program more readable. It is also a reminder about +how arguments and parameters work: when you call a function, the +arguments are assigned to the parameters. + +Interface design +---------------- + +The next step is to write circle, which takes a radius, r, as a +parameter. Here is a simple solution that uses polygon to draw a +50-sided polygon: + +:: + + import math + + def circle(t, r): + circumference = 2 * math.pi * r + n = 50 + length = circumference / n + polygon(t, n, length) + +The first line computes the circumference of a circle with radius r +using the formula :math:`2 \pi r`. Since we use math.pi, we have to +import math. By convention, import statements are usually at the +beginning of the script. + +n is the number of line segments in our approximation of a circle, so +length is the length of each segment. Thus, polygon draws a 50-sides +polygon that approximates a circle with radius r. + +One limitation of this solution is that n is a constant, which means +that for very big circles, the line segments are too long, and for small +circles, we waste time drawing very small segments. One solution would +be to generalize the function by taking n as a parameter. This would +give the user (whoever calls circle) more control, but the interface +would be less clean. + +The **interface** of a function is a summary of how it is used: what are +the parameters? What does the function do? And what is the return value? +An interface is “clean” if it allows the caller to do what they want +without dealing with unnecessary details. + +In this example, r belongs in the interface because it specifies the +circle to be drawn. n is less appropriate because it pertains to the +details of *how* the circle should be rendered. + +Rather than clutter up the interface, it is better to choose an +appropriate value of n depending on circumference: + +:: + + def circle(t, r): + circumference = 2 * math.pi * r + n = int(circumference / 3) + 1 + length = circumference / n + polygon(t, n, length) + +Now the number of segments is an integer near circumference/3, so the +length of each segment is approximately 3, which is small enough that +the circles look good, but big enough to be efficient, and acceptable +for any size circle. + +Refactoring +----------- + +When I wrote circle, I was able to re-use polygon because a many-sided +polygon is a good approximation of a circle. But arc is not as +cooperative; we can’t use polygon or circle to draw an arc. + +One alternative is to start with a copy of polygon and transform it into +arc. The result might look like this: + +:: + + def arc(t, r, angle): + arc_length = 2 * math.pi * r * angle / 360 + n = int(arc_length / 3) + 1 + step_length = arc_length / n + step_angle = angle / n + + for i in range(n): + t.fd(step_length) + t.lt(step_angle) + +The second half of this function looks like polygon, but we can’t re-use +polygon without changing the interface. We could generalize polygon to +take an angle as a third argument, but then polygon would no longer be +an appropriate name! Instead, let’s call the more general function +polyline: + +:: + + def polyline(t, n, length, angle): + for i in range(n): + t.fd(length) + t.lt(angle) + +Now we can rewrite polygon and arc to use polyline: + +:: + + def polygon(t, n, length): + angle = 360.0 / n + polyline(t, n, length, angle) + + def arc(t, r, angle): + arc_length = 2 * math.pi * r * angle / 360 + n = int(arc_length / 3) + 1 + step_length = arc_length / n + step_angle = float(angle) / n + polyline(t, n, step_length, step_angle) + +Finally, we can rewrite circle to use arc: + +:: + + def circle(t, r): + arc(t, r, 360) + +This process—rearranging a program to improve interfaces and facilitate +code re-use—is called **refactoring**. In this case, we noticed that +there was similar code in arc and polygon, so we “factored it out” into +polyline. + +If we had planned ahead, we might have written polyline first and +avoided refactoring, but often you don’t know enough at the beginning of +a project to design all the interfaces. Once you start coding, you +understand the problem better. Sometimes refactoring is a sign that you +have learned something. + +A development plan +------------------ + +A **development plan** is a process for writing programs. The process we +used in this case study is “encapsulation and generalization”. The steps +of this process are: + +#. Start by writing a small program with no function definitions. + +#. Once you get the program working, identify a coherent piece of it, + encapsulate the piece in a function and give it a name. + +#. Generalize the function by adding appropriate parameters. + +#. Repeat steps 1–3 until you have a set of working functions. Copy and + paste working code to avoid retyping (and re-debugging). + +#. Look for opportunities to improve the program by refactoring. For + example, if you have similar code in several places, consider + factoring it into an appropriately general function. + +This process has some drawbacks—we will see alternatives later—but it +can be useful if you don’t know ahead of time how to divide the program +into functions. This approach lets you design as you go along. + +docstring +--------- + +A **docstring** is a string at the beginning of a function that explains +the interface (“doc” is short for “documentation”). Here is an example: + +:: + + def polyline(t, n, length, angle): + """Draws n line segments with the given length and + angle (in degrees) between them. t is a turtle. + """ + for i in range(n): + t.fd(length) + t.lt(angle) + +By convention, all docstrings are triple-quoted strings, also known as +multiline strings because the triple quotes allow the string to span +more than one line. + +It is terse, but it contains the essential information someone would +need to use this function. It explains concisely what the function does +(without getting into the details of how it does it). It explains what +effect each parameter has on the behavior of the function and what type +each parameter should be (if it is not obvious). + +Writing this kind of documentation is an important part of interface +design. A well-designed interface should be simple to explain; if you +have a hard time explaining one of your functions, maybe the interface +could be improved. + +Debugging +--------- + +An interface is like a contract between a function and a caller. The +caller agrees to provide certain parameters and the function agrees to +do certain work. + +For example, polyline requires four arguments: t has to be a Turtle; n +has to be an integer; length should be a positive number; and angle has +to be a number, which is understood to be in degrees. + +These requirements are called **preconditions** because they are +supposed to be true before the function starts executing. Conversely, +conditions at the end of the function are **postconditions**. +Postconditions include the intended effect of the function (like drawing +line segments) and any side effects (like moving the Turtle or making +other changes). + +Preconditions are the responsibility of the caller. If the caller +violates a (properly documented!) precondition and the function doesn’t +work correctly, the bug is in the caller, not the function. + +If the preconditions are satisfied and the postconditions are not, the +bug is in the function. If your pre- and postconditions are clear, they +can help with debugging. + + +.. _glossary04: + +Glossary +-------- + +.. include:: glossary/04.txt + + +Exercises +--------- + +Download the code in this chapter from +http://thinkpython2.com/code/polygon.py. + +#. Draw a stack diagram that shows the state of the program while + executing circle(bob, radius). You can do the arithmetic by hand or + add print statements to the code. + +#. The version of arc in Section [refactoring] is not very accurate + because the linear approximation of the circle is always outside the + true circle. As a result, the Turtle ends up a few pixels away from + the correct destination. My solution shows a way to reduce the effect + of this error. Read the code and see if it makes sense to you. If you + draw a diagram, you might see how it works. + +.. figure:: figs/flowers.pdf + :alt: Turtle flowers. + + Turtle flowers. + +Write an appropriately general set of functions that can draw flowers as +in Figure [fig.flowers]. + +Solution: http://thinkpython2.com/code/flower.py, also requires +http://thinkpython2.com/code/polygon.py. + +.. figure:: figs/pies.pdf + :alt: Turtle pies. + + Turtle pies. + +Write an appropriately general set of functions that can draw shapes as +in Figure [fig.pies]. + +Solution: http://thinkpython2.com/code/pie.py. + +The letters of the alphabet can be constructed from a moderate number of +basic elements, like vertical and horizontal lines and a few curves. +Design an alphabet that can be drawn with a minimal number of basic +elements and then write functions that draw the letters. + +You should write one function for each letter, with names ``draw_a``, +``draw_b``, etc., and put your functions in a file named letters.py. You +can download a “turtle typewriter” from +http://thinkpython2.com/code/typewriter.py to help you test your code. + +You can get a solution from http://thinkpython2.com/code/letters.py; it +also requires http://thinkpython2.com/code/polygon.py. + +Read about spirals at http://en.wikipedia.org/wiki/Spiral; then write a +program that draws an Archimedian spiral (or one of the other kinds). +Solution: http://thinkpython2.com/code/spiral.py. diff --git a/book/05-cond-recur.rst b/book/05-cond-recur.rst new file mode 100644 index 0000000..28ae614 --- /dev/null +++ b/book/05-cond-recur.rst @@ -0,0 +1,675 @@ +Conditionals and recursion +========================== + +The main topic of this chapter is the if statement, which executes +different code depending on the state of the program. But first I want +to introduce two new operators: floor division and modulus. + +Floor division and modulus +-------------------------- + +The **floor division** operator, ``//``, divides two numbers and rounds +down to an integer. For example, suppose the run time of a movie is 105 +minutes. You might want to know how long that is in hours. Conventional +division returns a floating-point number: + +:: + + >>> minutes = 105 + >>> minutes / 60 + 1.75 + +But we don’t normally write hours with decimal points. Floor division +returns the integer number of hours, dropping the fraction part: + +:: + + >>> minutes = 105 + >>> hours = minutes // 60 + >>> hours + 1 + +To get the remainder, you could subtract off one hour in minutes: + +:: + + >>> remainder = minutes - hours * 60 + >>> remainder + 45 + +An alternative is to use the **modulus operator**, ``%``, which divides +two numbers and returns the remainder. + +:: + + >>> remainder = minutes % 60 + >>> remainder + 45 + +The modulus operator is more useful than it seems. For example, you can +check whether one number is divisible by another—if x % y is zero, then +x is divisible by y. + +Also, you can extract the right-most digit or digits from a number. For +example, x % 10 yields the right-most digit of x (in base 10). Similarly +x % 100 yields the last two digits. + +If you are using Python 2, division works differently. The division +operator, ``/``, performs floor division if both operands are integers, +and floating-point division if either operand is a float. + +Boolean expressions +------------------- + +A **boolean expression** is an expression that is either true or false. +The following examples use the operator ==, which compares two operands +and produces True if they are equal and False otherwise: + +:: + + >>> 5 == 5 + True + >>> 5 == 6 + False + +True and False are special values that belong to the type bool; they are +not strings: + +:: + + >>> type(True) + + >>> type(False) + + +The == operator is one of the **relational operators**; the others are: + +:: + + x != y # x is not equal to y + x > y # x is greater than y + x < y # x is less than y + x >= y # x is greater than or equal to y + x <= y # x is less than or equal to y + +Although these operations are probably familiar to you, the Python +symbols are different from the mathematical symbols. A common error is +to use a single equal sign (=) instead of a double equal sign (==). +Remember that = is an assignment operator and == is a relational +operator. There is no such thing as =< or =>. + +Logical operators +----------------- + +There are three **logical operators**: and, or, and not. The semantics +(meaning) of these operators is similar to their meaning in English. For +example, x > 0 and x < 10 is true only if x is greater than 0 *and* less +than 10. + +n%2 == 0 or n%3 == 0 is true if *either or both* of the conditions is +true, that is, if the number is divisible by 2 *or* 3. + +Finally, the not operator negates a boolean expression, so not (x > y) +is true if x > y is false, that is, if x is less than or equal to y. + +Strictly speaking, the operands of the logical operators should be +boolean expressions, but Python is not very strict. Any nonzero number +is interpreted as True: + +:: + + >>> 42 and True + True + +This flexibility can be useful, but there are some subtleties to it that +might be confusing. You might want to avoid it (unless you know what you +are doing). + +Conditional execution +--------------------- + +In order to write useful programs, we almost always need the ability to +check conditions and change the behavior of the program accordingly. +**Conditional statements** give us this ability. The simplest form is +the if statement: + +:: + + if x > 0: + print('x is positive') + +The boolean expression after if is called the **condition**. If it is +true, the indented statement runs. If not, nothing happens. + +if statements have the same structure as function definitions: a header +followed by an indented body. Statements like this are called **compound +statements**. + +There is no limit on the number of statements that can appear in the +body, but there has to be at least one. Occasionally, it is useful to +have a body with no statements (usually as a place keeper for code you +haven’t written yet). In that case, you can use the pass statement, +which does nothing. + +:: + + if x < 0: + pass # TODO: need to handle negative values! + +Alternative execution +--------------------- + +A second form of the if statement is “alternative execution”, in which +there are two possibilities and the condition determines which one runs. +The syntax looks like this: + +:: + + if x % 2 == 0: + print('x is even') + else: + print('x is odd') + +If the remainder when x is divided by 2 is 0, then we know that x is +even, and the program displays an appropriate message. If the condition +is false, the second set of statements runs. Since the condition must be +true or false, exactly one of the alternatives will run. The +alternatives are called **branches**, because they are branches in the +flow of execution. + +Chained conditionals +-------------------- + +Sometimes there are more than two possibilities and we need more than +two branches. One way to express a computation like that is a **chained +conditional**: + +:: + + if x < y: + print('x is less than y') + elif x > y: + print('x is greater than y') + else: + print('x and y are equal') + +elif is an abbreviation of “else if”. Again, exactly one branch will +run. There is no limit on the number of elif statements. If there is an +else clause, it has to be at the end, but there doesn’t have to be one. + +:: + + if choice == 'a': + draw_a() + elif choice == 'b': + draw_b() + elif choice == 'c': + draw_c() + +Each condition is checked in order. If the first is false, the next is +checked, and so on. If one of them is true, the corresponding branch +runs and the statement ends. Even if more than one condition is true, +only the first true branch runs. + +Nested conditionals +------------------- + +One conditional can also be nested within another. We could have written +the example in the previous section like this: + +:: + + if x == y: + print('x and y are equal') + else: + if x < y: + print('x is less than y') + else: + print('x is greater than y') + +The outer conditional contains two branches. The first branch contains a +simple statement. The second branch contains another if statement, which +has two branches of its own. Those two branches are both simple +statements, although they could have been conditional statements as +well. + +Although the indentation of the statements makes the structure apparent, +**nested conditionals** become difficult to read very quickly. It is a +good idea to avoid them when you can. + +Logical operators often provide a way to simplify nested conditional +statements. For example, we can rewrite the following code using a +single conditional: + +:: + + if 0 < x: + if x < 10: + print('x is a positive single-digit number.') + +The print statement runs only if we make it past both conditionals, so +we can get the same effect with the and operator: + +:: + + if 0 < x and x < 10: + print('x is a positive single-digit number.') + +For this kind of condition, Python provides a more concise option: + +:: + + if 0 < x < 10: + print('x is a positive single-digit number.') + +Recursion +--------- + +It is legal for one function to call another; it is also legal for a +function to call itself. It may not be obvious why that is a good thing, +but it turns out to be one of the most magical things a program can do. +For example, look at the following function: + +:: + + def countdown(n): + if n <= 0: + print('Blastoff!') + else: + print(n) + countdown(n-1) + +If n is 0 or negative, it outputs the word, “Blastoff!” Otherwise, it +outputs n and then calls a function named countdown—itself—passing n-1 +as an argument. + +What happens if we call this function like this? + +:: + + >>> countdown(3) + +The execution of countdown begins with n=3, and since n is greater than +0, it outputs the value 3, and then calls itself... + + The execution of countdown begins with n=2, and since n is greater + than 0, it outputs the value 2, and then calls itself... + + The execution of countdown begins with n=1, and since n is + greater than 0, it outputs the value 1, and then calls itself... + + The execution of countdown begins with n=0, and since n is + not greater than 0, it outputs the word, “Blastoff!” and + then returns. + + The countdown that got n=1 returns. + + The countdown that got n=2 returns. + +The countdown that got n=3 returns. + +And then you’re back in ``__main__``. So, the total output looks like +this: + +:: + + 3 + 2 + 1 + Blastoff! + +A function that calls itself is **recursive**; the process of executing +it is called **recursion**. + +As another example, we can write a function that prints a string n +times. + +:: + + def print_n(s, n): + if n <= 0: + return + print(s) + print_n(s, n-1) + +If n <= 0 the **return statement** exits the function. The flow of +execution immediately returns to the caller, and the remaining lines of +the function don’t run. + +The rest of the function is similar to countdown: it displays s and then +calls itself to display s :math:`n-1` additional times. So the number of +lines of output is 1 + (n - 1), which adds up to n. + +For simple examples like this, it is probably easier to use a for loop. +But we will see examples later that are hard to write with a for loop +and easy to write with recursion, so it is good to start early. + +Stack diagrams for recursive functions +-------------------------------------- + +In Section [stackdiagram], we used a stack diagram to represent the +state of a program during a function call. The same kind of diagram can +help interpret a recursive function. + +Every time a function gets called, Python creates a frame to contain the +function’s local variables and parameters. For a recursive function, +there might be more than one frame on the stack at the same time. + +Figure [fig.stack2] shows a stack diagram for countdown called with n = +3. + +.. figure:: figs/stack2.pdf + :alt: Stack diagram. + + Stack diagram. + +As usual, the top of the stack is the frame for ``__main__``. It is +empty because we did not create any variables in ``__main__`` or pass +any arguments to it. + +The four countdown frames have different values for the parameter n. The +bottom of the stack, where n=0, is called the **base case**. It does not +make a recursive call, so there are no more frames. + +As an exercise, draw a stack diagram for ``print_n`` called with +``s = 'Hello'`` and n=2. Then write a function called ``do_n`` that +takes a function object and a number, n, as arguments, and that calls +the given function n times. + +Infinite recursion +------------------ + +If a recursion never reaches a base case, it goes on making recursive +calls forever, and the program never terminates. This is known as +**infinite recursion**, and it is generally not a good idea. Here is a +minimal program with an infinite recursion: + +:: + + def recurse(): + recurse() + +In most programming environments, a program with infinite recursion does +not really run forever. Python reports an error message when the maximum +recursion depth is reached: + +:: + + File "", line 2, in recurse + File "", line 2, in recurse + File "", line 2, in recurse + . + . + . + File "", line 2, in recurse + RuntimeError: Maximum recursion depth exceeded + +This traceback is a little bigger than the one we saw in the previous +chapter. When the error occurs, there are 1000 recurse frames on the +stack! + +If you write encounter an infinite recursion by accident, review your +function to confirm that there is a base case that does not make a +recursive call. And if there is a base case, check whether you are +guaranteed to reach it. + +Keyboard input +-------------- + +The programs we have written so far accept no input from the user. They +just do the same thing every time. + +Python provides a built-in function called input that stops the program +and waits for the user to type something. When the user presses Return +or Enter, the program resumes and ``input`` returns what the user typed +as a string. In Python 2, the same function is called ``raw_input``. + +:: + + >>> text = input() + What are you waiting for? + >>> text + What are you waiting for? + +Before getting input from the user, it is a good idea to print a prompt +telling the user what to type. ``input`` can take a prompt as an +argument: + +:: + + >>> name = input('What...is your name?\n') + What...is your name? + Arthur, King of the Britons! + >>> name + Arthur, King of the Britons! + +The sequence ``\n`` at the end of the prompt represents a **newline**, +which is a special character that causes a line break. That’s why the +user’s input appears below the prompt. + +If you expect the user to type an integer, you can try to convert the +return value to int: + +:: + + >>> prompt = 'What...is the airspeed velocity of an unladen swallow?\n' + >>> speed = input(prompt) + What...is the airspeed velocity of an unladen swallow? + 42 + >>> int(speed) + 42 + +But if the user types something other than a string of digits, you get +an error: + +:: + + >>> speed = input(prompt) + What...is the airspeed velocity of an unladen swallow? + What do you mean, an African or a European swallow? + >>> int(speed) + ValueError: invalid literal for int() with base 10 + +We will see how to handle this kind of error later. + +Debugging +--------- + +When a syntax or runtime error occurs, the error message contains a lot +of information, but it can be overwhelming. The most useful parts are +usually: + +- What kind of error it was, and + +- Where it occurred. + +Syntax errors are usually easy to find, but there are a few gotchas. +Whitespace errors can be tricky because spaces and tabs are invisible +and we are used to ignoring them. + +:: + + >>> x = 5 + >>> y = 6 + File "", line 1 + y = 6 + ^ + IndentationError: unexpected indent + +In this example, the problem is that the second line is indented by one +space. But the error message points to y, which is misleading. In +general, error messages indicate where the problem was discovered, but +the actual error might be earlier in the code, sometimes on a previous +line. + +The same is true of runtime errors. Suppose you are trying to compute a +signal-to-noise ratio in decibels. The formula is +:math:`SNR_{db} = 10 \log_{10} (P_{signal} / P_{noise})`. In Python, you +might write something like this: + +:: + + import math + signal_power = 9 + noise_power = 10 + ratio = signal_power // noise_power + decibels = 10 * math.log10(ratio) + print(decibels) + +When you run this program, you get an exception: + +:: + + Traceback (most recent call last): + File "snr.py", line 5, in ? + decibels = 10 * math.log10(ratio) + ValueError: math domain error + +The error message indicates line 5, but there is nothing wrong with that +line. To find the real error, it might be useful to print the value of +ratio, which turns out to be 0. The problem is in line 4, which uses +floor division instead of floating-point division. + +You should take the time to read error messages carefully, but don’t +assume that everything they say is correct. + +.. _glossary05: + +Glossary +-------- + +.. include:: glossary/05.txt + + +Exercises +--------- + +The time module provides a function, also named time, that returns the +current Greenwich Mean Time in “the epoch”, which is an arbitrary time +used as a reference point. On UNIX systems, the epoch is 1 January 1970. + +:: + + >>> import time + >>> time.time() + 1437746094.5735958 + +Write a script that reads the current time and converts it to a time of +day in hours, minutes, and seconds, plus the number of days since the +epoch. + +Fermat’s Last Theorem says that there are no positive integers +:math:`a`, :math:`b`, and :math:`c` such that + +.. math:: a^n + b^n = c^n + +for any values of :math:`n` greater than 2. + +#. Write a function named ``check_fermat`` that takes four parameters—a, + b, c and n—and checks to see if Fermat’s theorem holds. If :math:`n` + is greater than 2 and + + .. math:: a^n + b^n = c^n + + the program should print, “Holy smokes, Fermat was wrong!” Otherwise + the program should print, “No, that doesn’t work.” + +#. Write a function that prompts the user to input values for a, b, c + and n, converts them to integers, and uses ``check_fermat`` to check + whether they violate Fermat’s theorem. + +If you are given three sticks, you may or may not be able to arrange +them in a triangle. For example, if one of the sticks is 12 inches long +and the other two are one inch long, you will not be able to get the +short sticks to meet in the middle. For any three lengths, there is a +simple test to see if it is possible to form a triangle: + + If any of the three lengths is greater than the sum of the other + two, then you cannot form a triangle. Otherwise, you can. (If the + sum of two lengths equals the third, they form what is called a + “degenerate” triangle.) + +#. Write a function named ``is_triangle`` that takes three integers as + arguments, and that prints either “Yes” or “No”, depending on whether + you can or cannot form a triangle from sticks with the given lengths. + +#. Write a function that prompts the user to input three stick lengths, + converts them to integers, and uses ``is_triangle`` to check whether + sticks with the given lengths can form a triangle. + +What is the output of the following program? Draw a stack diagram that +shows the state of the program when it prints the result. + +:: + + def recurse(n, s): + if n == 0: + print(s) + else: + recurse(n-1, n+s) + + recurse(3, 0) + +#. What would happen if you called this function like this: recurse(-1, + 0)? + +#. Write a docstring that explains everything someone would need to know + in order to use this function (and nothing else). + +The following exercises use the turtle module, described in +Chapter [turtlechap]: + +Read the following function and see if you can figure out what it does. +Then run it (see the examples in Chapter [turtlechap]). + +:: + + def draw(t, length, n): + if n == 0: + return + angle = 50 + t.fd(length*n) + t.lt(angle) + draw(t, length, n-1) + t.rt(2*angle) + draw(t, length, n-1) + t.lt(angle) + t.bk(length*n) + +.. figure:: figs/koch.pdf + :alt: A Koch curve. + + A Koch curve. + +The Koch curve is a fractal that looks something like Figure [fig.koch]. +To draw a Koch curve with length :math:`x`, all you have to do is + +#. Draw a Koch curve with length :math:`x/3`. + +#. Turn left 60 degrees. + +#. Draw a Koch curve with length :math:`x/3`. + +#. Turn right 120 degrees. + +#. Draw a Koch curve with length :math:`x/3`. + +#. Turn left 60 degrees. + +#. Draw a Koch curve with length :math:`x/3`. + +The exception is if :math:`x` is less than 3: in that case, you can just +draw a straight line with length :math:`x`. + +#. Write a function called koch that takes a turtle and a length as + parameters, and that uses the turtle to draw a Koch curve with the + given length. + +#. Write a function called snowflake that draws three Koch curves to + make the outline of a snowflake. + + Solution: http://thinkpython2.com/code/koch.py. + +#. The Koch curve can be generalized in several ways. See + http://en.wikipedia.org/wiki/Koch_snowflake for examples and + implement your favorite. diff --git a/book/06-fruitful-fn.rst b/book/06-fruitful-fn.rst new file mode 100644 index 0000000..48c51aa --- /dev/null +++ b/book/06-fruitful-fn.rst @@ -0,0 +1,732 @@ +Fruitful functions +================== + +Many of the Python functions we have used, such as the math functions, +produce return values. But the functions we’ve written are all void: +they have an effect, like printing a value or moving a turtle, but they +don’t have a return value. In this chapter you will learn to write +fruitful functions. + +Return values +------------- + +Calling the function generates a return value, which we usually assign +to a variable or use as part of an expression. + +:: + + e = math.exp(1.0) + height = radius * math.sin(radians) + +The functions we have written so far are void. Speaking casually, they +have no return value; more precisely, their return value is None. + +In this chapter, we are (finally) going to write fruitful functions. The +first example is area, which returns the area of a circle with the given +radius: + +:: + + def area(radius): + a = math.pi * radius**2 + return a + +We have seen the return statement before, but in a fruitful function the +return statement includes an expression. This statement means: “Return +immediately from this function and use the following expression as a +return value.” The expression can be arbitrarily complicated, so we +could have written this function more concisely: + +:: + + def area(radius): + return math.pi * radius**2 + +On the other hand, **temporary variables** like a can make debugging +easier. + +Sometimes it is useful to have multiple return statements, one in each +branch of a conditional: + +:: + + def absolute_value(x): + if x < 0: + return -x + else: + return x + +Since these return statements are in an alternative conditional, only +one runs. + +As soon as a return statement runs, the function terminates without +executing any subsequent statements. Code that appears after a return +statement, or any other place the flow of execution can never reach, is +called **dead code**. + +In a fruitful function, it is a good idea to ensure that every possible +path through the program hits a return statement. For example: + +:: + + def absolute_value(x): + if x < 0: + return -x + if x > 0: + return x + +This function is incorrect because if x happens to be 0, neither +condition is true, and the function ends without hitting a return +statement. If the flow of execution gets to the end of a function, the +return value is None, which is not the absolute value of 0. + +:: + + >>> absolute_value(0) + None + +By the way, Python provides a built-in function called abs that computes +absolute values. + +As an exercise, write a compare function takes two values, x and y, and +returns 1 if x > y, 0 if x == y, and -1 if x < y. + +Incremental development +----------------------- + +As you write larger functions, you might find yourself spending more +time debugging. + +To deal with increasingly complex programs, you might want to try a +process called **incremental development**. The goal of incremental +development is to avoid long debugging sessions by adding and testing +only a small amount of code at a time. + +As an example, suppose you want to find the distance between two points, +given by the coordinates :math:`(x_1, y_1)` and :math:`(x_2, y_2)`. By +the Pythagorean theorem, the distance is: + +.. math:: \mathrm{distance} = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2} + +The first step is to consider what a distance function should look like +in Python. In other words, what are the inputs (parameters) and what is +the output (return value)? + +In this case, the inputs are two points, which you can represent using +four numbers. The return value is the distance represented by a +floating-point value. + +Immediately you can write an outline of the function: + +:: + + def distance(x1, y1, x2, y2): + return 0.0 + +Obviously, this version doesn’t compute distances; it always returns +zero. But it is syntactically correct, and it runs, which means that you +can test it before you make it more complicated. + +To test the new function, call it with sample arguments: + +:: + + >>> distance(1, 2, 4, 6) + 0.0 + +I chose these values so that the horizontal distance is 3 and the +vertical distance is 4; that way, the result is 5, the hypotenuse of a +3-4-5 triangle. When testing a function, it is useful to know the right +answer. + +At this point we have confirmed that the function is syntactically +correct, and we can start adding code to the body. A reasonable next +step is to find the differences :math:`x_2 - x_1` and :math:`y_2 - y_1`. +The next version stores those values in temporary variables and prints +them. + +:: + + def distance(x1, y1, x2, y2): + dx = x2 - x1 + dy = y2 - y1 + print('dx is', dx) + print('dy is', dy) + return 0.0 + +If the function is working, it should display ``dx is 3`` and +``dy is 4``. If so, we know that the function is getting the right +arguments and performing the first computation correctly. If not, there +are only a few lines to check. + +Next we compute the sum of squares of dx and dy: + +:: + + def distance(x1, y1, x2, y2): + dx = x2 - x1 + dy = y2 - y1 + dsquared = dx**2 + dy**2 + print('dsquared is: ', dsquared) + return 0.0 + +Again, you would run the program at this stage and check the output +(which should be 25). Finally, you can use math.sqrt to compute and +return the result: + +:: + + def distance(x1, y1, x2, y2): + dx = x2 - x1 + dy = y2 - y1 + dsquared = dx**2 + dy**2 + result = math.sqrt(dsquared) + return result + +If that works correctly, you are done. Otherwise, you might want to +print the value of result before the return statement. + +The final version of the function doesn’t display anything when it runs; +it only returns a value. The print statements we wrote are useful for +debugging, but once you get the function working, you should remove +them. Code like that is called **scaffolding** because it is helpful for +building the program but is not part of the final product. + +When you start out, you should add only a line or two of code at a time. +As you gain more experience, you might find yourself writing and +debugging bigger chunks. Either way, incremental development can save +you a lot of debugging time. + +The key aspects of the process are: + +#. Start with a working program and make small incremental changes. At + any point, if there is an error, you should have a good idea where it + is. + +#. Use variables to hold intermediate values so you can display and + check them. + +#. Once the program is working, you might want to remove some of the + scaffolding or consolidate multiple statements into compound + expressions, but only if it does not make the program difficult to + read. + +As an exercise, use incremental development to write a function called +hypotenuse that returns the length of the hypotenuse of a right triangle +given the lengths of the other two legs as arguments. Record each stage +of the development process as you go. + +Composition +----------- + +As you should expect by now, you can call one function from within +another. As an example, we’ll write a function that takes two points, +the center of the circle and a point on the perimeter, and computes the +area of the circle. + +Assume that the center point is stored in the variables xc and yc, and +the perimeter point is in xp and yp. The first step is to find the +radius of the circle, which is the distance between the two points. We +just wrote a function, distance, that does that: + +:: + + radius = distance(xc, yc, xp, yp) + +The next step is to find the area of a circle with that radius; we just +wrote that, too: + +:: + + result = area(radius) + +Encapsulating these steps in a function, we get: + +:: + + def circle_area(xc, yc, xp, yp): + radius = distance(xc, yc, xp, yp) + result = area(radius) + return result + +The temporary variables radius and result are useful for development and +debugging, but once the program is working, we can make it more concise +by composing the function calls: + +:: + + def circle_area(xc, yc, xp, yp): + return area(distance(xc, yc, xp, yp)) + +Boolean functions +----------------- + +Functions can return booleans, which is often convenient for hiding +complicated tests inside functions. For example: + +:: + + def is_divisible(x, y): + if x % y == 0: + return True + else: + return False + +It is common to give boolean functions names that sound like yes/no +questions; ``is_divisible`` returns either True or False to indicate +whether x is divisible by y. + +Here is an example: + +:: + + >>> is_divisible(6, 4) + False + >>> is_divisible(6, 3) + True + +The result of the == operator is a boolean, so we can write the function +more concisely by returning it directly: + +:: + + def is_divisible(x, y): + return x % y == 0 + +Boolean functions are often used in conditional statements: + +:: + + if is_divisible(x, y): + print('x is divisible by y') + +It might be tempting to write something like: + +:: + + if is_divisible(x, y) == True: + print('x is divisible by y' + +But the extra comparison is unnecessary. + +As an exercise, write a function ``is_between(x, y, z)`` that returns +True if :math:`x \le y \le z` or False otherwise. + +More recursion +-------------- + +We have only covered a small subset of Python, but you might be +interested to know that this subset is a *complete* programming +language, which means that anything that can be computed can be +expressed in this language. Any program ever written could be rewritten +using only the language features you have learned so far (actually, you +would need a few commands to control devices like the mouse, disks, +etc., but that’s all). + +Proving that claim is a nontrivial exercise first accomplished by Alan +Turing, one of the first computer scientists (some would argue that he +was a mathematician, but a lot of early computer scientists started as +mathematicians). Accordingly, it is known as the Turing Thesis. For a +more complete (and accurate) discussion of the Turing Thesis, I +recommend Michael Sipser’s book *Introduction to the Theory of +Computation*. + +To give you an idea of what you can do with the tools you have learned +so far, we’ll evaluate a few recursively defined mathematical functions. +A recursive definition is similar to a circular definition, in the sense +that the definition contains a reference to the thing being defined. A +truly circular definition is not very useful: + +vorpal: + An adjective used to describe something that is vorpal. + +If you saw that definition in the dictionary, you might be annoyed. On +the other hand, if you looked up the definition of the factorial +function, denoted with the symbol :math:`!`, you might get something +like this: + +.. math:: + + \begin{aligned} + && 0! = 1 \\ + && n! = n (n-1)!\end{aligned} + +This definition says that the factorial of 0 is 1, and the factorial of +any other value, :math:`n`, is :math:`n` multiplied by the factorial of +:math:`n-1`. + +So :math:`3!` is 3 times :math:`2!`, which is 2 times :math:`1!`, which +is 1 times :math:`0!`. Putting it all together, :math:`3!` equals 3 +times 2 times 1 times 1, which is 6. + +If you can write a recursive definition of something, you can write a +Python program to evaluate it. The first step is to decide what the +parameters should be. In this case it should be clear that factorial +takes an integer: + +:: + + def factorial(n): + +If the argument happens to be 0, all we have to do is return 1: + +:: + + def factorial(n): + if n == 0: + return 1 + +Otherwise, and this is the interesting part, we have to make a recursive +call to find the factorial of :math:`n-1` and then multiply it by +:math:`n`: + +:: + + def factorial(n): + if n == 0: + return 1 + else: + recurse = factorial(n-1) + result = n * recurse + return result + +The flow of execution for this program is similar to the flow of +countdown in Section [recursion]. If we call factorial with the value 3: + +Since 3 is not 0, we take the second branch and calculate the factorial +of n-1... + + Since 2 is not 0, we take the second branch and calculate the + factorial of n-1... + + Since 1 is not 0, we take the second branch and calculate the + factorial of n-1... + + Since 0 equals 0, we take the first branch and return 1 + without making any more recursive calls. + + The return value, 1, is multiplied by :math:`n`, which is 1, and + the result is returned. + + The return value, 1, is multiplied by :math:`n`, which is 2, and the + result is returned. + +The return value (2) is multiplied by :math:`n`, which is 3, and the +result, 6, becomes the return value of the function call that started +the whole process. + +Figure [fig.stack3] shows what the stack diagram looks like for this +sequence of function calls. + +.. figure:: figs/stack3.pdf + :alt: Stack diagram. + + Stack diagram. + +The return values are shown being passed back up the stack. In each +frame, the return value is the value of result, which is the product of +n and recurse. + +In the last frame, the local variables recurse and result do not exist, +because the branch that creates them does not run. + +Leap of faith +------------- + +Following the flow of execution is one way to read programs, but it can +quickly become overwhelming. An alternative is what I call the “leap of +faith”. When you come to a function call, instead of following the flow +of execution, you *assume* that the function works correctly and returns +the right result. + +In fact, you are already practicing this leap of faith when you use +built-in functions. When you call math.cos or math.exp, you don’t +examine the bodies of those functions. You just assume that they work +because the people who wrote the built-in functions were good +programmers. + +The same is true when you call one of your own functions. For example, +in Section [boolean], we wrote a function called ``is_divisible`` that +determines whether one number is divisible by another. Once we have +convinced ourselves that this function is correct—by examining the code +and testing—we can use the function without looking at the body again. + +The same is true of recursive programs. When you get to the recursive +call, instead of following the flow of execution, you should assume that +the recursive call works (returns the correct result) and then ask +yourself, “Assuming that I can find the factorial of :math:`n-1`, can I +compute the factorial of :math:`n`?” It is clear that you can, by +multiplying by :math:`n`. + +Of course, it’s a bit strange to assume that the function works +correctly when you haven’t finished writing it, but that’s why it’s +called a leap of faith! + +One more example +---------------- + +After factorial, the most common example of a recursively defined +mathematical function is fibonacci, which has the following definition +(see http://en.wikipedia.org/wiki/Fibonacci_number): + +.. math:: + + \begin{aligned} + && \mathrm{fibonacci}(0) = 0 \\ + && \mathrm{fibonacci}(1) = 1 \\ + && \mathrm{fibonacci}(n) = \mathrm{fibonacci}(n-1) + \mathrm{fibonacci}(n-2)\end{aligned} + +Translated into Python, it looks like this: + +:: + + def fibonacci (n): + if n == 0: + return 0 + elif n == 1: + return 1 + else: + return fibonacci(n-1) + fibonacci(n-2) + +If you try to follow the flow of execution here, even for fairly small +values of :math:`n`, your head explodes. But according to the leap of +faith, if you assume that the two recursive calls work correctly, then +it is clear that you get the right result by adding them together. + +Checking types +-------------- + +What happens if we call factorial and give it 1.5 as an argument? + +:: + + >>> factorial(1.5) + RuntimeError: Maximum recursion depth exceeded + +It looks like an infinite recursion. How can that be? The function has a +base case—when n == 0. But if n is not an integer, we can *miss* the +base case and recurse forever. + +In the first recursive call, the value of n is 0.5. In the next, it is +-0.5. From there, it gets smaller (more negative), but it will never be +0. + +We have two choices. We can try to generalize the factorial function to +work with floating-point numbers, or we can make factorial check the +type of its argument. The first option is called the gamma function and +it’s a little beyond the scope of this book. So we’ll go for the second. + +We can use the built-in function isinstance to verify the type of the +argument. While we’re at it, we can also make sure the argument is +positive: + +:: + + def factorial (n): + if not isinstance(n, int): + print('Factorial is only defined for integers.') + return None + elif n < 0: + print('Factorial is not defined for negative integers.') + return None + elif n == 0: + return 1 + else: + return n * factorial(n-1) + +The first base case handles nonintegers; the second handles negative +integers. In both cases, the program prints an error message and returns +None to indicate that something went wrong: + +:: + + >>> factorial('fred') + Factorial is only defined for integers. + None + >>> factorial(-2) + Factorial is not defined for negative integers. + None + +If we get past both checks, we know that :math:`n` is positive or zero, +so we can prove that the recursion terminates. + +This program demonstrates a pattern sometimes called a **guardian**. The +first two conditionals act as guardians, protecting the code that +follows from values that might cause an error. The guardians make it +possible to prove the correctness of the code. + +In Section [raise] we will see a more flexible alternative to printing +an error message: raising an exception. + +Debugging +--------- + +Breaking a large program into smaller functions creates natural +checkpoints for debugging. If a function is not working, there are three +possibilities to consider: + +- There is something wrong with the arguments the function is getting; + a precondition is violated. + +- There is something wrong with the function; a postcondition is + violated. + +- There is something wrong with the return value or the way it is being + used. + +To rule out the first possibility, you can add a print statement at the +beginning of the function and display the values of the parameters (and +maybe their types). Or you can write code that checks the preconditions +explicitly. + +If the parameters look good, add a print statement before each return +statement and display the return value. If possible, check the result by +hand. Consider calling the function with values that make it easy to +check the result (as in Section [incremental.development]). + +If the function seems to be working, look at the function call to make +sure the return value is being used correctly (or used at all!). + +Adding print statements at the beginning and end of a function can help +make the flow of execution more visible. For example, here is a version +of factorial with print statements: + +:: + + def factorial(n): + space = ' ' * (4 * n) + print(space, 'factorial', n) + if n == 0: + print(space, 'returning 1') + return 1 + else: + recurse = factorial(n-1) + result = n * recurse + print(space, 'returning', result) + return result + +space is a string of space characters that controls the indentation of +the output. Here is the result of factorial(4) : + +:: + + factorial 4 + factorial 3 + factorial 2 + factorial 1 + factorial 0 + returning 1 + returning 1 + returning 2 + returning 6 + returning 24 + +If you are confused about the flow of execution, this kind of output can +be helpful. It takes some time to develop effective scaffolding, but a +little bit of scaffolding can save a lot of debugging. + + +.. _glossary06: + +Glossary +-------- + +.. include:: glossary/06.txt + + +Exercises +--------- + +Draw a stack diagram for the following program. What does the program +print? + +:: + + def b(z): + prod = a(z, z) + print(z, prod) + return prod + + def a(x, y): + x = x + 1 + return x * y + + def c(x, y, z): + total = x + y + z + square = b(total)**2 + return square + + x = 1 + y = x + 1 + print(c(x, y+3, x+y)) + +[ackermann] + +The Ackermann function, :math:`A(m, n)`, is defined: + +.. math:: + + \begin{aligned} + A(m, n) = \begin{cases} + n+1 & \mbox{if } m = 0 \\ + A(m-1, 1) & \mbox{if } m > 0 \mbox{ and } n = 0 \\ + A(m-1, A(m, n-1)) & \mbox{if } m > 0 \mbox{ and } n > 0. + \end{cases} \end{aligned} + +See http://en.wikipedia.org/wiki/Ackermann_function. Write a function +named ack that evaluates the Ackermann function. Use your function to +evaluate ack(3, 4), which should be 125. What happens for larger values +of m and n? Solution: http://thinkpython2.com/code/ackermann.py. + +[palindrome] + +A palindrome is a word that is spelled the same backward and forward, +like “noon” and “redivider”. Recursively, a word is a palindrome if the +first and last letters are the same and the middle is a palindrome. + +The following are functions that take a string argument and return the +first, last, and middle letters: + +:: + + def first(word): + return word[0] + + def last(word): + return word[-1] + + def middle(word): + return word[1:-1] + +We’ll see how they work in Chapter [strings]. + +#. Type these functions into a file named palindrome.py and test them + out. What happens if you call middle with a string with two letters? + One letter? What about the empty string, which is written ``''`` and + contains no letters? + +#. Write a function called ``is_palindrome`` that takes a string + argument and returns True if it is a palindrome and False otherwise. + Remember that you can use the built-in function len to check the + length of a string. + +Solution: http://thinkpython2.com/code/palindrome_soln.py. + +A number, :math:`a`, is a power of :math:`b` if it is divisible by +:math:`b` and :math:`a/b` is a power of :math:`b`. Write a function +called ``is_power`` that takes parameters a and b and returns True if a +is a power of b. Note: you will have to think about the base case. + +The greatest common divisor (GCD) of :math:`a` and :math:`b` is the +largest number that divides both of them with no remainder. + +One way to find the GCD of two numbers is based on the observation that +if :math:`r` is the remainder when :math:`a` is divided by :math:`b`, +then :math:`gcd(a, +b) = gcd(b, r)`. As a base case, we can use :math:`gcd(a, 0) = a`. + +Write a function called ``gcd`` that takes parameters a and b and +returns their greatest common divisor. + +Credit: This exercise is based on an example from Abelson and Sussman’s +*Structure and Interpretation of Computer Programs*. diff --git a/book/07-iteration.rst b/book/07-iteration.rst new file mode 100644 index 0000000..11b8084 --- /dev/null +++ b/book/07-iteration.rst @@ -0,0 +1,453 @@ +Iteration +========= + +This chapter is about iteration, which is the ability to run a block of +statements repeatedly. We saw a kind of iteration, using recursion, in +Section [recursion]. We saw another kind, using a for loop, in +Section [repetition]. In this chapter we’ll see yet another kind, using +a while statement. But first I want to say a little more about variable +assignment. + +Reassignment +------------ + +As you may have discovered, it is legal to make more than one assignment +to the same variable. A new assignment makes an existing variable refer +to a new value (and stop referring to the old value). + +:: + + >>> x = 5 + >>> x + 5 + >>> x = 7 + >>> x + 7 + +The first time we display x, its value is 5; the second time, its value +is 7. + +Figure [fig.assign2] shows what **reassignment** looks like in a state +diagram. + +At this point I want to address a common source of confusion. Because +Python uses the equal sign (=) for assignment, it is tempting to +interpret a statement like a = b as a mathematical proposition of +equality; that is, the claim that a and b are equal. But this +interpretation is wrong. + +First, equality is a symmetric relationship and assignment is not. For +example, in mathematics, if :math:`a=7` then :math:`7=a`. But in Python, +the statement a = 7 is legal and 7 = a is not. + +Also, in mathematics, a proposition of equality is either true or false +for all time. If :math:`a=b` now, then :math:`a` will always equal +:math:`b`. In Python, an assignment statement can make two variables +equal, but they don’t have to stay that way: + +:: + + >>> a = 5 + >>> b = a # a and b are now equal + >>> a = 3 # a and b are no longer equal + >>> b + 5 + +The third line changes the value of a but does not change the value of +b, so they are no longer equal. + +Reassigning variables is often useful, but you should use it with +caution. If the values of variables change frequently, it can make the +code difficult to read and debug. + +.. figure:: figs/assign2.pdf + :alt: State diagram. + + State diagram. + +Updating variables +------------------ + +A common kind of reassignment is an **update**, where the new value of +the variable depends on the old. + +:: + + >>> x = x + 1 + +This means “get the current value of x, add one, and then update x with +the new value.” + +If you try to update a variable that doesn’t exist, you get an error, +because Python evaluates the right side before it assigns a value to x: + +:: + + >>> x = x + 1 + NameError: name 'x' is not defined + +Before you can update a variable, you have to **initialize** it, usually +with a simple assignment: + +:: + + >>> x = 0 + >>> x = x + 1 + +Updating a variable by adding 1 is called an **increment**; subtracting +1 is called a **decrement**. + +The while statement +------------------- + +Computers are often used to automate repetitive tasks. Repeating +identical or similar tasks without making errors is something that +computers do well and people do poorly. In a computer program, +repetition is also called **iteration**. + +We have already seen two functions, countdown and ``print_n``, that +iterate using recursion. Because iteration is so common, Python provides +language features to make it easier. One is the for statement we saw in +Section [repetition]. We’ll get back to that later. + +Another is the while statement. Here is a version of countdown that uses +a while statement: + +:: + + def countdown(n): + while n > 0: + print(n) + n = n - 1 + print('Blastoff!') + +You can almost read the while statement as if it were English. It means, +“While n is greater than 0, display the value of n and then decrement n. +When you get to 0, display the word Blastoff!” + +More formally, here is the flow of execution for a while statement: + +#. Determine whether the condition is true or false. + +#. If false, exit the while statement and continue execution at the next + statement. + +#. If the condition is true, run the body and then go back to step 1. + +This type of flow is called a loop because the third step loops back +around to the top. + +The body of the loop should change the value of one or more variables so +that the condition becomes false eventually and the loop terminates. +Otherwise the loop will repeat forever, which is called an **infinite +loop**. An endless source of amusement for computer scientists is the +observation that the directions on shampoo, “Lather, rinse, repeat”, are +an infinite loop. + +In the case of countdown, we can prove that the loop terminates: if n is +zero or negative, the loop never runs. Otherwise, n gets smaller each +time through the loop, so eventually we have to get to 0. + +For some other loops, it is not so easy to tell. For example: + +:: + + def sequence(n): + while n != 1: + print(n) + if n % 2 == 0: # n is even + n = n / 2 + else: # n is odd + n = n*3 + 1 + +The condition for this loop is n != 1, so the loop will continue until n +is 1, which makes the condition false. + +Each time through the loop, the program outputs the value of n and then +checks whether it is even or odd. If it is even, n is divided by 2. If +it is odd, the value of n is replaced with n\*3 + 1. For example, if the +argument passed to sequence is 3, the resulting values of n are 3, 10, +5, 16, 8, 4, 2, 1. + +Since n sometimes increases and sometimes decreases, there is no obvious +proof that n will ever reach 1, or that the program terminates. For some +particular values of n, we can prove termination. For example, if the +starting value is a power of two, n will be even every time through the +loop until it reaches 1. The previous example ends with such a sequence, +starting with 16. + +The hard question is whether we can prove that this program terminates +for *all* positive values of n. So far, no one has been able to prove it +*or* disprove it! (See http://en.wikipedia.org/wiki/Collatz_conjecture.) + +As an exercise, rewrite the function ``print_n`` from +Section [recursion] using iteration instead of recursion. + +break +----- + +Sometimes you don’t know it’s time to end a loop until you get half way +through the body. In that case you can use the break statement to jump +out of the loop. + +For example, suppose you want to take input from the user until they +type done. You could write: + +:: + + while True: + line = input('> ') + if line == 'done': + break + print(line) + + print('Done!') + +The loop condition is True, which is always true, so the loop runs until +it hits the break statement. + +Each time through, it prompts the user with an angle bracket. If the +user types done, the break statement exits the loop. Otherwise the +program echoes whatever the user types and goes back to the top of the +loop. Here’s a sample run: + +:: + + > not done + not done + > done + Done! + +This way of writing while loops is common because you can check the +condition anywhere in the loop (not just at the top) and you can express +the stop condition affirmatively (“stop when this happens”) rather than +negatively (“keep going until that happens”). + +Square roots +------------ + +Loops are often used in programs that compute numerical results by +starting with an approximate answer and iteratively improving it. + +For example, one way of computing square roots is Newton’s method. +Suppose that you want to know the square root of :math:`a`. If you start +with almost any estimate, :math:`x`, you can compute a better estimate +with the following formula: + +.. math:: y = \frac{x + a/x}{2} + +For example, if :math:`a` is 4 and :math:`x` is 3: + +:: + + >>> a = 4 + >>> x = 3 + >>> y = (x + a/x) / 2 + >>> y + 2.16666666667 + +The result is closer to the correct answer (:math:`\sqrt{4} = 2`). If we +repeat the process with the new estimate, it gets even closer: + +:: + + >>> x = y + >>> y = (x + a/x) / 2 + >>> y + 2.00641025641 + +After a few more updates, the estimate is almost exact: + +:: + + >>> x = y + >>> y = (x + a/x) / 2 + >>> y + 2.00001024003 + >>> x = y + >>> y = (x + a/x) / 2 + >>> y + 2.00000000003 + +In general we don’t know ahead of time how many steps it takes to get to +the right answer, but we know when we get there because the estimate +stops changing: + +:: + + >>> x = y + >>> y = (x + a/x) / 2 + >>> y + 2.0 + >>> x = y + >>> y = (x + a/x) / 2 + >>> y + 2.0 + +When y == x, we can stop. Here is a loop that starts with an initial +estimate, x, and improves it until it stops changing: + +:: + + while True: + print(x) + y = (x + a/x) / 2 + if y == x: + break + x = y + +For most values of a this works fine, but in general it is dangerous to +test float equality. Floating-point values are only approximately right: +most rational numbers, like :math:`1/3`, and irrational numbers, like +:math:`\sqrt{2}`, can’t be represented exactly with a float. + +Rather than checking whether x and y are exactly equal, it is safer to +use the built-in function abs to compute the absolute value, or +magnitude, of the difference between them: + +:: + + if abs(y-x) < epsilon: + break + +Where ``epsilon`` has a value like 0.0000001 that determines how close +is close enough. + +Algorithms +---------- + +Newton’s method is an example of an **algorithm**: it is a mechanical +process for solving a category of problems (in this case, computing +square roots). + +To understand what an algorithm is, it might help to start with +something that is not an algorithm. When you learned to multiply +single-digit numbers, you probably memorized the multiplication table. +In effect, you memorized 100 specific solutions. That kind of knowledge +is not algorithmic. + +But if you were “lazy”, you might have learned a few tricks. For +example, to find the product of :math:`n` and 9, you can write +:math:`n-1` as the first digit and :math:`10-n` as the second digit. +This trick is a general solution for multiplying any single-digit number +by 9. That’s an algorithm! + +Similarly, the techniques you learned for addition with carrying, +subtraction with borrowing, and long division are all algorithms. One of +the characteristics of algorithms is that they do not require any +intelligence to carry out. They are mechanical processes where each step +follows from the last according to a simple set of rules. + +Executing algorithms is boring, but designing them is interesting, +intellectually challenging, and a central part of computer science. + +Some of the things that people do naturally, without difficulty or +conscious thought, are the hardest to express algorithmically. +Understanding natural language is a good example. We all do it, but so +far no one has been able to explain *how* we do it, at least not in the +form of an algorithm. + +Debugging +--------- + +As you start writing bigger programs, you might find yourself spending +more time debugging. More code means more chances to make an error and +more places for bugs to hide. + +One way to cut your debugging time is “debugging by bisection”. For +example, if there are 100 lines in your program and you check them one +at a time, it would take 100 steps. + +Instead, try to break the problem in half. Look at the middle of the +program, or near it, for an intermediate value you can check. Add a +print statement (or something else that has a verifiable effect) and run +the program. + +If the mid-point check is incorrect, there must be a problem in the +first half of the program. If it is correct, the problem is in the +second half. + +Every time you perform a check like this, you halve the number of lines +you have to search. After six steps (which is fewer than 100), you would +be down to one or two lines of code, at least in theory. + +In practice it is not always clear what the “middle of the program” is +and not always possible to check it. It doesn’t make sense to count +lines and find the exact midpoint. Instead, think about places in the +program where there might be errors and places where it is easy to put a +check. Then choose a spot where you think the chances are about the same +that the bug is before or after the check. + + +.. _glossary07: + +Glossary +-------- + +.. include:: glossary/07.txt + + +Exercises +--------- + +Copy the loop from Section [squareroot] and encapsulate it in a function +called ``mysqrt`` that takes a as a parameter, chooses a reasonable +value of x, and returns an estimate of the square root of a. + +To test it, write a function named ``test_square_root`` that prints a +table like this: + +:: + + a mysqrt(a) math.sqrt(a) diff + - --------- ------------ ---- + 1.0 1.0 1.0 0.0 + 2.0 1.41421356237 1.41421356237 2.22044604925e-16 + 3.0 1.73205080757 1.73205080757 0.0 + 4.0 2.0 2.0 0.0 + 5.0 2.2360679775 2.2360679775 0.0 + 6.0 2.44948974278 2.44948974278 0.0 + 7.0 2.64575131106 2.64575131106 0.0 + 8.0 2.82842712475 2.82842712475 4.4408920985e-16 + 9.0 3.0 3.0 0.0 + +The first column is a number, :math:`a`; the second column is the square +root of :math:`a` computed with ``mysqrt``; the third column is the +square root computed by math.sqrt; the fourth column is the absolute +value of the difference between the two estimates. + +The built-in function eval takes a string and evaluates it using the +Python interpreter. For example: + +:: + + >>> eval('1 + 2 * 3') + 7 + >>> import math + >>> eval('math.sqrt(5)') + 2.2360679774997898 + >>> eval('type(math.pi)') + + +Write a function called ``eval_loop`` that iteratively prompts the user, +takes the resulting input and evaluates it using eval, and prints the +result. + +It should continue until the user enters ``'done'``, and then return the +value of the last expression it evaluated. + +The mathematician Srinivasa Ramanujan found an infinite series that can +be used to generate a numerical approximation of :math:`1 / \pi`: + +.. math:: + + \frac{1}{\pi} = \frac{2\sqrt{2}}{9801} + \sum^\infty_{k=0} \frac{(4k)!(1103+26390k)}{(k!)^4 396^{4k}} + +Write a function called ``estimate_pi`` that uses this formula to +compute and return an estimate of :math:`\pi`. It should use a while +loop to compute terms of the summation until the last term is smaller +than 1e-15 (which is Python notation for :math:`10^{-15}`). You can +check the result by comparing it to math.pi. + +Solution: http://thinkpython2.com/code/pi.py. diff --git a/book/08-string.rst b/book/08-string.rst new file mode 100644 index 0000000..6cf8ece --- /dev/null +++ b/book/08-string.rst @@ -0,0 +1,655 @@ +Strings +======= + +Strings are not like integers, floats, and booleans. A string is a +**sequence**, which means it is an ordered collection of other values. +In this chapter you’ll see how to access the characters that make up a +string, and you’ll learn about some of the methods strings provide. + +A string is a sequence +---------------------- + +A string is a sequence of characters. You can access the characters one +at a time with the bracket operator: + +:: + + >>> fruit = 'banana' + >>> letter = fruit[1] + +The second statement selects character number 1 from fruit and assigns +it to letter. + +The expression in brackets is called an **index**. The index indicates +which character in the sequence you want (hence the name). + +But you might not get what you expect: + +:: + + >>> letter + 'a' + +For most people, the first letter of ``'banana'`` is b, not a. But for +computer scientists, the index is an offset from the beginning of the +string, and the offset of the first letter is zero. + +:: + + >>> letter = fruit[0] + >>> letter + 'b' + +So b is the 0th letter (“zero-eth”) of ``'banana'``, a is the 1th letter +(“one-eth”), and n is the 2th letter (“two-eth”). + +As an index you can use an expression that contains variables and +operators: + +:: + + >>> i = 1 + >>> fruit[i] + 'a' + >>> fruit[i+1] + 'n' + +But the value of the index has to be an integer. Otherwise you get: + +:: + + >>> letter = fruit[1.5] + TypeError: string indices must be integers + +len +--- + +len is a built-in function that returns the number of characters in a +string: + +:: + + >>> fruit = 'banana' + >>> len(fruit) + 6 + +To get the last letter of a string, you might be tempted to try +something like this: + +:: + + >>> length = len(fruit) + >>> last = fruit[length] + IndexError: string index out of range + +The reason for the IndexError is that there is no letter in ’banana’ +with the index 6. Since we started counting at zero, the six letters are +numbered 0 to 5. To get the last character, you have to subtract 1 from +length: + +:: + + >>> last = fruit[length-1] + >>> last + 'a' + +Or you can use negative indices, which count backward from the end of +the string. The expression fruit[-1] yields the last letter, fruit[-2] +yields the second to last, and so on. + +Traversal with a for loop +------------------------- + +A lot of computations involve processing a string one character at a +time. Often they start at the beginning, select each character in turn, +do something to it, and continue until the end. This pattern of +processing is called a **traversal**. One way to write a traversal is +with a while loop: + +:: + + index = 0 + while index < len(fruit): + letter = fruit[index] + print(letter) + index = index + 1 + +This loop traverses the string and displays each letter on a line by +itself. The loop condition is index < len(fruit), so when index is equal +to the length of the string, the condition is false, and the body of the +loop doesn’t run. The last character accessed is the one with the index +len(fruit)-1, which is the last character in the string. + +As an exercise, write a function that takes a string as an argument and +displays the letters backward, one per line. + +Another way to write a traversal is with a for loop: + +:: + + for letter in fruit: + print(letter) + +Each time through the loop, the next character in the string is assigned +to the variable letter. The loop continues until no characters are left. + +The following example shows how to use concatenation (string addition) +and a for loop to generate an abecedarian series (that is, in +alphabetical order). In Robert McCloskey’s book *Make Way for +Ducklings*, the names of the ducklings are Jack, Kack, Lack, Mack, Nack, +Ouack, Pack, and Quack. This loop outputs these names in order: + +:: + + prefixes = 'JKLMNOPQ' + suffix = 'ack' + + for letter in prefixes: + print(letter + suffix) + +The output is: + +:: + + Jack + Kack + Lack + Mack + Nack + Oack + Pack + Qack + +Of course, that’s not quite right because “Ouack” and “Quack” are +misspelled. As an exercise, modify the program to fix this error. + +String slices +------------- + +A segment of a string is called a **slice**. Selecting a slice is +similar to selecting a character: + +:: + + >>> s = 'Monty Python' + >>> s[0:5] + 'Monty' + >>> s[6:12] + 'Python' + +The operator returns the part of the string from the “n-eth” character +to the “m-eth” character, including the first but excluding the last. +This behavior is counterintuitive, but it might help to imagine the +indices pointing *between* the characters, as in Figure [fig.banana]. + +.. figure:: figs/banana.pdf + :alt: Slice indices. + + Slice indices. + +If you omit the first index (before the colon), the slice starts at the +beginning of the string. If you omit the second index, the slice goes to +the end of the string: + +:: + + >>> fruit = 'banana' + >>> fruit[:3] + 'ban' + >>> fruit[3:] + 'ana' + +If the first index is greater than or equal to the second the result is +an **empty string**, represented by two quotation marks: + +:: + + >>> fruit = 'banana' + >>> fruit[3:3] + '' + +An empty string contains no characters and has length 0, but other than +that, it is the same as any other string. + +Continuing this example, what do you think fruit[:] means? Try it and +see. + +Strings are immutable +--------------------- + +It is tempting to use the operator on the left side of an assignment, +with the intention of changing a character in a string. For example: + +:: + + >>> greeting = 'Hello, world!' + >>> greeting[0] = 'J' + TypeError: 'str' object does not support item assignment + +The “object” in this case is the string and the “item” is the character +you tried to assign. For now, an object is the same thing as a value, +but we will refine that definition later (Section [equivalence]). + +The reason for the error is that strings are **immutable**, which means +you can’t change an existing string. The best you can do is create a new +string that is a variation on the original: + +:: + + >>> greeting = 'Hello, world!' + >>> new_greeting = 'J' + greeting[1:] + >>> new_greeting + 'Jello, world!' + +This example concatenates a new first letter onto a slice of greeting. +It has no effect on the original string. + +Searching +--------- + +What does the following function do? + +:: + + def find(word, letter): + index = 0 + while index < len(word): + if word[index] == letter: + return index + index = index + 1 + return -1 + +In a sense, find is the inverse of the operator. Instead of taking an +index and extracting the corresponding character, it takes a character +and finds the index where that character appears. If the character is +not found, the function returns -1. + +This is the first example we have seen of a return statement inside a +loop. If word[index] == letter, the function breaks out of the loop and +returns immediately. + +If the character doesn’t appear in the string, the program exits the +loop normally and returns -1. + +This pattern of computation—traversing a sequence and returning when we +find what we are looking for—is called a **search**. + +As an exercise, modify find so that it has a third parameter, the index +in word where it should start looking. + +Looping and counting +-------------------- + +The following program counts the number of times the letter a appears in +a string: + +:: + + word = 'banana' + count = 0 + for letter in word: + if letter == 'a': + count = count + 1 + print(count) + +This program demonstrates another pattern of computation called a +**counter**. The variable count is initialized to 0 and then incremented +each time an a is found. When the loop exits, count contains the +result—the total number of a’s. + +As an exercise, encapsulate this code in a function named count, and +generalize it so that it accepts the string and the letter as arguments. + +Then rewrite the function so that instead of traversing the string, it +uses the three-parameter version of find from the previous section. + +String methods +-------------- + +Strings provide methods that perform a variety of useful operations. A +method is similar to a function—it takes arguments and returns a +value—but the syntax is different. For example, the method upper takes a +string and returns a new string with all uppercase letters. + +Instead of the function syntax upper(word), it uses the method syntax +word.upper(). + +:: + + >>> word = 'banana' + >>> new_word = word.upper() + >>> new_word + 'BANANA' + +This form of dot notation specifies the name of the method, upper, and +the name of the string to apply the method to, word. The empty +parentheses indicate that this method takes no arguments. + +A method call is called an **invocation**; in this case, we would say +that we are invoking upper on word. + +As it turns out, there is a string method named find that is remarkably +similar to the function we wrote: + +:: + + >>> word = 'banana' + >>> index = word.find('a') + >>> index + 1 + +In this example, we invoke find on word and pass the letter we are +looking for as a parameter. + +Actually, the find method is more general than our function; it can find +substrings, not just characters: + +:: + + >>> word.find('na') + 2 + +By default, find starts at the beginning of the string, but it can take +a second argument, the index where it should start: + +:: + + >>> word.find('na', 3) + 4 + +This is an example of an **optional argument**; find can also take a +third argument, the index where it should stop: + +:: + + >>> name = 'bob' + >>> name.find('b', 1, 2) + -1 + +This search fails because b does not appear in the index range from 1 to +2, not including 2. Searching up to, but not including, the second index +makes find consistent with the slice operator. + +The in operator +--------------- + +The word in is a boolean operator that takes two strings and returns +True if the first appears as a substring in the second: + +:: + + >>> 'a' in 'banana' + True + >>> 'seed' in 'banana' + False + +For example, the following function prints all the letters from word1 +that also appear in word2: + +:: + + def in_both(word1, word2): + for letter in word1: + if letter in word2: + print(letter) + +With well-chosen variable names, Python sometimes reads like English. +You could read this loop, “for (each) letter in (the first) word, if +(the) letter (appears) in (the second) word, print (the) letter.” + +Here’s what you get if you compare apples and oranges: + +:: + + >>> in_both('apples', 'oranges') + a + e + s + +String comparison +----------------- + +The relational operators work on strings. To see if two strings are +equal: + +:: + + if word == 'banana': + print('All right, bananas.') + +Other relational operations are useful for putting words in alphabetical +order: + +:: + + if word < 'banana': + print('Your word, ' + word + ', comes before banana.') + elif word > 'banana': + print('Your word, ' + word + ', comes after banana.') + else: + print('All right, bananas.') + +Python does not handle uppercase and lowercase letters the same way +people do. All the uppercase letters come before all the lowercase +letters, so: + +:: + + Your word, Pineapple, comes before banana. + +A common way to address this problem is to convert strings to a standard +format, such as all lowercase, before performing the comparison. Keep +that in mind in case you have to defend yourself against a man armed +with a Pineapple. + +Debugging +--------- + +When you use indices to traverse the values in a sequence, it is tricky +to get the beginning and end of the traversal right. Here is a function +that is supposed to compare two words and return True if one of the +words is the reverse of the other, but it contains two errors: + +:: + + def is_reverse(word1, word2): + if len(word1) != len(word2): + return False + + i = 0 + j = len(word2) + + while j > 0: + if word1[i] != word2[j]: + return False + i = i+1 + j = j-1 + + return True + +The first if statement checks whether the words are the same length. If +not, we can return False immediately. Otherwise, for the rest of the +function, we can assume that the words are the same length. This is an +example of the guardian pattern in Section [guardian]. + +i and j are indices: i traverses word1 forward while j traverses word2 +backward. If we find two letters that don’t match, we can return False +immediately. If we get through the whole loop and all the letters match, +we return True. + +If we test this function with the words “pots” and “stop”, we expect the +return value True, but we get an IndexError: + +:: + + >>> is_reverse('pots', 'stop') + ... + File "reverse.py", line 15, in is_reverse + if word1[i] != word2[j]: + IndexError: string index out of range + +For debugging this kind of error, my first move is to print the values +of the indices immediately before the line where the error appears. + +:: + + while j > 0: + print(i, j) # print here + + if word1[i] != word2[j]: + return False + i = i+1 + j = j-1 + +Now when I run the program again, I get more information: + +:: + + >>> is_reverse('pots', 'stop') + 0 4 + ... + IndexError: string index out of range + +The first time through the loop, the value of j is 4, which is out of +range for the string ``'pots'``. The index of the last character is 3, +so the initial value for j should be len(word2)-1. + +If I fix that error and run the program again, I get: + +:: + + >>> is_reverse('pots', 'stop') + 0 3 + 1 2 + 2 1 + True + +This time we get the right answer, but it looks like the loop only ran +three times, which is suspicious. To get a better idea of what is +happening, it is useful to draw a state diagram. During the first +iteration, the frame for ``is_reverse`` is shown in Figure [fig.state4]. + +.. figure:: figs/state4.pdf + :alt: State diagram. + + State diagram. + +I took some license by arranging the variables in the frame and adding +dotted lines to show that the values of i and j indicate characters in +word1 and word2. + +Starting with this diagram, run the program on paper, changing the +values of i and j during each iteration. Find and fix the second error +in this function. [isreverse] + + +.. _glossary08: + +Glossary +-------- + +.. include:: glossary/08.txt + + +Exercises +--------- + +Read the documentation of the string methods at +http://docs.python.org/3/library/stdtypes.html#string-methods. You might +want to experiment with some of them to make sure you understand how +they work. strip and replace are particularly useful. + +The documentation uses a syntax that might be confusing. For example, in +``find(sub[, start[, end]])``, the brackets indicate optional arguments. +So sub is required, but start is optional, and if you include start, +then end is optional. + +There is a string method called count that is similar to the function in +Section [counter]. Read the documentation of this method and write an +invocation that counts the number of a’s in ``'banana'``. + +A string slice can take a third index that specifies the “step size”; +that is, the number of spaces between successive characters. A step size +of 2 means every other character; 3 means every third, etc. + +:: + + >>> fruit = 'banana' + >>> fruit[0:5:2] + 'bnn' + +A step size of -1 goes through the word backwards, so the slice +``[::-1]`` generates a reversed string. + +Use this idiom to write a one-line version of ``is_palindrome`` from +Exercise [palindrome]. + +The following functions are all *intended* to check whether a string +contains any lowercase letters, but at least some of them are wrong. For +each function, describe what the function actually does (assuming that +the parameter is a string). + +:: + + def any_lowercase1(s): + for c in s: + if c.islower(): + return True + else: + return False + + def any_lowercase2(s): + for c in s: + if 'c'.islower(): + return 'True' + else: + return 'False' + + def any_lowercase3(s): + for c in s: + flag = c.islower() + return flag + + def any_lowercase4(s): + flag = False + for c in s: + flag = flag or c.islower() + return flag + + def any_lowercase5(s): + for c in s: + if not c.islower(): + return False + return True + +[exrotate] A Caesar cypher is a weak form of encryption that involves +“rotating” each letter by a fixed number of places. To rotate a letter +means to shift it through the alphabet, wrapping around to the beginning +if necessary, so ’A’ rotated by 3 is ’D’ and ’Z’ rotated by 1 is ’A’. + +To rotate a word, rotate each letter by the same amount. For example, +“cheer” rotated by 7 is “jolly” and “melon” rotated by -10 is “cubed”. +In the movie *2001: A Space Odyssey*, the ship computer is called HAL, +which is IBM rotated by -1. + +Write a function called ``rotate_word`` that takes a string and an +integer as parameters, and returns a new string that contains the +letters from the original string rotated by the given amount. + +You might want to use the built-in function ord, which converts a +character to a numeric code, and chr, which converts numeric codes to +characters. Letters of the alphabet are encoded in alphabetical order, +so for example: + +:: + + >>> ord('c') - ord('a') + 2 + +Because ``'c'`` is the two-eth letter of the alphabet. But beware: the +numeric codes for upper case letters are different. + +Potentially offensive jokes on the Internet are sometimes encoded in +ROT13, which is a Caesar cypher with rotation 13. If you are not easily +offended, find and decode some of them. Solution: +http://thinkpython2.com/code/rotate.py. diff --git a/book/09-case-word.rst b/book/09-case-word.rst new file mode 100644 index 0000000..2fcd300 --- /dev/null +++ b/book/09-case-word.rst @@ -0,0 +1,395 @@ +Case study: word play +===================== + +This chapter presents the second case study, which involves solving word +puzzles by searching for words that have certain properties. For +example, we’ll find the longest palindromes in English and search for +words whose letters appear in alphabetical order. And I will present +another program development plan: reduction to a previously solved +problem. + +Reading word lists +------------------ + +For the exercises in this chapter we need a list of English words. There +are lots of word lists available on the Web, but the one most suitable +for our purpose is one of the word lists collected and contributed to +the public domain by Grady Ward as part of the Moby lexicon project (see +http://wikipedia.org/wiki/Moby_Project). It is a list of 113,809 +official crosswords; that is, words that are considered valid in +crossword puzzles and other word games. In the Moby collection, the +filename is 113809of.fic; you can download a copy, with the simpler name +words.txt, from http://thinkpython2.com/code/words.txt. + +This file is in plain text, so you can open it with a text editor, but +you can also read it from Python. The built-in function open takes the +name of the file as a parameter and returns a **file object** you can +use to read the file. + +:: + + >>> fin = open('words.txt') + +fin is a common name for a file object used for input. The file object +provides several methods for reading, including readline, which reads +characters from the file until it gets to a newline and returns the +result as a string: + +:: + + >>> fin.readline() + 'aa\r\n' + +The first word in this particular list is “aa”, which is a kind of lava. +The sequence ``\r\n`` represents two whitespace characters, a carriage +return and a newline, that separate this word from the next. + +The file object keeps track of where it is in the file, so if you call +readline again, you get the next word: + +:: + + >>> fin.readline() + 'aah\r\n' + +The next word is “aah”, which is a perfectly legitimate word, so stop +looking at me like that. Or, if it’s the whitespace that’s bothering +you, we can get rid of it with the string method strip: + +:: + + >>> line = fin.readline() + >>> word = line.strip() + >>> word + 'aahed' + +You can also use a file object as part of a for loop. This program reads +words.txt and prints each word, one per line: + +:: + + fin = open('words.txt') + for line in fin: + word = line.strip() + print(word) + +Exercises +--------- + +There are solutions to these exercises in the next section. You should +at least attempt each one before you read the solutions. + +Write a program that reads words.txt and prints only the words with more +than 20 characters (not counting whitespace). + +In 1939 Ernest Vincent Wright published a 50,000 word novel called +*Gadsby* that does not contain the letter “e”. Since “e” is the most +common letter in English, that’s not easy to do. + +In fact, it is difficult to construct a solitary thought without using +that most common symbol. It is slow going at first, but with caution and +hours of training you can gradually gain facility. + +All right, I’ll stop now. + +Write a function called ``has_no_e`` that returns True if the given word +doesn’t have the letter “e” in it. + +Modify your program from the previous section to print only the words +that have no “e” and compute the percentage of the words in the list +that have no “e”. + +Write a function named avoids that takes a word and a string of +forbidden letters, and that returns True if the word doesn’t use any of +the forbidden letters. + +Modify your program to prompt the user to enter a string of forbidden +letters and then print the number of words that don’t contain any of +them. Can you find a combination of 5 forbidden letters that excludes +the smallest number of words? + +Write a function named ``uses_only`` that takes a word and a string of +letters, and that returns True if the word contains only letters in the +list. Can you make a sentence using only the letters acefhlo? Other than +“Hoe alfalfa?” + +Write a function named ``uses_all`` that takes a word and a string of +required letters, and that returns True if the word uses all the +required letters at least once. How many words are there that use all +the vowels aeiou? How about aeiouy? + +Write a function called ``is_abecedarian`` that returns True if the +letters in a word appear in alphabetical order (double letters are ok). +How many abecedarian words are there? + +Search +------ + +All of the exercises in the previous section have something in common; +they can be solved with the search pattern we saw in Section [find]. The +simplest example is: + +:: + + def has_no_e(word): + for letter in word: + if letter == 'e': + return False + return True + +The for loop traverses the characters in word. If we find the letter +“e”, we can immediately return False; otherwise we have to go to the +next letter. If we exit the loop normally, that means we didn’t find an +“e”, so we return True. + +You could write this function more concisely using the in operator, but +I started with this version because it demonstrates the logic of the +search pattern. + +is a more general version of ``has_no_e`` but it has the same structure: + +:: + + def avoids(word, forbidden): + for letter in word: + if letter in forbidden: + return False + return True + +We can return False as soon as we find a forbidden letter; if we get to +the end of the loop, we return True. + +``uses_only`` is similar except that the sense of the condition is +reversed: + +:: + + def uses_only(word, available): + for letter in word: + if letter not in available: + return False + return True + +Instead of a list of forbidden letters, we have a list of available +letters. If we find a letter in word that is not in available, we can +return False. + +``uses_all`` is similar except that we reverse the role of the word and +the string of letters: + +:: + + def uses_all(word, required): + for letter in required: + if letter not in word: + return False + return True + +Instead of traversing the letters in word, the loop traverses the +required letters. If any of the required letters do not appear in the +word, we can return False. + +If you were really thinking like a computer scientist, you would have +recognized that ``uses_all`` was an instance of a previously solved +problem, and you would have written: + +:: + + def uses_all(word, required): + return uses_only(required, word) + +This is an example of a program development plan called **reduction to a +previously solved problem**, which means that you recognize the problem +you are working on as an instance of a solved problem and apply an +existing solution. + +Looping with indices +-------------------- + +I wrote the functions in the previous section with for loops because I +only needed the characters in the strings; I didn’t have to do anything +with the indices. + +For ``is_abecedarian`` we have to compare adjacent letters, which is a +little tricky with a for loop: + +:: + + def is_abecedarian(word): + previous = word[0] + for c in word: + if c < previous: + return False + previous = c + return True + +An alternative is to use recursion: + +:: + + def is_abecedarian(word): + if len(word) <= 1: + return True + if word[0] > word[1]: + return False + return is_abecedarian(word[1:]) + +Another option is to use a while loop: + +:: + + def is_abecedarian(word): + i = 0 + while i < len(word)-1: + if word[i+1] < word[i]: + return False + i = i+1 + return True + +The loop starts at i=0 and ends when i=len(word)-1. Each time through +the loop, it compares the :math:`i`\ th character (which you can think +of as the current character) to the :math:`i+1`\ th character (which you +can think of as the next). + +If the next character is less than (alphabetically before) the current +one, then we have discovered a break in the abecedarian trend, and we +return False. + +If we get to the end of the loop without finding a fault, then the word +passes the test. To convince yourself that the loop ends correctly, +consider an example like ``'flossy'``. The length of the word is 6, so +the last time the loop runs is when i is 4, which is the index of the +second-to-last character. On the last iteration, it compares the +second-to-last character to the last, which is what we want. + +Here is a version of ``is_palindrome`` (see Exercise [palindrome]) that +uses two indices; one starts at the beginning and goes up; the other +starts at the end and goes down. + +:: + + def is_palindrome(word): + i = 0 + j = len(word)-1 + + while i>> cheeses = ['Cheddar', 'Edam', 'Gouda'] + >>> numbers = [42, 123] + >>> empty = [] + >>> print(cheeses, numbers, empty) + ['Cheddar', 'Edam', 'Gouda'] [42, 123] [] + +Lists are mutable +----------------- + +The syntax for accessing the elements of a list is the same as for +accessing the characters of a string—the bracket operator. The +expression inside the brackets specifies the index. Remember that the +indices start at 0: + +:: + + >>> cheeses[0] + 'Cheddar' + +Unlike strings, lists are mutable. When the bracket operator appears on +the left side of an assignment, it identifies the element of the list +that will be assigned. + +:: + + >>> numbers = [42, 123] + >>> numbers[1] = 5 + >>> numbers + [42, 5] + +The one-eth element of numbers, which used to be 123, is now 5. + +Figure [fig.liststate] shows the state diagram for cheeses, numbers and +empty: + +.. figure:: figs/liststate.pdf + :alt: State diagram. + + State diagram. + +Lists are represented by boxes with the word “list” outside and the +elements of the list inside. cheeses refers to a list with three +elements indexed 0, 1 and 2. numbers contains two elements; the diagram +shows that the value of the second element has been reassigned from 123 +to 5. empty refers to a list with no elements. + +List indices work the same way as string indices: + +- Any integer expression can be used as an index. + +- If you try to read or write an element that does not exist, you get + an IndexError. + +- If an index has a negative value, it counts backward from the end of + the list. + +The in operator also works on lists. + +:: + + >>> cheeses = ['Cheddar', 'Edam', 'Gouda'] + >>> 'Edam' in cheeses + True + >>> 'Brie' in cheeses + False + +Traversing a list +----------------- + +The most common way to traverse the elements of a list is with a for +loop. The syntax is the same as for strings: + +:: + + for cheese in cheeses: + print(cheese) + +This works well if you only need to read the elements of the list. But +if you want to write or update the elements, you need the indices. A +common way to do that is to combine the built-in functions range and +len: + +:: + + for i in range(len(numbers)): + numbers[i] = numbers[i] * 2 + +This loop traverses the list and updates each element. len returns the +number of elements in the list. range returns a list of indices from 0 +to :math:`n-1`, where :math:`n` is the length of the list. Each time +through the loop i gets the index of the next element. The assignment +statement in the body uses i to read the old value of the element and to +assign the new value. + +A for loop over an empty list never runs the body: + +:: + + for x in []: + print('This never happens.') + +Although a list can contain another list, the nested list still counts +as a single element. The length of this list is four: + +:: + + ['spam', 1, ['Brie', 'Roquefort', 'Pol le Veq'], [1, 2, 3]] + +List operations +--------------- + +The + operator concatenates lists: + +:: + + >>> a = [1, 2, 3] + >>> b = [4, 5, 6] + >>> c = a + b + >>> c + [1, 2, 3, 4, 5, 6] + +The operator repeats a list a given number of times: + +:: + + >>> [0] * 4 + [0, 0, 0, 0] + >>> [1, 2, 3] * 3 + [1, 2, 3, 1, 2, 3, 1, 2, 3] + +The first example repeats four times. The second example repeats the +list three times. + +List slices +----------- + +The slice operator also works on lists: + +:: + + >>> t = ['a', 'b', 'c', 'd', 'e', 'f'] + >>> t[1:3] + ['b', 'c'] + >>> t[:4] + ['a', 'b', 'c', 'd'] + >>> t[3:] + ['d', 'e', 'f'] + +If you omit the first index, the slice starts at the beginning. If you +omit the second, the slice goes to the end. So if you omit both, the +slice is a copy of the whole list. + +:: + + >>> t[:] + ['a', 'b', 'c', 'd', 'e', 'f'] + +Since lists are mutable, it is often useful to make a copy before +performing operations that modify lists. + +A slice operator on the left side of an assignment can update multiple +elements: + +:: + + >>> t = ['a', 'b', 'c', 'd', 'e', 'f'] + >>> t[1:3] = ['x', 'y'] + >>> t + ['a', 'x', 'y', 'd', 'e', 'f'] + +List methods +------------ + +Python provides methods that operate on lists. For example, append adds +a new element to the end of a list: + +:: + + >>> t = ['a', 'b', 'c'] + >>> t.append('d') + >>> t + ['a', 'b', 'c', 'd'] + +extend takes a list as an argument and appends all of the elements: + +:: + + >>> t1 = ['a', 'b', 'c'] + >>> t2 = ['d', 'e'] + >>> t1.extend(t2) + >>> t1 + ['a', 'b', 'c', 'd', 'e'] + +This example leaves t2 unmodified. + +sort arranges the elements of the list from low to high: + +:: + + >>> t = ['d', 'c', 'e', 'b', 'a'] + >>> t.sort() + >>> t + ['a', 'b', 'c', 'd', 'e'] + +Most list methods are void; they modify the list and return None. If you +accidentally write t = t.sort(), you will be disappointed with the +result. + +Map, filter and reduce +---------------------- + +To add up all the numbers in a list, you can use a loop like this: + +:: + + def add_all(t): + total = 0 + for x in t: + total += x + return total + +total is initialized to 0. Each time through the loop, x gets one +element from the list. The += operator provides a short way to update a +variable. This **augmented assignment statement**, + +:: + + total += x + +is equivalent to + +:: + + total = total + x + +As the loop runs, total accumulates the sum of the elements; a variable +used this way is sometimes called an **accumulator**. + +Adding up the elements of a list is such a common operation that Python +provides it as a built-in function, sum: + +:: + + >>> t = [1, 2, 3] + >>> sum(t) + 6 + +An operation like this that combines a sequence of elements into a +single value is sometimes called **reduce**. + +Sometimes you want to traverse one list while building another. For +example, the following function takes a list of strings and returns a +new list that contains capitalized strings: + +:: + + def capitalize_all(t): + res = [] + for s in t: + res.append(s.capitalize()) + return res + +res is initialized with an empty list; each time through the loop, we +append the next element. So res is another kind of accumulator. + +An operation like ``capitalize_all`` is sometimes called a **map** +because it “maps” a function (in this case the method capitalize) onto +each of the elements in a sequence. + +Another common operation is to select some of the elements from a list +and return a sublist. For example, the following function takes a list +of strings and returns a list that contains only the uppercase strings: + +:: + + def only_upper(t): + res = [] + for s in t: + if s.isupper(): + res.append(s) + return res + +isupper is a string method that returns True if the string contains only +upper case letters. + +An operation like ``only_upper`` is called a **filter** because it +selects some of the elements and filters out the others. + +Most common list operations can be expressed as a combination of map, +filter and reduce. + +Deleting elements +----------------- + +There are several ways to delete elements from a list. If you know the +index of the element you want, you can use pop: + +:: + + >>> t = ['a', 'b', 'c'] + >>> x = t.pop(1) + >>> t + ['a', 'c'] + >>> x + 'b' + +pop modifies the list and returns the element that was removed. If you +don’t provide an index, it deletes and returns the last element. + +If you don’t need the removed value, you can use the del operator: + +:: + + >>> t = ['a', 'b', 'c'] + >>> del t[1] + >>> t + ['a', 'c'] + +If you know the element you want to remove (but not the index), you can +use remove: + +:: + + >>> t = ['a', 'b', 'c'] + >>> t.remove('b') + >>> t + ['a', 'c'] + +The return value from remove is None. + +To remove more than one element, you can use del with a slice index: + +:: + + >>> t = ['a', 'b', 'c', 'd', 'e', 'f'] + >>> del t[1:5] + >>> t + ['a', 'f'] + +As usual, the slice selects all the elements up to but not including the +second index. + +Lists and strings +----------------- + +A string is a sequence of characters and a list is a sequence of values, +but a list of characters is not the same as a string. To convert from a +string to a list of characters, you can use list: + +:: + + >>> s = 'spam' + >>> t = list(s) + >>> t + ['s', 'p', 'a', 'm'] + +Because list is the name of a built-in function, you should avoid using +it as a variable name. I also avoid l because it looks too much like 1. +So that’s why I use t. + +The list function breaks a string into individual letters. If you want +to break a string into words, you can use the split method: + +:: + + >>> s = 'pining for the fjords' + >>> t = s.split() + >>> t + ['pining', 'for', 'the', 'fjords'] + +An optional argument called a **delimiter** specifies which characters +to use as word boundaries. The following example uses a hyphen as a +delimiter: + +:: + + >>> s = 'spam-spam-spam' + >>> delimiter = '-' + >>> t = s.split(delimiter) + >>> t + ['spam', 'spam', 'spam'] + +join is the inverse of split. It takes a list of strings and +concatenates the elements. join is a string method, so you have to +invoke it on the delimiter and pass the list as a parameter: + +:: + + >>> t = ['pining', 'for', 'the', 'fjords'] + >>> delimiter = ' ' + >>> s = delimiter.join(t) + >>> s + 'pining for the fjords' + +In this case the delimiter is a space character, so join puts a space +between words. To concatenate strings without spaces, you can use the +empty string, ``''``, as a delimiter. + +Objects and values +------------------ + +If we run these assignment statements: + +:: + + a = 'banana' + b = 'banana' + +We know that a and b both refer to a string, but we don’t know whether +they refer to the *same* string. There are two possible states, shown in +Figure [fig.list1]. + +.. figure:: figs/list1.pdf + :alt: State diagram. + + State diagram. + +In one case, a and b refer to two different objects that have the same +value. In the second case, they refer to the same object. + +To check whether two variables refer to the same object, you can use the +is operator. + +:: + + >>> a = 'banana' + >>> b = 'banana' + >>> a is b + True + +In this example, Python only created one string object, and both a and b +refer to it. But when you create two lists, you get two objects: + +:: + + >>> a = [1, 2, 3] + >>> b = [1, 2, 3] + >>> a is b + False + +So the state diagram looks like Figure [fig.list2]. + +.. figure:: figs/list2.pdf + :alt: State diagram. + + State diagram. + +In this case we would say that the two lists are **equivalent**, because +they have the same elements, but not **identical**, because they are not +the same object. If two objects are identical, they are also equivalent, +but if they are equivalent, they are not necessarily identical. + +Until now, we have been using “object” and “value” interchangeably, but +it is more precise to say that an object has a value. If you evaluate , +you get a list object whose value is a sequence of integers. If another +list has the same elements, we say it has the same value, but it is not +the same object. + +Aliasing +-------- + +If a refers to an object and you assign b = a, then both variables refer +to the same object: + +:: + + >>> a = [1, 2, 3] + >>> b = a + >>> b is a + True + +The state diagram looks like Figure [fig.list3]. + +.. figure:: figs/list3.pdf + :alt: State diagram. + + State diagram. + +The association of a variable with an object is called a **reference**. +In this example, there are two references to the same object. + +An object with more than one reference has more than one name, so we say +that the object is **aliased**. + +If the aliased object is mutable, changes made with one alias affect the +other: + +:: + + >>> b[0] = 42 + >>> a + [42, 2, 3] + +Although this behavior can be useful, it is error-prone. In general, it +is safer to avoid aliasing when you are working with mutable objects. + +For immutable objects like strings, aliasing is not as much of a +problem. In this example: + +:: + + a = 'banana' + b = 'banana' + +It almost never makes a difference whether a and b refer to the same +string or not. + +List arguments +-------------- + +When you pass a list to a function, the function gets a reference to the +list. If the function modifies the list, the caller sees the change. For +example, ``delete_head`` removes the first element from a list: + +:: + + def delete_head(t): + del t[0] + +Here’s how it is used: + +:: + + >>> letters = ['a', 'b', 'c'] + >>> delete_head(letters) + >>> letters + ['b', 'c'] + +The parameter t and the variable letters are aliases for the same +object. The stack diagram looks like Figure [fig.stack5]. + +.. figure:: figs/stack5.pdf + :alt: Stack diagram. + + Stack diagram. + +Since the list is shared by two frames, I drew it between them. + +It is important to distinguish between operations that modify lists and +operations that create new lists. For example, the append method +modifies a list, but the + operator creates a new list: + +:: + + >>> t1 = [1, 2] + >>> t2 = t1.append(3) + >>> t1 + [1, 2, 3] + >>> t2 + None + +append modifies the list and returns None. + +:: + + >>> t3 = t1 + [4] + >>> t1 + [1, 2, 3] + >>> t3 + [1, 2, 3, 4] + >>> t1 + +The + operator creates a new list and leaves the original list +unchanged. + +This difference is important when you write functions that are supposed +to modify lists. For example, this function *does not* delete the head +of a list: + +:: + + def bad_delete_head(t): + t = t[1:] # WRONG! + +The slice operator creates a new list and the assignment makes t refer +to it, but that doesn’t affect the caller. + +:: + + >>> t4 = [1, 2, 3] + >>> bad_delete_head(t4) + >>> t4 + [1, 2, 3] + +At the beginning of ``bad_delete_head``, t and t4 refer to the same +list. At the end, t refers to a new list, but t4 still refers to the +original, unmodified list. + +An alternative is to write a function that creates and returns a new +list. For example, tail returns all but the first element of a list: + +:: + + def tail(t): + return t[1:] + +This function leaves the original list unmodified. Here’s how it is +used: + +:: + + >>> letters = ['a', 'b', 'c'] + >>> rest = tail(letters) + >>> rest + ['b', 'c'] + +Debugging +--------- + +Careless use of lists (and other mutable objects) can lead to long hours +of debugging. Here are some common pitfalls and ways to avoid them: + +#. Most list methods modify the argument and return None. This is the + opposite of the string methods, which return a new string and leave + the original alone. + + If you are used to writing string code like this: + + :: + + word = word.strip() + + It is tempting to write list code like this: + + :: + + t = t.sort() # WRONG! + + Because sort returns None, the next operation you perform with t is + likely to fail. + + Before using list methods and operators, you should read the + documentation carefully and then test them in interactive mode. + +#. Pick an idiom and stick with it. + + Part of the problem with lists is that there are too many ways to do + things. For example, to remove an element from a list, you can use + pop, remove, del, or even a slice assignment. + + To add an element, you can use the append method or the + operator. + Assuming that t is a list and x is a list element, these are correct: + + :: + + t.append(x) + t = t + [x] + t += [x] + + And these are wrong: + + :: + + t.append([x]) # WRONG! + t = t.append(x) # WRONG! + t + [x] # WRONG! + t = t + x # WRONG! + + Try out each of these examples in interactive mode to make sure you + understand what they do. Notice that only the last one causes a + runtime error; the other three are legal, but they do the wrong + thing. + +#. Make copies to avoid aliasing. + + If you want to use a method like sort that modifies the argument, but + you need to keep the original list as well, you can make a copy. + + :: + + >>> t = [3, 1, 2] + >>> t2 = t[:] + >>> t2.sort() + >>> t + [3, 1, 2] + >>> t2 + [1, 2, 3] + + In this example you could also use the built-in function sorted, + which returns a new, sorted list and leaves the original alone. + + :: + + >>> t2 = sorted(t) + >>> t + [3, 1, 2] + >>> t2 + [1, 2, 3] + + +.. _glossary10: + +Glossary +-------- + +.. include:: glossary/10.txt + + +Exercises +--------- + +You can download solutions to these exercises from +http://thinkpython2.com/code/list_exercises.py. + +Write a function called ``nested_sum`` that takes a list of lists of +integers and adds up the elements from all of the nested lists. For +example: + +:: + + >>> t = [[1, 2], [3], [4, 5, 6]] + >>> nested_sum(t) + 21 + +[cumulative] + +Write a function called cumsum that takes a list of numbers and returns +the cumulative sum; that is, a new list where the :math:`i`\ th element +is the sum of the first :math:`i+1` elements from the original list. For +example: + +:: + + >>> t = [1, 2, 3] + >>> cumsum(t) + [1, 3, 6] + +Write a function called ``middle`` that takes a list and returns a new +list that contains all but the first and last elements. For example: + +:: + + >>> t = [1, 2, 3, 4] + >>> middle(t) + [2, 3] + +Write a function called ``chop`` that takes a list, modifies it by +removing the first and last elements, and returns None. For example: + +:: + + >>> t = [1, 2, 3, 4] + >>> chop(t) + >>> t + [2, 3] + +Write a function called ``is_sorted`` that takes a list as a parameter +and returns True if the list is sorted in ascending order and False +otherwise. For example: + +:: + + >>> is_sorted([1, 2, 2]) + True + >>> is_sorted(['b', 'a']) + False + +[anagram] + +Two words are anagrams if you can rearrange the letters from one to +spell the other. Write a function called ``is_anagram`` that takes two +strings and returns True if they are anagrams. + +[duplicate] + +Write a function called ``has_duplicates`` that takes a list and returns +True if there is any element that appears more than once. It should not +modify the original list. + +This exercise pertains to the so-called Birthday Paradox, which you can +read about at http://en.wikipedia.org/wiki/Birthday_paradox. + +If there are 23 students in your class, what are the chances that two of +you have the same birthday? You can estimate this probability by +generating random samples of 23 birthdays and checking for matches. +Hint: you can generate random birthdays with the randint function in the +random module. + +You can download my solution from +http://thinkpython2.com/code/birthday.py. + +Write a function that reads the file words.txt and builds a list with +one element per word. Write two versions of this function, one using the +append method and the other using the idiom t = t + [x]. Which one takes +longer to run? Why? + +Solution: http://thinkpython2.com/code/wordlist.py. + +[wordlist1] [bisection] + +To check whether a word is in the word list, you could use the in +operator, but it would be slow because it searches through the words in +order. + +Because the words are in alphabetical order, we can speed things up with +a bisection search (also known as binary search), which is similar to +what you do when you look a word up in the dictionary. You start in the +middle and check to see whether the word you are looking for comes +before the word in the middle of the list. If so, you search the first +half of the list the same way. Otherwise you search the second half. + +Either way, you cut the remaining search space in half. If the word list +has 113,809 words, it will take about 17 steps to find the word or +conclude that it’s not there. + +Write a function called ``in_bisect`` that takes a sorted list and a +target value and returns the index of the value in the list if it’s +there, or None if it’s not. + +Or you could read the documentation of the bisect module and use that! +Solution: http://thinkpython2.com/code/inlist.py. + +Two words are a “reverse pair” if each is the reverse of the other. +Write a program that finds all the reverse pairs in the word list. +Solution: http://thinkpython2.com/code/reverse_pair.py. + +Two words “interlock” if taking alternating letters from each forms a +new word. For example, “shoe” and “cold” interlock to form “schooled”. +Solution: http://thinkpython2.com/code/interlock.py. Credit: This +exercise is inspired by an example at http://puzzlers.org. + +#. Write a program that finds all pairs of words that interlock. Hint: + don’t enumerate all pairs! + +#. Can you find any words that are three-way interlocked; that is, every + third letter forms a word, starting from the first, second or third? diff --git a/book/11-dict.rst b/book/11-dict.rst new file mode 100644 index 0000000..3664e8f --- /dev/null +++ b/book/11-dict.rst @@ -0,0 +1,686 @@ +Dictionaries +============ + +This chapter presents another built-in type called a dictionary. +Dictionaries are one of Python’s best features; they are the building +blocks of many efficient and elegant algorithms. + +A dictionary is a mapping +------------------------- + +A **dictionary** is like a list, but more general. In a list, the +indices have to be integers; in a dictionary they can be (almost) any +type. + +A dictionary contains a collection of indices, which are called +**keys**, and a collection of values. Each key is associated with a +single value. The association of a key and a value is called a +**key-value pair** or sometimes an **item**. + +In mathematical language, a dictionary represents a **mapping** from +keys to values, so you can also say that each key “maps to” a value. As +an example, we’ll build a dictionary that maps from English to Spanish +words, so the keys and the values are all strings. + +The function dict creates a new dictionary with no items. Because dict +is the name of a built-in function, you should avoid using it as a +variable name. + +:: + + >>> eng2sp = dict() + >>> eng2sp + {} + +The squiggly-brackets, ``{}``, represent an empty dictionary. To add +items to the dictionary, you can use square brackets: + +:: + + >>> eng2sp['one'] = 'uno' + +This line creates an item that maps from the key ``'one'`` to the value +``'uno'``. If we print the dictionary again, we see a key-value pair +with a colon between the key and value: + +:: + + >>> eng2sp + {'one': 'uno'} + +This output format is also an input format. For example, you can create +a new dictionary with three items: + +:: + + >>> eng2sp = {'one': 'uno', 'two': 'dos', 'three': 'tres'} + +But if you print eng2sp, you might be surprised: + +:: + + >>> eng2sp + {'one': 'uno', 'three': 'tres', 'two': 'dos'} + +The order of the key-value pairs might not be the same. If you type the +same example on your computer, you might get a different result. In +general, the order of items in a dictionary is unpredictable. + +But that’s not a problem because the elements of a dictionary are never +indexed with integer indices. Instead, you use the keys to look up the +corresponding values: + +:: + + >>> eng2sp['two'] + 'dos' + +The key ``'two'`` always maps to the value ``'dos'`` so the order of the +items doesn’t matter. + +If the key isn’t in the dictionary, you get an exception: + +:: + + >>> eng2sp['four'] + KeyError: 'four' + +The len function works on dictionaries; it returns the number of +key-value pairs: + +:: + + >>> len(eng2sp) + 3 + +The in operator works on dictionaries, too; it tells you whether +something appears as a *key* in the dictionary (appearing as a value is +not good enough). + +:: + + >>> 'one' in eng2sp + True + >>> 'uno' in eng2sp + False + +To see whether something appears as a value in a dictionary, you can use +the method values, which returns a collection of values, and then use +the in operator: + +:: + + >>> vals = eng2sp.values() + >>> 'uno' in vals + True + +The in operator uses different algorithms for lists and dictionaries. +For lists, it searches the elements of the list in order, as in +Section [find]. As the list gets longer, the search time gets longer in +direct proportion. + +For dictionaries, Python uses an algorithm called a **hashtable** that +has a remarkable property: the in operator takes about the same amount +of time no matter how many items are in the dictionary. I explain how +that’s possible in Section [hashtable], but the explanation might not +make sense until you’ve read a few more chapters. + +Dictionary as a collection of counters +-------------------------------------- + +Suppose you are given a string and you want to count how many times each +letter appears. There are several ways you could do it: + +#. You could create 26 variables, one for each letter of the alphabet. + Then you could traverse the string and, for each character, increment + the corresponding counter, probably using a chained conditional. + +#. You could create a list with 26 elements. Then you could convert each + character to a number (using the built-in function ord), use the + number as an index into the list, and increment the appropriate + counter. + +#. You could create a dictionary with characters as keys and counters as + the corresponding values. The first time you see a character, you + would add an item to the dictionary. After that you would increment + the value of an existing item. + +Each of these options performs the same computation, but each of them +implements that computation in a different way. + +An **implementation** is a way of performing a computation; some +implementations are better than others. For example, an advantage of the +dictionary implementation is that we don’t have to know ahead of time +which letters appear in the string and we only have to make room for the +letters that do appear. + +Here is what the code might look like: + +:: + + def histogram(s): + d = dict() + for c in s: + if c not in d: + d[c] = 1 + else: + d[c] += 1 + return d + +The name of the function is histogram, which is a statistical term for a +collection of counters (or frequencies). + +The first line of the function creates an empty dictionary. The for loop +traverses the string. Each time through the loop, if the character c is +not in the dictionary, we create a new item with key c and the initial +value 1 (since we have seen this letter once). If c is already in the +dictionary we increment d[c]. + +Here’s how it works: + +:: + + >>> h = histogram('brontosaurus') + >>> h + {'a': 1, 'b': 1, 'o': 2, 'n': 1, 's': 2, 'r': 2, 'u': 2, 't': 1} + +The histogram indicates that the letters ``'a'`` and ``'b'`` appear +once; ``'o'`` appears twice, and so on. + +Dictionaries have a method called get that takes a key and a default +value. If the key appears in the dictionary, get returns the +corresponding value; otherwise it returns the default value. For +example: + +:: + + >>> h = histogram('a') + >>> h + {'a': 1} + >>> h.get('a', 0) + 1 + >>> h.get('b', 0) + 0 + +As an exercise, use get to write histogram more concisely. You should be +able to eliminate the if statement. + +Looping and dictionaries +------------------------ + +If you use a dictionary in a for statement, it traverses the keys of the +dictionary. For example, ``print_hist`` prints each key and the +corresponding value: + +:: + + def print_hist(h): + for c in h: + print(c, h[c]) + +Here’s what the output looks like: + +:: + + >>> h = histogram('parrot') + >>> print_hist(h) + a 1 + p 1 + r 2 + t 1 + o 1 + +Again, the keys are in no particular order. To traverse the keys in +sorted order, you can use the built-in function sorted: + +:: + + >>> for key in sorted(h): + ... print(key, h[key]) + a 1 + o 1 + p 1 + r 2 + t 1 + +Reverse lookup +-------------- + +Given a dictionary d and a key k, it is easy to find the corresponding +value v = d[k]. This operation is called a **lookup**. + +But what if you have v and you want to find k? You have two problems: +first, there might be more than one key that maps to the value v. +Depending on the application, you might be able to pick one, or you +might have to make a list that contains all of them. Second, there is no +simple syntax to do a **reverse lookup**; you have to search. + +Here is a function that takes a value and returns the first key that +maps to that value: + +:: + + def reverse_lookup(d, v): + for k in d: + if d[k] == v: + return k + raise LookupError() + +This function is yet another example of the search pattern, but it uses +a feature we haven’t seen before, raise. The **raise statement** causes +an exception; in this case it causes a LookupError, which is a built-in +exception used to indicate that a lookup operation failed. + +If we get to the end of the loop, that means v doesn’t appear in the +dictionary as a value, so we raise an exception. + +Here is an example of a successful reverse lookup: + +:: + + >>> h = histogram('parrot') + >>> key = reverse_lookup(h, 2) + >>> key + 'r' + +And an unsuccessful one: + +:: + + >>> key = reverse_lookup(h, 3) + Traceback (most recent call last): + File "", line 1, in + File "", line 5, in reverse_lookup + LookupError + +The effect when you raise an exception is the same as when Python raises +one: it prints a traceback and an error message. + +The raise statement can take a detailed error message as an optional +argument. For example: + +:: + + >>> raise LookupError('value does not appear in the dictionary') + Traceback (most recent call last): + File "", line 1, in ? + LookupError: value does not appear in the dictionary + +A reverse lookup is much slower than a forward lookup; if you have to do +it often, or if the dictionary gets big, the performance of your program +will suffer. + +Dictionaries and lists +---------------------- + +Lists can appear as values in a dictionary. For example, if you are +given a dictionary that maps from letters to frequencies, you might want +to invert it; that is, create a dictionary that maps from frequencies to +letters. Since there might be several letters with the same frequency, +each value in the inverted dictionary should be a list of letters. + +Here is a function that inverts a dictionary: + +:: + + def invert_dict(d): + inverse = dict() + for key in d: + val = d[key] + if val not in inverse: + inverse[val] = [key] + else: + inverse[val].append(key) + return inverse + +Each time through the loop, key gets a key from d and val gets the +corresponding value. If val is not in inverse, that means we haven’t +seen it before, so we create a new item and initialize it with a +**singleton** (a list that contains a single element). Otherwise we have +seen this value before, so we append the corresponding key to the list. + +Here is an example: + +:: + + >>> hist = histogram('parrot') + >>> hist + {'a': 1, 'p': 1, 'r': 2, 't': 1, 'o': 1} + >>> inverse = invert_dict(hist) + >>> inverse + {1: ['a', 'p', 't', 'o'], 2: ['r']} + +.. figure:: figs/dict1.pdf + :alt: State diagram. + + State diagram. + +Figure [fig.dict1] is a state diagram showing hist and inverse. A +dictionary is represented as a box with the type dict above it and the +key-value pairs inside. If the values are integers, floats or strings, I +draw them inside the box, but I usually draw lists outside the box, just +to keep the diagram simple. + +Lists can be values in a dictionary, as this example shows, but they +cannot be keys. Here’s what happens if you try: + +:: + + >>> t = [1, 2, 3] + >>> d = dict() + >>> d[t] = 'oops' + Traceback (most recent call last): + File "", line 1, in ? + TypeError: list objects are unhashable + +I mentioned earlier that a dictionary is implemented using a hashtable +and that means that the keys have to be **hashable**. + +A **hash** is a function that takes a value (of any kind) and returns an +integer. Dictionaries use these integers, called hash values, to store +and look up key-value pairs. + +This system works fine if the keys are immutable. But if the keys are +mutable, like lists, bad things happen. For example, when you create a +key-value pair, Python hashes the key and stores it in the corresponding +location. If you modify the key and then hash it again, it would go to a +different location. In that case you might have two entries for the same +key, or you might not be able to find a key. Either way, the dictionary +wouldn’t work correctly. + +That’s why keys have to be hashable, and why mutable types like lists +aren’t. The simplest way to get around this limitation is to use tuples, +which we will see in the next chapter. + +Since dictionaries are mutable, they can’t be used as keys, but they +*can* be used as values. + +Memos +----- + +If you played with the fibonacci function from +Section [one.more.example], you might have noticed that the bigger the +argument you provide, the longer the function takes to run. Furthermore, +the run time increases quickly. + +To understand why, consider Figure [fig.fibonacci], which shows the +**call graph** for fibonacci with n=4: + +.. figure:: figs/fibonacci.pdf + :alt: Call graph. + + Call graph. + +A call graph shows a set of function frames, with lines connecting each +frame to the frames of the functions it calls. At the top of the graph, +fibonacci with n=4 calls fibonacci with n=3 and n=2. In turn, fibonacci +with n=3 calls fibonacci with n=2 and n=1. And so on. + +Count how many times fibonacci(0) and fibonacci(1) are called. This is +an inefficient solution to the problem, and it gets worse as the +argument gets bigger. + +One solution is to keep track of values that have already been computed +by storing them in a dictionary. A previously computed value that is +stored for later use is called a **memo**. Here is a “memoized” version +of fibonacci: + +:: + + known = {0:0, 1:1} + + def fibonacci(n): + if n in known: + return known[n] + + res = fibonacci(n-1) + fibonacci(n-2) + known[n] = res + return res + +known is a dictionary that keeps track of the Fibonacci numbers we +already know. It starts with two items: 0 maps to 0 and 1 maps to 1. + +Whenever fibonacci is called, it checks known. If the result is already +there, it can return immediately. Otherwise it has to compute the new +value, add it to the dictionary, and return it. + +If you run this version of fibonacci and compare it with the original, +you will find that it is much faster. + +Global variables +---------------- + +In the previous example, known is created outside the function, so it +belongs to the special frame called ``__main__``. Variables in +``__main__`` are sometimes called **global** because they can be +accessed from any function. Unlike local variables, which disappear when +their function ends, global variables persist from one function call to +the next. + +It is common to use global variables for **flags**; that is, boolean +variables that indicate (“flag”) whether a condition is true. For +example, some programs use a flag named verbose to control the level of +detail in the output: + +:: + + verbose = True + + def example1(): + if verbose: + print('Running example1') + +If you try to reassign a global variable, you might be surprised. The +following example is supposed to keep track of whether the function has +been called: + +:: + + been_called = False + + def example2(): + been_called = True # WRONG + +But if you run it you will see that the value of ``been_called`` doesn’t +change. The problem is that example2 creates a new local variable named +``been_called``. The local variable goes away when the function ends, +and has no effect on the global variable. + +To reassign a global variable inside a function you have to **declare** +the global variable before you use it: + +:: + + been_called = False + + def example2(): + global been_called + been_called = True + +The **global statement** tells the interpreter something like, “In this +function, when I say ``been_called``, I mean the global variable; don’t +create a local one.” + +Here’s an example that tries to update a global variable: + +:: + + count = 0 + + def example3(): + count = count + 1 # WRONG + +If you run it you get: + +:: + + UnboundLocalError: local variable 'count' referenced before assignment + +Python assumes that count is local, and under that assumption you are +reading it before writing it. The solution, again, is to declare count +global. + +:: + + def example3(): + global count + count += 1 + +If a global variable refers to a mutable value, you can modify the value +without declaring the variable: + +:: + + known = {0:0, 1:1} + + def example4(): + known[2] = 1 + +So you can add, remove and replace elements of a global list or +dictionary, but if you want to reassign the variable, you have to +declare it: + +:: + + def example5(): + global known + known = dict() + +Global variables can be useful, but if you have a lot of them, and you +modify them frequently, they can make programs hard to debug. + +Debugging +--------- + +As you work with bigger datasets it can become unwieldy to debug by +printing and checking the output by hand. Here are some suggestions for +debugging large datasets: + +Scale down the input: + If possible, reduce the size of the dataset. For example if the + program reads a text file, start with just the first 10 lines, or + with the smallest example you can find. You can either edit the + files themselves, or (better) modify the program so it reads only + the first n lines. + + If there is an error, you can reduce n to the smallest value that + manifests the error, and then increase it gradually as you find and + correct errors. + +Check summaries and types: + Instead of printing and checking the entire dataset, consider + printing summaries of the data: for example, the number of items in + a dictionary or the total of a list of numbers. + + A common cause of runtime errors is a value that is not the right + type. For debugging this kind of error, it is often enough to print + the type of a value. + +Write self-checks: + Sometimes you can write code to check for errors automatically. For + example, if you are computing the average of a list of numbers, you + could check that the result is not greater than the largest element + in the list or less than the smallest. This is called a “sanity + check” because it detects results that are “insane”. + + Another kind of check compares the results of two different + computations to see if they are consistent. This is called a + “consistency check”. + +Format the output: + Formatting debugging output can make it easier to spot an error. We + saw an example in Section [factdebug]. The pprint module provides a + pprint function that displays built-in types in a more + human-readable format (pprint stands for “pretty print”). + +Again, time you spend building scaffolding can reduce the time you spend +debugging. + +.. _glossary11: + +Glossary +-------- + +.. include:: glossary/11.txt + + +Exercises +--------- + +[wordlist2] + +Write a function that reads the words in words.txt and stores them as +keys in a dictionary. It doesn’t matter what the values are. Then you +can use the in operator as a fast way to check whether a string is in +the dictionary. + +If you did Exercise [wordlist1], you can compare the speed of this +implementation with the list in operator and the bisection search. + +[setdefault] + +Read the documentation of the dictionary method setdefault and use it to +write a more concise version of ``invert_dict``. Solution: +http://thinkpython2.com/code/invert_dict.py. + +Memoize the Ackermann function from Exercise [ackermann] and see if +memoization makes it possible to evaluate the function with bigger +arguments. Hint: no. Solution: +http://thinkpython2.com/code/ackermann_memo.py. + +If you did Exercise [duplicate], you already have a function named +``has_duplicates`` that takes a list as a parameter and returns True if +there is any object that appears more than once in the list. + +Use a dictionary to write a faster, simpler version of +``has_duplicates``. Solution: +http://thinkpython2.com/code/has_duplicates.py. + +[exrotatepairs] + +Two words are “rotate pairs” if you can rotate one of them and get the +other (see ``rotate_word`` in Exercise [exrotate]). + +Write a program that reads a wordlist and finds all the rotate pairs. +Solution: http://thinkpython2.com/code/rotate_pairs.py. + +Here’s another Puzzler from *Car Talk* +(http://www.cartalk.com/content/puzzlers): + + This was sent in by a fellow named Dan O’Leary. He came upon a + common one-syllable, five-letter word recently that has the + following unique property. When you remove the first letter, the + remaining letters form a homophone of the original word, that is a + word that sounds exactly the same. Replace the first letter, that + is, put it back and remove the second letter and the result is yet + another homophone of the original word. And the question is, what’s + the word? + + Now I’m going to give you an example that doesn’t work. Let’s look + at the five-letter word, ‘wrack.’ W-R-A-C-K, you know like to ‘wrack + with pain.’ If I remove the first letter, I am left with a + four-letter word, ’R-A-C-K.’ As in, ‘Holy cow, did you see the rack + on that buck! It must have been a nine-pointer!’ It’s a perfect + homophone. If you put the ‘w’ back, and remove the ‘r,’ instead, + you’re left with the word, ‘wack,’ which is a real word, it’s just + not a homophone of the other two words. + + But there is, however, at least one word that Dan and we know of, + which will yield two homophones if you remove either of the first + two letters to make two, new four-letter words. The question is, + what’s the word? + +You can use the dictionary from Exercise [wordlist2] to check whether a +string is in the word list. + +To check whether two words are homophones, you can use the CMU +Pronouncing Dictionary. You can download it from +http://www.speech.cs.cmu.edu/cgi-bin/cmudict or from +http://thinkpython2.com/code/c06d and you can also download +http://thinkpython2.com/code/pronounce.py, which provides a function +named ``read_dictionary`` that reads the pronouncing dictionary and +returns a Python dictionary that maps from each word to a string that +describes its primary pronunciation. + +Write a program that lists all the words that solve the Puzzler. +Solution: http://thinkpython2.com/code/homophone.py. diff --git a/book/12-tuple.rst b/book/12-tuple.rst new file mode 100644 index 0000000..7c6ed2b --- /dev/null +++ b/book/12-tuple.rst @@ -0,0 +1,660 @@ +Tuples +====== + +This chapter presents one more built-in type, the tuple, and then shows +how lists, dictionaries, and tuples work together. I also present a +useful feature for variable-length argument lists, the gather and +scatter operators. + +One note: there is no consensus on how to pronounce “tuple”. Some people +say “tuh-ple”, which rhymes with “supple”. But in the context of +programming, most people say “too-ple”, which rhymes with “quadruple”. + +Tuples are immutable +-------------------- + +A tuple is a sequence of values. The values can be any type, and they +are indexed by integers, so in that respect tuples are a lot like lists. +The important difference is that tuples are immutable. + +Syntactically, a tuple is a comma-separated list of values: + +:: + + >>> t = 'a', 'b', 'c', 'd', 'e' + +Although it is not necessary, it is common to enclose tuples in +parentheses: + +:: + + >>> t = ('a', 'b', 'c', 'd', 'e') + +To create a tuple with a single element, you have to include a final +comma: + +:: + + >>> t1 = 'a', + >>> type(t1) + + +A value in parentheses is not a tuple: + +:: + + >>> t2 = ('a') + >>> type(t2) + + +Another way to create a tuple is the built-in function tuple. With no +argument, it creates an empty tuple: + +:: + + >>> t = tuple() + >>> t + () + +If the argument is a sequence (string, list or tuple), the result is a +tuple with the elements of the sequence: + +:: + + >>> t = tuple('lupins') + >>> t + ('l', 'u', 'p', 'i', 'n', 's') + +Because tuple is the name of a built-in function, you should avoid using +it as a variable name. + +Most list operators also work on tuples. The bracket operator indexes an +element: + +:: + + >>> t = ('a', 'b', 'c', 'd', 'e') + >>> t[0] + 'a' + +And the slice operator selects a range of elements. + +:: + + >>> t[1:3] + ('b', 'c') + +But if you try to modify one of the elements of the tuple, you get an +error: + +:: + + >>> t[0] = 'A' + TypeError: object doesn't support item assignment + +Because tuples are immutable, you can’t modify the elements. But you can +replace one tuple with another: + +:: + + >>> t = ('A',) + t[1:] + >>> t + ('A', 'b', 'c', 'd', 'e') + +This statement makes a new tuple and then makes t refer to it. + +The relational operators work with tuples and other sequences; Python +starts by comparing the first element from each sequence. If they are +equal, it goes on to the next elements, and so on, until it finds +elements that differ. Subsequent elements are not considered (even if +they are really big). + +:: + + >>> (0, 1, 2) < (0, 3, 4) + True + >>> (0, 1, 2000000) < (0, 3, 4) + True + +Tuple assignment +---------------- + +It is often useful to swap the values of two variables. With +conventional assignments, you have to use a temporary variable. For +example, to swap a and b: + +:: + + >>> temp = a + >>> a = b + >>> b = temp + +This solution is cumbersome; **tuple assignment** is more elegant: + +:: + + >>> a, b = b, a + +The left side is a tuple of variables; the right side is a tuple of +expressions. Each value is assigned to its respective variable. All the +expressions on the right side are evaluated before any of the +assignments. + +The number of variables on the left and the number of values on the +right have to be the same: + +:: + + >>> a, b = 1, 2, 3 + ValueError: too many values to unpack + +More generally, the right side can be any kind of sequence (string, list +or tuple). For example, to split an email address into a user name and a +domain, you could write: + +:: + + >>> addr = 'monty@python.org' + >>> uname, domain = addr.split('@') + +The return value from split is a list with two elements; the first +element is assigned to uname, the second to domain. + +:: + + >>> uname + 'monty' + >>> domain + 'python.org' + +Tuples as return values +----------------------- + +Strictly speaking, a function can only return one value, but if the +value is a tuple, the effect is the same as returning multiple values. +For example, if you want to divide two integers and compute the quotient +and remainder, it is inefficient to compute x/y and then x%y. It is +better to compute them both at the same time. + +The built-in function divmod takes two arguments and returns a tuple of +two values, the quotient and remainder. You can store the result as a +tuple: + +:: + + >>> t = divmod(7, 3) + >>> t + (2, 1) + +Or use tuple assignment to store the elements separately: + +:: + + >>> quot, rem = divmod(7, 3) + >>> quot + 2 + >>> rem + 1 + +Here is an example of a function that returns a tuple: + +:: + + def min_max(t): + return min(t), max(t) + +max and min are built-in functions that find the largest and smallest +elements of a sequence. ``min_max`` computes both and returns a tuple of +two values. + +Variable-length argument tuples +------------------------------- + +Functions can take a variable number of arguments. A parameter name that +begins with **gathers** arguments into a tuple. For example, printall +takes any number of arguments and prints them: + +:: + + def printall(*args): + print(args) + +The gather parameter can have any name you like, but args is +conventional. Here’s how the function works: + +:: + + >>> printall(1, 2.0, '3') + (1, 2.0, '3') + +The complement of gather is **scatter**. If you have a sequence of +values and you want to pass it to a function as multiple arguments, you +can use the operator. For example, divmod takes exactly two arguments; +it doesn’t work with a tuple: + +:: + + >>> t = (7, 3) + >>> divmod(t) + TypeError: divmod expected 2 arguments, got 1 + +But if you scatter the tuple, it works: + +:: + + >>> divmod(*t) + (2, 1) + +Many of the built-in functions use variable-length argument tuples. For +example, max and min can take any number of arguments: + +:: + + >>> max(1, 2, 3) + 3 + +But sum does not. + +:: + + >>> sum(1, 2, 3) + TypeError: sum expected at most 2 arguments, got 3 + +As an exercise, write a function called sumall that takes any number of +arguments and returns their sum. + +Lists and tuples +---------------- + +zip is a built-in function that takes two or more sequences and returns +a list of tuples where each tuple contains one element from each +sequence. The name of the function refers to a zipper, which joins and +interleaves two rows of teeth. + +This example zips a string and a list: + +:: + + >>> s = 'abc' + >>> t = [0, 1, 2] + >>> zip(s, t) + + +The result is a **zip object** that knows how to iterate through the +pairs. The most common use of zip is in a for loop: + +:: + + >>> for pair in zip(s, t): + ... print(pair) + ... + ('a', 0) + ('b', 1) + ('c', 2) + +A zip object is a kind of **iterator**, which is any object that +iterates through a sequence. Iterators are similar to lists in some +ways, but unlike lists, you can’t use an index to select an element from +an iterator. + +If you want to use list operators and methods, you can use a zip object +to make a list: + +:: + + >>> list(zip(s, t)) + [('a', 0), ('b', 1), ('c', 2)] + +The result is a list of tuples; in this example, each tuple contains a +character from the string and the corresponding element from the list. + +If the sequences are not the same length, the result has the length of +the shorter one. + +:: + + >>> list(zip('Anne', 'Elk')) + [('A', 'E'), ('n', 'l'), ('n', 'k')] + +You can use tuple assignment in a for loop to traverse a list of tuples: + +:: + + t = [('a', 0), ('b', 1), ('c', 2)] + for letter, number in t: + print(number, letter) + +Each time through the loop, Python selects the next tuple in the list +and assigns the elements to letter and number. The output of this loop +is: + +:: + + 0 a + 1 b + 2 c + +If you combine zip, for and tuple assignment, you get a useful idiom for +traversing two (or more) sequences at the same time. For example, +``has_match`` takes two sequences, t1 and t2, and returns True if there +is an index i such that t1[i] == t2[i]: + +:: + + def has_match(t1, t2): + for x, y in zip(t1, t2): + if x == y: + return True + return False + +If you need to traverse the elements of a sequence and their indices, +you can use the built-in function enumerate: + +:: + + for index, element in enumerate('abc'): + print(index, element) + +The result from enumerate is an enumerate object, which iterates a +sequence of pairs; each pair contains an index (starting from 0) and an +element from the given sequence. In this example, the output is + +:: + + 0 a + 1 b + 2 c + +Again. + +Dictionaries and tuples +----------------------- + +Dictionaries have a method called items that returns a sequence of +tuples, where each tuple is a key-value pair. + +:: + + >>> d = {'a':0, 'b':1, 'c':2} + >>> t = d.items() + >>> t + dict_items([('c', 2), ('a', 0), ('b', 1)]) + +The result is a ``dict_items`` object, which is an iterator that +iterates the key-value pairs. You can use it in a for loop like this: + +:: + + >>> for key, value in d.items(): + ... print(key, value) + ... + c 2 + a 0 + b 1 + +As you should expect from a dictionary, the items are in no particular +order. + +Going in the other direction, you can use a list of tuples to initialize +a new dictionary: + +:: + + >>> t = [('a', 0), ('c', 2), ('b', 1)] + >>> d = dict(t) + >>> d + {'a': 0, 'c': 2, 'b': 1} + +Combining dict with zip yields a concise way to create a dictionary: + +:: + + >>> d = dict(zip('abc', range(3))) + >>> d + {'a': 0, 'c': 2, 'b': 1} + +The dictionary method update also takes a list of tuples and adds them, +as key-value pairs, to an existing dictionary. + +It is common to use tuples as keys in dictionaries (primarily because +you can’t use lists). For example, a telephone directory might map from +last-name, first-name pairs to telephone numbers. Assuming that we have +defined last, first and number, we could write: + +:: + + directory[last, first] = number + +The expression in brackets is a tuple. We could use tuple assignment to +traverse this dictionary. + +:: + + for last, first in directory: + print(first, last, directory[last,first]) + +This loop traverses the keys in directory, which are tuples. It assigns +the elements of each tuple to last and first, then prints the name and +corresponding telephone number. + +There are two ways to represent tuples in a state diagram. The more +detailed version shows the indices and elements just as they appear in a +list. For example, the tuple ``('Cleese', 'John')`` would appear as in +Figure [fig.tuple1]. + +.. figure:: figs/tuple1.pdf + :alt: State diagram. + + State diagram. + +But in a larger diagram you might want to leave out the details. For +example, a diagram of the telephone directory might appear as in +Figure [fig.dict2]. + +.. figure:: figs/dict2.pdf + :alt: State diagram. + + State diagram. + +Here the tuples are shown using Python syntax as a graphical shorthand. +The telephone number in the diagram is the complaints line for the BBC, +so please don’t call it. + +Sequences of sequences +---------------------- + +I have focused on lists of tuples, but almost all of the examples in +this chapter also work with lists of lists, tuples of tuples, and tuples +of lists. To avoid enumerating the possible combinations, it is +sometimes easier to talk about sequences of sequences. + +In many contexts, the different kinds of sequences (strings, lists and +tuples) can be used interchangeably. So how should you choose one over +the others? + +To start with the obvious, strings are more limited than other sequences +because the elements have to be characters. They are also immutable. If +you need the ability to change the characters in a string (as opposed to +creating a new string), you might want to use a list of characters +instead. + +Lists are more common than tuples, mostly because they are mutable. But +there are a few cases where you might prefer tuples: + +#. In some contexts, like a return statement, it is syntactically + simpler to create a tuple than a list. + +#. If you want to use a sequence as a dictionary key, you have to use an + immutable type like a tuple or string. + +#. If you are passing a sequence as an argument to a function, using + tuples reduces the potential for unexpected behavior due to aliasing. + +Because tuples are immutable, they don’t provide methods like sort and +reverse, which modify existing lists. But Python provides the built-in +function sorted, which takes any sequence and returns a new list with +the same elements in sorted order, and reversed, which takes a sequence +and returns an iterator that traverses the list in reverse order. + +Debugging +--------- + +Lists, dictionaries and tuples are examples of **data structures**; in +this chapter we are starting to see compound data structures, like lists +of tuples, or dictionaries that contain tuples as keys and lists as +values. Compound data structures are useful, but they are prone to what +I call **shape errors**; that is, errors caused when a data structure +has the wrong type, size, or structure. For example, if you are +expecting a list with one integer and I give you a plain old integer +(not in a list), it won’t work. + +To help debug these kinds of errors, I have written a module called +structshape that provides a function, also called structshape, that +takes any kind of data structure as an argument and returns a string +that summarizes its shape. You can download it from +http://thinkpython2.com/code/structshape.py + +Here’s the result for a simple list: + +:: + + >>> from structshape import structshape + >>> t = [1, 2, 3] + >>> structshape(t) + 'list of 3 int' + +A fancier program might write “list of 3 int\ *s*”, but it was easier +not to deal with plurals. Here’s a list of lists: + +:: + + >>> t2 = [[1,2], [3,4], [5,6]] + >>> structshape(t2) + 'list of 3 list of 2 int' + +If the elements of the list are not the same type, structshape groups +them, in order, by type: + +:: + + >>> t3 = [1, 2, 3, 4.0, '5', '6', [7], [8], 9] + >>> structshape(t3) + 'list of (3 int, float, 2 str, 2 list of int, int)' + +Here’s a list of tuples: + +:: + + >>> s = 'abc' + >>> lt = list(zip(t, s)) + >>> structshape(lt) + 'list of 3 tuple of (int, str)' + +And here’s a dictionary with 3 items that map integers to strings. + +:: + + >>> d = dict(lt) + >>> structshape(d) + 'dict of 3 int->str' + +If you are having trouble keeping track of your data structures, +structshape can help. + +.. _glossary12: + +Glossary +-------- + +.. include:: glossary/12.txt + + +Exercises +--------- + +Write a function called ``most_frequent`` that takes a string and prints +the letters in decreasing order of frequency. Find text samples from +several different languages and see how letter frequency varies between +languages. Compare your results with the tables at +http://en.wikipedia.org/wiki/Letter_frequencies. Solution: +http://thinkpython2.com/code/most_frequent.py. + +[anagrams] + +More anagrams! + +#. Write a program that reads a word list from a file (see + Section [wordlist]) and prints all the sets of words that are + anagrams. + + Here is an example of what the output might look like: + + :: + + ['deltas', 'desalt', 'lasted', 'salted', 'slated', 'staled'] + ['retainers', 'ternaries'] + ['generating', 'greatening'] + ['resmelts', 'smelters', 'termless'] + + Hint: you might want to build a dictionary that maps from a + collection of letters to a list of words that can be spelled with + those letters. The question is, how can you represent the collection + of letters in a way that can be used as a key? + +#. Modify the previous program so that it prints the longest list of + anagrams first, followed by the second longest, and so on. + +#. In Scrabble a “bingo” is when you play all seven tiles in your rack, + along with a letter on the board, to form an eight-letter word. What + collection of 8 letters forms the most possible bingos? Hint: there + are seven. + + Solution: http://thinkpython2.com/code/anagram_sets.py. + +Two words form a “metathesis pair” if you can transform one into the +other by swapping two letters; for example, “converse” and “conserve”. +Write a program that finds all of the metathesis pairs in the +dictionary. Hint: don’t test all pairs of words, and don’t test all +possible swaps. Solution: http://thinkpython2.com/code/metathesis.py. +Credit: This exercise is inspired by an example at http://puzzlers.org. + +Here’s another Car Talk Puzzler +(http://www.cartalk.com/content/puzzlers): + + What is the longest English word, that remains a valid English word, + as you remove its letters one at a time? + + Now, letters can be removed from either end, or the middle, but you + can’t rearrange any of the letters. Every time you drop a letter, + you wind up with another English word. If you do that, you’re + eventually going to wind up with one letter and that too is going to + be an English word—one that’s found in the dictionary. I want to + know what’s the longest word and how many letters does it have? + + I’m going to give you a little modest example: Sprite. Ok? You start + off with sprite, you take a letter off, one from the interior of the + word, take the r away, and we’re left with the word spite, then we + take the e off the end, we’re left with spit, we take the s off, + we’re left with pit, it, and I. + +Write a program to find all words that can be reduced in this way, and +then find the longest one. + +This exercise is a little more challenging than most, so here are some +suggestions: + +#. You might want to write a function that takes a word and computes a + list of all the words that can be formed by removing one letter. + These are the “children” of the word. + +#. Recursively, a word is reducible if any of its children are + reducible. As a base case, you can consider the empty string + reducible. + +#. The wordlist I provided, words.txt, doesn’t contain single letter + words. So you might want to add “I”, “a”, and the empty string. + +#. To improve the performance of your program, you might want to memoize + the words that are known to be reducible. + +Solution: http://thinkpython2.com/code/reducible.py. diff --git a/book/13-case-struct.rst b/book/13-case-struct.rst new file mode 100644 index 0000000..cf4717e --- /dev/null +++ b/book/13-case-struct.rst @@ -0,0 +1,668 @@ +Case study: data structure selection +==================================== + +At this point you have learned about Python’s core data structures, and +you have seen some of the algorithms that use them. If you would like to +know more about algorithms, this might be a good time to read +Chapter [algorithms]. But you don’t have to read it before you go on; +you can read it whenever you are interested. + +This chapter presents a case study with exercises that let you think +about choosing data structures and practice using them. + +Word frequency analysis +----------------------- + +As usual, you should at least attempt the exercises before you read my +solutions. + +Write a program that reads a file, breaks each line into words, strips +whitespace and punctuation from the words, and converts them to +lowercase. + +Hint: The string module provides a string named whitespace, which +contains space, tab, newline, etc., and punctuation which contains the +punctuation characters. Let’s see if we can make Python swear: + +:: + + >>> import string + >>> string.punctuation + '!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~' + +Also, you might consider using the string methods strip, replace and +translate. + +Go to Project Gutenberg (http://gutenberg.org) and download your +favorite out-of-copyright book in plain text format. + +Modify your program from the previous exercise to read the book you +downloaded, skip over the header information at the beginning of the +file, and process the rest of the words as before. + +Then modify the program to count the total number of words in the book, +and the number of times each word is used. + +Print the number of different words used in the book. Compare different +books by different authors, written in different eras. Which author uses +the most extensive vocabulary? + +Modify the program from the previous exercise to print the 20 most +frequently used words in the book. + +Modify the previous program to read a word list (see Section [wordlist]) +and then print all the words in the book that are not in the word list. +How many of them are typos? How many of them are common words that +*should* be in the word list, and how many of them are really obscure? + +Random numbers +-------------- + +Given the same inputs, most computer programs generate the same outputs +every time, so they are said to be **deterministic**. Determinism is +usually a good thing, since we expect the same calculation to yield the +same result. For some applications, though, we want the computer to be +unpredictable. Games are an obvious example, but there are more. + +Making a program truly nondeterministic turns out to be difficult, but +there are ways to make it at least seem nondeterministic. One of them is +to use algorithms that generate **pseudorandom** numbers. Pseudorandom +numbers are not truly random because they are generated by a +deterministic computation, but just by looking at the numbers it is all +but impossible to distinguish them from random. + +The random module provides functions that generate pseudorandom numbers +(which I will simply call “random” from here on). + +The function random returns a random float between 0.0 and 1.0 +(including 0.0 but not 1.0). Each time you call random, you get the next +number in a long series. To see a sample, run this loop: + +:: + + import random + + for i in range(10): + x = random.random() + print(x) + +The function randint takes parameters low and high and returns an +integer between low and high (including both). + +:: + + >>> random.randint(5, 10) + 5 + >>> random.randint(5, 10) + 9 + +To choose an element from a sequence at random, you can use choice: + +:: + + >>> t = [1, 2, 3] + >>> random.choice(t) + 2 + >>> random.choice(t) + 3 + +The random module also provides functions to generate random values from +continuous distributions including Gaussian, exponential, gamma, and a +few more. + +Write a function named ``choose_from_hist`` that takes a histogram as +defined in Section [histogram] and returns a random value from the +histogram, chosen with probability in proportion to frequency. For +example, for this histogram: + +:: + + >>> t = ['a', 'a', 'b'] + >>> hist = histogram(t) + >>> hist + {'a': 2, 'b': 1} + +your function should return ``'a'`` with probability :math:`2/3` and +``'b'`` with probability :math:`1/3`. + +Word histogram +-------------- + +You should attempt the previous exercises before you go on. You can +download my solution from http://thinkpython2.com/code/analyze_book1.py. +You will also need http://thinkpython2.com/code/emma.txt. + +Here is a program that reads a file and builds a histogram of the words +in the file: + +:: + + import string + + def process_file(filename): + hist = dict() + fp = open(filename) + for line in fp: + process_line(line, hist) + return hist + + def process_line(line, hist): + line = line.replace('-', ' ') + + for word in line.split(): + word = word.strip(string.punctuation + string.whitespace) + word = word.lower() + hist[word] = hist.get(word, 0) + 1 + + hist = process_file('emma.txt') + +This program reads emma.txt, which contains the text of *Emma* by Jane +Austen. + +``process_file`` loops through the lines of the file, passing them one +at a time to ``process_line``. The histogram hist is being used as an +accumulator. + +``process_line`` uses the string method replace to replace hyphens with +spaces before using split to break the line into a list of strings. It +traverses the list of words and uses strip and lower to remove +punctuation and convert to lower case. (It is a shorthand to say that +strings are “converted”; remember that strings are immutable, so methods +like strip and lower return new strings.) + +Finally, ``process_line`` updates the histogram by creating a new item +or incrementing an existing one. + +To count the total number of words in the file, we can add up the +frequencies in the histogram: + +:: + + def total_words(hist): + return sum(hist.values()) + +The number of different words is just the number of items in the +dictionary: + +:: + + def different_words(hist): + return len(hist) + +Here is some code to print the results: + +:: + + print('Total number of words:', total_words(hist)) + print('Number of different words:', different_words(hist)) + +And the results: + +:: + + Total number of words: 161080 + Number of different words: 7214 + +Most common words +----------------- + +To find the most common words, we can make a list of tuples, where each +tuple contains a word and its frequency, and sort it. + +The following function takes a histogram and returns a list of +word-frequency tuples: + +:: + + def most_common(hist): + t = [] + for key, value in hist.items(): + t.append((value, key)) + + t.sort(reverse=True) + return t + +In each tuple, the frequency appears first, so the resulting list is +sorted by frequency. Here is a loop that prints the ten most common +words: + +:: + + t = most_common(hist) + print('The most common words are:') + for freq, word in t[:10]: + print(word, freq, sep='\t') + +I use the keyword argument sep to tell print to use a tab character as a +“separator”, rather than a space, so the second column is lined up. Here +are the results from *Emma*: + +:: + + The most common words are: + to 5242 + the 5205 + and 4897 + of 4295 + i 3191 + a 3130 + it 2529 + her 2483 + was 2400 + she 2364 + +This code can be simplified using the key parameter of the sort +function. If you are curious, you can read about it at +https://wiki.python.org/moin/HowTo/Sorting. + +Optional parameters +------------------- + +We have seen built-in functions and methods that take optional +arguments. It is possible to write programmer-defined functions with +optional arguments, too. For example, here is a function that prints the +most common words in a histogram + +:: + + def print_most_common(hist, num=10): + t = most_common(hist) + print('The most common words are:') + for freq, word in t[:num]: + print(word, freq, sep='\t') + +The first parameter is required; the second is optional. The **default +value** of num is 10. + +If you only provide one argument: + +:: + + print_most_common(hist) + +num gets the default value. If you provide two arguments: + +:: + + print_most_common(hist, 20) + +num gets the value of the argument instead. In other words, the optional +argument **overrides** the default value. + +If a function has both required and optional parameters, all the +required parameters have to come first, followed by the optional ones. + +Dictionary subtraction +---------------------- + +Finding the words from the book that are not in the word list from +words.txt is a problem you might recognize as set subtraction; that is, +we want to find all the words from one set (the words in the book) that +are not in the other (the words in the list). + +subtract takes dictionaries d1 and d2 and returns a new dictionary that +contains all the keys from d1 that are not in d2. Since we don’t really +care about the values, we set them all to None. + +:: + + def subtract(d1, d2): + res = dict() + for key in d1: + if key not in d2: + res[key] = None + return res + +To find the words in the book that are not in words.txt, we can use +``process_file`` to build a histogram for words.txt, and then subtract: + +:: + + words = process_file('words.txt') + diff = subtract(hist, words) + + print("Words in the book that aren't in the word list:") + for word in diff.keys(): + print(word, end=' ') + +Here are some of the results from *Emma*: + +:: + + Words in the book that aren't in the word list: + rencontre jane's blanche woodhouses disingenuousness + friend's venice apartment ... + +Some of these words are names and possessives. Others, like “rencontre”, +are no longer in common use. But a few are common words that should +really be in the list! + +Python provides a data structure called set that provides many common +set operations. You can read about them in Section [sets], or read the +documentation at +http://docs.python.org/3/library/stdtypes.html#types-set. + +Write a program that uses set subtraction to find words in the book that +are not in the word list. Solution: +http://thinkpython2.com/code/analyze_book2.py. + +Random words +------------ + +To choose a random word from the histogram, the simplest algorithm is to +build a list with multiple copies of each word, according to the +observed frequency, and then choose from the list: + +:: + + def random_word(h): + t = [] + for word, freq in h.items(): + t.extend([word] * freq) + + return random.choice(t) + +The expression \* freq creates a list with freq copies of the string +word. The extend method is similar to append except that the argument is +a sequence. + +This algorithm works, but it is not very efficient; each time you choose +a random word, it rebuilds the list, which is as big as the original +book. An obvious improvement is to build the list once and then make +multiple selections, but the list is still big. + +An alternative is: + +#. Use keys to get a list of the words in the book. + +#. Build a list that contains the cumulative sum of the word frequencies + (see Exercise [cumulative]). The last item in this list is the total + number of words in the book, :math:`n`. + +#. Choose a random number from 1 to :math:`n`. Use a bisection search + (See Exercise [bisection]) to find the index where the random number + would be inserted in the cumulative sum. + +#. Use the index to find the corresponding word in the word list. + +[randhist] + +Write a program that uses this algorithm to choose a random word from +the book. Solution: http://thinkpython2.com/code/analyze_book3.py. + +Markov analysis +--------------- + +If you choose words from the book at random, you can get a sense of the +vocabulary, but you probably won’t get a sentence: + +:: + + this the small regard harriet which knightley's it most things + +A series of random words seldom makes sense because there is no +relationship between successive words. For example, in a real sentence +you would expect an article like “the” to be followed by an adjective or +a noun, and probably not a verb or adverb. + +One way to measure these kinds of relationships is Markov analysis, +which characterizes, for a given sequence of words, the probability of +the words that might come next. For example, the song *Eric, the Half a +Bee* begins: + + | Half a bee, philosophically, + | Must, ipso facto, half not be. + | But half the bee has got to be + | Vis a vis, its entity. D’you see? + | But can a bee be said to be + | Or not to be an entire bee + | When half the bee is not a bee + | Due to some ancient injury? + +In this text, the phrase “half the” is always followed by the word +“bee”, but the phrase “the bee” might be followed by either “has” or +“is”. + +The result of Markov analysis is a mapping from each prefix (like “half +the” and “the bee”) to all possible suffixes (like “has” and “is”). + +Given this mapping, you can generate a random text by starting with any +prefix and choosing at random from the possible suffixes. Next, you can +combine the end of the prefix and the new suffix to form the next +prefix, and repeat. + +For example, if you start with the prefix “Half a”, then the next word +has to be “bee”, because the prefix only appears once in the text. The +next prefix is “a bee”, so the next suffix might be “philosophically”, +“be” or “due”. + +In this example the length of the prefix is always two, but you can do +Markov analysis with any prefix length. + +Markov analysis: + +#. Write a program to read a text from a file and perform Markov + analysis. The result should be a dictionary that maps from prefixes + to a collection of possible suffixes. The collection might be a list, + tuple, or dictionary; it is up to you to make an appropriate choice. + You can test your program with prefix length two, but you should + write the program in a way that makes it easy to try other lengths. + +#. Add a function to the previous program to generate random text based + on the Markov analysis. Here is an example from *Emma* with prefix + length 2: + + He was very clever, be it sweetness or be angry, ashamed or only + amused, at such a stroke. She had never thought of Hannah till + you were never meant for me?“ ”I cannot make speeches, Emma:" he + soon cut it all himself. + + For this example, I left the punctuation attached to the words. The + result is almost syntactically correct, but not quite. Semantically, + it almost makes sense, but not quite. + + What happens if you increase the prefix length? Does the random text + make more sense? + +#. Once your program is working, you might want to try a mash-up: if you + combine text from two or more books, the random text you generate + will blend the vocabulary and phrases from the sources in interesting + ways. + +Credit: This case study is based on an example from Kernighan and Pike, +*The Practice of Programming*, Addison-Wesley, 1999. + +You should attempt this exercise before you go on; then you can can +download my solution from http://thinkpython2.com/code/markov.py. You +will also need http://thinkpython2.com/code/emma.txt. + +Data structures +--------------- + +Using Markov analysis to generate random text is fun, but there is also +a point to this exercise: data structure selection. In your solution to +the previous exercises, you had to choose: + +- How to represent the prefixes. + +- How to represent the collection of possible suffixes. + +- How to represent the mapping from each prefix to the collection of + possible suffixes. + +The last one is easy: a dictionary is the obvious choice for a mapping +from keys to corresponding values. + +For the prefixes, the most obvious options are string, list of strings, +or tuple of strings. + +For the suffixes, one option is a list; another is a histogram +(dictionary). + +How should you choose? The first step is to think about the operations +you will need to implement for each data structure. For the prefixes, we +need to be able to remove words from the beginning and add to the end. +For example, if the current prefix is “Half a”, and the next word is +“bee”, you need to be able to form the next prefix, “a bee”. + +Your first choice might be a list, since it is easy to add and remove +elements, but we also need to be able to use the prefixes as keys in a +dictionary, so that rules out lists. With tuples, you can’t append or +remove, but you can use the addition operator to form a new tuple: + +:: + + def shift(prefix, word): + return prefix[1:] + (word,) + +shift takes a tuple of words, prefix, and a string, word, and forms a +new tuple that has all the words in prefix except the first, and word +added to the end. + +For the collection of suffixes, the operations we need to perform +include adding a new suffix (or increasing the frequency of an existing +one), and choosing a random suffix. + +Adding a new suffix is equally easy for the list implementation or the +histogram. Choosing a random element from a list is easy; choosing from +a histogram is harder to do efficiently (see Exercise [randhist]). + +So far we have been talking mostly about ease of implementation, but +there are other factors to consider in choosing data structures. One is +run time. Sometimes there is a theoretical reason to expect one data +structure to be faster than other; for example, I mentioned that the in +operator is faster for dictionaries than for lists, at least when the +number of elements is large. + +But often you don’t know ahead of time which implementation will be +faster. One option is to implement both of them and see which is better. +This approach is called **benchmarking**. A practical alternative is to +choose the data structure that is easiest to implement, and then see if +it is fast enough for the intended application. If so, there is no need +to go on. If not, there are tools, like the profile module, that can +identify the places in a program that take the most time. + +The other factor to consider is storage space. For example, using a +histogram for the collection of suffixes might take less space because +you only have to store each word once, no matter how many times it +appears in the text. In some cases, saving space can also make your +program run faster, and in the extreme, your program might not run at +all if you run out of memory. But for many applications, space is a +secondary consideration after run time. + +One final thought: in this discussion, I have implied that we should use +one data structure for both analysis and generation. But since these are +separate phases, it would also be possible to use one structure for +analysis and then convert to another structure for generation. This +would be a net win if the time saved during generation exceeded the time +spent in conversion. + +Debugging +--------- + +When you are debugging a program, and especially if you are working on a +hard bug, there are five things to try: + +Reading: + Examine your code, read it back to yourself, and check that it says + what you meant to say. + +Running: + Experiment by making changes and running different versions. Often + if you display the right thing at the right place in the program, + the problem becomes obvious, but sometimes you have to build + scaffolding. + +Ruminating: + Take some time to think! What kind of error is it: syntax, runtime, + or semantic? What information can you get from the error messages, + or from the output of the program? What kind of error could cause + the problem you’re seeing? What did you change last, before the + problem appeared? + +Rubberducking: + If you explain the problem to someone else, you sometimes find the + answer before you finish asking the question. Often you don’t need + the other person; you could just talk to a rubber duck. And that’s + the origin of the well-known strategy called **rubber duck + debugging**. I am not making this up; see + https://en.wikipedia.org/wiki/Rubber_duck_debugging. + +Retreating: + At some point, the best thing to do is back off, undoing recent + changes, until you get back to a program that works and that you + understand. Then you can start rebuilding. + +Beginning programmers sometimes get stuck on one of these activities and +forget the others. Each activity comes with its own failure mode. + +For example, reading your code might help if the problem is a +typographical error, but not if the problem is a conceptual +misunderstanding. If you don’t understand what your program does, you +can read it 100 times and never see the error, because the error is in +your head. + +Running experiments can help, especially if you run small, simple tests. +But if you run experiments without thinking or reading your code, you +might fall into a pattern I call “random walk programming”, which is the +process of making random changes until the program does the right thing. +Needless to say, random walk programming can take a long time. + +You have to take time to think. Debugging is like an experimental +science. You should have at least one hypothesis about what the problem +is. If there are two or more possibilities, try to think of a test that +would eliminate one of them. + +But even the best debugging techniques will fail if there are too many +errors, or if the code you are trying to fix is too big and complicated. +Sometimes the best option is to retreat, simplifying the program until +you get to something that works and that you understand. + +Beginning programmers are often reluctant to retreat because they can’t +stand to delete a line of code (even if it’s wrong). If it makes you +feel better, copy your program into another file before you start +stripping it down. Then you can copy the pieces back one at a time. + +Finding a hard bug requires reading, running, ruminating, and sometimes +retreating. If you get stuck on one of these activities, try the others. + +.. _glossary13: + +Glossary +-------- + +.. include:: glossary/13.txt + + +Exercises +--------- + +The “rank” of a word is its position in a list of words sorted by +frequency: the most common word has rank 1, the second most common has +rank 2, etc. + +Zipf’s law describes a relationship between the ranks and frequencies of +words in natural languages (http://en.wikipedia.org/wiki/Zipf's_law). +Specifically, it predicts that the frequency, :math:`f`, of the word +with rank :math:`r` is: + +.. math:: f = c r^{-s} + +where :math:`s` and :math:`c` are parameters that depend on the language +and the text. If you take the logarithm of both sides of this equation, +you get: + +.. math:: \log f = \log c - s \log r + +So if you plot log :math:`f` versus log :math:`r`, you should get a +straight line with slope :math:`-s` and intercept log :math:`c`. + +Write a program that reads a text from a file, counts word frequencies, +and prints one line for each word, in descending order of frequency, +with log :math:`f` and log :math:`r`. Use the graphing program of your +choice to plot the results and check whether they form a straight line. +Can you estimate the value of :math:`s`? + +Solution: http://thinkpython2.com/code/zipf.py. To run my solution, you +need the plotting module matplotlib. If you installed Anaconda, you +already have matplotlib; otherwise you might have to install it. diff --git a/book/14-file.rst b/book/14-file.rst new file mode 100644 index 0000000..1d0e440 --- /dev/null +++ b/book/14-file.rst @@ -0,0 +1,619 @@ +Files +===== + +This chapter introduces the idea of “persistent” programs that keep data +in permanent storage, and shows how to use different kinds of permanent +storage, like files and databases. + +Persistence +----------- + +Most of the programs we have seen so far are transient in the sense that +they run for a short time and produce some output, but when they end, +their data disappears. If you run the program again, it starts with a +clean slate. + +Other programs are **persistent**: they run for a long time (or all the +time); they keep at least some of their data in permanent storage (a +hard drive, for example); and if they shut down and restart, they pick +up where they left off. + +Examples of persistent programs are operating systems, which run pretty +much whenever a computer is on, and web servers, which run all the time, +waiting for requests to come in on the network. + +One of the simplest ways for programs to maintain their data is by +reading and writing text files. We have already seen programs that read +text files; in this chapter we will see programs that write them. + +An alternative is to store the state of the program in a database. In +this chapter I will present a simple database and a module, pickle, that +makes it easy to store program data. + +Reading and writing +------------------- + +A text file is a sequence of characters stored on a permanent medium +like a hard drive, flash memory, or CD-ROM. We saw how to open and read +a file in Section [wordlist]. + +To write a file, you have to open it with mode ``'w'`` as a second +parameter: + +:: + + >>> fout = open('output.txt', 'w') + +If the file already exists, opening it in write mode clears out the old +data and starts fresh, so be careful! If the file doesn’t exist, a new +one is created. + +open returns a file object that provides methods for working with the +file. The write method puts data into the file. + +:: + + >>> line1 = "This here's the wattle,\n" + >>> fout.write(line1) + 24 + +The return value is the number of characters that were written. The file +object keeps track of where it is, so if you call write again, it adds +the new data to the end of the file. + +:: + + >>> line2 = "the emblem of our land.\n" + >>> fout.write(line2) + 24 + +When you are done writing, you should close the file. + +:: + + >>> fout.close() + +If you don’t close the file, it gets closed for you when the program +ends. + +Format operator +--------------- + +The argument of write has to be a string, so if we want to put other +values in a file, we have to convert them to strings. The easiest way to +do that is with str: + +:: + + >>> x = 52 + >>> fout.write(str(x)) + +An alternative is to use the **format operator**, %. When applied to +integers, % is the modulus operator. But when the first operand is a +string, % is the format operator. + +The first operand is the **format string**, which contains one or more +**format sequences**, which specify how the second operand is formatted. +The result is a string. + +For example, the format sequence ``'%d'`` means that the second operand +should be formatted as a decimal integer: + +:: + + >>> camels = 42 + >>> '%d' % camels + '42' + +The result is the string ``'42'``, which is not to be confused with the +integer value 42. + +A format sequence can appear anywhere in the string, so you can embed a +value in a sentence: + +:: + + >>> 'I have spotted %d camels.' % camels + 'I have spotted 42 camels.' + +If there is more than one format sequence in the string, the second +argument has to be a tuple. Each format sequence is matched with an +element of the tuple, in order. + +The following example uses ``'%d'`` to format an integer, ``'%g'`` to +format a floating-point number, and ``'%s'`` to format a string: + +:: + + >>> 'In %d years I have spotted %g %s.' % (3, 0.1, 'camels') + 'In 3 years I have spotted 0.1 camels.' + +The number of elements in the tuple has to match the number of format +sequences in the string. Also, the types of the elements have to match +the format sequences: + +:: + + >>> '%d %d %d' % (1, 2) + TypeError: not enough arguments for format string + >>> '%d' % 'dollars' + TypeError: %d format: a number is required, not str + +In the first example, there aren’t enough elements; in the second, the +element is the wrong type. + +For more information on the format operator, see +https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting. +A more powerful alternative is the string format method, which you can +read about at +https://docs.python.org/3/library/stdtypes.html#str.format. + +Filenames and paths +------------------- + +Files are organized into **directories** (also called “folders”). Every +running program has a “current directory”, which is the default +directory for most operations. For example, when you open a file for +reading, Python looks for it in the current directory. + +The os module provides functions for working with files and directories +(“os” stands for “operating system”). os.getcwd returns the name of the +current directory: + +:: + + >>> import os + >>> cwd = os.getcwd() + >>> cwd + '/home/dinsdale' + +cwd stands for “current working directory”. The result in this example +is /home/dinsdale, which is the home directory of a user named dinsdale. + +A string like ``'/home/dinsdale'`` that identifies a file or directory +is called a **path**. + +A simple filename, like memo.txt is also considered a path, but it is a +**relative path** because it relates to the current directory. If the +current directory is /home/dinsdale, the filename memo.txt would refer +to /home/dinsdale/memo.txt. + +A path that begins with / does not depend on the current directory; it +is called an **absolute path**. To find the absolute path to a file, you +can use os.path.abspath: + +:: + + >>> os.path.abspath('memo.txt') + '/home/dinsdale/memo.txt' + +os.path provides other functions for working with filenames and paths. +For example, os.path.exists checks whether a file or directory exists: + +:: + + >>> os.path.exists('memo.txt') + True + +If it exists, os.path.isdir checks whether it’s a directory: + +:: + + >>> os.path.isdir('memo.txt') + False + >>> os.path.isdir('/home/dinsdale') + True + +Similarly, os.path.isfile checks whether it’s a file. + +os.listdir returns a list of the files (and other directories) in the +given directory: + +:: + + >>> os.listdir(cwd) + ['music', 'photos', 'memo.txt'] + +To demonstrate these functions, the following example “walks” through a +directory, prints the names of all the files, and calls itself +recursively on all the directories. + +:: + + def walk(dirname): + for name in os.listdir(dirname): + path = os.path.join(dirname, name) + + if os.path.isfile(path): + print(path) + else: + walk(path) + +os.path.join takes a directory and a file name and joins them into a +complete path. + +The os module provides a function called walk that is similar to this +one but more versatile. As an exercise, read the documentation and use +it to print the names of the files in a given directory and its +subdirectories. You can download my solution from +http://thinkpython2.com/code/walk.py. + +Catching exceptions +------------------- + +A lot of things can go wrong when you try to read and write files. If +you try to open a file that doesn’t exist, you get an IOError: + +:: + + >>> fin = open('bad_file') + IOError: [Errno 2] No such file or directory: 'bad_file' + +If you don’t have permission to access a file: + +:: + + >>> fout = open('/etc/passwd', 'w') + PermissionError: [Errno 13] Permission denied: '/etc/passwd' + +And if you try to open a directory for reading, you get + +:: + + >>> fin = open('/home') + IsADirectoryError: [Errno 21] Is a directory: '/home' + +To avoid these errors, you could use functions like os.path.exists and +os.path.isfile, but it would take a lot of time and code to check all +the possibilities (if “Errno 21” is any indication, there are at least +21 things that can go wrong). + +It is better to go ahead and try—and deal with problems if they +happen—which is exactly what the try statement does. The syntax is +similar to an if...else statement: + +:: + + try: + fin = open('bad_file') + except: + print('Something went wrong.') + +Python starts by executing the try clause. If all goes well, it skips +the except clause and proceeds. If an exception occurs, it jumps out of +the try clause and runs the except clause. + +Handling an exception with a try statement is called **catching** an +exception. In this example, the except clause prints an error message +that is not very helpful. In general, catching an exception gives you a +chance to fix the problem, or try again, or at least end the program +gracefully. + +Databases +--------- + +A **database** is a file that is organized for storing data. Many +databases are organized like a dictionary in the sense that they map +from keys to values. The biggest difference between a database and a +dictionary is that the database is on disk (or other permanent storage), +so it persists after the program ends. + +The module dbm provides an interface for creating and updating database +files. As an example, I’ll create a database that contains captions for +image files. + +Opening a database is similar to opening other files: + +:: + + >>> import dbm + >>> db = dbm.open('captions', 'c') + +The mode ``'c'`` means that the database should be created if it doesn’t +already exist. The result is a database object that can be used (for +most operations) like a dictionary. + +When you create a new item, dbm updates the database file. + +:: + + >>> db['cleese.png'] = 'Photo of John Cleese.' + +When you access one of the items, dbm reads the file: + +:: + + >>> db['cleese.png'] + b'Photo of John Cleese.' + +The result is a **bytes object**, which is why it begins with b. A bytes +object is similar to a string in many ways. When you get farther into +Python, the difference becomes important, but for now we can ignore it. + +If you make another assignment to an existing key, dbm replaces the old +value: + +:: + + >>> db['cleese.png'] = 'Photo of John Cleese doing a silly walk.' + >>> db['cleese.png'] + b'Photo of John Cleese doing a silly walk.' + +Some dictionary methods, like keys and items, don’t work with database +objects. But iteration with a for loop works: + +:: + + for key in db: + print(key, db[key]) + +As with other files, you should close the database when you are done: + +:: + + >>> db.close() + +Pickling +-------- + +A limitation of dbm is that the keys and values have to be strings or +bytes. If you try to use any other type, you get an error. + +The pickle module can help. It translates almost any type of object into +a string suitable for storage in a database, and then translates strings +back into objects. + +pickle.dumps takes an object as a parameter and returns a string +representation (dumps is short for “dump string”): + +:: + + >>> import pickle + >>> t = [1, 2, 3] + >>> pickle.dumps(t) + b'\x80\x03]q\x00(K\x01K\x02K\x03e.' + +The format isn’t obvious to human readers; it is meant to be easy for +pickle to interpret. pickle.loads (“load string”) reconstitutes the +object: + +:: + + >>> t1 = [1, 2, 3] + >>> s = pickle.dumps(t1) + >>> t2 = pickle.loads(s) + >>> t2 + [1, 2, 3] + +Although the new object has the same value as the old, it is not (in +general) the same object: + +:: + + >>> t1 == t2 + True + >>> t1 is t2 + False + +In other words, pickling and then unpickling has the same effect as +copying the object. + +You can use pickle to store non-strings in a database. In fact, this +combination is so common that it has been encapsulated in a module +called shelve. + +Pipes +----- + +Most operating systems provide a command-line interface, also known as a +**shell**. Shells usually provide commands to navigate the file system +and launch applications. For example, in Unix you can change directories +with cd, display the contents of a directory with ls, and launch a web +browser by typing (for example) firefox. + +Any program that you can launch from the shell can also be launched from +Python using a **pipe object**, which represents a running program. + +For example, the Unix command ls -l normally displays the contents of +the current directory in long format. You can launch ls with +os.popen [1]_: + +:: + + >>> cmd = 'ls -l' + >>> fp = os.popen(cmd) + +The argument is a string that contains a shell command. The return value +is an object that behaves like an open file. You can read the output +from the ls process one line at a time with readline or get the whole +thing at once with read: + +:: + + >>> res = fp.read() + +When you are done, you close the pipe like a file: + +:: + + >>> stat = fp.close() + >>> print(stat) + None + +The return value is the final status of the ls process; None means that +it ended normally (with no errors). + +For example, most Unix systems provide a command called md5sum that +reads the contents of a file and computes a “checksum”. You can read +about MD5 at http://en.wikipedia.org/wiki/Md5. This command provides an +efficient way to check whether two files have the same contents. The +probability that different contents yield the same checksum is very +small (that is, unlikely to happen before the universe collapses). + +You can use a pipe to run md5sum from Python and get the result: + +:: + + >>> filename = 'book.tex' + >>> cmd = 'md5sum ' + filename + >>> fp = os.popen(cmd) + >>> res = fp.read() + >>> stat = fp.close() + >>> print(res) + 1e0033f0ed0656636de0d75144ba32e0 book.tex + >>> print(stat) + None + +Writing modules +--------------- + +Any file that contains Python code can be imported as a module. For +example, suppose you have a file named wc.py with the following code: + +:: + + def linecount(filename): + count = 0 + for line in open(filename): + count += 1 + return count + + print(linecount('wc.py')) + +If you run this program, it reads itself and prints the number of lines +in the file, which is 7. You can also import it like this: + +:: + + >>> import wc + 7 + +Now you have a module object wc: + +:: + + >>> wc + + +The module object provides ``linecount``: + +:: + + >>> wc.linecount('wc.py') + 7 + +So that’s how you write modules in Python. + +The only problem with this example is that when you import the module it +runs the test code at the bottom. Normally when you import a module, it +defines new functions but it doesn’t run them. + +Programs that will be imported as modules often use the following idiom: + +:: + + if __name__ == '__main__': + print(linecount('wc.py')) + +``__name__`` is a built-in variable that is set when the program starts. +If the program is running as a script, ``__name__`` has the value +``'__main__'``; in that case, the test code runs. Otherwise, if the +module is being imported, the test code is skipped. + +As an exercise, type this example into a file named wc.py and run it as +a script. Then run the Python interpreter and import wc. What is the +value of ``__name__`` when the module is being imported? + +Warning: If you import a module that has already been imported, Python +does nothing. It does not re-read the file, even if it has changed. + +If you want to reload a module, you can use the built-in function +reload, but it can be tricky, so the safest thing to do is restart the +interpreter and then import the module again. + +Debugging +--------- + +When you are reading and writing files, you might run into problems with +whitespace. These errors can be hard to debug because spaces, tabs and +newlines are normally invisible: + +:: + + >>> s = '1 2\t 3\n 4' + >>> print(s) + 1 2 3 + 4 + +The built-in function repr can help. It takes any object as an argument +and returns a string representation of the object. For strings, it +represents whitespace characters with backslash sequences: + +:: + + >>> print(repr(s)) + '1 2\t 3\n 4' + +This can be helpful for debugging. + +One other problem you might run into is that different systems use +different characters to indicate the end of a line. Some systems use a +newline, represented ``\n``. Others use a return character, represented +``\r``. Some use both. If you move files between different systems, +these inconsistencies can cause problems. + +For most systems, there are applications to convert from one format to +another. You can find them (and read more about this issue) at +http://en.wikipedia.org/wiki/Newline. Or, of course, you could write one +yourself. + +.. _glossary14: + +Glossary +-------- + +.. include:: glossary/14.txt + + +Exercises +--------- + +Write a function called sed that takes as arguments a pattern string, a +replacement string, and two filenames; it should read the first file and +write the contents into the second file (creating it if necessary). If +the pattern string appears anywhere in the file, it should be replaced +with the replacement string. + +If an error occurs while opening, reading, writing or closing files, +your program should catch the exception, print an error message, and +exit. Solution: http://thinkpython2.com/code/sed.py. + +If you download my solution to Exercise [anagrams] from +http://thinkpython2.com/code/anagram_sets.py, you’ll see that it creates +a dictionary that maps from a sorted string of letters to the list of +words that can be spelled with those letters. For example, ``'opst'`` +maps to the list ``['opts', 'post', 'pots', 'spot', 'stop', 'tops']``. + +Write a module that imports ``anagram_sets`` and provides two new +functions: ``store_anagrams`` should store the anagram dictionary in a +“shelf”; ``read_anagrams`` should look up a word and return a list of +its anagrams. Solution: http://thinkpython2.com/code/anagram_db.py. + +[checksum] + +In a large collection of MP3 files, there may be more than one copy of +the same song, stored in different directories or with different file +names. The goal of this exercise is to search for duplicates. + +#. Write a program that searches a directory and all of its + subdirectories, recursively, and returns a list of complete paths for + all files with a given suffix (like .mp3). Hint: os.path provides + several useful functions for manipulating file and path names. + +#. To recognize duplicates, you can use md5sum to compute a “checksum” + for each files. If two files have the same checksum, they probably + have the same contents. + +#. To double-check, you can use the Unix command diff. + +Solution: http://thinkpython2.com/code/find_duplicates.py. diff --git a/book/15-cls-object.rst b/book/15-cls-object.rst new file mode 100644 index 0000000..0fbb920 --- /dev/null +++ b/book/15-cls-object.rst @@ -0,0 +1,460 @@ +Classes and objects +=================== + +At this point you know how to use functions to organize code and +built-in types to organize data. The next step is to learn +“object-oriented programming”, which uses programmer-defined types to +organize both code and data. Object-oriented programming is a big topic; +it will take a few chapters to get there. + +Code examples from this chapter are available from +http://thinkpython2.com/code/Point1.py; solutions to the exercises are +available from http://thinkpython2.com/code/Point1_soln.py. + +Programmer-defined types +------------------------ + +We have used many of Python’s built-in types; now we are going to define +a new type. As an example, we will create a type called Point that +represents a point in two-dimensional space. + +In mathematical notation, points are often written in parentheses with a +comma separating the coordinates. For example, :math:`(0,0)` represents +the origin, and :math:`(x,y)` represents the point :math:`x` units to +the right and :math:`y` units up from the origin. + +There are several ways we might represent points in Python: + +- We could store the coordinates separately in two variables, x and y. + +- We could store the coordinates as elements in a list or tuple. + +- We could create a new type to represent points as objects. + +Creating a new type is more complicated than the other options, but it +has advantages that will be apparent soon. + +A programmer-defined type is also called a **class**. A class definition +looks like this: + +:: + + class Point: + """Represents a point in 2-D space.""" + +The header indicates that the new class is called Point. The body is a +docstring that explains what the class is for. You can define variables +and methods inside a class definition, but we will get back to that +later. + +Defining a class named Point creates a **class object**. + +:: + + >>> Point + + +Because Point is defined at the top level, its “full name” is +``__main__.Point``. + +The class object is like a factory for creating objects. To create a +Point, you call Point as if it were a function. + +:: + + >>> blank = Point() + >>> blank + <__main__.Point object at 0xb7e9d3ac> + +The return value is a reference to a Point object, which we assign to +blank. + +Creating a new object is called **instantiation**, and the object is an +**instance** of the class. + +When you print an instance, Python tells you what class it belongs to +and where it is stored in memory (the prefix 0x means that the following +number is in hexadecimal). + +Every object is an instance of some class, so “object” and “instance” +are interchangeable. But in this chapter I use “instance” to indicate +that I am talking about a programmer-defined type. + +Attributes +---------- + +You can assign values to an instance using dot notation: + +:: + + >>> blank.x = 3.0 + >>> blank.y = 4.0 + +This syntax is similar to the syntax for selecting a variable from a +module, such as math.pi or string.whitespace. In this case, though, we +are assigning values to named elements of an object. These elements are +called **attributes**. + +As a noun, “AT-trib-ute” is pronounced with emphasis on the first +syllable, as opposed to “a-TRIB-ute”, which is a verb. + +The following diagram shows the result of these assignments. A state +diagram that shows an object and its attributes is called an **object +diagram**; see Figure [fig.point]. + +.. figure:: figs/point.pdf + :alt: Object diagram. + + Object diagram. + +The variable blank refers to a Point object, which contains two +attributes. Each attribute refers to a floating-point number. + +You can read the value of an attribute using the same syntax: + +:: + + >>> blank.y + 4.0 + >>> x = blank.x + >>> x + 3.0 + +The expression blank.x means, “Go to the object blank refers to and get +the value of x.” In the example, we assign that value to a variable +named x. There is no conflict between the variable x and the attribute +x. + +You can use dot notation as part of any expression. For example: + +:: + + >>> '(%g, %g)' % (blank.x, blank.y) + '(3.0, 4.0)' + >>> distance = math.sqrt(blank.x**2 + blank.y**2) + >>> distance + 5.0 + +You can pass an instance as an argument in the usual way. For example: + +:: + + def print_point(p): + print('(%g, %g)' % (p.x, p.y)) + +``print_point`` takes a point as an argument and displays it in +mathematical notation. To invoke it, you can pass blank as an argument: + +:: + + >>> print_point(blank) + (3.0, 4.0) + +Inside the function, p is an alias for blank, so if the function +modifies p, blank changes. + +As an exercise, write a function called ``distance_between_points`` that +takes two Points as arguments and returns the distance between them. + +Rectangles +---------- + +Sometimes it is obvious what the attributes of an object should be, but +other times you have to make decisions. For example, imagine you are +designing a class to represent rectangles. What attributes would you use +to specify the location and size of a rectangle? You can ignore angle; +to keep things simple, assume that the rectangle is either vertical or +horizontal. + +There are at least two possibilities: + +- You could specify one corner of the rectangle (or the center), the + width, and the height. + +- You could specify two opposing corners. + +At this point it is hard to say whether either is better than the other, +so we’ll implement the first one, just as an example. + +Here is the class definition: + +:: + + class Rectangle: + """Represents a rectangle. + + attributes: width, height, corner. + """ + +The docstring lists the attributes: width and height are numbers; corner +is a Point object that specifies the lower-left corner. + +To represent a rectangle, you have to instantiate a Rectangle object and +assign values to the attributes: + +:: + + box = Rectangle() + box.width = 100.0 + box.height = 200.0 + box.corner = Point() + box.corner.x = 0.0 + box.corner.y = 0.0 + +The expression box.corner.x means, “Go to the object box refers to and +select the attribute named corner; then go to that object and select the +attribute named x.” + +.. figure:: figs/rectangle.pdf + :alt: Object diagram. + + Object diagram. + +Figure [fig.rectangle] shows the state of this object. An object that is +an attribute of another object is **embedded**. + +Instances as return values +-------------------------- + +Functions can return instances. For example, ``find_center`` takes a +Rectangle as an argument and returns a Point that contains the +coordinates of the center of the Rectangle: + +:: + + def find_center(rect): + p = Point() + p.x = rect.corner.x + rect.width/2 + p.y = rect.corner.y + rect.height/2 + return p + +Here is an example that passes box as an argument and assigns the +resulting Point to center: + +:: + + >>> center = find_center(box) + >>> print_point(center) + (50, 100) + +Objects are mutable +------------------- + +You can change the state of an object by making an assignment to one of +its attributes. For example, to change the size of a rectangle without +changing its position, you can modify the values of width and height: + +:: + + box.width = box.width + 50 + box.height = box.height + 100 + +You can also write functions that modify objects. For example, +``grow_rectangle`` takes a Rectangle object and two numbers, dwidth and +dheight, and adds the numbers to the width and height of the rectangle: + +:: + + def grow_rectangle(rect, dwidth, dheight): + rect.width += dwidth + rect.height += dheight + +Here is an example that demonstrates the effect: + +:: + + >>> box.width, box.height + (150.0, 300.0) + >>> grow_rectangle(box, 50, 100) + >>> box.width, box.height + (200.0, 400.0) + +Inside the function, rect is an alias for box, so when the function +modifies rect, box changes. + +As an exercise, write a function named ``move_rectangle`` that takes a +Rectangle and two numbers named dx and dy. It should change the location +of the rectangle by adding dx to the x coordinate of corner and adding +dy to the y coordinate of corner. + +Copying +------- + +Aliasing can make a program difficult to read because changes in one +place might have unexpected effects in another place. It is hard to keep +track of all the variables that might refer to a given object. + +Copying an object is often an alternative to aliasing. The copy module +contains a function called copy that can duplicate any object: + +:: + + >>> p1 = Point() + >>> p1.x = 3.0 + >>> p1.y = 4.0 + + >>> import copy + >>> p2 = copy.copy(p1) + +p1 and p2 contain the same data, but they are not the same Point. + +:: + + >>> print_point(p1) + (3, 4) + >>> print_point(p2) + (3, 4) + >>> p1 is p2 + False + >>> p1 == p2 + False + +The is operator indicates that p1 and p2 are not the same object, which +is what we expected. But you might have expected == to yield True +because these points contain the same data. In that case, you will be +disappointed to learn that for instances, the default behavior of the == +operator is the same as the is operator; it checks object identity, not +object equivalence. That’s because for programmer-defined types, Python +doesn’t know what should be considered equivalent. At least, not yet. + +If you use copy.copy to duplicate a Rectangle, you will find that it +copies the Rectangle object but not the embedded Point. + +:: + + >>> box2 = copy.copy(box) + >>> box2 is box + False + >>> box2.corner is box.corner + True + +.. figure:: figs/rectangle2.pdf + :alt: Object diagram. + + Object diagram. + +Figure [fig.rectangle2] shows what the object diagram looks like. This +operation is called a **shallow copy** because it copies the object and +any references it contains, but not the embedded objects. + +For most applications, this is not what you want. In this example, +invoking ``grow_rectangle`` on one of the Rectangles would not affect +the other, but invoking ``move_rectangle`` on either would affect both! +This behavior is confusing and error-prone. + +Fortunately, the copy module provides a method named deepcopy that +copies not only the object but also the objects it refers to, and the +objects *they* refer to, and so on. You will not be surprised to learn +that this operation is called a **deep copy**. + +:: + + >>> box3 = copy.deepcopy(box) + >>> box3 is box + False + >>> box3.corner is box.corner + False + +box3 and box are completely separate objects. + +As an exercise, write a version of ``move_rectangle`` that creates and +returns a new Rectangle instead of modifying the old one. + +Debugging +--------- + +When you start working with objects, you are likely to encounter some +new exceptions. If you try to access an attribute that doesn’t exist, +you get an AttributeError: + +:: + + >>> p = Point() + >>> p.x = 3 + >>> p.y = 4 + >>> p.z + AttributeError: Point instance has no attribute 'z' + +If you are not sure what type an object is, you can ask: + +:: + + >>> type(p) + + +You can also use isinstance to check whether an object is an instance of +a class: + +:: + + >>> isinstance(p, Point) + True + +If you are not sure whether an object has a particular attribute, you +can use the built-in function hasattr: + +:: + + >>> hasattr(p, 'x') + True + >>> hasattr(p, 'z') + False + +The first argument can be any object; the second argument is a *string* +that contains the name of the attribute. + +You can also use a try statement to see if the object has the attributes +you need: + +:: + + try: + x = p.x + except AttributeError: + x = 0 + +This approach can make it easier to write functions that work with +different types; more on that topic is coming up in +Section [polymorphism]. + + +.. _glossary15: + +Glossary +-------- + +.. include:: glossary/15.txt + + +Exercises +--------- + +Write a definition for a class named Circle with attributes center and +radius, where center is a Point object and radius is a number. + +Instantiate a Circle object that represents a circle with its center at +:math:`(150, 100)` and radius 75. + +Write a function named ``point_in_circle`` that takes a Circle and a +Point and returns True if the Point lies in or on the boundary of the +circle. + +Write a function named ``rect_in_circle`` that takes a Circle and a +Rectangle and returns True if the Rectangle lies entirely in or on the +boundary of the circle. + +Write a function named ``rect_circle_overlap`` that takes a Circle and a +Rectangle and returns True if any of the corners of the Rectangle fall +inside the circle. Or as a more challenging version, return True if any +part of the Rectangle falls inside the circle. + +Solution: http://thinkpython2.com/code/Circle.py. + +Write a function called ``draw_rect`` that takes a Turtle object and a +Rectangle and uses the Turtle to draw the Rectangle. See +Chapter [turtlechap] for examples using Turtle objects. + +Write a function called ``draw_circle`` that takes a Turtle and a Circle +and draws the Circle. + +Solution: http://thinkpython2.com/code/draw.py. diff --git a/book/16-cls-fn.rst b/book/16-cls-fn.rst new file mode 100644 index 0000000..96d6de9 --- /dev/null +++ b/book/16-cls-fn.rst @@ -0,0 +1,360 @@ +Classes and functions +===================== + +Now that we know how to create new types, the next step is to write +functions that take programmer-defined objects as parameters and return +them as results. In this chapter I also present “functional programming +style” and two new program development plans. + +Code examples from this chapter are available from +http://thinkpython2.com/code/Time1.py. Solutions to the exercises are at +http://thinkpython2.com/code/Time1_soln.py. + +Time +---- + +As another example of a programmer-defined type, we’ll define a class +called Time that records the time of day. The class definition looks +like this: + +:: + + class Time: + """Represents the time of day. + + attributes: hour, minute, second + """ + +We can create a new Time object and assign attributes for hours, +minutes, and seconds: + +:: + + time = Time() + time.hour = 11 + time.minute = 59 + time.second = 30 + +The state diagram for the Time object looks like Figure [fig.time]. + +As an exercise, write a function called ``print_time`` that takes a Time +object and prints it in the form hour:minute:second. Hint: the format +sequence ``'%.2d'`` prints an integer using at least two digits, +including a leading zero if necessary. + +Write a boolean function called ``is_after`` that takes two Time +objects, t1 and t2, and returns True if t1 follows t2 chronologically +and False otherwise. Challenge: don’t use an if statement. + +.. figure:: figs/time.pdf + :alt: Object diagram. + + Object diagram. + +Pure functions +-------------- + +In the next few sections, we’ll write two functions that add time +values. They demonstrate two kinds of functions: pure functions and +modifiers. They also demonstrate a development plan I’ll call +**prototype and patch**, which is a way of tackling a complex problem by +starting with a simple prototype and incrementally dealing with the +complications. + +Here is a simple prototype of ``add_time``: + +:: + + def add_time(t1, t2): + sum = Time() + sum.hour = t1.hour + t2.hour + sum.minute = t1.minute + t2.minute + sum.second = t1.second + t2.second + return sum + +The function creates a new Time object, initializes its attributes, and +returns a reference to the new object. This is called a **pure +function** because it does not modify any of the objects passed to it as +arguments and it has no effect, like displaying a value or getting user +input, other than returning a value. + +To test this function, I’ll create two Time objects: start contains the +start time of a movie, like *Monty Python and the Holy Grail*, and +duration contains the run time of the movie, which is one hour 35 +minutes. + +``add_time`` figures out when the movie will be done. + +:: + + >>> start = Time() + >>> start.hour = 9 + >>> start.minute = 45 + >>> start.second = 0 + + >>> duration = Time() + >>> duration.hour = 1 + >>> duration.minute = 35 + >>> duration.second = 0 + + >>> done = add_time(start, duration) + >>> print_time(done) + 10:80:00 + +The result, 10:80:00 might not be what you were hoping for. The problem +is that this function does not deal with cases where the number of +seconds or minutes adds up to more than sixty. When that happens, we +have to “carry” the extra seconds into the minute column or the extra +minutes into the hour column. + +Here’s an improved version: + +:: + + def add_time(t1, t2): + sum = Time() + sum.hour = t1.hour + t2.hour + sum.minute = t1.minute + t2.minute + sum.second = t1.second + t2.second + + if sum.second >= 60: + sum.second -= 60 + sum.minute += 1 + + if sum.minute >= 60: + sum.minute -= 60 + sum.hour += 1 + + return sum + +Although this function is correct, it is starting to get big. We will +see a shorter alternative later. + +Modifiers +--------- + +Sometimes it is useful for a function to modify the objects it gets as +parameters. In that case, the changes are visible to the caller. +Functions that work this way are called **modifiers**. + +increment, which adds a given number of seconds to a Time object, can be +written naturally as a modifier. Here is a rough draft: + +:: + + def increment(time, seconds): + time.second += seconds + + if time.second >= 60: + time.second -= 60 + time.minute += 1 + + if time.minute >= 60: + time.minute -= 60 + time.hour += 1 + +The first line performs the basic operation; the remainder deals with +the special cases we saw before. + +Is this function correct? What happens if seconds is much greater than +sixty? + +In that case, it is not enough to carry once; we have to keep doing it +until time.second is less than sixty. One solution is to replace the if +statements with while statements. That would make the function correct, +but not very efficient. As an exercise, write a correct version of +increment that doesn’t contain any loops. + +Anything that can be done with modifiers can also be done with pure +functions. In fact, some programming languages only allow pure +functions. There is some evidence that programs that use pure functions +are faster to develop and less error-prone than programs that use +modifiers. But modifiers are convenient at times, and functional +programs tend to be less efficient. + +In general, I recommend that you write pure functions whenever it is +reasonable and resort to modifiers only if there is a compelling +advantage. This approach might be called a **functional programming +style**. + +As an exercise, write a “pure” version of increment that creates and +returns a new Time object rather than modifying the parameter. + +Prototyping versus planning +--------------------------- + +The development plan I am demonstrating is called “prototype and patch”. +For each function, I wrote a prototype that performed the basic +calculation and then tested it, patching errors along the way. + +This approach can be effective, especially if you don’t yet have a deep +understanding of the problem. But incremental corrections can generate +code that is unnecessarily complicated—since it deals with many special +cases—and unreliable—since it is hard to know if you have found all the +errors. + +An alternative is **designed development**, in which high-level insight +into the problem can make the programming much easier. In this case, the +insight is that a Time object is really a three-digit number in base 60 +(see http://en.wikipedia.org/wiki/Sexagesimal.)! The second attribute is +the “ones column”, the minute attribute is the “sixties column”, and the +hour attribute is the “thirty-six hundreds column”. + +When we wrote ``add_time`` and increment, we were effectively doing +addition in base 60, which is why we had to carry from one column to the +next. + +This observation suggests another approach to the whole problem—we can +convert Time objects to integers and take advantage of the fact that the +computer knows how to do integer arithmetic. + +Here is a function that converts Times to integers: + +:: + + def time_to_int(time): + minutes = time.hour * 60 + time.minute + seconds = minutes * 60 + time.second + return seconds + +And here is a function that converts an integer to a Time (recall that +divmod divides the first argument by the second and returns the quotient +and remainder as a tuple). + +:: + + def int_to_time(seconds): + time = Time() + minutes, time.second = divmod(seconds, 60) + time.hour, time.minute = divmod(minutes, 60) + return time + +You might have to think a bit, and run some tests, to convince yourself +that these functions are correct. One way to test them is to check that +``time_to_int(int_to_time(x)) == x`` for many values of x. This is an +example of a consistency check. + +Once you are convinced they are correct, you can use them to rewrite +``add_time``: + +:: + + def add_time(t1, t2): + seconds = time_to_int(t1) + time_to_int(t2) + return int_to_time(seconds) + +This version is shorter than the original, and easier to verify. As an +exercise, rewrite increment using ``time_to_int`` and ``int_to_time``. + +In some ways, converting from base 60 to base 10 and back is harder than +just dealing with times. Base conversion is more abstract; our intuition +for dealing with time values is better. + +But if we have the insight to treat times as base 60 numbers and make +the investment of writing the conversion functions (``time_to_int`` and +``int_to_time``), we get a program that is shorter, easier to read and +debug, and more reliable. + +It is also easier to add features later. For example, imagine +subtracting two Times to find the duration between them. The naive +approach would be to implement subtraction with borrowing. Using the +conversion functions would be easier and more likely to be correct. + +Ironically, sometimes making a problem harder (or more general) makes it +easier (because there are fewer special cases and fewer opportunities +for error). + +Debugging +--------- + +A Time object is well-formed if the values of minute and second are +between 0 and 60 (including 0 but not 60) and if hour is positive. hour +and minute should be integral values, but we might allow second to have +a fraction part. + +Requirements like these are called **invariants** because they should +always be true. To put it a different way, if they are not true, +something has gone wrong. + +Writing code to check invariants can help detect errors and find their +causes. For example, you might have a function like ``valid_time`` that +takes a Time object and returns False if it violates an invariant: + +:: + + def valid_time(time): + if time.hour < 0 or time.minute < 0 or time.second < 0: + return False + if time.minute >= 60 or time.second >= 60: + return False + return True + +At the beginning of each function you could check the arguments to make +sure they are valid: + +:: + + def add_time(t1, t2): + if not valid_time(t1) or not valid_time(t2): + raise ValueError('invalid Time object in add_time') + seconds = time_to_int(t1) + time_to_int(t2) + return int_to_time(seconds) + +Or you could use an **assert statement**, which checks a given invariant +and raises an exception if it fails: + +:: + + def add_time(t1, t2): + assert valid_time(t1) and valid_time(t2) + seconds = time_to_int(t1) + time_to_int(t2) + return int_to_time(seconds) + +assert statements are useful because they distinguish code that deals +with normal conditions from code that checks for errors. + +.. _glossary16: + +Glossary +-------- + +.. include:: glossary/16.txt + + +Exercises +--------- + +Code examples from this chapter are available from +http://thinkpython2.com/code/Time1.py; solutions to the exercises are +available from http://thinkpython2.com/code/Time1_soln.py. + +Write a function called ``mul_time`` that takes a Time object and a +number and returns a new Time object that contains the product of the +original Time and the number. + +Then use ``mul_time`` to write a function that takes a Time object that +represents the finishing time in a race, and a number that represents +the distance, and returns a Time object that represents the average pace +(time per mile). + +The datetime module provides time objects that are similar to the Time +objects in this chapter, but they provide a rich set of methods and +operators. Read the documentation at +http://docs.python.org/3/library/datetime.html. + +#. Use the datetime module to write a program that gets the current date + and prints the day of the week. + +#. Write a program that takes a birthday as input and prints the user’s + age and the number of days, hours, minutes and seconds until their + next birthday. + +#. For two people born on different days, there is a day when one is + twice as old as the other. That’s their Double Day. Write a program + that takes two birthdays and computes their Double Day. + +#. For a little more challenge, write the more general version that + computes the day when one person is :math:`n` times older than the + other. + +Solution: http://thinkpython2.com/code/double.py diff --git a/book/17-cls-meth.rst b/book/17-cls-meth.rst new file mode 100644 index 0000000..860e0bb --- /dev/null +++ b/book/17-cls-meth.rst @@ -0,0 +1,623 @@ +Classes and methods +=================== + +Although we are using some of Python’s object-oriented features, the +programs from the last two chapters are not really object-oriented +because they don’t represent the relationships between +programmer-defined types and the functions that operate on them. The +next step is to transform those functions into methods that make the +relationships explicit. + +Code examples from this chapter are available from +http://thinkpython2.com/code/Time2.py, and solutions to the exercises +are in http://thinkpython2.com/code/Point2_soln.py. + +Object-oriented features +------------------------ + +Python is an **object-oriented programming language**, which means that +it provides features that support object-oriented programming, which has +these defining characteristics: + +- Programs include class and method definitions. + +- Most of the computation is expressed in terms of operations on + objects. + +- Objects often represent things in the real world, and methods often + correspond to the ways things in the real world interact. + +For example, the Time class defined in Chapter [time] corresponds to the +way people record the time of day, and the functions we defined +correspond to the kinds of things people do with times. Similarly, the +Point and Rectangle classes in Chapter [clobjects] correspond to the +mathematical concepts of a point and a rectangle. + +So far, we have not taken advantage of the features Python provides to +support object-oriented programming. These features are not strictly +necessary; most of them provide alternative syntax for things we have +already done. But in many cases, the alternative is more concise and +more accurately conveys the structure of the program. + +For example, in Time1.py there is no obvious connection between the +class definition and the function definitions that follow. With some +examination, it is apparent that every function takes at least one Time +object as an argument. + +This observation is the motivation for **methods**; a method is a +function that is associated with a particular class. We have seen +methods for strings, lists, dictionaries and tuples. In this chapter, we +will define methods for programmer-defined types. + +Methods are semantically the same as functions, but there are two +syntactic differences: + +- Methods are defined inside a class definition in order to make the + relationship between the class and the method explicit. + +- The syntax for invoking a method is different from the syntax for + calling a function. + +In the next few sections, we will take the functions from the previous +two chapters and transform them into methods. This transformation is +purely mechanical; you can do it by following a sequence of steps. If +you are comfortable converting from one form to another, you will be +able to choose the best form for whatever you are doing. + +Printing objects +---------------- + +In Chapter [time], we defined a class named Time and in +Section [isafter], you wrote a function named ``print_time``: + +:: + + class Time: + """Represents the time of day.""" + + def print_time(time): + print('%.2d:%.2d:%.2d' % (time.hour, time.minute, time.second)) + +To call this function, you have to pass a Time object as an argument: + +:: + + >>> start = Time() + >>> start.hour = 9 + >>> start.minute = 45 + >>> start.second = 00 + >>> print_time(start) + 09:45:00 + +To make ``print_time`` a method, all we have to do is move the function +definition inside the class definition. Notice the change in +indentation. + +:: + + class Time: + def print_time(time): + print('%.2d:%.2d:%.2d' % (time.hour, time.minute, time.second)) + +Now there are two ways to call ``print_time``. The first (and less +common) way is to use function syntax: + +:: + + >>> Time.print_time(start) + 09:45:00 + +In this use of dot notation, Time is the name of the class, and +``print_time`` is the name of the method. start is passed as a +parameter. + +The second (and more concise) way is to use method syntax: + +:: + + >>> start.print_time() + 09:45:00 + +In this use of dot notation, ``print_time`` is the name of the method +(again), and start is the object the method is invoked on, which is +called the **subject**. Just as the subject of a sentence is what the +sentence is about, the subject of a method invocation is what the method +is about. + +Inside the method, the subject is assigned to the first parameter, so in +this case start is assigned to time. + +By convention, the first parameter of a method is called self, so it +would be more common to write ``print_time`` like this: + +:: + + class Time: + def print_time(self): + print('%.2d:%.2d:%.2d' % (self.hour, self.minute, self.second)) + +The reason for this convention is an implicit metaphor: + +- The syntax for a function call, ``print_time(start)``, suggests that + the function is the active agent. It says something like, “Hey + ``print_time``! Here’s an object for you to print.” + +- In object-oriented programming, the objects are the active agents. A + method invocation like ``start.print_time()`` says “Hey start! Please + print yourself.” + +This change in perspective might be more polite, but it is not obvious +that it is useful. In the examples we have seen so far, it may not be. +But sometimes shifting responsibility from the functions onto the +objects makes it possible to write more versatile functions (or +methods), and makes it easier to maintain and reuse code. + +As an exercise, rewrite ``time_to_int`` (from Section [prototype]) as a +method. You might be tempted to rewrite ``int_to_time`` as a method, +too, but that doesn’t really make sense because there would be no object +to invoke it on. + +Another example +--------------- + +Here’s a version of increment (from Section [increment]) rewritten as a +method: + +:: + + # inside class Time: + + def increment(self, seconds): + seconds += self.time_to_int() + return int_to_time(seconds) + +This version assumes that ``time_to_int`` is written as a method. Also, +note that it is a pure function, not a modifier. + +Here’s how you would invoke increment: + +:: + + >>> start.print_time() + 09:45:00 + >>> end = start.increment(1337) + >>> end.print_time() + 10:07:17 + +The subject, start, gets assigned to the first parameter, self. The +argument, 1337, gets assigned to the second parameter, seconds. + +This mechanism can be confusing, especially if you make an error. For +example, if you invoke increment with two arguments, you get: + +:: + + >>> end = start.increment(1337, 460) + TypeError: increment() takes 2 positional arguments but 3 were given + +The error message is initially confusing, because there are only two +arguments in parentheses. But the subject is also considered an +argument, so all together that’s three. + +By the way, a **positional argument** is an argument that doesn’t have a +parameter name; that is, it is not a keyword argument. In this function +call: + +:: + + sketch(parrot, cage, dead=True) + +parrot and cage are positional, and dead is a keyword argument. + +A more complicated example +-------------------------- + +Rewriting ``is_after`` (from Section [isafter]) is slightly more +complicated because it takes two Time objects as parameters. In this +case it is conventional to name the first parameter self and the second +parameter other: + +:: + + # inside class Time: + + def is_after(self, other): + return self.time_to_int() > other.time_to_int() + +To use this method, you have to invoke it on one object and pass the +other as an argument: + +:: + + >>> end.is_after(start) + True + +One nice thing about this syntax is that it almost reads like English: +“end is after start?” + +The init method +--------------- + +The init method (short for “initialization”) is a special method that +gets invoked when an object is instantiated. Its full name is +``__init__`` (two underscore characters, followed by init, and then two +more underscores). An init method for the Time class might look like +this: + +:: + + # inside class Time: + + def __init__(self, hour=0, minute=0, second=0): + self.hour = hour + self.minute = minute + self.second = second + +It is common for the parameters of ``__init__`` to have the same names +as the attributes. The statement + +:: + + self.hour = hour + +stores the value of the parameter hour as an attribute of self. + +The parameters are optional, so if you call Time with no arguments, you +get the default values. + +:: + + >>> time = Time() + >>> time.print_time() + 00:00:00 + +If you provide one argument, it overrides hour: + +:: + + >>> time = Time (9) + >>> time.print_time() + 09:00:00 + +If you provide two arguments, they override hour and minute. + +:: + + >>> time = Time(9, 45) + >>> time.print_time() + 09:45:00 + +And if you provide three arguments, they override all three default +values. + +As an exercise, write an init method for the Point class that takes x +and y as optional parameters and assigns them to the corresponding +attributes. + +The \_\_str\_\_ method +---------------------- + +``__str__`` is a special method, like ``__init__``, that is supposed to +return a string representation of an object. + +For example, here is a str method for Time objects: + +:: + + # inside class Time: + + def __str__(self): + return '%.2d:%.2d:%.2d' % (self.hour, self.minute, self.second) + +When you print an object, Python invokes the str method: + +:: + + >>> time = Time(9, 45) + >>> print(time) + 09:45:00 + +When I write a new class, I almost always start by writing ``__init__``, +which makes it easier to instantiate objects, and ``__str__``, which is +useful for debugging. + +As an exercise, write a str method for the Point class. Create a Point +object and print it. + +Operator overloading +-------------------- + +By defining other special methods, you can specify the behavior of +operators on programmer-defined types. For example, if you define a +method named ``__add__`` for the Time class, you can use the + operator +on Time objects. + +Here is what the definition might look like: + +:: + + # inside class Time: + + def __add__(self, other): + seconds = self.time_to_int() + other.time_to_int() + return int_to_time(seconds) + +And here is how you could use it: + +:: + + >>> start = Time(9, 45) + >>> duration = Time(1, 35) + >>> print(start + duration) + 11:20:00 + +When you apply the + operator to Time objects, Python invokes +``__add__``. When you print the result, Python invokes ``__str__``. So +there is a lot happening behind the scenes! + +Changing the behavior of an operator so that it works with +programmer-defined types is called **operator overloading**. For every +operator in Python there is a corresponding special method, like +``__add__``. For more details, see +http://docs.python.org/3/reference/datamodel.html#specialnames. + +As an exercise, write an add method for the Point class. + +Type-based dispatch +------------------- + +In the previous section we added two Time objects, but you also might +want to add an integer to a Time object. The following is a version of +``__add__`` that checks the type of other and invokes either +``add_time`` or increment: + +:: + + # inside class Time: + + def __add__(self, other): + if isinstance(other, Time): + return self.add_time(other) + else: + return self.increment(other) + + def add_time(self, other): + seconds = self.time_to_int() + other.time_to_int() + return int_to_time(seconds) + + def increment(self, seconds): + seconds += self.time_to_int() + return int_to_time(seconds) + +The built-in function isinstance takes a value and a class object, and +returns True if the value is an instance of the class. + +If other is a Time object, ``__add__`` invokes ``add_time``. Otherwise +it assumes that the parameter is a number and invokes increment. This +operation is called a **type-based dispatch** because it dispatches the +computation to different methods based on the type of the arguments. + +Here are examples that use the + operator with different types: + +:: + + >>> start = Time(9, 45) + >>> duration = Time(1, 35) + >>> print(start + duration) + 11:20:00 + >>> print(start + 1337) + 10:07:17 + +Unfortunately, this implementation of addition is not commutative. If +the integer is the first operand, you get + +:: + + >>> print(1337 + start) + TypeError: unsupported operand type(s) for +: 'int' and 'instance' + +The problem is, instead of asking the Time object to add an integer, +Python is asking an integer to add a Time object, and it doesn’t know +how. But there is a clever solution for this problem: the special method +``__radd__``, which stands for “right-side add”. This method is invoked +when a Time object appears on the right side of the + operator. Here’s +the definition: + +:: + + # inside class Time: + + def __radd__(self, other): + return self.__add__(other) + +And here’s how it’s used: + +:: + + >>> print(1337 + start) + 10:07:17 + +As an exercise, write an add method for Points that works with either a +Point object or a tuple: + +- If the second operand is a Point, the method should return a new + Point whose :math:`x` coordinate is the sum of the :math:`x` + coordinates of the operands, and likewise for the :math:`y` + coordinates. + +- If the second operand is a tuple, the method should add the first + element of the tuple to the :math:`x` coordinate and the second + element to the :math:`y` coordinate, and return a new Point with the + result. + +Polymorphism +------------ + +Type-based dispatch is useful when it is necessary, but (fortunately) it +is not always necessary. Often you can avoid it by writing functions +that work correctly for arguments with different types. + +Many of the functions we wrote for strings also work for other sequence +types. For example, in Section [histogram] we used histogram to count +the number of times each letter appears in a word. + +:: + + def histogram(s): + d = dict() + for c in s: + if c not in d: + d[c] = 1 + else: + d[c] = d[c]+1 + return d + +This function also works for lists, tuples, and even dictionaries, as +long as the elements of s are hashable, so they can be used as keys in +d. + +:: + + >>> t = ['spam', 'egg', 'spam', 'spam', 'bacon', 'spam'] + >>> histogram(t) + {'bacon': 1, 'egg': 1, 'spam': 4} + +Functions that work with several types are called **polymorphic**. +Polymorphism can facilitate code reuse. For example, the built-in +function sum, which adds the elements of a sequence, works as long as +the elements of the sequence support addition. + +Since Time objects provide an add method, they work with sum: + +:: + + >>> t1 = Time(7, 43) + >>> t2 = Time(7, 41) + >>> t3 = Time(7, 37) + >>> total = sum([t1, t2, t3]) + >>> print(total) + 23:01:00 + +In general, if all of the operations inside a function work with a given +type, the function works with that type. + +The best kind of polymorphism is the unintentional kind, where you +discover that a function you already wrote can be applied to a type you +never planned for. + +Debugging +--------- + +It is legal to add attributes to objects at any point in the execution +of a program, but if you have objects with the same type that don’t have +the same attributes, it is easy to make mistakes. It is considered a +good idea to initialize all of an object’s attributes in the init +method. + +If you are not sure whether an object has a particular attribute, you +can use the built-in function hasattr (see Section [hasattr]). + +Another way to access attributes is the built-in function vars, which +takes an object and returns a dictionary that maps from attribute names +(as strings) to their values: + +:: + + >>> p = Point(3, 4) + >>> vars(p) + {'y': 4, 'x': 3} + +For purposes of debugging, you might find it useful to keep this +function handy: + +:: + + def print_attributes(obj): + for attr in vars(obj): + print(attr, getattr(obj, attr)) + +``print_attributes`` traverses the dictionary and prints each attribute +name and its corresponding value. + +The built-in function getattr takes an object and an attribute name (as +a string) and returns the attribute’s value. + +Interface and implementation +---------------------------- + +One of the goals of object-oriented design is to make software more +maintainable, which means that you can keep the program working when +other parts of the system change, and modify the program to meet new +requirements. + +A design principle that helps achieve that goal is to keep interfaces +separate from implementations. For objects, that means that the methods +a class provides should not depend on how the attributes are +represented. + +For example, in this chapter we developed a class that represents a time +of day. Methods provided by this class include ``time_to_int``, +``is_after``, and ``add_time``. + +We could implement those methods in several ways. The details of the +implementation depend on how we represent time. In this chapter, the +attributes of a Time object are hour, minute, and second. + +As an alternative, we could replace these attributes with a single +integer representing the number of seconds since midnight. This +implementation would make some methods, like ``is_after``, easier to +write, but it makes other methods harder. + +After you deploy a new class, you might discover a better +implementation. If other parts of the program are using your class, it +might be time-consuming and error-prone to change the interface. + +But if you designed the interface carefully, you can change the +implementation without changing the interface, which means that other +parts of the program don’t have to change. + +.. _glossary17: + +Glossary +-------- + +.. include:: glossary/17.txt + + +Exercises +--------- + +Download the code from this chapter from +http://thinkpython2.com/code/Time2.py. Change the attributes of Time to +be a single integer representing seconds since midnight. Then modify the +methods (and the function ``int_to_time``) to work with the new +implementation. You should not have to modify the test code in main. +When you are done, the output should be the same as before. Solution: +http://thinkpython2.com/code/Time2_soln.py. + +[kangaroo] + +This exercise is a cautionary tale about one of the most common, and +difficult to find, errors in Python. Write a definition for a class +named Kangaroo with the following methods: + +#. An ``__init__`` method that initializes an attribute named + ``pouch_contents`` to an empty list. + +#. A method named ``put_in_pouch`` that takes an object of any type and + adds it to ``pouch_contents``. + +#. A ``__str__`` method that returns a string representation of the + Kangaroo object and the contents of the pouch. + +Test your code by creating two Kangaroo objects, assigning them to +variables named kanga and roo, and then adding roo to the contents of +kanga’s pouch. + +Download http://thinkpython2.com/code/BadKangaroo.py. It contains a +solution to the previous problem with one big, nasty bug. Find and fix +the bug. + +If you get stuck, you can download +http://thinkpython2.com/code/GoodKangaroo.py, which explains the problem +and demonstrates a solution. diff --git a/book/18-inherit.rst b/book/18-inherit.rst new file mode 100644 index 0000000..6725512 --- /dev/null +++ b/book/18-inherit.rst @@ -0,0 +1,727 @@ +Inheritance +=========== + +The language feature most often associated with object-oriented +programming is **inheritance**. Inheritance is the ability to define a +new class that is a modified version of an existing class. In this +chapter I demonstrate inheritance using classes that represent playing +cards, decks of cards, and poker hands. + +If you don’t play poker, you can read about it at +http://en.wikipedia.org/wiki/Poker, but you don’t have to; I’ll tell you +what you need to know for the exercises. + +Code examples from this chapter are available from +http://thinkpython2.com/code/Card.py. + +Card objects +------------ + +There are fifty-two cards in a deck, each of which belongs to one of +four suits and one of thirteen ranks. The suits are Spades, Hearts, +Diamonds, and Clubs (in descending order in bridge). The ranks are Ace, +2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, and King. Depending on the game +that you are playing, an Ace may be higher than King or lower than 2. + +If we want to define a new object to represent a playing card, it is +obvious what the attributes should be: rank and suit. It is not as +obvious what type the attributes should be. One possibility is to use +strings containing words like ``'Spade'`` for suits and ``'Queen'`` for +ranks. One problem with this implementation is that it would not be easy +to compare cards to see which had a higher rank or suit. + +An alternative is to use integers to **encode** the ranks and suits. In +this context, “encode” means that we are going to define a mapping +between numbers and suits, or between numbers and ranks. This kind of +encoding is not meant to be a secret (that would be “encryption”). + +For example, this table shows the suits and the corresponding integer +codes: + ++------------+-------------------+-----+ +| Spades | :math:`\mapsto` | 3 | ++------------+-------------------+-----+ +| Hearts | :math:`\mapsto` | 2 | ++------------+-------------------+-----+ +| Diamonds | :math:`\mapsto` | 1 | ++------------+-------------------+-----+ +| Clubs | :math:`\mapsto` | 0 | ++------------+-------------------+-----+ + +This code makes it easy to compare cards; because higher suits map to +higher numbers, we can compare suits by comparing their codes. + +The mapping for ranks is fairly obvious; each of the numerical ranks +maps to the corresponding integer, and for face cards: + ++---------+-------------------+------+ +| Jack | :math:`\mapsto` | 11 | ++---------+-------------------+------+ +| Queen | :math:`\mapsto` | 12 | ++---------+-------------------+------+ +| King | :math:`\mapsto` | 13 | ++---------+-------------------+------+ + +I am using the :math:`\mapsto` symbol to make it clear that these +mappings are not part of the Python program. They are part of the +program design, but they don’t appear explicitly in the code. + +The class definition for Card looks like this: + +:: + + class Card: + """Represents a standard playing card.""" + + def __init__(self, suit=0, rank=2): + self.suit = suit + self.rank = rank + +As usual, the init method takes an optional parameter for each +attribute. The default card is the 2 of Clubs. + +To create a Card, you call Card with the suit and rank of the card you +want. + +:: + + queen_of_diamonds = Card(1, 12) + +Class attributes +---------------- + +In order to print Card objects in a way that people can easily read, we +need a mapping from the integer codes to the corresponding ranks and +suits. A natural way to do that is with lists of strings. We assign +these lists to **class attributes**: + +:: + + # inside class Card: + + suit_names = ['Clubs', 'Diamonds', 'Hearts', 'Spades'] + rank_names = [None, 'Ace', '2', '3', '4', '5', '6', '7', + '8', '9', '10', 'Jack', 'Queen', 'King'] + + def __str__(self): + return '%s of %s' % (Card.rank_names[self.rank], + Card.suit_names[self.suit]) + +Variables like ``suit_names`` and ``rank_names``, which are defined +inside a class but outside of any method, are called class attributes +because they are associated with the class object Card. + +This term distinguishes them from variables like suit and rank, which +are called **instance attributes** because they are associated with a +particular instance. + +Both kinds of attribute are accessed using dot notation. For example, in +``__str__``, self is a Card object, and self.rank is its rank. +Similarly, Card is a class object, and ``Card.rank_names`` is a list of +strings associated with the class. + +Every card has its own suit and rank, but there is only one copy of +``suit_names`` and ``rank_names``. + +Putting it all together, the expression ``Card.rank_names[self.rank]`` +means “use the attribute rank from the object self as an index into the +list ``rank_names`` from the class Card, and select the appropriate +string.” + +The first element of ``rank_names`` is None because there is no card +with rank zero. By including None as a place-keeper, we get a mapping +with the nice property that the index 2 maps to the string ``'2'``, and +so on. To avoid this tweak, we could have used a dictionary instead of a +list. + +With the methods we have so far, we can create and print cards: + +:: + + >>> card1 = Card(2, 11) + >>> print(card1) + Jack of Hearts + +.. figure:: figs/card1.pdf + :alt: Object diagram. + + Object diagram. + +Figure [fig.card1] is a diagram of the Card class object and one Card +instance. Card is a class object; its type is type. card1 is an instance +of Card, so its type is Card. To save space, I didn’t draw the contents +of ``suit_names`` and ``rank_names``. + +Comparing cards +--------------- + +For built-in types, there are relational operators (<, >, ==, etc.) that +compare values and determine when one is greater than, less than, or +equal to another. For programmer-defined types, we can override the +behavior of the built-in operators by providing a method named +``__lt__``, which stands for “less than”. + +``__lt__`` takes two parameters, self and other, and True if self is +strictly less than other. + +The correct ordering for cards is not obvious. For example, which is +better, the 3 of Clubs or the 2 of Diamonds? One has a higher rank, but +the other has a higher suit. In order to compare cards, you have to +decide whether rank or suit is more important. + +The answer might depend on what game you are playing, but to keep things +simple, we’ll make the arbitrary choice that suit is more important, so +all of the Spades outrank all of the Diamonds, and so on. + +With that decided, we can write ``__lt__``: + +:: + + # inside class Card: + + def __lt__(self, other): + # check the suits + if self.suit < other.suit: return True + if self.suit > other.suit: return False + + # suits are the same... check ranks + return self.rank < other.rank + +You can write this more concisely using tuple comparison: + +:: + + # inside class Card: + + def __lt__(self, other): + t1 = self.suit, self.rank + t2 = other.suit, other.rank + return t1 < t2 + +As an exercise, write an ``__lt__`` method for Time objects. You can use +tuple comparison, but you also might consider comparing integers. + +Decks +----- + +Now that we have Cards, the next step is to define Decks. Since a deck +is made up of cards, it is natural for each Deck to contain a list of +cards as an attribute. + +The following is a class definition for Deck. The init method creates +the attribute cards and generates the standard set of fifty-two cards: + +:: + + class Deck: + + def __init__(self): + self.cards = [] + for suit in range(4): + for rank in range(1, 14): + card = Card(suit, rank) + self.cards.append(card) + +The easiest way to populate the deck is with a nested loop. The outer +loop enumerates the suits from 0 to 3. The inner loop enumerates the +ranks from 1 to 13. Each iteration creates a new Card with the current +suit and rank, and appends it to self.cards. + +Printing the deck +----------------- + +Here is a ``__str__`` method for Deck: + +:: + + #inside class Deck: + + def __str__(self): + res = [] + for card in self.cards: + res.append(str(card)) + return '\n'.join(res) + +This method demonstrates an efficient way to accumulate a large string: +building a list of strings and then using the string method join. The +built-in function str invokes the ``__str__`` method on each card and +returns the string representation. + +Since we invoke join on a newline character, the cards are separated by +newlines. Here’s what the result looks like: + +:: + + >>> deck = Deck() + >>> print(deck) + Ace of Clubs + 2 of Clubs + 3 of Clubs + ... + 10 of Spades + Jack of Spades + Queen of Spades + King of Spades + +Even though the result appears on 52 lines, it is one long string that +contains newlines. + +Add, remove, shuffle and sort +----------------------------- + +To deal cards, we would like a method that removes a card from the deck +and returns it. The list method pop provides a convenient way to do +that: + +:: + + #inside class Deck: + + def pop_card(self): + return self.cards.pop() + +Since pop removes the *last* card in the list, we are dealing from the +bottom of the deck. + +To add a card, we can use the list method append: + +:: + + #inside class Deck: + + def add_card(self, card): + self.cards.append(card) + +A method like this that uses another method without doing much work is +sometimes called a **veneer**. The metaphor comes from woodworking, +where a veneer is a thin layer of good quality wood glued to the surface +of a cheaper piece of wood to improve the appearance. + +In this case ``add_card`` is a “thin” method that expresses a list +operation in terms appropriate for decks. It improves the appearance, or +interface, of the implementation. + +As another example, we can write a Deck method named shuffle using the +function shuffle from the random module: + +:: + + # inside class Deck: + + def shuffle(self): + random.shuffle(self.cards) + +Don’t forget to import random. + +As an exercise, write a Deck method named sort that uses the list method +sort to sort the cards in a Deck. sort uses the ``__lt__`` method we +defined to determine the order. + +Inheritance +----------- + +Inheritance is the ability to define a new class that is a modified +version of an existing class. As an example, let’s say we want a class +to represent a “hand”, that is, the cards held by one player. A hand is +similar to a deck: both are made up of a collection of cards, and both +require operations like adding and removing cards. + +A hand is also different from a deck; there are operations we want for +hands that don’t make sense for a deck. For example, in poker we might +compare two hands to see which one wins. In bridge, we might compute a +score for a hand in order to make a bid. + +This relationship between classes—similar, but different—lends itself to +inheritance. To define a new class that inherits from an existing class, +you put the name of the existing class in parentheses: + +:: + + class Hand(Deck): + """Represents a hand of playing cards.""" + +This definition indicates that Hand inherits from Deck; that means we +can use methods like ``pop_card`` and ``add_card`` for Hands as well as +Decks. + +When a new class inherits from an existing one, the existing one is +called the **parent** and the new class is called the **child**. + +In this example, Hand inherits ``__init__`` from Deck, but it doesn’t +really do what we want: instead of populating the hand with 52 new +cards, the init method for Hands should initialize cards with an empty +list. + +If we provide an init method in the Hand class, it overrides the one in +the Deck class: + +:: + + # inside class Hand: + + def __init__(self, label=''): + self.cards = [] + self.label = label + +When you create a Hand, Python invokes this init method, not the one in +Deck. + +:: + + >>> hand = Hand('new hand') + >>> hand.cards + [] + >>> hand.label + 'new hand' + +The other methods are inherited from Deck, so we can use ``pop_card`` +and ``add_card`` to deal a card: + +:: + + >>> deck = Deck() + >>> card = deck.pop_card() + >>> hand.add_card(card) + >>> print(hand) + King of Spades + +A natural next step is to encapsulate this code in a method called +``move_cards``: + +:: + + #inside class Deck: + + def move_cards(self, hand, num): + for i in range(num): + hand.add_card(self.pop_card()) + +``move_cards`` takes two arguments, a Hand object and the number of +cards to deal. It modifies both self and hand, and returns None. + +In some games, cards are moved from one hand to another, or from a hand +back to the deck. You can use ``move_cards`` for any of these +operations: self can be either a Deck or a Hand, and hand, despite the +name, can also be a Deck. + +Inheritance is a useful feature. Some programs that would be repetitive +without inheritance can be written more elegantly with it. Inheritance +can facilitate code reuse, since you can customize the behavior of +parent classes without having to modify them. In some cases, the +inheritance structure reflects the natural structure of the problem, +which makes the design easier to understand. + +On the other hand, inheritance can make programs difficult to read. When +a method is invoked, it is sometimes not clear where to find its +definition. The relevant code may be spread across several modules. +Also, many of the things that can be done using inheritance can be done +as well or better without it. + +Class diagrams +-------------- + +So far we have seen stack diagrams, which show the state of a program, +and object diagrams, which show the attributes of an object and their +values. These diagrams represent a snapshot in the execution of a +program, so they change as the program runs. + +They are also highly detailed; for some purposes, too detailed. A class +diagram is a more abstract representation of the structure of a program. +Instead of showing individual objects, it shows classes and the +relationships between them. + +There are several kinds of relationship between classes: + +- Objects in one class might contain references to objects in another + class. For example, each Rectangle contains a reference to a Point, + and each Deck contains references to many Cards. This kind of + relationship is called **HAS-A**, as in, “a Rectangle has a Point.” + +- One class might inherit from another. This relationship is called + **IS-A**, as in, “a Hand is a kind of a Deck.” + +- One class might depend on another in the sense that objects in one + class take objects in the second class as parameters, or use objects + in the second class as part of a computation. This kind of + relationship is called a **dependency**. + +A **class diagram** is a graphical representation of these +relationships. For example, Figure [fig.class1] shows the relationships +between Card, Deck and Hand. + +.. figure:: figs/class1.pdf + :alt: Class diagram. + + Class diagram. + +The arrow with a hollow triangle head represents an IS-A relationship; +in this case it indicates that Hand inherits from Deck. + +The standard arrow head represents a HAS-A relationship; in this case a +Deck has references to Card objects. + +The star () near the arrow head is a **multiplicity**; it indicates how +many Cards a Deck has. A multiplicity can be a simple number, like 52, a +range, like 5..7 or a star, which indicates that a Deck can have any +number of Cards. + +There are no dependencies in this diagram. They would normally be shown +with a dashed arrow. Or if there are a lot of dependencies, they are +sometimes omitted. + +A more detailed diagram might show that a Deck actually contains a +*list* of Cards, but built-in types like list and dict are usually not +included in class diagrams. + +Debugging +--------- + +Inheritance can make debugging difficult because when you invoke a +method on an object, it might be hard to figure out which method will be +invoked. + +Suppose you are writing a function that works with Hand objects. You +would like it to work with all kinds of Hands, like PokerHands, +BridgeHands, etc. If you invoke a method like shuffle, you might get the +one defined in Deck, but if any of the subclasses override this method, +you’ll get that version instead. This behavior is usually a good thing, +but it can be confusing. + +Any time you are unsure about the flow of execution through your +program, the simplest solution is to add print statements at the +beginning of the relevant methods. If Deck.shuffle prints a message that +says something like Running Deck.shuffle, then as the program runs it +traces the flow of execution. + +As an alternative, you could use this function, which takes an object +and a method name (as a string) and returns the class that provides the +definition of the method: + +:: + + def find_defining_class(obj, meth_name): + for ty in type(obj).mro(): + if meth_name in ty.__dict__: + return ty + +Here’s an example: + +:: + + >>> hand = Hand() + >>> find_defining_class(hand, 'shuffle') + + +So the shuffle method for this Hand is the one in Deck. + +``find_defining_class`` uses the mro method to get the list of class +objects (types) that will be searched for methods. “MRO” stands for +“method resolution order”, which is the sequence of classes Python +searches to “resolve” a method name. + +Here’s a design suggestion: when you override a method, the interface of +the new method should be the same as the old. It should take the same +parameters, return the same type, and obey the same preconditions and +postconditions. If you follow this rule, you will find that any function +designed to work with an instance of a parent class, like a Deck, will +also work with instances of child classes like a Hand and PokerHand. + +If you violate this rule, which is called the “Liskov substitution +principle”, your code will collapse like (sorry) a house of cards. + +Data encapsulation +------------------ + +The previous chapters demonstrate a development plan we might call +“object-oriented design”. We identified objects we needed—like Point, +Rectangle and Time—and defined classes to represent them. In each case +there is an obvious correspondence between the object and some entity in +the real world (or at least a mathematical world). + +But sometimes it is less obvious what objects you need and how they +should interact. In that case you need a different development plan. In +the same way that we discovered function interfaces by encapsulation and +generalization, we can discover class interfaces by **data +encapsulation**. + +Markov analysis, from Section [markov], provides a good example. If you +download my code from http://thinkpython2.com/code/markov.py, you’ll see +that it uses two global variables—\ ``suffix_map`` and ``prefix``—that +are read and written from several functions. + +:: + + suffix_map = {} + prefix = () + +Because these variables are global, we can only run one analysis at a +time. If we read two texts, their prefixes and suffixes would be added +to the same data structures (which makes for some interesting generated +text). + +To run multiple analyses, and keep them separate, we can encapsulate the +state of each analysis in an object. Here’s what that looks like: + +:: + + class Markov: + + def __init__(self): + self.suffix_map = {} + self.prefix = () + +Next, we transform the functions into methods. For example, here’s +``process_word``: + +:: + + def process_word(self, word, order=2): + if len(self.prefix) < order: + self.prefix += (word,) + return + + try: + self.suffix_map[self.prefix].append(word) + except KeyError: + # if there is no entry for this prefix, make one + self.suffix_map[self.prefix] = [word] + + self.prefix = shift(self.prefix, word) + +Transforming a program like this—changing the design without changing +the behavior—is another example of refactoring (see +Section [refactoring]). + +This example suggests a development plan for designing objects and +methods: + +#. Start by writing functions that read and write global variables (when + necessary). + +#. Once you get the program working, look for associations between + global variables and the functions that use them. + +#. Encapsulate related variables as attributes of an object. + +#. Transform the associated functions into methods of the new class. + +As an exercise, download my Markov code from +http://thinkpython2.com/code/markov.py, and follow the steps described +above to encapsulate the global variables as attributes of a new class +called Markov. Solution: http://thinkpython2.com/code/Markov.py (note +the capital M). + +.. _glossary18: + +Glossary +-------- + +.. include:: glossary/18.txt + + +Exercises +--------- + +For the following program, draw a UML class diagram that shows these +classes and the relationships among them. + +:: + + class PingPongParent: + pass + + class Ping(PingPongParent): + def __init__(self, pong): + self.pong = pong + + + class Pong(PingPongParent): + def __init__(self, pings=None): + if pings is None: + self.pings = [] + else: + self.pings = pings + + def add_ping(self, ping): + self.pings.append(ping) + + pong = Pong() + ping = Ping(pong) + pong.add_ping(ping) + +Write a Deck method called ``deal_hands`` that takes two parameters, the +number of hands and the number of cards per hand. It should create the +appropriate number of Hand objects, deal the appropriate number of cards +per hand, and return a list of Hands. + +[poker] + +The following are the possible hands in poker, in increasing order of +value and decreasing order of probability: + +pair: + two cards with the same rank + +two pair: + two pairs of cards with the same rank + +three of a kind: + three cards with the same rank + +straight: + five cards with ranks in sequence (aces can be high or low, so + Ace-2-3-4-5 is a straight and so is 10-Jack-Queen-King-Ace, but + Queen-King-Ace-2-3 is not.) + +flush: + five cards with the same suit + +full house: + three cards with one rank, two cards with another + +four of a kind: + four cards with the same rank + +straight flush: + five cards in sequence (as defined above) and with the same suit + +The goal of these exercises is to estimate the probability of drawing +these various hands. + +#. Download the following files from http://thinkpython2.com/code: + + Card.py + : A complete version of the Card, Deck and Hand classes in this + chapter. + + PokerHand.py + : An incomplete implementation of a class that represents a poker + hand, and some code that tests it. + +#. If you run PokerHand.py, it deals seven 7-card poker hands and checks + to see if any of them contains a flush. Read this code carefully + before you go on. + +#. Add methods to PokerHand.py named ``has_pair``, ``has_twopair``, etc. + that return True or False according to whether or not the hand meets + the relevant criteria. Your code should work correctly for “hands” + that contain any number of cards (although 5 and 7 are the most + common sizes). + +#. Write a method named classify that figures out the highest-value + classification for a hand and sets the label attribute accordingly. + For example, a 7-card hand might contain a flush and a pair; it + should be labeled “flush”. + +#. When you are convinced that your classification methods are working, + the next step is to estimate the probabilities of the various hands. + Write a function in PokerHand.py that shuffles a deck of cards, + divides it into hands, classifies the hands, and counts the number of + times various classifications appear. + +#. Print a table of the classifications and their probabilities. Run + your program with larger and larger numbers of hands until the output + values converge to a reasonable degree of accuracy. Compare your + results to the values at http://en.wikipedia.org/wiki/Hand_rankings. + +Solution: http://thinkpython2.com/code/PokerHandSoln.py. diff --git a/book/19-goodies.rst b/book/19-goodies.rst new file mode 100644 index 0000000..9865283 --- /dev/null +++ b/book/19-goodies.rst @@ -0,0 +1,662 @@ +The Goodies +=========== + +One of my goals for this book has been to teach you as little Python as +possible. When there were two ways to do something, I picked one and +avoided mentioning the other. Or sometimes I put the second one into an +exercise. + +Now I want to go back for some of the good bits that got left behind. +Python provides a number of features that are not really necessary—you +can write good code without them—but with them you can sometimes write +code that’s more concise, readable or efficient, and sometimes all +three. + +Conditional expressions +----------------------- + +We saw conditional statements in Section [conditional.execution]. +Conditional statements are often used to choose one of two values; for +example: + +:: + + if x > 0: + y = math.log(x) + else: + y = float('nan') + +This statement checks whether x is positive. If so, it computes +math.log. If not, math.log would raise a ValueError. To avoid stopping +the program, we generate a “NaN”, which is a special floating-point +value that represents “Not a Number”. + +We can write this statement more concisely using a **conditional +expression**: + +:: + + y = math.log(x) if x > 0 else float('nan') + +You can almost read this line like English: “y gets log-x if x is +greater than 0; otherwise it gets NaN”. + +Recursive functions can sometimes be rewritten using conditional +expressions. For example, here is a recursive version of factorial: + +:: + + def factorial(n): + if n == 0: + return 1 + else: + return n * factorial(n-1) + +We can rewrite it like this: + +:: + + def factorial(n): + return 1 if n == 0 else n * factorial(n-1) + +Another use of conditional expressions is handling optional arguments. +For example, here is the init method from GoodKangaroo (see +Exercise [kangaroo]): + +:: + + def __init__(self, name, contents=None): + self.name = name + if contents == None: + contents = [] + self.pouch_contents = contents + +We can rewrite this one like this: + +:: + + def __init__(self, name, contents=None): + self.name = name + self.pouch_contents = [] if contents == None else contents + +In general, you can replace a conditional statement with a conditional +expression if both branches contain simple expressions that are either +returned or assigned to the same variable. + +List comprehensions +------------------- + +In Section [filter] we saw the map and filter patterns. For example, +this function takes a list of strings, maps the string method capitalize +to the elements, and returns a new list of strings: + +:: + + def capitalize_all(t): + res = [] + for s in t: + res.append(s.capitalize()) + return res + +We can write this more concisely using a **list comprehension**: + +:: + + def capitalize_all(t): + return [s.capitalize() for s in t] + +The bracket operators indicate that we are constructing a new list. The +expression inside the brackets specifies the elements of the list, and +the for clause indicates what sequence we are traversing. + +The syntax of a list comprehension is a little awkward because the loop +variable, s in this example, appears in the expression before we get to +the definition. + +List comprehensions can also be used for filtering. For example, this +function selects only the elements of t that are upper case, and returns +a new list: + +:: + + def only_upper(t): + res = [] + for s in t: + if s.isupper(): + res.append(s) + return res + +We can rewrite it using a list comprehension + +:: + + def only_upper(t): + return [s for s in t if s.isupper()] + +List comprehensions are concise and easy to read, at least for simple +expressions. And they are usually faster than the equivalent for loops, +sometimes much faster. So if you are mad at me for not mentioning them +earlier, I understand. + +But, in my defense, list comprehensions are harder to debug because you +can’t put a print statement inside the loop. I suggest that you use them +only if the computation is simple enough that you are likely to get it +right the first time. And for beginners that means never. + +Generator expressions +--------------------- + +**Generator expressions** are similar to list comprehensions, but with +parentheses instead of square brackets: + +:: + + >>> g = (x**2 for x in range(5)) + >>> g + at 0x7f4c45a786c0> + +The result is a generator object that knows how to iterate through a +sequence of values. But unlike a list comprehension, it does not compute +the values all at once; it waits to be asked. The built-in function next +gets the next value from the generator: + +:: + + >>> next(g) + 0 + >>> next(g) + 1 + +When you get to the end of the sequence, next raises a StopIteration +exception. You can also use a for loop to iterate through the values: + +:: + + >>> for val in g: + ... print(val) + 4 + 9 + 16 + +The generator object keeps track of where it is in the sequence, so the +for loop picks up where next left off. Once the generator is exhausted, +it continues to raise StopException: + +:: + + >>> next(g) + StopIteration + +Generator expressions are often used with functions like sum, max, and +min: + +:: + + >>> sum(x**2 for x in range(5)) + 30 + +any and all +----------- + +Python provides a built-in function, any, that takes a sequence of +boolean values and returns True if any of the values are True. It works +on lists: + +:: + + >>> any([False, False, True]) + True + +But it is often used with generator expressions: + +:: + + >>> any(letter == 't' for letter in 'monty') + True + +That example isn’t very useful because it does the same thing as the in +operator. But we could use any to rewrite some of the search functions +we wrote in Section [search]. For example, we could write avoids like +this: + +:: + + def avoids(word, forbidden): + return not any(letter in forbidden for letter in word) + +The function almost reads like English, “word avoids forbidden if there +are not any forbidden letters in word.” + +Using any with a generator expression is efficient because it stops +immediately if it finds a True value, so it doesn’t have to evaluate the +whole sequence. + +Python provides another built-in function, all, that returns True if +every element of the sequence is True. As an exercise, use all to +re-write ``uses_all`` from Section [search]. + +Sets +---- + +In Section [dictsub] I use dictionaries to find the words that appear in +a document but not in a word list. The function I wrote takes d1, which +contains the words from the document as keys, and d2, which contains the +list of words. It returns a dictionary that contains the keys from d1 +that are not in d2. + +:: + + def subtract(d1, d2): + res = dict() + for key in d1: + if key not in d2: + res[key] = None + return res + +In all of these dictionaries, the values are None because we never use +them. As a result, we waste some storage space. + +Python provides another built-in type, called a set, that behaves like a +collection of dictionary keys with no values. Adding elements to a set +is fast; so is checking membership. And sets provide methods and +operators to compute common set operations. + +For example, set subtraction is available as a method called difference +or as an operator, -. So we can rewrite subtract like this: + +:: + + def subtract(d1, d2): + return set(d1) - set(d2) + +The result is a set instead of a dictionary, but for operations like +iteration, the behavior is the same. + +Some of the exercises in this book can be done concisely and efficiently +with sets. For example, here is a solution to ``has_duplicates``, from +Exercise [duplicate], that uses a dictionary: + +:: + + def has_duplicates(t): + d = {} + for x in t: + if x in d: + return True + d[x] = True + return False + +When an element appears for the first time, it is added to the +dictionary. If the same element appears again, the function returns +True. + +Using sets, we can write the same function like this: + +:: + + def has_duplicates(t): + return len(set(t)) < len(t) + +An element can only appear in a set once, so if an element in t appears +more than once, the set will be smaller than t. If there are no +duplicates, the set will be the same size as t. + +We can also use sets to do some of the exercises in Chapter [wordplay]. +For example, here’s a version of ``uses_only`` with a loop: + +:: + + def uses_only(word, available): + for letter in word: + if letter not in available: + return False + return True + +``uses_only`` checks whether all letters in word are in available. We +can rewrite it like this: + +:: + + def uses_only(word, available): + return set(word) <= set(available) + +The ``<=`` operator checks whether one set is a subset or another, +including the possibility that they are equal, which is true if all the +letters in word appear in available. + +As an exercise, rewrite ``avoids`` using sets. + +Counters +-------- + +A Counter is like a set, except that if an element appears more than +once, the Counter keeps track of how many times it appears. If you are +familiar with the mathematical idea of a **multiset**, a Counter is a +natural way to represent a multiset. + +Counter is defined in a standard module called collections, so you have +to import it. You can initialize a Counter with a string, list, or +anything else that supports iteration: + +:: + + >>> from collections import Counter + >>> count = Counter('parrot') + >>> count + Counter({'r': 2, 't': 1, 'o': 1, 'p': 1, 'a': 1}) + +Counters behave like dictionaries in many ways; they map from each key +to the number of times it appears. As in dictionaries, the keys have to +be hashable. + +Unlike dictionaries, Counters don’t raise an exception if you access an +element that doesn’t appear. Instead, they return 0: + +:: + + >>> count['d'] + 0 + +We can use Counters to rewrite ``is_anagram`` from Exercise [anagram]: + +:: + + def is_anagram(word1, word2): + return Counter(word1) == Counter(word2) + +If two words are anagrams, they contain the same letters with the same +counts, so their Counters are equivalent. + +Counters provide methods and operators to perform set-like operations, +including addition, subtraction, union and intersection. And they +provide an often-useful method, ``most_common``, which returns a list of +value-frequency pairs, sorted from most common to least: + +:: + + >>> count = Counter('parrot') + >>> for val, freq in count.most_common(3): + ... print(val, freq) + r 2 + p 1 + a 1 + +defaultdict +----------- + +The collections module also provides defaultdict, which is like a +dictionary except that if you access a key that doesn’t exist, it can +generate a new value on the fly. + +When you create a defaultdict, you provide a function that’s used to +create new values. A function used to create objects is sometimes called +a **factory**. The built-in functions that create lists, sets, and other +types can be used as factories: + +:: + + >>> from collections import defaultdict + >>> d = defaultdict(list) + +Notice that the argument is list, which is a class object, not list(), +which is a new list. The function you provide doesn’t get called unless +you access a key that doesn’t exist. + +:: + + >>> t = d['new key'] + >>> t + [] + +The new list, which we’re calling t, is also added to the dictionary. So +if we modify t, the change appears in d: + +:: + + >>> t.append('new value') + >>> d + defaultdict(, {'new key': ['new value']}) + +If you are making a dictionary of lists, you can often write simpler +code using defaultdict. In my solution to Exercise [anagrams], which you +can get from http://thinkpython2.com/code/anagram_sets.py, I make a +dictionary that maps from a sorted string of letters to the list of +words that can be spelled with those letters. For example, ’opst’ maps +to the list . + +Here’s the original code: + +:: + + def all_anagrams(filename): + d = {} + for line in open(filename): + word = line.strip().lower() + t = signature(word) + if t not in d: + d[t] = [word] + else: + d[t].append(word) + return d + +This can be simplified using setdefault, which you might have used in +Exercise [setdefault]: + +:: + + def all_anagrams(filename): + d = {} + for line in open(filename): + word = line.strip().lower() + t = signature(word) + d.setdefault(t, []).append(word) + return d + +This solution has the drawback that it makes a new list every time, +regardless of whether it is needed. For lists, that’s no big deal, but +if the factory function is complicated, it might be. + +We can avoid this problem and simplify the code using a defaultdict: + +:: + + def all_anagrams(filename): + d = defaultdict(list) + for line in open(filename): + word = line.strip().lower() + t = signature(word) + d[t].append(word) + return d + +My solution to Exercise [poker], which you can download from +http://thinkpython2.com/code/PokerHandSoln.py, uses setdefault in the +function ``has_straightflush``. This solution has the drawback of +creating a Hand object every time through the loop, whether it is needed +or not. As an exercise, rewrite it using a defaultdict. + +Named tuples +------------ + +Many simple objects are basically collections of related values. For +example, the Point object defined in Chapter [clobjects] contains two +numbers, x and y. When you define a class like this, you usually start +with an init method and a str method: + +:: + + class Point: + + def __init__(self, x=0, y=0): + self.x = x + self.y = y + + def __str__(self): + return '(%g, %g)' % (self.x, self.y) + +This is a lot of code to convey a small amount of information. Python +provides a more concise way to say the same thing: + +:: + + from collections import namedtuple + Point = namedtuple('Point', ['x', 'y']) + +The first argument is the name of the class you want to create. The +second is a list of the attributes Point objects should have, as +strings. The return value from namedtuple is a class object: + +:: + + >>> Point + + +Point automatically provides methods like ``__init__`` and ``__str__`` +so you don’t have to write them. + +To create a Point object, you use the Point class as a function: + +:: + + >>> p = Point(1, 2) + >>> p + Point(x=1, y=2) + +The init method assigns the arguments to attributes using the names you +provided. The str method prints a representation of the Point object and +its attributes. + +You can access the elements of the named tuple by name: + +:: + + >>> p.x, p.y + (1, 2) + +But you can also treat a named tuple as a tuple: + +:: + + >>> p[0], p[1] + (1, 2) + + >>> x, y = p + >>> x, y + (1, 2) + +Named tuples provide a quick way to define simple classes. The drawback +is that simple classes don’t always stay simple. You might decide later +that you want to add methods to a named tuple. In that case, you could +define a new class that inherits from the named tuple: + +:: + + class Pointier(Point): + # add more methods here + +Or you could switch to a conventional class definition. + +Gathering keyword args +---------------------- + +In Section [gather], we saw how to write a function that gathers its +arguments into a tuple: + +:: + + def printall(*args): + print(args) + +You can call this function with any number of positional arguments (that +is, arguments that don’t have keywords): + +:: + + >>> printall(1, 2.0, '3') + (1, 2.0, '3') + +But the operator doesn’t gather keyword arguments: + +:: + + >>> printall(1, 2.0, third='3') + TypeError: printall() got an unexpected keyword argument 'third' + +To gather keyword arguments, you can use the \* operator: + +:: + + def printall(*args, **kwargs): + print(args, kwargs) + +You can call the keyword gathering parameter anything you want, but +kwargs is a common choice. The result is a dictionary that maps keywords +to values: + +:: + + >>> printall(1, 2.0, third='3') + (1, 2.0) {'third': '3'} + +If you have a dictionary of keywords and values, you can use the scatter +operator, \* to call a function: + +:: + + >>> d = dict(x=1, y=2) + >>> Point(**d) + Point(x=1, y=2) + +Without the scatter operator, the function would treat d as a single +positional argument, so it would assign d to x and complain because +there’s nothing to assign to y: + +:: + + >>> d = dict(x=1, y=2) + >>> Point(d) + Traceback (most recent call last): + File "", line 1, in + TypeError: __new__() missing 1 required positional argument: 'y' + +When you are working with functions that have a large number of +parameters, it is often useful to create and pass around dictionaries +that specify frequently used options. + +.. _glossary19: + +Glossary +-------- + +.. include:: glossary/19.txt + + +Exercises +--------- + +The following is a function computes the binomial coefficient +recursively. + +:: + + def binomial_coeff(n, k): + """Compute the binomial coefficient "n choose k". + + n: number of trials + k: number of successes + + returns: int + """ + if k == 0: + return 1 + if n == 0: + return 0 + + res = binomial_coeff(n-1, k) + binomial_coeff(n-1, k-1) + return res + +Rewrite the body of the function using nested conditional expressions. + +One note: this function is not very efficient because it ends up +computing the same values over and over. You could make it more +efficient by memoizing (see Section [memoize]). But you will find that +it’s harder to memoize if you write it using conditional expressions. diff --git a/book/A-debug.rst b/book/A-debug.rst new file mode 100644 index 0000000..e31616f --- /dev/null +++ b/book/A-debug.rst @@ -0,0 +1,500 @@ + +Debugging +========= + +When you are debugging, you should distinguish among different kinds of +errors in order to track them down more quickly: + +- Syntax errors are discovered by the interpreter when it is + translating the source code into byte code. They indicate that there + is something wrong with the structure of the program. Example: + Omitting the colon at the end of a def statement generates the + somewhat redundant message SyntaxError: invalid syntax. + +- Runtime errors are produced by the interpreter if something goes + wrong while the program is running. Most runtime error messages + include information about where the error occurred and what functions + were executing. Example: An infinite recursion eventually causes the + runtime error “maximum recursion depth exceeded”. + +- Semantic errors are problems with a program that runs without + producing error messages but doesn’t do the right thing. Example: An + expression may not be evaluated in the order you expect, yielding an + incorrect result. + +The first step in debugging is to figure out which kind of error you are +dealing with. Although the following sections are organized by error +type, some techniques are applicable in more than one situation. + +Syntax errors +------------- + +Syntax errors are usually easy to fix once you figure out what they are. +Unfortunately, the error messages are often not helpful. The most common +messages are SyntaxError: invalid syntax and SyntaxError: invalid token, +neither of which is very informative. + +On the other hand, the message does tell you where in the program the +problem occurred. Actually, it tells you where Python noticed a problem, +which is not necessarily where the error is. Sometimes the error is +prior to the location of the error message, often on the preceding line. + +If you are building the program incrementally, you should have a good +idea about where the error is. It will be in the last line you added. + +If you are copying code from a book, start by comparing your code to the +book’s code very carefully. Check every character. At the same time, +remember that the book might be wrong, so if you see something that +looks like a syntax error, it might be. + +Here are some ways to avoid the most common syntax errors: + +#. Make sure you are not using a Python keyword for a variable name. + +#. Check that you have a colon at the end of the header of every + compound statement, including for, while, if, and def statements. + +#. Make sure that any strings in the code have matching quotation marks. + Make sure that all quotation marks are “straight quotes”, not “curly + quotes”. + +#. If you have multiline strings with triple quotes (single or double), + make sure you have terminated the string properly. An unterminated + string may cause an invalid token error at the end of your program, + or it may treat the following part of the program as a string until + it comes to the next string. In the second case, it might not produce + an error message at all! + +#. An unclosed opening operator—\ ``(``, ``{``, or ``[``—makes Python + continue with the next line as part of the current statement. + Generally, an error occurs almost immediately in the next line. + +#. Check for the classic = instead of == inside a conditional. + +#. Check the indentation to make sure it lines up the way it is supposed + to. Python can handle space and tabs, but if you mix them it can + cause problems. The best way to avoid this problem is to use a text + editor that knows about Python and generates consistent indentation. + +#. If you have non-ASCII characters in the code (including strings and + comments), that might cause a problem, although Python 3 usually + handles non-ASCII characters. Be careful if you paste in text from a + web page or other source. + +If nothing works, move on to the next section... + +I keep making changes and it makes no difference. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If the interpreter says there is an error and you don’t see it, that +might be because you and the interpreter are not looking at the same +code. Check your programming environment to make sure that the program +you are editing is the one Python is trying to run. + +If you are not sure, try putting an obvious and deliberate syntax error +at the beginning of the program. Now run it again. If the interpreter +doesn’t find the new error, you are not running the new code. + +There are a few likely culprits: + +- You edited the file and forgot to save the changes before running it + again. Some programming environments do this for you, but some don’t. + +- You changed the name of the file, but you are still running the old + name. + +- Something in your development environment is configured incorrectly. + +- If you are writing a module and using import, make sure you don’t + give your module the same name as one of the standard Python modules. + +- If you are using import to read a module, remember that you have to + restart the interpreter or use reload to read a modified file. If you + import the module again, it doesn’t do anything. + +If you get stuck and you can’t figure out what is going on, one approach +is to start again with a new program like “Hello, World!”, and make sure +you can get a known program to run. Then gradually add the pieces of the +original program to the new one. + +Runtime errors +-------------- + +Once your program is syntactically correct, Python can read it and at +least start running it. What could possibly go wrong? + +My program does absolutely nothing. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This problem is most common when your file consists of functions and +classes but does not actually invoke a function to start execution. This +may be intentional if you only plan to import this module to supply +classes and functions. + +If it is not intentional, make sure there is a function call in the +program, and make sure the flow of execution reaches it (see “Flow of +Execution” below). + +My program hangs. +~~~~~~~~~~~~~~~~~ + +If a program stops and seems to be doing nothing, it is “hanging”. Often +that means that it is caught in an infinite loop or infinite recursion. + +- If there is a particular loop that you suspect is the problem, add a + print statement immediately before the loop that says “entering the + loop” and another immediately after that says “exiting the loop”. + + Run the program. If you get the first message and not the second, + you’ve got an infinite loop. Go to the “Infinite Loop” section below. + +- Most of the time, an infinite recursion will cause the program to run + for a while and then produce a “RuntimeError: Maximum recursion depth + exceeded” error. If that happens, go to the “Infinite Recursion” + section below. + + If you are not getting this error but you suspect there is a problem + with a recursive method or function, you can still use the techniques + in the “Infinite Recursion” section. + +- If neither of those steps works, start testing other loops and other + recursive functions and methods. + +- If that doesn’t work, then it is possible that you don’t understand + the flow of execution in your program. Go to the “Flow of Execution” + section below. + +Infinite Loop +^^^^^^^^^^^^^ + +If you think you have an infinite loop and you think you know what loop +is causing the problem, add a print statement at the end of the loop +that prints the values of the variables in the condition and the value +of the condition. + +For example: + +:: + + while x > 0 and y < 0 : + # do something to x + # do something to y + + print('x: ', x) + print('y: ', y) + print("condition: ", (x > 0 and y < 0)) + +Now when you run the program, you will see three lines of output for +each time through the loop. The last time through the loop, the +condition should be False. If the loop keeps going, you will be able to +see the values of x and y, and you might figure out why they are not +being updated correctly. + +Infinite Recursion +^^^^^^^^^^^^^^^^^^ + +Most of the time, infinite recursion causes the program to run for a +while and then produce a Maximum recursion depth exceeded error. + +If you suspect that a function is causing an infinite recursion, make +sure that there is a base case. There should be some condition that +causes the function to return without making a recursive invocation. If +not, you need to rethink the algorithm and identify a base case. + +If there is a base case but the program doesn’t seem to be reaching it, +add a print statement at the beginning of the function that prints the +parameters. Now when you run the program, you will see a few lines of +output every time the function is invoked, and you will see the +parameter values. If the parameters are not moving toward the base case, +you will get some ideas about why not. + +Flow of Execution +^^^^^^^^^^^^^^^^^ + +If you are not sure how the flow of execution is moving through your +program, add print statements to the beginning of each function with a +message like “entering function foo”, where foo is the name of the +function. + +Now when you run the program, it will print a trace of each function as +it is invoked. + +When I run the program I get an exception. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If something goes wrong during runtime, Python prints a message that +includes the name of the exception, the line of the program where the +problem occurred, and a traceback. + +The traceback identifies the function that is currently running, and +then the function that called it, and then the function that called +*that*, and so on. In other words, it traces the sequence of function +calls that got you to where you are, including the line number in your +file where each call occurred. + +The first step is to examine the place in the program where the error +occurred and see if you can figure out what happened. These are some of +the most common runtime errors: + +NameError: + You are trying to use a variable that doesn’t exist in the current + environment. Check if the name is spelled right, or at least + consistently. And remember that local variables are local; you + cannot refer to them from outside the function where they are + defined. + +TypeError: + There are several possible causes: + + - You are trying to use a value improperly. Example: indexing a + string, list, or tuple with something other than an integer. + + - There is a mismatch between the items in a format string and the + items passed for conversion. This can happen if either the number + of items does not match or an invalid conversion is called for. + + - You are passing the wrong number of arguments to a function. For + methods, look at the method definition and check that the first + parameter is self. Then look at the method invocation; make sure + you are invoking the method on an object with the right type and + providing the other arguments correctly. + +KeyError: + You are trying to access an element of a dictionary using a key that + the dictionary does not contain. If the keys are strings, remember + that capitalization matters. + +AttributeError: + You are trying to access an attribute or method that does not exist. + Check the spelling! You can use the built-in function vars to list + the attributes that do exist. + + If an AttributeError indicates that an object has NoneType, that + means that it is None. So the problem is not the attribute name, but + the object. + + The reason the object is none might be that you forgot to return a + value from a function; if you get to the end of a function without + hitting a return statement, it returns None. Another common cause is + using the result from a list method, like sort, that returns None. + +IndexError: + The index you are using to access a list, string, or tuple is + greater than its length minus one. Immediately before the site of + the error, add a print statement to display the value of the index + and the length of the array. Is the array the right size? Is the + index the right value? + +The Python debugger (pdb) is useful for tracking down exceptions because +it allows you to examine the state of the program immediately before the +error. You can read about pdb at +https://docs.python.org/3/library/pdb.html. + +I added so many print statements I get inundated with output. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +One of the problems with using print statements for debugging is that +you can end up buried in output. There are two ways to proceed: simplify +the output or simplify the program. + +To simplify the output, you can remove or comment out print statements +that aren’t helping, or combine them, or format the output so it is +easier to understand. + +To simplify the program, there are several things you can do. First, +scale down the problem the program is working on. For example, if you +are searching a list, search a *small* list. If the program takes input +from the user, give it the simplest input that causes the problem. + +Second, clean up the program. Remove dead code and reorganize the +program to make it as easy to read as possible. For example, if you +suspect that the problem is in a deeply nested part of the program, try +rewriting that part with simpler structure. If you suspect a large +function, try splitting it into smaller functions and testing them +separately. + +Often the process of finding the minimal test case leads you to the bug. +If you find that a program works in one situation but not in another, +that gives you a clue about what is going on. + +Similarly, rewriting a piece of code can help you find subtle bugs. If +you make a change that you think shouldn’t affect the program, and it +does, that can tip you off. + +Semantic errors +--------------- + +In some ways, semantic errors are the hardest to debug, because the +interpreter provides no information about what is wrong. Only you know +what the program is supposed to do. + +The first step is to make a connection between the program text and the +behavior you are seeing. You need a hypothesis about what the program is +actually doing. One of the things that makes that hard is that computers +run so fast. + +You will often wish that you could slow the program down to human speed, +and with some debuggers you can. But the time it takes to insert a few +well-placed print statements is often short compared to setting up the +debugger, inserting and removing breakpoints, and “stepping” the program +to where the error is occurring. + +My program doesn’t work. +~~~~~~~~~~~~~~~~~~~~~~~~ + +You should ask yourself these questions: + +- Is there something the program was supposed to do but which doesn’t + seem to be happening? Find the section of the code that performs that + function and make sure it is executing when you think it should. + +- Is something happening that shouldn’t? Find code in your program that + performs that function and see if it is executing when it shouldn’t. + +- Is a section of code producing an effect that is not what you + expected? Make sure that you understand the code in question, + especially if it involves functions or methods in other Python + modules. Read the documentation for the functions you call. Try them + out by writing simple test cases and checking the results. + +In order to program, you need a mental model of how programs work. If +you write a program that doesn’t do what you expect, often the problem +is not in the program; it’s in your mental model. + +The best way to correct your mental model is to break the program into +its components (usually the functions and methods) and test each +component independently. Once you find the discrepancy between your +model and reality, you can solve the problem. + +Of course, you should be building and testing components as you develop +the program. If you encounter a problem, there should be only a small +amount of new code that is not known to be correct. + +I’ve got a big hairy expression and it doesn’t do what I expect. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Writing complex expressions is fine as long as they are readable, but +they can be hard to debug. It is often a good idea to break a complex +expression into a series of assignments to temporary variables. + +For example: + +:: + + self.hands[i].addCard(self.hands[self.findNeighbor(i)].popCard()) + +This can be rewritten as: + +:: + + neighbor = self.findNeighbor(i) + pickedCard = self.hands[neighbor].popCard() + self.hands[i].addCard(pickedCard) + +The explicit version is easier to read because the variable names +provide additional documentation, and it is easier to debug because you +can check the types of the intermediate variables and display their +values. + +Another problem that can occur with big expressions is that the order of +evaluation may not be what you expect. For example, if you are +translating the expression :math:`\frac{x}{2 \pi}` into Python, you +might write: + +:: + + y = x / 2 * math.pi + +That is not correct because multiplication and division have the same +precedence and are evaluated from left to right. So this expression +computes :math:`x \pi / 2`. + +A good way to debug expressions is to add parentheses to make the order +of evaluation explicit: + +:: + + y = x / (2 * math.pi) + +Whenever you are not sure of the order of evaluation, use parentheses. +Not only will the program be correct (in the sense of doing what you +intended), it will also be more readable for other people who haven’t +memorized the order of operations. + +I’ve got a function that doesn’t return what I expect. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you have a return statement with a complex expression, you don’t have +a chance to print the result before returning. Again, you can use a +temporary variable. For example, instead of: + +:: + + return self.hands[i].removeMatches() + +you could write: + +:: + + count = self.hands[i].removeMatches() + return count + +Now you have the opportunity to display the value of count before +returning. + +I’m really, really stuck and I need help. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +First, try getting away from the computer for a few minutes. Computers +emit waves that affect the brain, causing these symptoms: + +- Frustration and rage. + +- Superstitious beliefs (“the computer hates me”) and magical thinking + (“the program only works when I wear my hat backward”). + +- Random walk programming (the attempt to program by writing every + possible program and choosing the one that does the right thing). + +If you find yourself suffering from any of these symptoms, get up and go +for a walk. When you are calm, think about the program. What is it +doing? What are some possible causes of that behavior? When was the last +time you had a working program, and what did you do next? + +Sometimes it just takes time to find a bug. I often find bugs when I am +away from the computer and let my mind wander. Some of the best places +to find bugs are trains, showers, and in bed, just before you fall +asleep. + +No, I really need help. +~~~~~~~~~~~~~~~~~~~~~~~ + +It happens. Even the best programmers occasionally get stuck. Sometimes +you work on a program so long that you can’t see the error. You need a +fresh pair of eyes. + +Before you bring someone else in, make sure you are prepared. Your +program should be as simple as possible, and you should be working on +the smallest input that causes the error. You should have print +statements in the appropriate places (and the output they produce should +be comprehensible). You should understand the problem well enough to +describe it concisely. + +When you bring someone in to help, be sure to give them the information +they need: + +- If there is an error message, what is it and what part of the program + does it indicate? + +- What was the last thing you did before this error occurred? What were + the last lines of code that you wrote, or what is the new test case + that fails? + +- What have you tried so far, and what have you learned? + +When you find the bug, take a second to think about what you could have +done to find it faster. Next time you see something similar, you will be +able to find the bug more quickly. + +Remember, the goal is not just to make the program work. The goal is to +learn how to make the program work. diff --git a/book/B-analysis-alg.rst b/book/B-analysis-alg.rst new file mode 100644 index 0000000..3f7fd8c --- /dev/null +++ b/book/B-analysis-alg.rst @@ -0,0 +1,563 @@ +Analysis of Algorithms +====================== + + This appendix is an edited excerpt from *Think Complexity*, by Allen + B. Downey, also published by O’Reilly Media (2012). When you are + done with this book, you might want to move on to that one. + +**Analysis of algorithms** is a branch of computer science that studies +the performance of algorithms, especially their run time and space +requirements. See http://en.wikipedia.org/wiki/Analysis_of_algorithms. + +The practical goal of algorithm analysis is to predict the performance +of different algorithms in order to guide design decisions. + +During the 2008 United States Presidential Campaign, candidate Barack +Obama was asked to perform an impromptu analysis when he visited Google. +Chief executive Eric Schmidt jokingly asked him for “the most efficient +way to sort a million 32-bit integers.” Obama had apparently been tipped +off, because he quickly replied, “I think the bubble sort would be the +wrong way to go.” See http://www.youtube.com/watch?v=k4RRi_ntQc8. + +This is true: bubble sort is conceptually simple but slow for large +datasets. The answer Schmidt was probably looking for is “radix sort” +(http://en.wikipedia.org/wiki/Radix_sort) [2]_. + +The goal of algorithm analysis is to make meaningful comparisons between +algorithms, but there are some problems: + +- The relative performance of the algorithms might depend on + characteristics of the hardware, so one algorithm might be faster on + Machine A, another on Machine B. The general solution to this problem + is to specify a **machine model** and analyze the number of steps, or + operations, an algorithm requires under a given model. + +- Relative performance might depend on the details of the dataset. For + example, some sorting algorithms run faster if the data are already + partially sorted; other algorithms run slower in this case. A common + way to avoid this problem is to analyze the **worst case** scenario. + It is sometimes useful to analyze average case performance, but + that’s usually harder, and it might not be obvious what set of cases + to average over. + +- Relative performance also depends on the size of the problem. A + sorting algorithm that is fast for small lists might be slow for long + lists. The usual solution to this problem is to express run time (or + number of operations) as a function of problem size, and group + functions into categories depending on how quickly they grow as + problem size increases. + +The good thing about this kind of comparison is that it lends itself to +simple classification of algorithms. For example, if I know that the run +time of Algorithm A tends to be proportional to the size of the input, +:math:`n`, and Algorithm B tends to be proportional to :math:`n^2`, then +I expect A to be faster than B, at least for large values of :math:`n`. + +This kind of analysis comes with some caveats, but we’ll get to that +later. + +Order of growth +--------------- + +Suppose you have analyzed two algorithms and expressed their run times +in terms of the size of the input: Algorithm A takes :math:`100n+1` +steps to solve a problem with size :math:`n`; Algorithm B takes +:math:`n^2 + n + 1` steps. + +The following table shows the run time of these algorithms for different +problem sizes: + ++----------+---------------+---------------------+ +| Input | Run time of | Run time of | ++----------+---------------+---------------------+ +| size | Algorithm A | Algorithm B | ++----------+---------------+---------------------+ +| 10 | 1 001 | 111 | ++----------+---------------+---------------------+ +| 100 | 10 001 | 10 101 | ++----------+---------------+---------------------+ +| 1 000 | 100 001 | 1 001 001 | ++----------+---------------+---------------------+ +| 10 000 | 1 000 001 | :math:`> 10^{10}` | ++----------+---------------+---------------------+ + +At :math:`n=10`, Algorithm A looks pretty bad; it takes almost 10 times +longer than Algorithm B. But for :math:`n=100` they are about the same, +and for larger values A is much better. + +The fundamental reason is that for large values of :math:`n`, any +function that contains an :math:`n^2` term will grow faster than a +function whose leading term is :math:`n`. The **leading term** is the +term with the highest exponent. + +For Algorithm A, the leading term has a large coefficient, 100, which is +why B does better than A for small :math:`n`. But regardless of the +coefficients, there will always be some value of :math:`n` where +:math:`a n^2 > b n`, for any values of :math:`a` and :math:`b`. + +The same argument applies to the non-leading terms. Even if the run time +of Algorithm A were :math:`n+1000000`, it would still be better than +Algorithm B for sufficiently large :math:`n`. + +In general, we expect an algorithm with a smaller leading term to be a +better algorithm for large problems, but for smaller problems, there may +be a **crossover point** where another algorithm is better. The location +of the crossover point depends on the details of the algorithms, the +inputs, and the hardware, so it is usually ignored for purposes of +algorithmic analysis. But that doesn’t mean you can forget about it. + +If two algorithms have the same leading order term, it is hard to say +which is better; again, the answer depends on the details. So for +algorithmic analysis, functions with the same leading term are +considered equivalent, even if they have different coefficients. + +An **order of growth** is a set of functions whose growth behavior is +considered equivalent. For example, :math:`2n`, :math:`100n` and +:math:`n+1` belong to the same order of growth, which is written +:math:`O(n)` in **Big-Oh notation** and often called **linear** because +every function in the set grows linearly with :math:`n`. + +All functions with the leading term :math:`n^2` belong to +:math:`O(n^2)`; they are called **quadratic**. + +The following table shows some of the orders of growth that appear most +commonly in algorithmic analysis, in increasing order of badness. + ++-------------------------+-----------------------------------+----+ +| Order of | Name | | ++-------------------------+-----------------------------------+----+ +| growth | | | ++-------------------------+-----------------------------------+----+ +| :math:`O(1)` | constant | | ++-------------------------+-----------------------------------+----+ +| :math:`O(\log_b n)` | logarithmic (for any :math:`b`) | | ++-------------------------+-----------------------------------+----+ +| :math:`O(n)` | linear | | ++-------------------------+-----------------------------------+----+ +| :math:`O(n \log_b n)` | linearithmic | | ++-------------------------+-----------------------------------+----+ +| :math:`O(n^2)` | quadratic | | ++-------------------------+-----------------------------------+----+ +| :math:`O(n^3)` | cubic | | ++-------------------------+-----------------------------------+----+ +| :math:`O(c^n)` | exponential (for any :math:`c`) | | ++-------------------------+-----------------------------------+----+ + +For the logarithmic terms, the base of the logarithm doesn’t matter; +changing bases is the equivalent of multiplying by a constant, which +doesn’t change the order of growth. Similarly, all exponential functions +belong to the same order of growth regardless of the base of the +exponent. Exponential functions grow very quickly, so exponential +algorithms are only useful for small problems. + +Read the Wikipedia page on Big-Oh notation at +http://en.wikipedia.org/wiki/Big_O_notation and answer the following +questions: + +#. What is the order of growth of :math:`n^3 + n^2`? What about + :math:`1000000 n^3 + n^2`? What about :math:`n^3 + 1000000 n^2`? + +#. What is the order of growth of :math:`(n^2 + n) \cdot (n + 1)`? + Before you start multiplying, remember that you only need the leading + term. + +#. If :math:`f` is in :math:`O(g)`, for some unspecified function + :math:`g`, what can we say about :math:`af+b`? + +#. If :math:`f_1` and :math:`f_2` are in :math:`O(g)`, what can we say + about :math:`f_1 + f_2`? + +#. If :math:`f_1` is in :math:`O(g)` and :math:`f_2` is in :math:`O(h)`, + what can we say about :math:`f_1 + f_2`? + +#. If :math:`f_1` is in :math:`O(g)` and :math:`f_2` is :math:`O(h)`, + what can we say about :math:`f_1 \cdot f_2`? + +Programmers who care about performance often find this kind of analysis +hard to swallow. They have a point: sometimes the coefficients and the +non-leading terms make a real difference. Sometimes the details of the +hardware, the programming language, and the characteristics of the input +make a big difference. And for small problems asymptotic behavior is +irrelevant. + +But if you keep those caveats in mind, algorithmic analysis is a useful +tool. At least for large problems, the “better” algorithms is usually +better, and sometimes it is *much* better. The difference between two +algorithms with the same order of growth is usually a constant factor, +but the difference between a good algorithm and a bad algorithm is +unbounded! + +Analysis of basic Python operations +----------------------------------- + +In Python, most arithmetic operations are constant time; multiplication +usually takes longer than addition and subtraction, and division takes +even longer, but these run times don’t depend on the magnitude of the +operands. Very large integers are an exception; in that case the run +time increases with the number of digits. + +Indexing operations—reading or writing elements in a sequence or +dictionary—are also constant time, regardless of the size of the data +structure. + +A for loop that traverses a sequence or dictionary is usually linear, as +long as all of the operations in the body of the loop are constant time. +For example, adding up the elements of a list is linear: + +:: + + total = 0 + for x in t: + total += x + +The built-in function sum is also linear because it does the same thing, +but it tends to be faster because it is a more efficient implementation; +in the language of algorithmic analysis, it has a smaller leading +coefficient. + +As a rule of thumb, if the body of a loop is in :math:`O(n^a)` then the +whole loop is in :math:`O(n^{a+1})`. The exception is if you can show +that the loop exits after a constant number of iterations. If a loop +runs :math:`k` times regardless of :math:`n`, then the loop is in +:math:`O(n^a)`, even for large :math:`k`. + +Multiplying by :math:`k` doesn’t change the order of growth, but neither +does dividing. So if the body of a loop is in :math:`O(n^a)` and it runs +:math:`n/k` times, the loop is in :math:`O(n^{a+1})`, even for large +:math:`k`. + +Most string and tuple operations are linear, except indexing and len, +which are constant time. The built-in functions min and max are linear. +The run-time of a slice operation is proportional to the length of the +output, but independent of the size of the input. + +String concatenation is linear; the run time depends on the sum of the +lengths of the operands. + +All string methods are linear, but if the lengths of the strings are +bounded by a constant—for example, operations on single characters—they +are considered constant time. The string method join is linear; the run +time depends on the total length of the strings. + +Most list methods are linear, but there are some exceptions: + +- Adding an element to the end of a list is constant time on average; + when it runs out of room it occasionally gets copied to a bigger + location, but the total time for :math:`n` operations is + :math:`O(n)`, so the average time for each operation is :math:`O(1)`. + +- Removing an element from the end of a list is constant time. + +- Sorting is :math:`O(n \log n)`. + +Most dictionary operations and methods are constant time, but there are +some exceptions: + +- The run time of update is proportional to the size of the dictionary + passed as a parameter, not the dictionary being updated. + +- keys, values and items are constant time because they return + iterators. But if you loop through the iterators, the loop will be + linear. + +The performance of dictionaries is one of the minor miracles of computer +science. We will see how they work in Section [hashtable]. + +Read the Wikipedia page on sorting algorithms at +http://en.wikipedia.org/wiki/Sorting_algorithm and answer the following +questions: + +#. What is a “comparison sort?” What is the best worst-case order of + growth for a comparison sort? What is the best worst-case order of + growth for any sort algorithm? + +#. What is the order of growth of bubble sort, and why does Barack Obama + think it is “the wrong way to go?” + +#. What is the order of growth of radix sort? What preconditions do we + need to use it? + +#. What is a stable sort and why might it matter in practice? + +#. What is the worst sorting algorithm (that has a name)? + +#. What sort algorithm does the C library use? What sort algorithm does + Python use? Are these algorithms stable? You might have to Google + around to find these answers. + +#. Many of the non-comparison sorts are linear, so why does does Python + use an :math:`O(n \log n)` comparison sort? + +Analysis of search algorithms +----------------------------- + +A **search** is an algorithm that takes a collection and a target item +and determines whether the target is in the collection, often returning +the index of the target. + +The simplest search algorithm is a “linear search”, which traverses the +items of the collection in order, stopping if it finds the target. In +the worst case it has to traverse the entire collection, so the run time +is linear. + +The in operator for sequences uses a linear search; so do string methods +like find and count. + +If the elements of the sequence are in order, you can use a **bisection +search**, which is :math:`O(\log n)`. Bisection search is similar to the +algorithm you might use to look a word up in a dictionary (a paper +dictionary, not the data structure). Instead of starting at the +beginning and checking each item in order, you start with the item in +the middle and check whether the word you are looking for comes before +or after. If it comes before, then you search the first half of the +sequence. Otherwise you search the second half. Either way, you cut the +number of remaining items in half. + +If the sequence has 1,000,000 items, it will take about 20 steps to find +the word or conclude that it’s not there. So that’s about 50,000 times +faster than a linear search. + +Bisection search can be much faster than linear search, but it requires +the sequence to be in order, which might require extra work. + +There is another data structure, called a **hashtable** that is even +faster—it can do a search in constant time—and it doesn’t require the +items to be sorted. Python dictionaries are implemented using +hashtables, which is why most dictionary operations, including the in +operator, are constant time. + +Hashtables +---------- + +To explain how hashtables work and why their performance is so good, I +start with a simple implementation of a map and gradually improve it +until it’s a hashtable. + +I use Python to demonstrate these implementations, but in real life you +wouldn’t write code like this in Python; you would just use a +dictionary! So for the rest of this chapter, you have to imagine that +dictionaries don’t exist and you want to implement a data structure that +maps from keys to values. The operations you have to implement are: + +add(k, v): + Add a new item that maps from key k to value v. With a Python + dictionary, d, this operation is written d[k] = v. + +get(k): + Look up and return the value that corresponds to key k. With a + Python dictionary, d, this operation is written d[k] or d.get(k). + +For now, I assume that each key only appears once. The simplest +implementation of this interface uses a list of tuples, where each tuple +is a key-value pair. + +:: + + class LinearMap: + + def __init__(self): + self.items = [] + + def add(self, k, v): + self.items.append((k, v)) + + def get(self, k): + for key, val in self.items: + if key == k: + return val + raise KeyError + +add appends a key-value tuple to the list of items, which takes constant +time. + +get uses a for loop to search the list: if it finds the target key it +returns the corresponding value; otherwise it raises a KeyError. So get +is linear. + +An alternative is to keep the list sorted by key. Then get could use a +bisection search, which is :math:`O(\log n)`. But inserting a new item +in the middle of a list is linear, so this might not be the best option. +There are other data structures that can implement add and get in log +time, but that’s still not as good as constant time, so let’s move on. + +One way to improve LinearMap is to break the list of key-value pairs +into smaller lists. Here’s an implementation called BetterMap, which is +a list of 100 LinearMaps. As we’ll see in a second, the order of growth +for get is still linear, but BetterMap is a step on the path toward +hashtables: + +:: + + class BetterMap: + + def __init__(self, n=100): + self.maps = [] + for i in range(n): + self.maps.append(LinearMap()) + + def find_map(self, k): + index = hash(k) % len(self.maps) + return self.maps[index] + + def add(self, k, v): + m = self.find_map(k) + m.add(k, v) + + def get(self, k): + m = self.find_map(k) + return m.get(k) + +``__init__`` makes a list of n LinearMaps. + +``find_map`` is used by add and get to figure out which map to put the +new item in, or which map to search. + +``find_map`` uses the built-in function hash, which takes almost any +Python object and returns an integer. A limitation of this +implementation is that it only works with hashable keys. Mutable types +like lists and dictionaries are unhashable. + +Hashable objects that are considered equivalent return the same hash +value, but the converse is not necessarily true: two objects with +different values can return the same hash value. + +``find_map`` uses the modulus operator to wrap the hash values into the +range from 0 to len(self.maps), so the result is a legal index into the +list. Of course, this means that many different hash values will wrap +onto the same index. But if the hash function spreads things out pretty +evenly (which is what hash functions are designed to do), then we expect +:math:`n/100` items per LinearMap. + +Since the run time of LinearMap.get is proportional to the number of +items, we expect BetterMap to be about 100 times faster than LinearMap. +The order of growth is still linear, but the leading coefficient is +smaller. That’s nice, but still not as good as a hashtable. + +Here (finally) is the crucial idea that makes hashtables fast: if you +can keep the maximum length of the LinearMaps bounded, LinearMap.get is +constant time. All you have to do is keep track of the number of items +and when the number of items per LinearMap exceeds a threshold, resize +the hashtable by adding more LinearMaps. + +Here is an implementation of a hashtable: + +:: + + class HashMap: + + def __init__(self): + self.maps = BetterMap(2) + self.num = 0 + + def get(self, k): + return self.maps.get(k) + + def add(self, k, v): + if self.num == len(self.maps.maps): + self.resize() + + self.maps.add(k, v) + self.num += 1 + + def resize(self): + new_maps = BetterMap(self.num * 2) + + for m in self.maps.maps: + for k, v in m.items: + new_maps.add(k, v) + + self.maps = new_maps + +Each HashMap contains a BetterMap; ``__init__`` starts with just 2 +LinearMaps and initializes num, which keeps track of the number of +items. + +get just dispatches to BetterMap. The real work happens in add, which +checks the number of items and the size of the BetterMap: if they are +equal, the average number of items per LinearMap is 1, so it calls +resize. + +resize make a new BetterMap, twice as big as the previous one, and then +“rehashes” the items from the old map to the new. + +Rehashing is necessary because changing the number of LinearMaps changes +the denominator of the modulus operator in ``find_map``. That means that +some objects that used to hash into the same LinearMap will get split up +(which is what we wanted, right?). + +Rehashing is linear, so resize is linear, which might seem bad, since I +promised that add would be constant time. But remember that we don’t +have to resize every time, so add is usually constant time and only +occasionally linear. The total amount of work to run add :math:`n` times +is proportional to :math:`n`, so the average time of each add is +constant time! + +To see how this works, think about starting with an empty HashTable and +adding a sequence of items. We start with 2 LinearMaps, so the first 2 +adds are fast (no resizing required). Let’s say that they take one unit +of work each. The next add requires a resize, so we have to rehash the +first two items (let’s call that 2 more units of work) and then add the +third item (one more unit). Adding the next item costs 1 unit, so the +total so far is 6 units of work for 4 items. + +The next add costs 5 units, but the next three are only one unit each, +so the total is 14 units for the first 8 adds. + +The next add costs 9 units, but then we can add 7 more before the next +resize, so the total is 30 units for the first 16 adds. + +After 32 adds, the total cost is 62 units, and I hope you are starting +to see a pattern. After :math:`n` adds, where :math:`n` is a power of +two, the total cost is :math:`2n-2` units, so the average work per add +is a little less than 2 units. When :math:`n` is a power of two, that’s +the best case; for other values of :math:`n` the average work is a +little higher, but that’s not important. The important thing is that it +is :math:`O(1)`. + +Figure [fig.hash] shows how this works graphically. Each block +represents a unit of work. The columns show the total work for each add +in order from left to right: the first two adds cost 1 units, the third +costs 3 units, etc. + +.. figure:: figs/towers.pdf + :alt: The cost of a hashtable add.[fig.hash] + + The cost of a hashtable add.[fig.hash] + +The extra work of rehashing appears as a sequence of increasingly tall +towers with increasing space between them. Now if you knock over the +towers, spreading the cost of resizing over all adds, you can see +graphically that the total cost after :math:`n` adds is :math:`2n - 2`. + +An important feature of this algorithm is that when we resize the +HashTable it grows geometrically; that is, we multiply the size by a +constant. If you increase the size arithmetically—adding a fixed number +each time—the average time per add is linear. + +You can download my implementation of HashMap from +http://thinkpython2.com/code/Map.py, but remember that there is no +reason to use it; if you want a map, just use a Python dictionary. + +.. _glossaryB: + +Glossary +-------- + +.. include:: glossary/B.txt + + +.. [1] + popen is deprecated now, which means we are supposed to stop using it + and start using the subprocess module. But for simple cases, I find + subprocess more complicated than necessary. So I am going to keep + using popen until they take it away. + +.. [2] + But if you get a question like this in an interview, I think a better + answer is, “The fastest way to sort a million integers is to use + whatever sort function is provided by the language I’m using. Its + performance is good enough for the vast majority of applications, but + if it turned out that my application was too slow, I would use a + profiler to see where the time was being spent. If it looked like a + faster sort algorithm would have a significant effect on performance, + then I would look around for a good implementation of radix sort.” diff --git a/book/C-glossary.rst b/book/C-glossary.rst new file mode 100644 index 0000000..5c03365 --- /dev/null +++ b/book/C-glossary.rst @@ -0,0 +1,11 @@ +Glossário Consolidado +===================== + +Este glossário é a união de todos os glossários dos capítulos. +Cada entrada está vinculada ao capítulo onde ela aparece, por exemplo: +*bug* :ref:`[1] `. + +Note que alguns termos aparecem em mais de um capítulo, às vezes +com definições diferentes, de acordo com o contexto. + + diff --git a/book/Makefile b/book/Makefile index e3a1074..92475e5 100644 --- a/book/Makefile +++ b/book/Makefile @@ -1,96 +1,192 @@ -LATEX = latex - -DVIPS = dvips - -PDFFLAGS = -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress \ - -dCompressPages=true -dUseFlateCompression=true \ - -dEmbedAllFonts=true -dSubsetFonts=true -dMaxSubsetPct=100 - - -%.dvi: %.tex - $(LATEX) $< - -%.ps: %.dvi - $(DVIPS) -o $@ $< - -%.pdf: %.ps - ps2pdf $(PDFFLAGS) $< - -all: book.tex - makeindex book.idx - pdflatex book - mv book.pdf thinkpython2.pdf - evince thinkpython2.pdf - -hevea: book.tex header.html footer.html - # replace the pdfs with eps - sed s/.pdf/.eps/g book.tex > thinkpython2.tex - latex thinkpython2 - rm -rf html - mkdir html - hevea -fix -O -e latexonly htmlonly thinkpython2 -# the following greps are a kludge to prevent imagen from seeing -# the definitions in latexonly, and to avoid headers on the images - grep -v latexonly thinkpython2.image.tex > a; mv a thinkpython2.image.tex - grep -v fancyhdr thinkpython2.image.tex > a; mv a thinkpython2.image.tex - imagen -png thinkpython2 - hacha thinkpython2.html - cp up.png next.png back.png html - mv index.html thinkpython2.css thinkpython2*.html thinkpython2*.png *motif.gif html - -DEST = /home/downey/public_html/greent/thinkpython2 - -epub: - cd html; ebook-convert index.html thinkpython2.epub - -distrib: - rm -rf dist - mkdir dist dist/tex dist/tex/figs - rsync -a thinkpython2.pdf html dist - rsync -a Makefile book.tex latexonly htmlonly dist/tex - rsync -a figs/*.fig figs/*.pdf dist/tex/figs - cd dist; zip -r thinkpython2.tex.zip tex - cd dist; zip -r thinkpython2.html.zip html - rsync -a dist/* $(DEST) - chmod -R o+r $(DEST)/* - cd $(DEST)/..; sh back - -# UPDATE THE PATHS BELOW BEFORE RUNNING PLASTEX - -plastex: - # Before running plastex, we need the current directory in PYTHONPATH - # export PYTHONPATH=$PYTHONPATH:. - python Filist.py book.tex > book.plastex - rm -rf /home/downey/thinkpython2/trunk/book - plastex --renderer=DocBook --theme=book --image-resolution=300 --filename=book.xml book.plastex - rm -rf /home/downey/thinkpython2/trunk/book/.svn - -plastest: - # Before running plastex, we need the current directory in PYTHONPATH - # export PYTHONPATH=$PYTHONPATH:. - python Filist.py test.tex > test.plastex - rm -rf /home/downey/thinkpython2/trunk/test - plastex --renderer=DocBook --theme=test --filename=test.xml test.plastex - rm -rf /home/downey/thinkpython2/trunk/test/.svn - -xxe: - xmlcopyeditor ~/ThinkDSP/book/book/book.xml & - -lint: - xmllint -noout book/book.xml - -OREILLY = atlas - -oreilly: - rsync -a book.tex $(OREILLY) - rsync -a book/ $(OREILLY) - rsync -a figs/* $(OREILLY)/figs - cd $(OREILLY); git add . - cd $(OREILLY); git commit -m "Automated check in." - cd $(OREILLY); git push +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " coverage to run coverage check of the documentation (if enabled)" clean: - rm -f *~ *.aux *.log *.dvi *.idx *.ilg *.ind *.toc - - + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PensePython.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PensePython.qhc" + +applehelp: + $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp + @echo + @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." + @echo "N.B. You won't be able to view it unless you put it in" \ + "~/Library/Documentation/Help or install it in your application" \ + "bundle." + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/PensePython" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PensePython" + @echo "# devhelp" +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +coverage: + $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage + @echo "Testing of coverage in the sources finished, look at the " \ + "results in $(BUILDDIR)/coverage/python.txt." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/book/conf.py b/book/conf.py new file mode 100644 index 0000000..6f14880 --- /dev/null +++ b/book/conf.py @@ -0,0 +1,359 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Pense Python documentation build configuration file, created by +# sphinx-quickstart on Sun Nov 15 23:39:59 2015. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.doctest', + 'sphinx.ext.todo', + 'sphinx.ext.pngmath', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = 'Pense Python' +copyright = '2015, Allen B. Downey' +author = 'Allen B. Downey' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '2e' +# The full version, including alpha/beta/rc tags. +release = '2e' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = 'pt-br' + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'PensePythondoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'PensePython.tex', 'Pense Python Documentation', + 'Allen B. Downey', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'pensepython', 'Pense Python Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'PensePython', 'Pense Python Documentation', + author, 'PensePython', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + + +# -- Options for Epub output ---------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project +epub_author = author +epub_publisher = author +epub_copyright = copyright + +# The basename for the epub file. It defaults to the project name. +#epub_basename = project + +# The HTML theme for the epub output. Since the default themes are not optimized +# for small screen space, using the same theme for HTML and epub output is +# usually not wise. This defaults to 'epub', a theme designed to save visual +# space. +#epub_theme = 'epub' + +# The language of the text. It defaults to the language option +# or 'en' if the language is not set. +#epub_language = '' + +# The scheme of the identifier. Typical schemes are ISBN or URL. +#epub_scheme = '' + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +#epub_identifier = '' + +# A unique identification for the text. +#epub_uid = '' + +# A tuple containing the cover image and cover page html template filenames. +#epub_cover = () + +# A sequence of (type, uri, title) tuples for the guide element of content.opf. +#epub_guide = () + +# HTML files that should be inserted before the pages created by sphinx. +# The format is a list of tuples containing the path and title. +#epub_pre_files = [] + +# HTML files shat should be inserted after the pages created by sphinx. +# The format is a list of tuples containing the path and title. +#epub_post_files = [] + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ['search.html'] + +# The depth of the table of contents in toc.ncx. +#epub_tocdepth = 3 + +# Allow duplicate toc entries. +#epub_tocdup = True + +# Choose between 'default' and 'includehidden'. +#epub_tocscope = 'default' + +# Fix unsupported image types using the Pillow. +#epub_fix_images = False + +# Scale large images. +#epub_max_image_width = 0 + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#epub_show_urls = 'inline' + +# If false, no index is generated. +#epub_use_index = True diff --git a/book/glossary/01.txt b/book/glossary/01.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/02.txt b/book/glossary/02.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/03.txt b/book/glossary/03.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/04.txt b/book/glossary/04.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/05.txt b/book/glossary/05.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/06.txt b/book/glossary/06.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/07.txt b/book/glossary/07.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/08.txt b/book/glossary/08.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/09.txt b/book/glossary/09.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/10.txt b/book/glossary/10.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/11.txt b/book/glossary/11.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/12.txt b/book/glossary/12.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/13.txt b/book/glossary/13.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/14.txt b/book/glossary/14.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/15.txt b/book/glossary/15.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/16.txt b/book/glossary/16.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/17.txt b/book/glossary/17.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/18.txt b/book/glossary/18.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/19.txt b/book/glossary/19.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/glossary/B.txt b/book/glossary/B.txt new file mode 100644 index 0000000..e69de29 diff --git a/book/index.rst b/book/index.rst new file mode 100644 index 0000000..859ec1b --- /dev/null +++ b/book/index.rst @@ -0,0 +1,44 @@ +.. Pense Python documentation master file, created by + sphinx-quickstart on Sun Nov 15 23:39:59 2015. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Pense Python's documentation! +======================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + 00-front-matter.rst + 01-the-way.rst + 02-statement.rst + 03-function.rst + 04-case-ui.rst + 05-cond-recur.rst + 06-fruitful-fn.rst + 07-iteration.rst + 08-string.rst + 09-case-word.rst + 10-list.rst + 11-dict.rst + 12-tuple.rst + 13-case-struct.rst + 14-file.rst + 15-cls-object.rst + 16-cls-fn.rst + 17-cls-meth.rst + 18-inherit.rst + 19-goodies.rst + A-debug.rst + B-analysis-alg.rst + C-glossary.rst + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/book/make.bat b/book/make.bat new file mode 100644 index 0000000..7df0dff --- /dev/null +++ b/book/make.bat @@ -0,0 +1,263 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. xml to make Docutils-native XML files + echo. pseudoxml to make pseudoxml-XML files for display purposes + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + echo. coverage to run coverage check of the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + + +REM Check if sphinx-build is available and fallback to Python version if any +%SPHINXBUILD% 2> nul +if errorlevel 9009 goto sphinx_python +goto sphinx_ok + +:sphinx_python + +set SPHINXBUILD=python -m sphinx.__init__ +%SPHINXBUILD% 2> nul +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +:sphinx_ok + + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\PensePython.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\PensePython.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdf" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf + cd %~dp0 + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdfja" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf-ja + cd %~dp0 + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +if "%1" == "coverage" ( + %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage + if errorlevel 1 exit /b 1 + echo. + echo.Testing of coverage in the sources finished, look at the ^ +results in %BUILDDIR%/coverage/python.txt. + goto end +) + +if "%1" == "xml" ( + %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The XML files are in %BUILDDIR%/xml. + goto end +) + +if "%1" == "pseudoxml" ( + %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. + goto end +) + +:end diff --git a/code/Markov.py b/code/Markov.py deleted file mode 100644 index 5a5344b..0000000 --- a/code/Markov.py +++ /dev/null @@ -1,102 +0,0 @@ -"""This module contains a code example related to - -Think Python, 2nd Edition -by Allen Downey -http://thinkpython2.com - -Copyright 2015 Allen Downey - -License: http://creativecommons.org/licenses/by/4.0/ -""" - -from __future__ import print_function, division - - -import sys -import random - -from markov import skip_gutenberg_header, shift - - -class Markov: - """Encapsulates the statistical summary of a text.""" - - def __init__(self): - self.suffix_map = {} # map from prefixes to a list of suffixes - self.prefix = () # current tuple of words - - def process_file(self, filename, order=2): - """Reads a file and performs Markov analysis. - - filename: string - order: integer number of words in the prefix - - Returns: map from prefix to list of possible suffixes. - """ - fp = open(filename) - skip_gutenberg_header(fp) - - for line in fp: - for word in line.rstrip().split(): - self.process_word(word, order) - - def process_word(self, word, order=2): - """Processes each word. - - word: string - order: integer - - During the first few iterations, all we do is store up the words; - after that we start adding entries to the dictionary. - """ - if len(self.prefix) < order: - self.prefix += (word,) - return - - try: - self.suffix_map[self.prefix].append(word) - except KeyError: - # if there is no entry for this prefix, make one - self.suffix_map[self.prefix] = [word] - - self.prefix = shift(self.prefix, word) - - def random_text(self, n=100): - """Generates random wordsfrom the analyzed text. - - Starts with a random prefix from the dictionary. - - n: number of words to generate - """ - # choose a random prefix (not weighted by frequency) - start = random.choice(list(self.suffix_map.keys())) - - for i in range(n): - suffixes = self.suffix_map.get(start, None) - if suffixes == None: - # if the prefix isn't in map, we got to the end of the - # original text, so we have to start again. - self.random_text(n-i) - return - - # choose a random suffix - word = random.choice(suffixes) - print(word, end=' ') - start = shift(start, word) - - -def main(script, filename='emma.txt', n=100, order=2): - try: - n = int(n) - order = int(order) - except ValueError: - print('Usage: %d filename [# of words] [prefix length]' % script) - else: - markov = Markov() - markov.process_file(filename, order) - markov.random_text(n) - - -if __name__ == '__main__': - main(*sys.argv) - diff --git a/data/a.csv b/data/a.csv new file mode 100644 index 0000000..fa71303 --- /dev/null +++ b/data/a.csv @@ -0,0 +1,20 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +acumulador,accumulator,acumulador,10,4,A variable used in a loop to add up or accumulate a result.,Uma variável usada em um laço para somar ou acumular um resultado. +algoritmo,algorithm,algoritmo,7,8,A general process for solving a category of problems.,Um processo geral para solucionar uma certa categoria de problema. +aliasing,aliasing,“apelidamento”,10,13,A circumstance where two or more variables refer to the same object.,Uma circunstância em que duas ou mais variáveis se referem ao mesmo objeto. +analisar,parse,analisar,1,19,To examine a program and analyze the syntactic structure.,Examinar um programa e analisar sua estrutura sintática. +análise de algoritmos,analysis of algorithms,análise de algoritmos,B,1,A way to compare algorithms in terms of their run time and/or space requirements.,Uma forma de comparar algoritmos em termos do seu tempo de execução e/ou requisitos de espaço. +argumento,argument,argumento,3,8,A value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function.,Valor fornecido a uma função quando ela é chamada. Este valor é atribuído ao parâmetro correspondente na função. +argumento nomeado,keyword argument,argumento nomeado,4,5,An argument that includes the name of the parameter as a “keyword”.,Um argumento que inclui o nome do parâmetro como uma palavra-chave. +argumento opcional,optional argument,argumento opcional,8,12,A function or method argument that is not required.,Argumento que não é obrigatório para uma função ou método. +argumento posicional,positional argument,argumento posicional,17,5,"An argument that does not include a parameter name, so it is not a keyword argument.","Argumento que não inclui o nome do parâmetro, então não é um argumento nomeado." +arquivo-texto,text file,arquivo-texto,14,5,A sequence of characters stored in permanent storage like a hard drive.,"Sequência de caracteres armazenado em armazenamento permanente, como um disco rígido." +"``assert``, instrução",``assert`` statement,instrução ``assert``,16,7,A statement that checks a condition and raises an exception if it fails.,Uma instrução que checa uma condição e levanta uma exceção se ela falhar. +assinatura,interface,"assinatura, interface",4,6,"A description of how to use a function, including the name and descriptions of the arguments and return value.","Uma descrição de como usar uma função, incluindo o nome da função, descrição dos argumentos e os valores que ela retorna." +atribuição,assignment,atribuição,2,2,A statement that assigns a value to a variable.,Uma instrução que atribui um valor a uma variável. +atribuição combinada,augmented assignment,atribuição combinada,10,5,A statement that updates the value of a variable using an operator like ``+=``.,"Uma instrução que atualiza o valor de uma variável usando um operador, como um “+=”." +atributo,attribute,atributo,15,5,One of the named values associated with an object.,Um dos valores nomeados associados a um objeto. +atributo de classe,class attribute,atributo de classe,18,2,An attribute associated with a class object. Class attributes are defined inside a class definition but outside any method.,"Um atributo associado com uma classe objeto. Atributos de classe são definidos dentro de uma definição de classe, mas fora de qualquer método." +atributo de instância,instance attribute,atributo de instância,18,3,An attribute associated with an instance of a class.,Um atributo associado com uma instância de uma classe. +atualização,update,atualização,7,2,An assignment where the new value of the variable depends on the old.,Uma atribuição em que o novo valor da variável depende da antiga. +avaliar,evaluate,avaliar,2,7,To simplify an expression by performing the operations in order to yield a single value.,"Simplificar uma expressão através da realização de operações, para obter um valor único." \ No newline at end of file diff --git a/data/b.csv b/data/b.csv new file mode 100644 index 0000000..ac547ac --- /dev/null +++ b/data/b.csv @@ -0,0 +1,7 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +banco de dados,database,banco de dados,14,11,A file whose contents are organized like a dictionary with keys that correspond to values.,"Um arquivo onde seus conteúdos são organizados como um dicionário, com chaves que correspondem a valores." +bug,bug,-,1,20,An error in a program.,Erro em um programa. +busca,search,busca,8,9,A pattern of traversal that stops when it finds what it is looking for.,Um padrão de travessia que para quando encontra o que está procurando. +busca,lookup,"busca, pesquisa",11,11,A dictionary operation that takes a key and finds the corresponding value.,Uma operação de dicionário que recebe uma chave e procura o valor correspondente. +busca,search,busca,B,10,The problem of locating an element of a collection (like a list or dictionary) or determining that it is not present.,O problema de localizar um elemento em uma coleção (como uma lista ou dicionário) ou determinar se ele não está presente. +busca invertida,reverse lookup,busca invertida,11,12,A dictionary operation that takes a value and finds one or more keys that map to it.,Uma operação de dicionário que recebe um valor e procura por uma ou mais chaves que mapeiam até ele. diff --git a/data/c.csv b/data/c.csv new file mode 100644 index 0000000..773e60c --- /dev/null +++ b/data/c.csv @@ -0,0 +1,28 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +cabeçalho,header,cabeçalho,3,4,The first line of a function definition.,A primeira linha da definição da função. +caminho,path,caminho,14,7,A string that identifies a file.,Uma string que identifica um arquivo. +caminho absoluto,absolute path,caminho absoluto,14,9,A path that starts from the topmost directory in the file system.,Um caminho que começa do diretório de nível mais elevado no sistema de arquivos. +caminho relativo,relative path,caminho relativo,14,8,A path that starts from the current directory.,Um caminho que começa do diretório atual. +capturar,catch,capturar,14,10,To prevent an exception from terminating a program using the try and except statements.,Para prevenir uma exceção de terminar um programa usando as declarações try e except. +cardinalidade,multiplicity,"cardinalidade, multiplicidadade",18,12,"A notation in a class diagram that shows, for a HAS-A relationship, how many references there are to instances of another class.","Uma notação em um diagrama de classe que mostra, através de uma relação TEM-A, quantas referências existem para instâncias de outras classes." +caso base,base case,caso base,5,14,A conditional branch in a recursive function that does not make a recursive call.,Uma ramificação condicional em uma função recursiva que não faz uma chamada recursiva. +caso especial,special case,caso especial,9,3,A test case that is atypical or non-obvious (and less likely to be handled correctly).,Um caso de teste que é atípico e nem óbvio (e menos susceptível de ser processado corretamente. +chamada de função,function call,chamada de função,3,7,A statement that runs a function. It consists of the function name followed by an argument list in parentheses.,Um comando que executa uma função. Ele consiste do nome da função seguido por uma lista de argumentos entre parentêses. +chave,key,chave,11,5,An object that appears in a dictionary as the first part of a key-value pair.,Um objeto que aparece em um dicionário como a primeira parte de um par chave-valor. +classe,class,classe,15,1,A programmer-defined type. A class definition creates a new class object.,Um tipo definido pelo programador. Uma definição de classe cria um novo objeto de classe. +classe base,parent class,"classe base, superclasse",18,6,The class from which a child class inherits.,A classe do qual uma classe filha herda. +classe derivada,child class,"classe derivada, subclasse",18,7,"A new class created by inheriting from an existing class, also called a “subclass”.","Uma nova classe criada ao herdar de outra classe existente, também chamada de subclasse." +codificar,encode,codificar,18,1,To represent one set of values using another set of values by constructing a mapping between them.,Representar um conjunto de valores usando um outro conjunto de valores ao construir um mapeamento entre eles. +código morto,dead code,código morto,6,2,"Part of a program that can never run, often because it appears after a return statement.","Parte de um programa que nunca é executado, em geral por aparecer após um comando “return”." +código provisório,scaffolding,"“andaime”, código provisório",6,4,Code that is used during program development but is not part of the final version.,Código que é usado durante o desenvolvimento do programa mas não é parte da versão final. +código provisório,slice,fatia,8,5,A part of a string specified by a range of indices.,A parte de uma string especificada pelo intervalo de índices. +comentário,comment,comentário,2,15,Information in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program.,Informação em um programa que é destinada para outros programadores (ou qualquer um que ler o código fonte) e não efeito na execução do programa. +composição,composition,composição,3,18,"Using an expression as part of a larger expression, or a statement as part of a larger statement.","Usar uma expressão como parte de outra expressão maior, ou uma declaração como parte de uma declaração maior." +concatenar,concatenate,concatenar,2,14,To join two operands end-to-end.,Para juntar dois operando de ponta a ponta. +condição,condition,condição,5,7,The boolean expression in a conditional statement that determines which branch runs.,Uma expressão booleana em um comando condicional que determina a ramificação a ser executada. +condicional aninhado,nested conditional,condicional aninhado,5,11,A conditional statement that appears in one of the branches of another conditional statement.,"Uma estrutura de programa dentro de outra, tal como um comando condicional dentro de uma ramificação de um outro comando condicional." +condicional encadeado,chained conditional,condicional encadeado,5,10,A conditional statement with a series of alternative branches.,Uma ramificação condicional com mais do que dois fluxos de execução possíveis. +contador,counter,contador,8,10,"A variable used to count something, usually initialized to zero and then incremented.","Uma variável usada para contar algo, em geral inicializada com zero e incrementada no corpo de um laço." +cópia profunda,deep copy,cópia profunda,15,8,"To copy the contents of an object as well as any embedded objects, and any objects embedded in them, and so on; implemented by the deepcopy function in the copy module.","Para copiar o conteúdo de um objeto, bem como quaisquer objetos incorporados, e dos objetos embutidos neles, e assim por diante; implementado pela função “deepcopy” do módulo “copy”." +cópia rasa,shallow copy,cópia rasa,15,7,"To copy the contents of an object, including any references to embedded objects; implemented by the copy function in the copy module.","Para copiar o conteúdo de um objeto, incluindo quaisquer referências a objetos embutidos; implementada pela função “copy” no módulo “copy”." +corpo,body,corpo,3,5,The sequence of statements inside a function definition.,A sequência de comandos dentro de uma definição de função. diff --git a/data/d.csv b/data/d.csv new file mode 100644 index 0000000..45e4a96 --- /dev/null +++ b/data/d.csv @@ -0,0 +1,23 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +declaração,declaration,declaração,11,20,A statement like global that tells the interpreter something about a variable.,Uma instrução como global que diz ao interpretador algo sobre uma variável. +decrementar,decrement,decrementar,7,5,An update that decreases the value of a variable.,Uma atualização que reduz o valor de uma variável. +definição de função,function definition,definição de função,3,2,"A statement that creates a new function, specifying its name, parameters, and the statements it contains.","Uma instrução que cria uma nova função especificando seu nome, parâmetros, e as instruções que contém." +delimitador,delimiter,delimitador,10,14,A character or string used to indicate where a string should be split.,Um caractere ou string que indica onde uma string deve ser dividida. +dependência,dependency,dependência,18,10,"A relationship between two classes where instances of one class use instances of the other class, but do not store them as attributes.",Um relacionamento entre duas classes onde instâncias de uma classe usam instâncias de outra classe sem armazená-las como atributos. +depuração,debugging,depuração,1,21,The process of finding and correcting bugs.,Processo de encontrar e corrigir bugs. +depuração com patinho de borracha,rubber duck debugging,depuração com patinho de borracha,13,6,"Debugging by explaining your problem to an inanimate object such as a rubber duck. Articulating the problem can help you solve it, even if the rubber duck doesn’t know Python.","Depuração explicando seu problema para um objeto inanimado como um patinho de borracha. Articular o problema pode ajudar a resolvê-lo, mesmo se o patinho de borracha não conheça Python." +desempacotamento de tupla,tuple assignment,desempacotamento de tupla,12,2,An assignment with a sequence on the right side and a tuple of variables on the left. The right side is evaluated and then its elements are assigned to the variables on the left.,Uma atribuição com uma sequencia no lado direito e uma tupla no esquerdo. O lado direito é avaliado e seus elementos atribuídos às variáveis a esquerda. +desenvolvimento incremental,incremental development,desenvolvimento incremental,6,3,A program development plan intended to avoid debugging by adding and testing only a small amount of code at a time., +desenvolvimento planejado,designed development,desenvolvimento planejado,16,2,A development plan that involves high-level insight into the problem and more planning than incremental development or prototype development.,Um plano de desenvolvimento que envolve alto nível de percepção do problema e mais planejamento que os desenvolvimentos incremental e por protótipo. +despacho por tipo,type-based dispatch,despacho por tipo,17,7,A programming pattern that checks the type of an operand and invokes different functions for different types.,Um padrão de programação que verifica o tipo de um operando e invoca diferentes funções para diferentes tipos. +desvio,branch,desvio,5,9,One of the alternative sequences of statements in a conditional statement.,Uma das sequencias de instruções alternativas em uma instrução condicional. +determinístico,deterministic,determinístico,13,1,"Pertaining to a program that does the same thing each time it runs, given the same inputs.","Diz-se de um programa que faz a mesma coisa a cada execução, dadas as mesmas entradas." +diagrama de chamadas,call graph,diagrama de chamadas,11,15,"A diagram that shows every frame created during the execution of a program, with an arrow from each caller to each callee.","Um diagrama que mostra todos os frames criados durante a execução de um programa, com uma seta de cada executor para cada executado." +diagrama de classe,class diagram,diagrama de classe,18,11,A diagram that shows the classes in a program and the relationships between them.,Um diagrama que mostra as classes em um programa e os relacionamentos entre elas. +diagrama de estado,state diagram,diagrama de estado,2,3,A graphical representation of a set of variables and the values they refer to.,Uma representação gráfica de um conjunto de variáveis e os valores a que se referem. +diagrama de objetos,object diagram,diagrama de objetos,15,9,"A diagram that shows objects, their attributes, and the values of the attributes.","Um diagrama que mostra objetos, seus atributos, e os valores dos atributos." +diagrama de pilha,stack diagram,diagrama de pilha,3,20,"A graphical representation of a stack of functions, their variables, and the values they refer to.","Uma representação gráfica de uma pilha de funções, suas variáveis, e os valores a que se referem." +dicionário,dictionary,dicionário,11,2,A mapping from keys to their corresponding values.,Um mapeamento de chaves aos seus valores correspondentes. +diretório,directory,diretório,14,6,"A named collection of files, also called a folder.","Uma coleção nomeada de arquivos, também conhecida como pasta." +divisão pelo piso,floor division,divisão pelo piso,5,1,"An operator, denoted //, that divides two numbers and rounds down (toward zero) to an integer.","Um operador, denotado //, que divide dois números e os arredonda para baixo (em direção ao zero) em um inteiro." +docstring,docstring,-,4,9,A string that appears at the top of a function definition to document the function’s interface.,Uma string no início de uma definição de função que documenta a assinatura da função. diff --git a/data/e-f.csv b/data/e-f.csv new file mode 100644 index 0000000..6373367 --- /dev/null +++ b/data/e-f.csv @@ -0,0 +1,26 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +elemento,element,elemento,10,2,"One of the values in a list (or other sequence), also called items.",Um dos valores em uma lista (ou outra sequência). O operador colchetes seleciona elementos de uma lista. +encapsulamento,encapsulation,encapsulamento,4,3,The process of transforming a sequence of statements into a function definition.,O processo de transformar uma sequência de instruções em uma definição de função. +encapsulamento de dados,data encapsulation,encapsulamento de dados,18,13,A program development plan that involves a prototype using global variables and a final version that makes the global variables into instance attributes.,Plano de desenvolvimento de programa que envolve um protótipo usando variáveis globais e uma versão final que torna as variáveis globais em atributos de instância. +equivalente,equivalent,equivalente,10,10,Having the same value.,Tem o mesmo valor. +erro semântico,semantic error,erro semântico,2,19,An error in a program that makes it do something other than what the programmer intended.,Um erro no programa que faz com que ele faça algo diferente do que o programador pretendia. +erro sintático,syntax error,erro sintático,2,16,An error in a program that makes it impossible to parse (and therefore impossible to interpret).,"Um erro em um programa que o torna impossível de analisar (e portanto, impossível de interpretar)." +erro estrutural,shape error,erro estrutural,12,8,"An error caused because a value has the wrong shape; that is, the wrong type or size.","Um erro causado porquê um valor tem um formato inadequado; isto é, o tipo ou tamanho errado." +estrutura de dados,data structure,estrutura de dados,12,7,"A collection of related values, often organized in lists, dictionaries, tuples, etc.","Uma coleção de valores relacionados, geralmente organizados em listas, dicionários, tuplas, etc." +exceção,exception,exceção,2,17,An error that is detected while the program is running.,Um erro que é detectado enquanto o programa está executando. +executar,execute,executar,2,9,To run a statement and do what it says.,Executar uma declaração e fazer o que ela pede. +explodir,scatter,explodir,12,4,The operation of treating a sequence as a list of arguments.,A operação de tratar uma sequência como uma lista de argumentos. +expressão,expression,expressão,2,6,"A combination of variables, operators, and values that represents a single result.",Uma combinação de operadores e operandos (variáveis e valores) que têm valor simples como resultado. +expressão booleana,boolean expression,expressão booleana,5,3,An expression whose value is either True or False.,Uma expressão que é ou verdadeira ou falsa. +expressão condicional,conditional expression,expressão condicional,19,1,"An expression that has one of two values, depending on a condition.","Uma expressão que tem um de dois valores, dependendo de uma condição." +expressão geradora,generator expression,expressão geradora,19,3,An expression with a for loop in parentheses that yields a generator object.,Uma expressão com um loop for em parênteses que produz um objeto gerador. +fachada,veneer,“verniz” ou fachada,18,4,A method or function that provides a different interface to another function without doing much computation.,Um método ou função que fornece uma interface diferente para outra função sem fazer muita cálculo. +factory,factory,fábrica,19,5,"A function, usually passed as a parameter, used to create objects.","Uma função, normalmente passada como um parâmetro, usada para criar objetos." +filtro,filter,filtro,10,8,A processing pattern that traverses a list and selects the elements that satisfy some criterion.,Um padrão de processamento que percorre uma lista e seleciona os elementos que satisfazem algum critério. +flag,flag,“indicador”,11,19,A boolean variable used to indicate whether a condition is true.,Uma váriável do tipo boolean usada para indicar se uma condição é verdadeira. +fluxo de execução,flow of execution,fluxo de execução,3,19,The order statements run in.,A ordem em que comandos são executados durante a execução de um programa. +frame,frame,,3,21,A box in a stack diagram that represents a function call. It contains the local variables and parameters of the function.,Uma caixa em um diagrama da pilha que representa uma chamada de função. Ela contém as variáveis locais e os parâmetros da função. +função,function,função,3,1,A named sequence of statements that performs some useful operation. Functions may or may not take arguments and may or may not produce a result.,Uma sequência de comandos com um nome que executa operações úteis. Funções podem ou não ter parâmetros e podem ou não produzir um resultado. +função de hash,hash function,função de espalhamento,11,9,A function used by a hashtable to compute the location for a key.,Uma função de uma tabela de hash utilizada para calcular a localização de uma chave. +função produtiva,fruitful function,função produtiva,3,11,A function that returns a value.,Uma função que retorna um valor ao invés de None. +função pura,pure function,função pura,16,3,A function that does not modify any of the objects it receives as arguments. Most pure functions are fruitful.,Uma função que não produz efeitos colaterais. Funções puras apenas alteram os estado (variáveis) das funções que a chamam através de valores de retorno. diff --git a/data/g-i.csv b/data/g-i.csv new file mode 100644 index 0000000..e1ff9b5 --- /dev/null +++ b/data/g-i.csv @@ -0,0 +1,26 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +generalização,generalization,generalização,4,4,The process of replacing something unnecessarily specific (like a number) with something appropriately general (like a variable or parameter)., +"``global``, declaração",``global`` statement,declaração ``global``,11,18,A statement that declares a variable name global., +guarda,guardian,guarda,6,5,A programming pattern that uses a conditional statement to check for and handle circumstances that might cause an error., +hashable,hashable,,11,10,"A type that has a hash function. Immutable types like integers, floats and strings are hashable; mutable types like lists and dictionaries are not.", +herança,inheritance,herança,18,5,The ability to define a new class that is a modified version of a previously defined class., +idêntico,identical,idêntico,10,11,Being the same object (which implies equivalence)., +implementação,implementation,implementação,11,7,A way of performing a computation., +"``import``, instrução",``import`` statement,instrução ``import``,3,15,A statement that reads a module file and creates a module object., +imutável,immutable,imutável,8,7,The property of a sequence whose items cannot be changed., +incrementar,increment,incrementar,7,4,An update that increases the value of a variable (often by one)., +índice,index,índice,8,4,"An integer value used to select an item in a sequence, such as a character in a string. In Python indices start from 0.", +inicialização,initialization,inicialização,7,3,An assignment that gives an initial value to a variable that will be updated., +instância,instance,instância,15,3,An object that belongs to a class., +instanciar,instantiate,instanciar,15,4,To create a new object., +instrução,statement,instrução,2,8,"A section of code that represents a command or action. So far, the statements we have seen are assignments and print statements.", +instrução composta,compound statement,instrução composta,5,8,A statement that consists of a header and a body. The header ends with a colon (:). The body is indented relative to the header., +instrução condicional,conditional statement,instrução condicional,5,6,A statement that controls the flow of execution depending on some condition., +inteiro,integer,inteiro,1,12,A type that represents whole numbers., +interpretador,interpreter,interpretador,1,5,A program that reads another program and executes it, +invariante,invariant,invariante,16,6,A condition that should always be true during the execution of a program., +invocação,invocation,invocação,8,11,A statement that calls a method., +item,item,item,8,3,One of the values in a sequence., +item,item,item,11,4,"In a dictionary, another name for a key-value pair.", +iteração,iteration,iteração,7,6,Repeated execution of a set of statements using either a recursive function call or a loop., +iterador,iterator,iterador,12,6,"An object that can iterate through a sequence, but which does not provide list operators and methods.", diff --git a/data/l-m.csv b/data/l-m.csv new file mode 100644 index 0000000..2c1bded --- /dev/null +++ b/data/l-m.csv @@ -0,0 +1,23 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +laço,loop,"laço, loop",4,2,A part of a program that can run repeatedly.,Parte de um programa que pode ser executada repetidamente. +laço infinito,infinite loop,laço infinito,7,7,A loop in which the terminating condition is never satisfied.,Um laço cuja sua condição de término nunca é satisfeita. +linear,linear,linear,B,8,"An algorithm whose run time is proportional to problem size, at least for large problem sizes.",Um algoritmo cujo tempo de execução é proporcional ao tamanho do problema, pelo menos para os problemas de tamanhos grandes. +linguagem de alto nível,high-level language,linguagem de alto nível,1,2,A programming language like Python that is designed to be easy for humans to read and write.,Linguagem de programação, como a linguagem Python, que é projetada para ser facilmente entendida por humanos. +linguagem de baixo nível,low-level language,linguagem de baixo nível,1,3,A programming language that is designed to be easy for a computer to run; also called “machine language” or “assembly language”.,Uma linguagem de programação que é projetada para ser fácilmente executada por um computador; também conhecida como "linguagem de máquina" ou "linguagem de assembly". +linguagem formal,formal language,linguagem formal,1,16,"Any one of the languages that people have designed for specific purposes, such as representing mathematical ideas or computer programs; all programming languages are formal languages.",Qualquer linguagem que as pessoas desenvolveram para propósitos específicos, como representar idéias matemáticas ou programas de computador; todas as linguagens de programação são linguagens formais. +linguagem natural,natural language,linguagem natural,1,15,Any one of the languages that people speak that evolved naturally.,Qualquer língua que as pessoas falam e que evoluíram naturalmente com o passar do tempo. +linguagem orientada a objetos,object-oriented language,linguagem orientada a objetos,17,1,"A language that provides features, such as programmer-defined types and methods, that facilitate object-oriented programming.",Uma linguagem que fornece recursos como tipos e métodos e que facilita a programação orientada a objetos. +lista,list,lista,10,1,A sequence of values.,Sequência de valores. +lista aninhada,nested list,lista aninhada,10,3,A list that is an element of another list.,Uma lista que é um elemento de uma outra lista. +listcomp,list comprehension,"“compreensão de lista”, listcomp",19,2,An expression with a for loop in square brackets that yields a new list.,Uma expressão com um laço for entre colchetes que produz uma nova lista. +map,map,"“mapear”, “de-para”",10,7,A processing pattern that traverses a sequence and performs an operation on each element.,Um padrão de processamento que percorre uma sequência e executa uma operação em cada elemento. +mapeamento,mapping,mapeamento,11,1,A relationship in which each element of one set corresponds to an element of another set.,Um relacionamento aonde cada elemento de um conjunto corresponde a um elemento de outro conjunto. +máquina-modelo,machine model,máquina-modelo,B,2,A simplified representation of a computer used to describe algorithms.,Uma representação simplificada de um computador usado para descrever algoritmos. +memo,memo,“lembrete”,11,16,A computed value stored to avoid unnecessary future computation.,Um valor calculado que é armazenado para evitar cálculo computacional desnecessário no futuro. +método,method,método,4,1,A function that is associated with an object and called using dot notation.,Função que é associada com um objeto e é chamada usando notação de ponto. +método,method,método,17,3,A function that is defined inside a class definition and is invoked on instances of that class.,Função que é definida dentro de uma definição de classe e é invocada em instâncias desta classe. +modificadora,modifier,modificadora,16,4,"A function that changes one or more of the objects it receives as arguments. Most modifiers are void; that is, they return None.",Uma função que modifica um ou mais objetos que recebe como argumento. A maioria dos modificadores são vazios; isto é, eles retornam vazio. +modo de script,script mode,modo de script,2,11,A way of using the Python interpreter to read code from a script and run it.,Uma maneira de usar o interpretador Python para ler código de um script e executá-lo. +modo interativo,interactive mode,modo interativo,2,10,A way of using the Python interpreter by typing code at the prompt.,Uma maneira de usar o interpretador Python digitando o código no prompt de comando. +módulo,module,módulo,3,14,A file that contains a collection of related functions and other definitions.,Um arquivo que contém uma coleção de funções relacionadas e outras definiçòes. +multiset,multiset,“multi-conjunto”,19,4,A mathematical entity that represents a mapping between the elements of a set and the number of times they appear.,Uma entidade matemática que representa um mapeamento entre os elementos de um conjunto e o número de vezes que eles aparecem. diff --git a/data/n-o.csv b/data/n-o.csv new file mode 100644 index 0000000..9677ef8 --- /dev/null +++ b/data/n-o.csv @@ -0,0 +1,23 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +``None``,``None``,-,3,13,A special value returned by void functions.,Um valor especial retornado por procedimentos. +notação assintótica,Big-Oh notation,notação assintótica,B,7,"Notation for representing an order of growth; for example, :math:`O(n)` represents the set of functions that grow linearly.","Notação para representação de uma ordem de crescimento; por exemplo, :math:`O(n)` representa o conjunto de funções que crescem linearmente." +notação de ponto,dot notation,notação de ponto,3,17,The syntax for calling a function in another module by specifying the module name followed by a dot (period) and the function name.,Sintaxe para chamada de uma função em outro módulo utilizando o nome do módulo seguido por um ponto e o nome da função. +objeto,object,objeto,8,1,"Something a variable can refer to. For now, you can use “object” and “value” interchangeably.","Algo a que uma variável possa se referir. Por enquanto, você pode usar “objeto” e “valor” sem distinção." +objeto,object,objeto,10,9,Something a variable can refer to. An object has a type and a value.,Algo a que uma variável possa se referir. Um objeto possui um tipo e um valor. +objeto “pipe”,pipe object,objeto “pipe”,14,14,"An object that represents a running program, allowing a Python program to run commands and read the results.","Um objeto que representa um programa em execução, permitindo que um programa Python execute programas e leia os resultados." +objeto ``bytes``,``bytes`` object,objeto ``bytes``,14,12,An object similar to a string.,Um objeto similar a uma string. +objeto ``zip``,``zip`` object,objeto ``zip``,12,5,The result of calling a built-in function zip; an object that iterates through a sequence of tuples.,O resultado da chamada de uma função nativa zip; um objeto que itera por uma sequencia de tuplas. +objeto embutido,embedded object,objeto embutido,15,6,An object that is stored as an attribute of another object.,Um objeto que é armazenado como um atributo de outro objeto. +objeto-arquivo,file object,objeto-arquivo,9,1,A value that represents an open file.,Um valor que representa um arquivo aberto. +objeto-classe,class object,objeto-classe,15,2,An object that contains information about a programmer-defined type. The class object can be used to create instances of the type.,Um objeto que contém informações sobre um tipo definido pelo programador. O objeto-classe pode ser utilizado para criar instâncias do tipo. +objeto-função,function object,objeto-função,3,3,A value created by a function definition. The name of the function is a variable that refers to a function object.,Um valor criado por uma definição de função. O nome da função é uma variável que referencia um objeto-função. +objeto-módulo,module object,objeto-módulo,3,16,A value created by an import statement that provides access to the values defined in a module.,Um valor criado por uma instrução import que dá acesso aos valores definidos em um módulo. +ocultação de informações,information hiding,ocultação de informações,17,9,"The principle that the interface provided by an object should not depend on its implementation, in particular the representation of its attributes.","Princípio em que a interface disponibilizada por um objeto não deve depender de sua implementação, em particular da representação de seus atributos." +operador,operator,operador,1,9,"A special symbol that represents a simple computation like addition, multiplication, or string concatenation.","Um símbolo especial que representa uma computação simples como adição, multiplicação ou concatenação de string." +operador de formatação,format operator,operador de formatação,14,2,"An operator, %, that takes a format string and a tuple and generates a string that includes the elements of the tuple formatted as specified by the format string.","Um operador, %, que recebe uma string de formatação e uma tupla e gera uma string que inclui os elementos da tupla formatados conforme especificado na string de formatação." +operador de módulo,modulus operator,operador de módulo,5,2,"An operator, denoted with a percent sign (%), that works on integers and returns the remainder when one number is divided by another.","Um operador, denotado por um sinal de porcentagem (%), que atua em inteiros e retorna o resto da divisão de um número por outro." +operador lógico,logical operator,operador lógico,5,5,"One of the operators that combines boolean expressions: and, or, and not.","Um dos operadores que combinam expressões booleanas: and, or e not." +operador relacional,relational operator,operador relacional,5,4,"One of the operators that compares its operands: ==, !=, >, <, >=, and <=.","Um dos operadores que comparam os operandos: ==, !=, >, <, >= e <=." +operando,operand,operando,2,5,One of the values on which an operator operates.,Um dos valores sobre os quais um operador opera. +ordem das operações,order of operations,ordem das operações,2,13,Rules governing the order in which expressions involving multiple operators and operands are evaluated.,Regras que determinam a ordem em que expressões envolvendo múltiplos operadores e operandos são avaliados. +ordem de crescimento,order of growth,ordem de crescimento,B,6,"A set of functions that all grow in a way considered equivalent for purposes of analysis of algorithms. For example, all functions that grow linearly belong to the same order of growth.","Um conjunto de funções que crescem de forma equivalente do ponto de vista da análise de algoritmos. Por exemplo, todas as funções que crescem linearmente pertencem à mesma ordem de crescimento." diff --git a/data/p-q.csv b/data/p-q.csv new file mode 100644 index 0000000..1a867c8 --- /dev/null +++ b/data/p-q.csv @@ -0,0 +1,23 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +palavra-chave,keyword,palavra-chave,2,4,"A reserved word that is used to parse a program; you cannot use keywords like if, def, and while as variable names.","Uma palavra reservada que é usada para analisar um programa; você não pode usar palavras-chave como por exemplo if, def, e while como nomes de variáveis.", +par chave-valor,key-value pair,par chave-valor,11,3,The representation of the mapping from a key to a value.,A representação do mapeamento a partir de uma chave para um determinado valor. +parâmetro,parameter,parâmetro,3,6,A name used inside a function to refer to the value passed as an argument.,Um nome usado dentro de uma função para se referir a um valor passado como um argumento. +percorrer,traverse,percorrer,8,8,"To iterate through the items in a sequence, performing a similar operation on each.",Percorrer os items em uma sequência, realizando uma operação similar em cada item. +persistente,persistent,persistente,14,1,Pertaining to a program that runs indefinitely and keeps at least some of its data in permanent storage.,Refere-se a um programa que é executado indefinidamente e mantém ao menos alguns dos seus dados em armazenamento permanente. +pior caso,worst case,pior caso,B,3,The input that makes a given algorithm run slowest (or require the most space.,Uma entrada que faz com que um determinado algoritmo execute de maneira mais lenta (ou exige mais espaço). +plano de desenvolvimento,development plan,plano de desenvolvimento,4,8,A process for writing programs.,Processo para escrever programas. +polimórfico,polymorphic,polimórfico,17,8,Pertaining to a function that can work with more than one type.,Refere-se a uma função que pode lidar com mais de um tipo. +ponto de cruzamento,crossover point,ponto de cruzamento,B,5,The problem size where two algorithms require the same run time or space.,Um problema que ocorre quando dois algoritmos requerem o mesmo tempo de execução ou espaço. +ponto-flutuante,floating-point,ponto-flutuante,1,13,A type that represents numbers with fractional parts.,Um tipo que representa números em partes fracionadas. +portabilidade,portability,portabilidade,1,4,A property of a program that can run on more than one kind of computer.,Propriedade de um programa que pode ser executado em mais de um tipo de computador. +pós-condição,postcondition,pós-condição,4,11,A requirement that should be satisfied by the function before it ends.,Requisito que deve ser satisfeito pela função antes que esta termine. +pré-condição,precondition,pré-condição,4,10,A requirement that should be satisfied by the caller before a function starts.,Um requisito que deve ser satisfeito por quem a chamou, antes desta função iniciar. +"``print``, instrução",``print`` statement,instrução ``print``,1,8,An instruction that causes the Python interpreter to display a value on the screen.,Uma instrução que faz com que o interpretador Python mostre um determinado valor na tela. +procedimento,void function,“função nula” ou procedimento,3,12,A function that always returns None.,Uma função que sempre retorna vazio +programação funcional,program,programação funcional,1,7,A set of instructions that specifies a computation.,Um conjunto de instruções que especifica um cálculo. +programação funcional,functional programming style,programação funcional,16,5,A style of program design in which the majority of functions are pure.,Um estilo de programação em que a maioria das funções são puras. +programação orientada a objetos,object-oriented programming,programação orientada a objetos,17,2,A style of programming in which data and the operations that manipulate it are organized into classes and methods.,Um estilo de programação em que dados e as operações que os manipulam são organizados em classes e métodos. +prompt,prompt,“sinal de pronto”,1,6,Characters displayed by the interpreter to indicate that it is ready to take input from the user.,Caracteres exibidos pelo interpretador para indicar que ele está pronto para receber a entrada do usuário. +prototipar e ajustar,prototype and patch,prototipar e ajustar,16,1,"A development plan that involves writing a rough draft of a program, testing, and correcting errors as they are found.",Um plano de desenvolvimento que envolve escrever um esboço de um programa, testar, e corrigir os erros assim que eles forem encontrados. +pseudo-aleatório,pseudorandom,pseudo-aleatório,13,2,"Pertaining to a sequence of numbers that appears to be random, but is generated by a deterministic program.",Uma sequência de números que parecem ser aleatórios, mas na verdade são gerados por uma programa com sequência determinística. +quadrático,quadratic,quadrático,B,9,"An algorithm whose run time is proportional to :math:`n^2`, where :math:`n` is a measure of problem size.",Um algoritmo cujo tempo de execução é proporcional a: mat: `n^2`, aonde mat:`n`, é uma medida de tamanho do problema. diff --git a/data/r-s.csv b/data/r-s.csv new file mode 100644 index 0000000..da1f919 --- /dev/null +++ b/data/r-s.csv @@ -0,0 +1,27 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +"``raise``, instrução",``raise`` statement,instrução ``raise``,11,13,A statement that (deliberately) raises an exception., +reatribuição,reassignment,reatribuição,7,1,Assigning a new value to a variable that already exists., +recursão,recursion,recursão,5,13,The process of calling the function that is currently executing., +recursão infinita,infinite recursion,recursão infinita,5,15,"A recursion that doesn’t have a base case, or never reaches it. Eventually, an infinite recursion causes a runtime error.", +redução a um problema resolvido,reduction to a previously solved problem,redução a um problema resolvido,9,2,A way of solving a problem by expressing it as an instance of a previously solved problem., +reduzir,reduce,reduzir,10,6,A processing pattern that traverses a sequence and accumulates the elements into a single result., +refatoração,refactoring,refatoração,4,7,The process of modifying a working program to improve function interfaces and other qualities of the code., +referência,reference,referência,10,12,The association between a variable and its value., +relação É-UM,IS-A relationship,relação É-UM,18,8,A relationship between a child class and its parent class., +relação TEM-UM,HAS-A relationship,relação TEM-UM,18,9,A relationship between two classes where instances of one class contain references to instances of the other., +"``return``, instrução",``return`` statement,instrução ``return``,5,12,A statement that causes a function to end immediately and return to the caller., +reunir,gather,reunir,12,3,The operation of assembling a variable-length argument tuple., +script,script,-,2,12,A program stored in a file., +semântica,semantics,semântica,2,18,The meaning of a program., +sequência de formatação,sequence,sequência de formatação,8,2,An ordered collection of values where each value is identified by an integer index., +sequência de formatação,format sequence,sequência de formatação,14,4,"A sequence of characters in a format string, like %d, that specifies how a value should be formatted.", +shell,shell,-,14,13,A program that allows users to type commands and then executes them by starting other programs., +singleton,singleton,-,11,14,A list (or other sequence) with a single element., +sintaxe,syntax,sintaxe,1,18,The rules that govern the structure of a program., +sobrecarga de operadores,operator overloading,sobrecarga de operadores,17,6,Changing the behavior of an operator like + so it works with a programmer-defined type., +sobrepor,override,sobrescrever,13,4,To replace a default value with an argument., +solução de problemas,problem solving,solução de problemas,1,1,"The process of formulating a problem, finding a solution, and expressing it.", +string,string,“cadeia de caracteres”,1,14,A type that represents sequences of characters., +string de formatação,format string,string de formatação,14,3,"A string, used with the format operator, that contains format sequences.", +string vazia,empty string,string vazia,8,6,"A string with no characters and length 0, represented by two quotation marks.", +sujeito,subject,sujeito,17,4,The object a method is invoked on., diff --git a/data/t-v.csv b/data/t-v.csv new file mode 100644 index 0000000..f058467 --- /dev/null +++ b/data/t-v.csv @@ -0,0 +1,17 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +tabela de hash,hashtable,tabela de espalhamento,11,8,The algorithm used to implement Python dictionaries.,Algoritmo utilizado para implementar dicionários Python. +tabela de hash,hashtable,tabela de espalhamento,B,11,A data structure that represents a collection of key-value pairs and performs search in constant time.,Uma estrutura de dados que representa uma coleção de pares chave-valor e permite realizar busca em tempo constante. +termo dominante,leading term,"termo dominante, termo de maior expoente",B,4,"In a polynomial, the term with the highest exponent.",Termo com o maior expoente em um polinômio. +teste de desempenho,benchmarking,teste de desempenho,13,5,The process of choosing between data structures by implementing alternatives and testing them on a sample of the possible inputs.,Processo de escolher entre estruturas de dados, implementando alternativas e as testando com amostras de possíveis entradas. +tipo,type,tipo,1,11,"A category of values. The types we have seen so far are integers (type int), floating-point numbers (type float), and strings (type str).",Categoria de valores. Os tipos que vimos até agora são inteiro (tipo int), números de ponto flutuante (tipo float) e strings (tipo str). +token,token,“símbolo”,1,17,"One of the basic elements of the syntactic structure of a program, analogous to a word in a natural language.",Um dos elementos básicos da estrutura sintática de um programa, análogo à uma palavra em uma linguagem natural. +traceback,traceback,,3,22,"A list of the functions that are executing, printed when an exception occurs.",Lista das funções em execução que são impressas quando uma exceção ocorre. +tupla,tuple,tupla,12,1,An immutable sequence of elements.,Uma sequência imutável de elementos. +valor,value,valor,1,10,"One of the basic units of data, like a number or string, that a program manipulates.",Uma das unidades básicas de dados, como um número ou uma string, que um programa pode manipular. +valor,value,valor,11,6,An object that appears in a dictionary as the second part of a key-value pair. This is more specific than our previous use of the word “value”.,Um objeto que aparece em um dicionário como a segunda parte de um par chave-valor. É mais específico que o uso anterior da palavra valor. +valor default,default value,valor default,13,3,The value given to an optional parameter if no argument is provided.,Valor dado a um parâmetro opcional se nenhum argumento for fornecido. +valor devolvido,return value,valor devolvido,3,10,"The result of a function. If a function call is used as an expression, the return value is the value of the expression.",Resultado de uma função. Se uma chamada de função for usada como uma expressão, o valor de retorno é o valor da expressão. +variável,variable,variável,2,1,A name that refers to a value.,Um nome que faz referência a um valor. +variável global,global variable,variável global,11,17,A variable defined outside a function. Global variables can be accessed from any function.,Uma variável definida fora de uma função. Variáveis globais podem ser acessadas por qualquer função. +variável local,local variable,variável local,3,9,A variable defined inside a function. A local variable can only be used inside its function.,Uma variável definida dentro de uma função. Uma variável local só pode ser utilizada dentro da função onde foi definida. +variável temporária,temporary variable,variável temporária,6,1,A variable used to store an intermediate value in a complex calculation.,Uma variável utilizada para armazenar um valor intermediário em um cálculo complexo. diff --git a/tools/chapter-plan.ods b/tools/chapter-plan.ods new file mode 100644 index 0000000..67b2db4 Binary files /dev/null and b/tools/chapter-plan.ods differ diff --git a/tools/gloss_stats.py b/tools/gloss_stats.py new file mode 100644 index 0000000..a09bbf9 --- /dev/null +++ b/tools/gloss_stats.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import csv +import unicodedata +import string +import collections + +GLOSSARY_DATA_PATH = './glossary.csv' +FIELDS = 'term us_term br_term chapter order us_definition br_definition'.split() + +GlossaryEntry = collections.namedtuple('GlossaryEntry', FIELDS) + +def asciize(txt): + """Return only ASCII letters from text""" + return ''.join(c for c in unicodedata.normalize('NFD', txt) + if c in string.ascii_lowercase) + +def count_glossary(): + counter = collections.Counter() + master_glossary = [] + with open(GLOSSARY_DATA_PATH) as csvfile: + reader = csv.DictReader(csvfile, FIELDS) + next(reader) # skip header line + for row in reader: + entry = GlossaryEntry(**row) + #print(entry) + normal_term = asciize(entry.term.casefold()) + counter[normal_term[0]] += 1 + return counter + +if __name__ == '__main__': + res = count_glossary().most_common() + for letter, count in sorted(res): + print(letter, count) diff --git a/tools/glossary.csv b/tools/glossary.csv new file mode 100644 index 0000000..2b8475b --- /dev/null +++ b/tools/glossary.csv @@ -0,0 +1,233 @@ +ADOPTED TERM,EN-US TERM,PT-BR TERM,CHAPTER,ORDER,EN-US DEFINITION,PT-BR DEFINITION +"``assert``, instrução",``assert`` statement,instrução ``assert``,16,7,A statement that check a condition and raises an exception if it fails., +"``global``, declaração",``global`` statement,declaração ``global``,11,18,A statement that declares a variable name global., +"``import``, instrução",``import`` statement,instrução ``import``,3,15,A statement that reads a module file and creates a module object., +``None``,``None``,-,3,13,A special value returned by void functions., +"``print``, instrução",``print`` statement,instrução ``print``,1,8,An instruction that causes the Python interpreter to display a value on the screen., +"``raise``, instrução",``raise`` statement,instrução ``raise``,11,13,A statement that (deliberately) raises an exception., +"``return``, instrução",``return`` statement,instrução ``return``,5,12,A statement that causes a function to end immediately and return to the caller., +acumulador,accumulator,acumulador,10,4,A variable used in a loop to add up or accumulate a result., +algoritmo,algorithm,algoritmo,7,8,A general process for solving a category of problems., +aliasing,aliasing,“apelidamento”,10,13,A circumstance where two or more variables refer to the same object., +analisar,parse,analisar,1,19,To examine a program and analyze the syntactic structure., +análise de algoritmos,analysis of algorithms,análise de algoritmos,B,1,A way to compare algorithms in terms of their run time and/or space requirements., +argumento,argument,argumento,3,8,A value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function., +argumento nomeado,keyword argument,argumento nomeado,4,5,An argument that includes the name of the parameter as a “keyword”., +argumento opcional,optional argument,argumento opcional,8,12,A function or method argument that is not required., +argumento posicional,positional argument,argumento posicional,17,5,"An argument that does not include a parameter name, so it is not a keyword argument.", +arquivo-texto,text file,arquivo-texto,14,5,A sequence of characters stored in permanent storage like a hard drive., +assinatura,interface,"assinatura, interface",4,6,"A description of how to use a function, including the name and descriptions of the arguments and return value.", +atribuição,assignment,atribuição,2,2,A statement that assigns a value to a variable., +atribuição combinada,augmented assignment,atribuição combinada,10,5,A statement that updates the value of a variable using an operator like ``+=``., +atributo,attribute,atributo,15,5,One of the named values associated with an object., +atributo de classe,class attribute,atributo de classe,18,2,An attribute associated with a class object. Class attributes are defined inside a class definition but outside any method., +atributo de instância,instance attribute,atributo de instância,18,3,An attribute associated with an instance of a class., +atualização,update,atualização,7,2,An assignment where the new value of the variable depends on the old., +avaliar,evaluate,avaliar,2,7,To simplify an expression by performing the operations in order to yield a single value., +banco de dados,database,banco de dados,14,11,A file whose contents are organized like a dictionary with keys that correspond to values.,"Um arquivo onde seus conteúdos são organizados como um dicionário, com chaves que correspondem a valores." +bug,bug,-,1,20,An error in a program.,Erro em um programa. +busca,search,busca,8,9,A pattern of traversal that stops when it finds what it is looking for.,Um padrão de travessia que para quando encontra o que está procurando. +busca,lookup,"busca, pesquisa",11,11,A dictionary operation that takes a key and finds the corresponding value.,Uma operação de dicionário que recebe uma chave e procura o valor correspondente. +busca,search,busca,B,10,The problem of locating an element of a collection (like a list or dictionary) or determining that it is not present.,O problema de localizar um elemento em uma coleção (como uma lista ou dicionário) ou determinar se ele não está presente. +busca invertida,reverse lookup,busca invertida,11,12,A dictionary operation that takes a value and finds one or more keys that map to it.,Uma operação de dicionário que recebe um valor e procura por uma ou mais chaves que mapeiam até ele. +cabeçalho,header,cabeçalho,3,4,The first line of a function definition., +caminho,path,caminho,14,7,A string that identifies a file., +caminho absoluto,absolute path,caminho absoluto,14,9,A path that starts from the topmost directory in the file system., +caminho relativo,relative path,caminho relativo,14,8,A path that starts from the current directory., +capturar,catch,capturar,14,10,To prevent an exception from terminating a program using the try and except statements., +cardinalidade,multiplicity,"cardinalidade, multiplicidadade",18,12,"A notation in a class diagram that shows, for a HAS-A relationship, how many references there are to instances of another class.", +caso base,base case,caso base,5,14,A conditional branch in a recursive function that does not make a recursive call., +caso especial,special case,caso especial,9,3,A test case that is atypical or non-obvious (and less likely to be handled correctly)., +chamada de função,function call,chamada de função,3,7,A statement that runs a function. It consists of the function name followed by an argument list in parentheses., +chave,key,chave,11,5,An object that appears in a dictionary as the first part of a key-value pair., +classe,class,classe,15,1,A programmer-defined type. A class definition creates a new class object., +classe base,parent class,"classe base, superclasse",18,6,The class from which a child class inherits., +classe derivada,child class,"classe derivada, subclasse",18,7,A new class created by inheriting from an existing class; also called a “subclass”., +codificar,encode,codificar,18,1,To represent one set of values using another set of values by constructing a mapping between them., +código morto,dead code,código morto,6,2,"Part of a program that can never run, often because it appears after a return statement.", +código provisório,scaffolding,"“andaime”, código provisório",6,4,Code that is used during program development but is not part of the final version., +código provisório,slice,fatia,8,5,A part of a string specified by a range of indices., +comentário,comment,comentário,2,15,Information in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program., +composição,composition,composição,3,18,"Using an expression as part of a larger expression, or a statement as part of a larger statement.", +concatenar,concatenate,concatenar,2,14,To join two operands end-to-end., +condição,condition,condição,5,7,The boolean expression in a conditional statement that determines which branch runs., +condicional aninhado,nested conditional,condicional aninhado,5,11,A conditional statement that appears in one of the branches of another conditional statement., +condicional encadeado,chained conditional,condicional encadeado,5,10,A conditional statement with a series of alternative branches., +contador,counter,contador,8,10,"A variable used to count something, usually initialized to zero and then incremented.", +cópia profunda,deep copy,cópia profunda,15,8,"To copy the contents of an object as well as any embedded objects, and any objects embedded in them, and so on; implemented by the deepcopy function in the copy module.", +cópia rasa,shallow copy,cópia rasa,15,7,"To copy the contents of an object, including any references to embedded objects; implemented by the copy function in the copy module.", +corpo,body,corpo,3,5,The sequence of statements inside a function definition., +declaração,declaration,declaração,11,20,A statement like global that tells the interpreter something about a variable., +decrementar,decrement,decrementar,7,5,An update that decreases the value of a variable., +definição de função,function definition,definição de função,3,2,"A statement that creates a new function, specifying its name, parameters, and the statements it contains.", +delimitador,delimiter,delimitador,10,14,A character or string used to indicate where a string should be split., +dependência,dependency,dependência,18,10,"A relationship between two classes where instances of one class use instances of the other class, but do not store them as attributes.", +depuração,debugging,depuração,1,21,The process of finding and correcting bugs., +depuração com patinho de borracha,rubber duck debugging,depuração com patinho de borracha,13,6,"Debugging by explaining your problem to an inanimate object such as a rubber duck. Articulating the problem can help you solve it, even if the rubber duck doesn’t know Python.", +desempacotamento de tupla,tuple assignment,desempacotamento de tupla,12,2,An assignment with a sequence on the right side and a tuple of variables on the left. The right side is evaluated and then its elements are assigned to the variables on the left., +desenvolvimento incremental,incremental development,desenvolvimento incremental,6,3,A program development plan intended to avoid debugging by adding and testing only a small amount of code at a time., +desenvolvimento planejado,designed development,desenvolvimento planejado,16,2,A development plan that involves high-level insight into the problem and more planning than incremental development or prototype development., +despacho por tipo,type-based dispatch,despacho por tipo,17,7,A programming pattern that checks the type of an operand and invokes different functions for different types., +desvio,branch,desvio,5,9,One of the alternative sequences of statements in a conditional statement., +determinístico,deterministic,determinístico,13,1,"Pertaining to a program that does the same thing each time it runs, given the same inputs.", +diagrama de chamadas,call graph,diagrama de chamadas,11,15,"A diagram that shows every frame created during the execution of a program, with an arrow from each caller to each callee.", +diagrama de classe,class diagram,diagrama de classe,18,11,A diagram that shows the classes in a program and the relationships between them., +diagrama de estado,state diagram,diagrama de estado,2,3,A graphical representation of a set of variables and the values they refer to., +diagrama de objetos,object diagram,diagrama de objetos,15,9,"A diagram that shows objects, their attributes, and the values of the attributes.", +diagrama de pilha,stack diagram,diagrama de pilha,3,20,"A graphical representation of a stack of functions, their variables, and the values they refer to.", +dicionário,dictionary,dicionário,11,2,A mapping from keys to their corresponding values., +diretório,directory,diretório,14,6,"A named collection of files, also called a folder.", +divisão pelo piso,floor division,divisão pelo piso,5,1,"An operator, denoted //, that divides two numbers and rounds down (toward zero) to an integer.", +docstring,docstring,-,4,9,A string that appears at the top of a function definition to document the function’s interface., +elemento,element,elemento,10,2,"One of the values in a list (or other sequence), also called items.", +encapsulamento,encapsulation,encapsulamento,4,3,The process of transforming a sequence of statements into a function definition., +encapsulamento de dados,data encapsulation,encapsulamento de dados,18,13,A program development plan that involves a prototype using global variables and a final version that makes the global variables into instance attributes., +equivalente,equivalent,equivalente,10,10,Having the same value., +erro semântico,semantic error,erro semântico,2,19,An error in a program that makes it do something other than what the programmer intended., +erro sintático,syntax error,erro sintático,2,16,An error in a program that makes it impossible to parse (and therefore impossible to interpret)., +errro estrutural,shape error,errro estrutural,12,8,"An error caused because a value has the wrong shape; that is, the wrong type or size.", +estrutura de dados,data structure,estrutura de dados,12,7,"A collection of related values, often organized in lists, dictionaries, tuples, etc.", +exceção,exception,exceção,2,17,An error that is detected while the program is running., +executar,execute,executar,2,9,To run a statement and do what it says., +explodir,scatter,explodir,12,4,The operation of treating a sequence as a list of arguments., +expressão,expression,expressão,2,6,"A combination of variables, operators, and values that represents a single result.", +expressão booleana,boolean expression,expressão booleana,5,3,An expression whose value is either True or False., +expressão condicional,conditional expression,expressão condicional,19,1,"An expression that has one of two values, depending on a condition.", +expressão geradora,generator expression,expressão geradora,19,3,An expression with a for loop in parentheses that yields a generator object., +fachada,veneer,“verniz” ou fachada,18,4,A method or function that provides a different interface to another function without doing much computation., +factory,factory,fábrica,19,5,"A function, usually passed as a parameter, used to create objects.", +filtro,filter,filtro,10,8,A processing pattern that traverses a list and selects the elements that satisfy some criterion., +flag,flag,“indicador”,11,19,A boolean variable used to indicate whether a condition is true., +fluxo de execução,flow of execution,fluxo de execução,3,19,The order statements run in., +frame,frame,,3,21,A box in a stack diagram that represents a function call. It contains the local variables and parameters of the function., +função,function,função,3,1,A named sequence of statements that performs some useful operation. Functions may or may not take arguments and may or may not produce a result., +função de hash,hash function,função de espalhamento,11,9,A function used by a hashtable to compute the location for a key., +função produtiva,fruitful function,função produtiva,3,11,A function that returns a value., +função pura,pure function,função pura,16,3,A function that does not modify any of the objects it receives as arguments. Most pure functions are fruitful., +generalização,generalization,generalização,4,4,The process of replacing something unnecessarily specific (like a number) with something appropriately general (like a variable or parameter)., +guarda,guardian,guarda,6,5,A programming pattern that uses a conditional statement to check for and handle circumstances that might cause an error., +hashable,hashable,,11,10,"A type that has a hash function. Immutable types like integers, floats and strings are hashable; mutable types like lists and dictionaries are not.", +herança,inheritance,herança,18,5,The ability to define a new class that is a modified version of a previously defined class., +idêntico,identical,idêntico,10,11,Being the same object (which implies equivalence)., +implementação,implementation,implementação,11,7,A way of performing a computation., +imutável,immutable,imutável,8,7,The property of a sequence whose items cannot be changed., +incrementar,increment,incrementar,7,4,An update that increases the value of a variable (often by one)., +índice,index,índice,8,4,"An integer value used to select an item in a sequence, such as a character in a string. In Python indices start from 0.", +inicialização,initialization,inicialização,7,3,An assignment that gives an initial value to a variable that will be updated., +instância,instance,instância,15,3,An object that belongs to a class., +instanciar,instantiate,instanciar,15,4,To create a new object., +instrução,statement,instrução,2,8,"A section of code that represents a command or action. So far, the statements we have seen are assignments and print statements.", +instrução composta,compound statement,instrução composta,5,8,A statement that consists of a header and a body. The header ends with a colon (:). The body is indented relative to the header., +instrução condicional,conditional statement,instrução condicional,5,6,A statement that controls the flow of execution depending on some condition., +inteiro,integer,inteiro,1,12,A type that represents whole numbers., +interpretador,interpreter,interpretador,1,5,A program that reads another program and executes it, +invariante,invariant,invariante,16,6,A condition that should always be true during the execution of a program., +invocação,invocation,invocação,8,11,A statement that calls a method., +item,item,item,8,3,One of the values in a sequence., +item,item,item,11,4,"In a dictionary, another name for a key-value pair.", +iteração,iteration,iteração,7,6,Repeated execution of a set of statements using either a recursive function call or a loop., +iterador,iterator,iterador,12,6,"An object that can iterate through a sequence, but which does not provide list operators and methods.", +laço,loop,"laço, loop",4,2,A part of a program that can run repeatedly., +laço infinito,infinite loop,laço infinito,7,7,A loop in which the terminating condition is never satisfied., +linear,linear,linear,B,8,"An algorithm whose run time is proportional to problem size, at least for large problem sizes.", +linguagem de alto nível,high-level language,linguagem de alto nível,1,2,A programming language like Python that is designed to be easy for humans to read and write., +linguagem de baixo nível,low-level language,linguagem de baixo nível,1,3,A programming language that is designed to be easy for a computer to run; also called “machine language” or “assembly language”., +linguagem formal,formal language,linguagem formal,1,16,"Any one of the languages that people have designed for specific purposes, such as representing mathematical ideas or computer programs; all programming languages are formal languages.", +linguagem natural,natural language,linguagem natural,1,15,Any one of the languages that people speak that evolved naturally., +linguagem orientada a objetos,object-oriented language,linguagem orientada a objetos,17,1,"A language that provides features, such as programmer-defined types and methods, that facilitate object-oriented programming.", +lista,list,lista,10,1,A sequence of values., +lista aninhada,nested list,lista aninhada,10,3,A list that is an element of another list., +listcomp,list comprehension,"“compreensão de lista”, listcomp",19,2,An expression with a for loop in square brackets that yields a new list., +map,map,"“mapear”, “de-para”",10,7,A processing pattern that traverses a sequence and performs an operation on each element., +mapeamento,mapping,mapeamento,11,1,A relationship in which each element of one set corresponds to an element of another set., +máquina-modelo,machine model,máquina-modelo,B,2,A simplified representation of a computer used to describe algorithms., +memo,memo,“lembrete”,11,16,A computed value stored to avoid unnecessary future computation., +método,method,método,4,1,A function that is associated with an object and called using dot notation., +método,method,método,17,3,A function that is defined inside a class definition and is invoked on instances of that class., +modificadora,modifier,modificadora,16,4,"A function that changes one or more of the objects it receives as arguments. Most modifiers are void; that is, they return None.", +modo de script,script mode,modo de script,2,11,A way of using the Python interpreter to read code from a script and run it., +modo interativo,interactive mode,modo interativo,2,10,A way of using the Python interpreter by typing code at the prompt., +módulo,module,módulo,3,14,A file that contains a collection of related functions and other definitions., +multiset,multiset,“multi-conjunto”,19,4,A mathematical entity that represents a mapping between the elements of a set and the number of times they appear., +notação assintótica,Big-Oh notation,notação assintótica,B,7,"Notation for representing an order of growth; for example, :math:`O(n)` represents the set of functions that grow linearly.", +notação de ponto,dot notation,notação de ponto,3,17,The syntax for calling a function in another module by specifying the module name followed by a dot (period) and the function name., +objeto,object,objeto,8,1,"Something a variable can refer to. For now, you can use “object” and “value” interchangeably.", +objeto,object,objeto,10,9,Something a variable can refer to. An object has a type and a value., +objeto “pipe”,pipe object,objeto “pipe”,14,14,"An object that represents a running program, allowing a Python program to run commands and read the results.", +objeto ``bytes``,``bytes`` object,objeto ``bytes``,14,12,An object similar to a string., +objeto ``zip``,``zip`` object,objeto ``zip``,12,5,The result of calling a built-in function zip; an object that iterates through a sequence of tuples., +objeto embutido,embedded object,objeto embutido,15,6,An object that is stored as an attribute of another object., +objeto-arquivo,file object,objeto-arquivo,9,1,A value that represents an open file., +objeto-classe,class object,objeto-classe,15,2,An object that contains information about a programmer-defined type. The class object can be used to create instances of the type., +objeto-função,function object,objeto-função,3,3,A value created by a function definition. The name of the function is a variable that refers to a function object., +objeto-módulo,module object,objeto-módulo,3,16,A value created by an import statement that provides access to the values defined in a module., +ocultação de informações,information hiding,ocultação de informações,17,9,"The principle that the interface provided by an object should not depend on its implementation, in particular the representation of its attributes.", +operador,operator,operador,1,9,"A special symbol that represents a simple computation like addition, multiplication, or string concatenation.", +operador de formatação,format operator,operador de formatação,14,2,"An operator, %, that takes a format string and a tuple and generates a string that includes the elements of the tuple formatted as specified by the format string.", +operador de módulo,modulus operator,operador de módulo,5,2,"An operator, denoted with a percent sign (%), that works on integers and returns the remainder when one number is divided by another.", +operador lógico,logical operator,operador lógico,5,5,"One of the operators that combines boolean expressions: and, or, and not.", +operador relacional,relational operator,operador relacional,5,4,"One of the operators that compares its operands: ==, !=, >, <, >=, and <=.", +operando,operand,operando,2,5,One of the values on which an operator operates., +ordem das operações,order of operations,ordem das operações,2,13,Rules governing the order in which expressions involving multiple operators and operands are evaluated., +ordem de crescimento,order of growth,ordem de crescimento,B,6,"A set of functions that all grow in a way considered equivalent for purposes of analysis of algorithms. For example, all functions that grow linearly belong to the same order of growth.", +palavra-chave,keyword,palavra-chave,2,4,"A reserved word that is used to parse a program; you cannot use keywords like if, def, and while as variable names.", +par chave-valor,key-value pair,par chave-valor,11,3,The representation of the mapping from a key to a value., +parâmetro,parameter,parâmetro,3,6,A name used inside a function to refer to the value passed as an argument., +percorrer,traverse,percorrer,8,8,"To iterate through the items in a sequence, performing a similar operation on each.", +persistente,persistent,persistente,14,1,Pertaining to a program that runs indefinitely and keeps at least some of its data in permanent storage., +pior caso,worst case,pior caso,B,3,The input that makes a given algorithm run slowest (or require the most space., +plano de desenvolvimento,development plan,plano de desenvolvimento,4,8,A process for writing programs., +polimórfico,polymorphic,polimórfico,17,8,Pertaining to a function that can work with more than one type., +ponto de cruzamento,crossover point,ponto de cruzamento,B,5,The problem size where two algorithms require the same run time or space., +ponto-flutuante,floating-point,ponto-flutuante,1,13,A type that represents numbers with fractional parts., +portabilidade,portability,portabilidade,1,4,A property of a program that can run on more than one kind of computer., +pós-condição,postcondition,pós-condição,4,11,A requirement that should be satisfied by the function before it ends., +pré-condição,precondition,pré-condição,4,10,A requirement that should be satisfied by the caller before a function starts., +procedimento,void function,“função nula” ou procedimento,3,12,A function that always returns None., +programação funcional,program,programação funcional,1,7,A set of instructions that specifies a computation., +programação funcional,functional programming style,programação funcional,16,5,A style of program design in which the majority of functions are pure., +programação orientada a objetos,object-oriented programming,programação orientada a objetos,17,2,A style of programming in which data and the operations that manipulate it are organized into classes and methods., +prompt,prompt,“sinal de pronto”,1,6,Characters displayed by the interpreter to indicate that it is ready to take input from the user., +prototipar e ajustar,prototype and patch,prototipar e ajustar,16,1,"A development plan that involves writing a rough draft of a program, testing, and correcting errors as they are found.", +pseudo-aleatório,pseudorandom,pseudo-aleatório,13,2,"Pertaining to a sequence of numbers that appears to be random, but is generated by a deterministic program.", +quadrático,quadratic,quadrático,B,9,"An algorithm whose run time is proportional to :math:`n^2`, where :math:`n` is a measure of problem size.", +reatribuição,reassignment,reatribuição,7,1,Assigning a new value to a variable that already exists., +recursão,recursion,recursão,5,13,The process of calling the function that is currently executing., +recursão infinita,infinite recursion,recursão infinita,5,15,"A recursion that doesn’t have a base case, or never reaches it. Eventually, an infinite recursion causes a runtime error.", +redução a um problema resolvido,reduction to a previously solved problem,redução a um problema resolvido,9,2,A way of solving a problem by expressing it as an instance of a previously solved problem., +reduzir,reduce,reduzir,10,6,A processing pattern that traverses a sequence and accumulates the elements into a single result., +refatoração,refactoring,refatoração,4,7,The process of modifying a working program to improve function interfaces and other qualities of the code., +referência,reference,referência,10,12,The association between a variable and its value., +relação É-UM,IS-A relationship,relação É-UM,18,8,A relationship between a child class and its parent class., +relação TEM-UM,HAS-A relationship,relação TEM-UM,18,9,A relationship between two classes where instances of one class contain references to instances of the other., +reunir,gather,reunir,12,3,The operation of assembling a variable-length argument tuple., +script,script,-,2,12,A program stored in a file., +semântica,semantics,semântica,2,18,The meaning of a program., +sequência de formatação,sequence,sequência de formatação,8,2,An ordered collection of values where each value is identified by an integer index., +sequência de formatação,format sequence,sequência de formatação,14,4,"A sequence of characters in a format string, like %d, that specifies how a value should be formatted.", +shell,shell,-,14,13,A program that allows users to type commands and then executes them by starting other programs., +singleton,singleton,-,11,14,A list (or other sequence) with a single element., +sintaxe,syntax,sintaxe,1,18,The rules that govern the structure of a program., +sobrecarga de operadores,operator overloading,sobrecarga de operadores,17,6,Changing the behavior of an operator like + so it works with a programmer-defined type., +sobrepor,override,sobrescrever,13,4,To replace a default value with an argument., +solução de problemas,problem solving,solução de problemas,1,1,"The process of formulating a problem, finding a solution, and expressing it.", +string,string,“cadeia de caracteres”,1,14,A type that represents sequences of characters., +string de formatação,format string,string de formatação,14,3,"A string, used with the format operator, that contains format sequences.", +string vazia,empty string,string vazia,8,6,"A string with no characters and length 0, represented by two quotation marks.", +sujeito,subject,sujeito,17,4,The object a method is invoked on., +tabela de hash,hashtable,tabela de espalhamento,11,8,The algorithm used to implement Python dictionaries., +tabela de hash,hashtable,tabela de espalhamento,B,11,A data structure that represents a collection of key-value pairs and performs search in constant time., +termo dominante,leading term,"termo dominante, termo de maior expoente",B,4,"In a polynomial, the term with the highest exponent.", +teste de desempenho,benchmarking,teste de desempenho,13,5,The process of choosing between data structures by implementing alternatives and testing them on a sample of the possible inputs., +tipo,type,tipo,1,11,"A category of values. The types we have seen so far are integers (type int), floating-point numbers (type float), and strings (type str).", +token,token,“símbolo”,1,17,"One of the basic elements of the syntactic structure of a program, analogous to a word in a natural language.", +traceback,traceback,,3,22,"A list of the functions that are executing, printed when an exception occurs.", +tupla,tuple,tupla,12,1,An immutable sequence of elements., +valor,value,valor,1,10,"One of the basic units of data, like a number or string, that a program manipulates.", +valor,value,valor,11,6,An object that appears in a dictionary as the second part of a key-value pair. This is more specific than our previous use of the word “value”., +valor default,default value,valor default,13,3,The value given to an optional parameter if no argument is provided., +valor devolvido,return value,valor devolvido,3,10,"The result of a function. If a function call is used as an expression, the return value is the value of the expression.", +variável,variable,variável,2,1,A name that refers to a value., +variável global,global variable,variável global,11,17,A variable defined outside a function. Global variables can be accessed from any function., +variável local,local variable,variável local,3,9,A variable defined inside a function. A local variable can only be used inside its function., +variável temporária,temporary variable,variável temporária,6,1,A variable used to store an intermediate value in a complex calculation., diff --git a/tools/join_glossary.py b/tools/join_glossary.py new file mode 100644 index 0000000..7ae432a --- /dev/null +++ b/tools/join_glossary.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 + +""" +Extract glossary entries from chapters 1-19 and appendix B and create +a consolidated glossary text file delimited by '|' (pipe characters). +""" + +import glob +import re +import os +import collections + +GLOSSARY = r'Gloss[^-]{3,7}-{8,15}\n(.*)' + +GLOSSARY_RE = re.compile(GLOSSARY, re.DOTALL) + +GLOSSARY_SECTION_RE = re.compile(GLOSSARY + r'-{8,15}', re.DOTALL) + +expected_entries = [ # glossary entries per chapter + ('01', 21), + ('02', 19), + ('03', 22), + ('04', 11), + ('05', 15), + ('06', 5), + ('07', 8), + ('08', 12), + ('09', 3), + ('10', 14), + ('11', 20), + ('12', 8), + ('13', 6), + ('14', 14), + ('15', 9), + ('16', 7), + ('17', 9), + ('18', 13), + ('19', 5), + ( 'B', 11), +] + +expected_entries_dic = dict(expected_entries) + +# \n(.*?)\n\n +ENTRY_RE = re.compile(r'([^\n]+):\n[ ]+(.*?)\n\n', re.DOTALL) + +GlossaryEntry = collections.namedtuple('GlossaryEntry', 'term definition') +Definition = collections.namedtuple('Definition', 'chapter_id position text') + + +def parse_entries(text, chapter_id): + matches = ENTRY_RE.findall(text) + entries = [] + for position, match in enumerate(matches, 1): + term = match[0] + definition_text = ' '.join(match[1].split()) + #print(term, '::', definition_text) + entries.append(GlossaryEntry(term, + Definition(chapter_id, position, definition_text))) + return entries + + +def scan_files(*paths): + entries = collections.defaultdict(list) + for path in paths: + for name in glob.glob(os.path.join(path, '*.rst')): + chapter_id = os.path.basename(name).split('-')[0] + + with open(name, encoding='utf-8') as infile: + rst = infile.read() + gloss_match = (GLOSSARY_SECTION_RE.search(rst) or + GLOSSARY_RE.search(rst)) + if gloss_match: + #print('*' * 40, name) + new_entries = parse_entries(gloss_match.group(1), chapter_id) + for term, definition in new_entries: + #if term in entries: + # print('duplicate term:', term) + entries[term].append(definition) + #print(len(new_entries)) + assert expected_entries_dic[chapter_id] == len(new_entries), ( + chapter_id, expected_entries_dic[chapter_id], len(new_entries)) + for term in sorted(entries, key=str.upper): + definitions = entries[term] + for i, (chapter_id, position, definition) in enumerate(sorted(definitions)): + if i: + term = '\t' + print(term, chapter_id, position, definition, sep='|') + + +if __name__ == '__main__': + import sys + scan_files(*sys.argv[1:]) diff --git a/tools/split_glossary.py b/tools/split_glossary.py new file mode 100755 index 0000000..cbceb33 --- /dev/null +++ b/tools/split_glossary.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python3 + +""" +Generate consolidated RST glossary file and chapter include files from +the CSV glossary files. +""" + +import glob +import os +import csv +import collections +import operator +import unicodedata +import string + +from join_glossary import expected_entries + +RST_PATH = '../book/' +GLOSSARY_DATA_PATH = '../data' +FIELDS = 'term us_term br_term chapter order us_definition br_definition'.split() + +GLOSSARY_HEAD = '''\ +Glossário Consolidado +===================== + +Este glossário é a união de todos os glossários dos capítulos. +Cada entrada está vinculada ao capítulo onde ela aparece, por exemplo: +*bug* :ref:`[1] `. + +Note que alguns termos aparecem em mais de um capítulo, às vezes +com definições diferentes, de acordo com o contexto. +\n\n''' + +GlossaryEntry = collections.namedtuple('GlossaryEntry', FIELDS) + + +def asciize(txt): + """Return only ASCII letters from text""" + return ''.join(c for c in unicodedata.normalize('NFD', txt) + if c in string.ascii_lowercase) + + +def master_order(entry): + return asciize(entry.term.casefold()) + '|' + entry.chapter + + +def read_glossary(): + master_glossary = [] + glossaries = collections.defaultdict(list) + paths = glob.glob(os.path.join(GLOSSARY_DATA_PATH, '*.csv')) + + for nome_arq in paths: + with open(nome_arq) as csvfile: + reader = csv.DictReader(csvfile, FIELDS) + next(reader) # skip header line + for row in reader: + row['order'] = int(row['order']) + import pdb; pdb.set_trace() + entry = GlossaryEntry(**row) + #print(entry) + glossaries[row['chapter']].append(entry) + master_glossary.append(entry) + return master_glossary, glossaries + + +def formatted_head(entry): + us_term = entry.us_term + if '``' in us_term: + if us_term != '``None``': + symbol, noun = us_term.split() + us_term = '{} *{}*'.format(symbol, noun) + else: + us_term = '*{}*'.format(us_term) + if entry.br_term == '-': # no BR term + head = us_term + elif entry.term != entry.us_term: # adopted BR term + head = '{} ({})'.format(entry.term, us_term) + else: # adopted US term + head = '{} ({})'.format(us_term, entry.br_term) + return head + + +def main(): + master_glossary, chapter_glossaries = read_glossary() + + link_fmt = ':ref:`[1] `' + + out_path = os.path.join(RST_PATH, 'C-glossary.rst') + with open(out_path, 'wt', encoding='utf-8') as out_file: + out_file.write(GLOSSARY_HEAD) + for entry in sorted(master_glossary, key=master_order): + short_chapter = entry.chapter.lstrip('0') + definition = entry.br_definition.strip() or entry.us_definition.strip() + out_file.write('{} :ref:`[{}] `\n {}\n\n' + .format(formatted_head(entry), short_chapter, + entry.chapter, definition)) + + for chapter_id, entries_qty in expected_entries: + chapter_glob = os.path.join(RST_PATH, chapter_id+'*.rst') + found = glob.glob(chapter_glob) + assert len(found) == 1, 'found: {}'.format(len(found)) + out_path = os.path.join(RST_PATH, 'glossary', chapter_id+'.txt') + glossary = chapter_glossaries[chapter_id] + print(out_path) + with open(out_path, 'wt', encoding='utf-8') as out_file: + for entry in sorted(glossary, key=operator.attrgetter('order')): + print('\t', entry) + definition = entry.br_definition.strip() or entry.us_definition.strip() + out_file.write('{}\n {}\n\n'.format(formatted_head(entry), definition)) + + print() + +if __name__ == '__main__': + main() + + + diff --git a/tools/split_glossary0.py b/tools/split_glossary0.py new file mode 100755 index 0000000..8e0cc97 --- /dev/null +++ b/tools/split_glossary0.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python3 + +""" +Generate consolidated RST glossary file and chapter include files from +consolidated CSV glossary file. + +THIS SCRIPT IS NO LONGER USED, SEE ``split_glossary.py`` +""" + +import glob +import os +import csv +import collections +import operator +import unicodedata +import string + +from join_glossary import expected_entries + +RST_PATH = '../book/' +GLOSSARY_DATA_PATH = './glossary.csv' +FIELDS = 'term us_term br_term chapter order us_definition br_definition'.split() + +GLOSSARY_HEAD = '''\ +Glossário Consolidado +===================== + +Este glossário é a união de todos os glossários dos capítulos. +Cada entrada está vinculada ao capítulo onde ela aparece, por exemplo: +*bug* :ref:`[1] `. + +Note que alguns termos aparecem em mais de um capítulo, às vezes +com definições diferentes, de acordo com o contexto. +\n\n''' + +GlossaryEntry = collections.namedtuple('GlossaryEntry', FIELDS) + + +def asciize(txt): + """Return only ASCII letters from text""" + return ''.join(c for c in unicodedata.normalize('NFD', txt) + if c in string.ascii_lowercase) + +def master_order(entry): + return asciize(entry.term.casefold()) + '|' + entry.chapter + + +def read_glossary(): + master_glossary = [] + glossaries = collections.defaultdict(list) + with open(GLOSSARY_DATA_PATH) as csvfile: + reader = csv.DictReader(csvfile, FIELDS) + next(reader) # skip header line + for row in reader: + row['order'] = int(row['order']) + entry = GlossaryEntry(**row) + #print(entry) + glossaries[row['chapter']].append(entry) + master_glossary.append(entry) + return master_glossary, glossaries + + +def formatted_head(entry): + us_term = entry.us_term + if '``' in us_term: + if us_term != '``None``': + symbol, noun = us_term.split() + us_term = '{} *{}*'.format(symbol, noun) + else: + us_term = '*{}*'.format(us_term) + if entry.br_term == '-': # no BR term + head = us_term + elif entry.term != entry.us_term: # adopted BR term + head = '{} ({})'.format(entry.term, us_term) + else: # adopted US term + head = '{} ({})'.format(us_term, entry.br_term) + return head + +def main(): + master_glossary, chapter_glossaries = read_glossary() + + link_fmt = ':ref:`[1] `' + + out_path = os.path.join(RST_PATH, 'C-glossary.rst') + with open(out_path, 'wt', encoding='utf-8') as out_file: + out_file.write(GLOSSARY_HEAD) + for entry in sorted(master_glossary, key=master_order): + short_chapter = entry.chapter.lstrip('0') + definition = entry.br_definition.strip() or entry.us_definition.strip() + out_file.write('{} :ref:`[{}] `\n {}\n\n' + .format(formatted_head(entry), short_chapter, + entry.chapter, definition)) + + for chapter_id, entries_qty in expected_entries: + chapter_glob = os.path.join(RST_PATH, chapter_id+'*.rst') + found = glob.glob(chapter_glob) + assert len(found) == 1, 'found: {}'.format(len(found)) + out_path = os.path.join(RST_PATH, 'glossary', chapter_id+'.txt') + glossary = chapter_glossaries[chapter_id] + with open(out_path, 'wt', encoding='utf-8') as out_file: + for entry in sorted(glossary, key=operator.attrgetter('order')): + definition = entry.br_definition.strip() or entry.us_definition.strip() + out_file.write('{}\n {}\n\n'.format(formatted_head(entry), definition)) + + print() + +if __name__ == '__main__': + main() + + +