From 86c88670ea757cee11864ec00e6819726c65473a Mon Sep 17 00:00:00 2001 From: Peter Ward Date: Thu, 18 Jul 2013 20:18:33 +1000 Subject: conditionally show the code --- docs/Makefile | 2 +- docs/closest_apple.tex | 2 ++ docs/random_avoid.tex | 2 ++ docs/random_simple.tex | 3 +++ docs/tutorial.tex | 5 +++++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index 5cd4a7e..1ccf8f0 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -17,7 +17,7 @@ ${BUILD_DIR}/%.tex: %.tex ./jinja2 --latex < $< > $@ ${BUILD_DIR}/%.py: %.py - ln $< $@ + ln -sf ../$< $@ tutorial.pdf: ${BUILD_DIR}/tutorial.tex ${BUILD_FILES} cd "${BUILD_DIR}" && \ diff --git a/docs/closest_apple.tex b/docs/closest_apple.tex index 36b7382..b00768d 100644 --- a/docs/closest_apple.tex +++ b/docs/closest_apple.tex @@ -10,4 +10,6 @@ To find the shortest path, we need to use an algorithm called \emph{breadth first search} (BFS). % TODO: description of the algorithm +\ifshowcode \pythonfile{closest_apple.py} +\fi diff --git a/docs/random_avoid.tex b/docs/random_avoid.tex index 90ac183..136a250 100644 --- a/docs/random_avoid.tex +++ b/docs/random_avoid.tex @@ -162,6 +162,8 @@ def bot(board, position): return choice(valid_moves) \end{pythoncode} +\ifshowcode If you’re really stuck, or want to check your solution, here’s my solution: \pythonfile{random_avoid.py} +\fi diff --git a/docs/random_simple.tex b/docs/random_simple.tex index a1ff557..778ae9c 100644 --- a/docs/random_simple.tex +++ b/docs/random_simple.tex @@ -45,6 +45,8 @@ doesn’t know any better, it will happily move into the square where its tail i \label{brd:random-death} \end{board} +\ifshowcode + \pagebreak By the way, how long was your solution? @@ -63,3 +65,4 @@ So if you write \mint{python}|choice('UDLR')|, that’s the same as if you had written \mint{python}|choice(['U', 'D', 'L', 'R'])|. +\fi diff --git a/docs/tutorial.tex b/docs/tutorial.tex index a76760b..a43db5d 100644 --- a/docs/tutorial.tex +++ b/docs/tutorial.tex @@ -1,5 +1,8 @@ \documentclass[12pt]{article} +\newif\ifshowcode +\showcodefalse + \usepackage{fontspec} \usepackage[pdfborder={0 0 0}]{hyperref} @@ -55,7 +58,9 @@ \input{look_ahead.tex} +\ifshowcode \break +\fi \input{closest_apple.tex} \end{document} -- cgit v1.2.3