diff options
Diffstat (limited to 'ss2016/algodat/01/H1-1.md')
-rw-r--r-- | ss2016/algodat/01/H1-1.md | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ss2016/algodat/01/H1-1.md b/ss2016/algodat/01/H1-1.md new file mode 100644 index 0000000..d93f86c --- /dev/null +++ b/ss2016/algodat/01/H1-1.md | |||
@@ -0,0 +1,32 @@ | |||
1 | a) | ||
2 | |||
3 | \begin{algorithmic}[1] | ||
4 | \FORALL{entries $e$ on the shopping list} | ||
5 | \STATE{$c \leftarrow \text{category of $e$}$} | ||
6 | \STATE{Go to shelf $s$ labeled $c$} | ||
7 | \FORALL{products $p$ on $s$} \label{alg:loopstart} | ||
8 | \IF{$p$ matches $e$} | ||
9 | \STATE{add $p$ to shopping basket} | ||
10 | \STATE{break out of loop started in line \ref{alg:loopstart}} | ||
11 | \ENDIF | ||
12 | \ENDFOR | ||
13 | \ENDFOR | ||
14 | \end{algorithmic} | ||
15 | |||
16 | b) | ||
17 | |||
18 | \begin{algorithmic}[1] | ||
19 | \WHILE{not at destination within forest} | ||
20 | \STATE{break crumb of bread} | ||
21 | \STATE{drop crumb} | ||
22 | \STATE{take step towards destination} | ||
23 | \ENDWHILE | ||
24 | \WHILE{not out of forest} | ||
25 | \IF{we see at least one crumb} | ||
26 | \STATE{Go to the closest one} | ||
27 | \STATE{Pick it up} | ||
28 | \ELSE | ||
29 | \STATE{Get eaten by a witch} | ||
30 | \ENDIF | ||
31 | \ENDWHILE | ||
32 | \end{algorithmic} | ||