From a61b998270e8f955c603de96775e072a555f735d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 19 Apr 2016 15:21:02 +0200 Subject: AlgoDat 01 --- ss2016/algodat/01/H1-1.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ss2016/algodat/01/H1-1.md (limited to 'ss2016/algodat/01/H1-1.md') 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 @@ +a) + +\begin{algorithmic}[1] + \FORALL{entries $e$ on the shopping list} + \STATE{$c \leftarrow \text{category of $e$}$} + \STATE{Go to shelf $s$ labeled $c$} + \FORALL{products $p$ on $s$} \label{alg:loopstart} + \IF{$p$ matches $e$} + \STATE{add $p$ to shopping basket} + \STATE{break out of loop started in line \ref{alg:loopstart}} + \ENDIF + \ENDFOR + \ENDFOR +\end{algorithmic} + +b) + +\begin{algorithmic}[1] + \WHILE{not at destination within forest} + \STATE{break crumb of bread} + \STATE{drop crumb} + \STATE{take step towards destination} + \ENDWHILE + \WHILE{not out of forest} + \IF{we see at least one crumb} + \STATE{Go to the closest one} + \STATE{Pick it up} + \ELSE + \STATE{Get eaten by a witch} + \ENDIF + \ENDWHILE +\end{algorithmic} -- cgit v1.2.3