cws/main_cw04.tex
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 17 Nov 2022 11:34:50 +0000
changeset 445 b73e7ce91c10
parent 444 7a0735db4788
child 476 7550c816187a
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
     1
% !TEX program = xelatex
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
\documentclass{article}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
\usepackage{chessboard}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
\usepackage[LSBC4,T1]{fontenc}
149
3a6f51bc6121 updated
Christian Urban <urbanc@in.tum.de>
parents: 148
diff changeset
     5
\let\clipbox\relax
426
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 418
diff changeset
     6
\usepackage{../styles/style}
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 418
diff changeset
     7
\usepackage{../styles/langs}
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
     8
\usepackage{disclaimer}
379
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 378
diff changeset
     9
\usepackage{ulem}
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
\begin{document}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
\setchessboard{smallboard,
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    14
               zero,
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
               showmover=false,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
               boardfontencoding=LSBC4,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
               hlabelformat=\arabic{ranklabel},
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
               vlabelformat=\arabic{filelabel}}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    20
\mbox{}\\[-18mm]\mbox{}
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
430
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
    22
\section*{Main Part 4 (Scala, 11 Marks)}
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
265
59779ce322a6 updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    24
\mbox{}\hfill\textit{``The problem with object-oriented languages is they’ve got all this implicit,}\\
59779ce322a6 updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    25
\mbox{}\hfill\textit{environment that they carry around with them. You wanted a banana but}\\
59779ce322a6 updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    26
\mbox{}\hfill\textit{what you got was a gorilla holding the banana and the entire jungle.''}\smallskip\\
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    27
\mbox{}\hfill\textit{ --- Joe Armstrong (creator of the Erlang programming language)}\medskip\bigskip
265
59779ce322a6 updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    28
59779ce322a6 updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    29
\noindent
306
Christian Urban <urbanc@in.tum.de>
parents: 296
diff changeset
    30
This part is about searching and backtracking. You are asked to
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    31
implement Scala programs that solve various versions of the
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
    32
\textit{Knight's Tour Problem} on a chessboard.
400
e48ea8300b2d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 397
diff changeset
    33
\medskip 
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
    34
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
    35
% Note the core, more advanced, part might include material you have not
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    36
%yet seen in the first three lectures. \bigskip
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
    37
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    38
\IMPORTANTNONE{}
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    39
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    40
\noindent
144
716042628398 updated
Christian Urban <urbanc@in.tum.de>
parents: 110
diff changeset
    41
Also note that the running time of each part will be restricted to a
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
    42
maximum of 30 seconds on my laptop: If you calculate a result once,
144
716042628398 updated
Christian Urban <urbanc@in.tum.de>
parents: 110
diff changeset
    43
try to avoid to calculate the result again. Feel free to copy any code
716042628398 updated
Christian Urban <urbanc@in.tum.de>
parents: 110
diff changeset
    44
you need from files \texttt{knight1.scala}, \texttt{knight2.scala} and
716042628398 updated
Christian Urban <urbanc@in.tum.de>
parents: 110
diff changeset
    45
\texttt{knight3.scala}.
39
c6fe374a5fca updated
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    46
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
    47
\DISCLAIMER{}
39
c6fe374a5fca updated
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    48
c6fe374a5fca updated
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    49
\subsection*{Background}
c6fe374a5fca updated
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    50
c6fe374a5fca updated
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
    51
The \textit{Knight's Tour Problem} is about finding a tour such that
110
62389faa66e4 updated
Christian Urban <urbanc@in.tum.de>
parents: 86
diff changeset
    52
the knight visits every field on an $n\times n$ chessboard once. For
62389faa66e4 updated
Christian Urban <urbanc@in.tum.de>
parents: 86
diff changeset
    53
example on a $5\times 5$ chessboard, a knight's tour is:
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    54
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    55
\chessboard[maxfield=d4, 
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    56
            pgfstyle= {[base,at={\pgfpoint{0pt}{-0.5ex}}]text},
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    57
            text = \small 24, markfield=Z4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    58
            text = \small 11, markfield=a4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    59
            text = \small  6, markfield=b4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    60
            text = \small 17, markfield=c4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    61
            text = \small  0, markfield=d4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    62
            text = \small 19, markfield=Z3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    63
            text = \small 16, markfield=a3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    64
            text = \small 23, markfield=b3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    65
            text = \small 12, markfield=c3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    66
            text = \small  7, markfield=d3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    67
            text = \small 10, markfield=Z2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    68
            text = \small  5, markfield=a2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    69
            text = \small 18, markfield=b2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    70
            text = \small  1, markfield=c2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    71
            text = \small 22, markfield=d2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    72
            text = \small 15, markfield=Z1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    73
            text = \small 20, markfield=a1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    74
            text = \small  3, markfield=b1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    75
            text = \small  8, markfield=c1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    76
            text = \small 13, markfield=d1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    77
            text = \small  4, markfield=Z0,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    78
            text = \small  9, markfield=a0,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    79
            text = \small 14, markfield=b0,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    80
            text = \small 21, markfield=c0,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    81
            text = \small  2, markfield=d0
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    82
           ]
144
716042628398 updated
Christian Urban <urbanc@in.tum.de>
parents: 110
diff changeset
    83
           
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    84
\noindent
212
4bda49ec24da updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
    85
This tour starts in the right-upper corner, then moves to field
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    86
$(3,2)$, then $(4,0)$ and so on. There are no knight's tours on
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    87
$2\times 2$, $3\times 3$ and $4\times 4$ chessboards, but for every
74
fb2d8012ed08 updated
Christian Urban <urbanc@in.tum.de>
parents: 60
diff changeset
    88
bigger board there is. 
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    89
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    90
A knight's tour is called \emph{closed}, if the last step in the tour
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    91
is within a knight's move to the beginning of the tour. So the above
110
62389faa66e4 updated
Christian Urban <urbanc@in.tum.de>
parents: 86
diff changeset
    92
knight's tour is \underline{not} closed because the last
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    93
step on field $(0, 4)$ is not within the reach of the first step on
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
    94
$(4, 4)$. It turns out there is no closed knight's tour on a $5\times
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
    95
5$ board. But there are on a $6\times 6$ board and on bigger ones, for
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
    96
example
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
\chessboard[maxfield=e5, 
147
72f7dd1a3754 updated
Christian Urban <urbanc@in.tum.de>
parents: 145
diff changeset
    99
            pgfstyle={[base,at={\pgfpoint{0pt}{-0.5ex}}]text},
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   100
            text = \small 10, markfield=Z5,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   101
            text = \small  5, markfield=a5,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   102
            text = \small 18, markfield=b5,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   103
            text = \small 25, markfield=c5,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   104
            text = \small 16, markfield=d5,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   105
            text = \small  7, markfield=e5,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   106
            text = \small 31, markfield=Z4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   107
            text = \small 26, markfield=a4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   108
            text = \small  9, markfield=b4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   109
            text = \small  6, markfield=c4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   110
            text = \small 19, markfield=d4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   111
            text = \small 24, markfield=e4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   112
            % 4  11  30  17   8  15 
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   113
            text = \small  4, markfield=Z3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   114
            text = \small 11, markfield=a3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   115
            text = \small 30, markfield=b3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   116
            text = \small 17, markfield=c3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   117
            text = \small  8, markfield=d3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   118
            text = \small 15, markfield=e3,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   119
            %29  32  27   0  23  20 
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   120
            text = \small 29, markfield=Z2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   121
            text = \small 32, markfield=a2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   122
            text = \small 27, markfield=b2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   123
            text = \small  0, markfield=c2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   124
            text = \small 23, markfield=d2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   125
            text = \small 20, markfield=e2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   126
            %12   3  34  21  14   1 
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   127
            text = \small 12, markfield=Z1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   128
            text = \small  3, markfield=a1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   129
            text = \small 34, markfield=b1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   130
            text = \small 21, markfield=c1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   131
            text = \small 14, markfield=d1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   132
            text = \small  1, markfield=e1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   133
            %33  28  13   2  35  22 
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   134
            text = \small 33, markfield=Z0,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   135
            text = \small 28, markfield=a0,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   136
            text = \small 13, markfield=b0,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   137
            text = \small  2, markfield=c0,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   138
            text = \small 35, markfield=d0,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   139
            text = \small 22, markfield=e0,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   140
            vlabel=false,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   141
            hlabel=false
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
           ]
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   144
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
\noindent
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   146
where the 35th move can join up again with the 0th move.
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   147
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   148
If you cannot remember how a knight moves in chess, or never played
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   149
chess, below are all potential moves indicated for two knights, one on
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   150
field $(2, 2)$ (blue moves) and another on $(7, 7)$ (red moves):
39
c6fe374a5fca updated
Christian Urban <urbanc@in.tum.de>
parents: 38
diff changeset
   151
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   152
{\chessboard[maxfield=g7,
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   153
            color=blue!50,
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
            linewidth=0.2em,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
            shortenstart=0.5ex,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
            shortenend=0.5ex,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
            markstyle=cross,
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   158
            markfields={a4, c4, Z3, d3, Z1, d1, a0, c0},
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
            color=red!50,
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   160
            markfields={f5, e6},
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   161
            setpieces={Ng7, Nb2},
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   162
            boardfontsize=12pt,labelfontsize=9pt]}
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   163
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   164
\subsection*{Reference Implementation}
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   165
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   166
%\mbox{}\alert{}\textcolor{red}{You need to download \texttt{knight1.jar} from K%EATS. The one
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   167
%supplied with github does not contain the correct code. See Scala coursework
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   168
%section on KEATS.}\medskip
372
e87462c9b895 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 356
diff changeset
   169
e87462c9b895 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 356
diff changeset
   170
\noindent
306
Christian Urban <urbanc@in.tum.de>
parents: 296
diff changeset
   171
This Scala part comes with three reference implementations in form of
216
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   172
\texttt{jar}-files. This allows you to run any test cases on your own
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   173
computer. For example you can call Scala on the command line with the
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   174
option \texttt{-cp knight1.jar} and then query any function from the
216
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   175
\texttt{knight1.scala} template file. As usual you have to
444
7a0735db4788 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 430
diff changeset
   176
prefix the calls with \texttt{M4a}, \texttt{M4b}, \texttt{M4c} and \texttt{M4d}.
216
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   177
Since some of the calls are time sensitive, I included some timing
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   178
information. For example
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   179
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   180
\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   181
$ scala -cp knight1.jar
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   182
scala> M4a.enum_tours(5, List((0, 0))).length
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   183
Time needed: 1.722 secs.
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   184
res0: Int = 304
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   185
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   186
scala> M4a.print_board(8, M4a.first_tour(8, List((0, 0))).get)
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   187
Time needed: 15.411 secs.
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   188
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   189
 51  46  55  44  53   4  21  12 
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   190
 56  43  52   3  22  13  24   5 
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   191
 47  50  45  54  25  20  11  14 
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   192
 42  57   2  49  40  23   6  19 
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   193
 35  48  41  26  61  10  15  28 
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   194
 58   1  36  39  32  27  18   7 
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   195
 37  34  31  60   9  62  29  16 
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   196
  0  59  38  33  30  17   8  63 
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   197
\end{lstlisting}%$
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   198
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   199
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   200
\subsection*{Hints}
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   201
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   202
\noindent
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   203
Useful list functions: \texttt{.contains(..)} checks
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   204
whether an element is in a list, \texttt{.flatten} turns a list of
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   205
lists into just a list, \texttt{\_::\_} puts an element on the head of
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   206
the list, \texttt{.head} gives you the first element of a list (make
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   207
sure the list is not \texttt{Nil}); a useful option function:
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   208
\texttt{.isDefined} returns true, if an option is \texttt{Some(..)};
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   209
anonymous functions can be constructed using \texttt{(x:Int) => ...},
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   210
this function takes an \texttt{Int} as an argument; 
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   211
a useful list function: \texttt{.sortBy} sorts a list
212
4bda49ec24da updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   212
according to a component given by the function; a function can be
216
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   213
tested to be tail-recursive by annotation \texttt{@tailrec}, which is
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   214
made available by importing \texttt{scala.annotation.tailrec}.\medskip
212
4bda49ec24da updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   215
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   216
430
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   217
%%\newpage
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   218
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   219
\subsection*{Tasks}
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   220
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   221
You are asked to implement the knight's tour problem such that the
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   222
dimension of the board can be changed.  Therefore most functions will
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   223
take the dimension of the board as an argument.  The fun with this
60
f099bcf9cff1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 59
diff changeset
   224
problem is that even for small chessboard dimensions it has already an
f099bcf9cff1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 59
diff changeset
   225
incredibly large search space---finding a tour is like finding a
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   226
needle in a haystack. In the first task we want to see how far we get
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   227
with exhaustively exploring the complete search space for small
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   228
chessboards.\medskip
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   229
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   230
\noindent
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   231
Let us first fix the basic datastructures for the implementation.  The
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   232
board dimension is an integer.
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   233
A \emph{position} (or field) on the chessboard is
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   234
a pair of integers, like $(0, 0)$. A \emph{path} is a list of
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   235
positions. The first (or 0th move) in a path is the last element in
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   236
this list; and the last move in the path is the first element. For
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   237
example the path for the $5\times 5$ chessboard above is represented
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   238
by
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   239
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   240
\[
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   241
\texttt{List($\underbrace{\texttt{(0, 4)}}_{24}$,
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   242
  $\underbrace{\texttt{(2, 3)}}_{23}$, ...,
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   243
  $\underbrace{\texttt{(3, 2)}}_1$, $\underbrace{\texttt{(4, 4)}}_0$)}
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   244
\]
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   245
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   246
\noindent
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   247
Suppose the dimension of a chessboard is $n$, then a path is a
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   248
\emph{tour} if the length of the path is $n \times n$, each element
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   249
occurs only once in the path, and each move follows the rules of how a
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   250
knight moves (see above for the rules).
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   251
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   252
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   253
\subsubsection*{Task 1 (file knight1.scala)}
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   254
378
7a5ad01a85b5 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 372
diff changeset
   255
7a5ad01a85b5 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 372
diff changeset
   256
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   257
\begin{itemize}
212
4bda49ec24da updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   258
\item[(1)] Implement an \texttt{is\_legal} function that takes a
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   259
  dimension, a path and a position as arguments and tests whether the
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   260
  position is inside the board and not yet element in the
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   261
  path. \hfill[1 Mark]
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   262
212
4bda49ec24da updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   263
\item[(2)] Implement a \texttt{legal\_moves} function that calculates for a
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   264
  position all legal onward moves. If the onward moves are
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   265
  placed on a circle, you should produce them starting from
145
d306102fd33b updated
Christian Urban <urbanc@in.tum.de>
parents: 144
diff changeset
   266
  ``12-o'clock'' following in clockwise order.  For example on an
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   267
  $8\times 8$ board for a knight at position $(2, 2)$ and otherwise
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   268
  empty board, the legal-moves function should produce the onward
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   269
  positions in this order:
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   270
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   271
  \begin{center}
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   272
  \texttt{List((3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4))}
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   273
  \end{center}
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   274
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   275
  If the board is not empty, then maybe some of the moves need to be
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   276
  filtered out from this list.  For a knight on field $(7, 7)$ and an
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   277
  empty board, the legal moves are
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   278
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   279
  \begin{center}
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   280
  \texttt{List((6,5), (5,6))}
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   281
  \end{center}
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   282
  \mbox{}\hfill[1 Mark]
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   283
212
4bda49ec24da updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   284
\item[(3)] Implement two recursive functions (\texttt{count\_tours} and
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   285
  \texttt{enum\_tours}). They each take a dimension and a path as
110
62389faa66e4 updated
Christian Urban <urbanc@in.tum.de>
parents: 86
diff changeset
   286
  arguments. They exhaustively search for tours starting
62389faa66e4 updated
Christian Urban <urbanc@in.tum.de>
parents: 86
diff changeset
   287
  from the given path. The first function counts all possible 
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   288
  tours (there can be none for certain board sizes) and the second
216
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   289
  collects all tours in a list of paths. These functions will be
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   290
  called with a path containing a single position---the starting field.
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   291
  They are expected to extend this path so as to find all tours starting
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   292
  from the given position.\\
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   293
  \mbox{}\hfill[1 Mark]
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   294
\end{itemize}
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   295
  
212
4bda49ec24da updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   296
\noindent \textbf{Test data:} For the marking, the functions in (3)
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   297
will be called with board sizes up to $5 \times 5$. If you search
110
62389faa66e4 updated
Christian Urban <urbanc@in.tum.de>
parents: 86
diff changeset
   298
for tours on a $5 \times 5$ board starting only from field $(0, 0)$,
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   299
there are 304 of tours. If you try out every field of a $5 \times
110
62389faa66e4 updated
Christian Urban <urbanc@in.tum.de>
parents: 86
diff changeset
   300
5$-board as a starting field and add up all tours, you obtain
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   301
1728. A $6\times 6$ board is already too large to be searched
110
62389faa66e4 updated
Christian Urban <urbanc@in.tum.de>
parents: 86
diff changeset
   302
exhaustively.\footnote{For your interest, the number of tours on
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   303
  $6\times 6$, $7\times 7$ and $8\times 8$ are 6637920, 165575218320,
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   304
  19591828170979904, respectively.}\smallskip
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   305
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   306
\begin{itemize}
212
4bda49ec24da updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   307
\item[(4)] Implement a \texttt{first}-function. This function takes a list of
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   308
  positions and a function $f$ as arguments; $f$ is the name we give to
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   309
  this argument). The function $f$ takes a position as argument and
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   310
  produces an optional path. So $f$'s type is \texttt{Pos =>
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   311
    Option[Path]}. The idea behind the \texttt{first}-function is as follows:
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   312
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   313
  \[
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   314
  \begin{array}{lcl}
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   315
  \textit{first}(\texttt{Nil}, f) & \dn & \texttt{None}\\  
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   316
  \textit{first}(x\!::\!xs, f) & \dn & \begin{cases}
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   317
    f(x) & \textit{if}\;f(x) \not=\texttt{None}\\
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   318
    \textit{first}(xs, f) & \textit{otherwise}\\
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   319
                              \end{cases}
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   320
  \end{array}
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   321
  \]
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   322
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   323
  \noindent That is, we want to find the first position where the
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   324
  result of $f$ is not \texttt{None}, if there is one. Note that
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   325
  `inside' \texttt{first}, you do not (need to) know anything about
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   326
  the argument $f$ except its type, namely \texttt{Pos =>
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   327
    Option[Path]}. If you want to find out what the result of $f$ is
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   328
  on a particular argument, say $x$, you can just write $f(x)$. 
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   329
  There is one additional point however you should
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   330
  take into account when implementing \texttt{first}: you will need to
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   331
  calculate what the result of $f(x)$ is; your code should do this
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   332
  only \textbf{once} and for as \textbf{few} elements in the list as
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   333
  possible! Do not calculate $f(x)$ for all elements and then see which 
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   334
  is the first \texttt{Some}.\\\mbox{}\hfill[1 Mark]
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   335
  
212
4bda49ec24da updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   336
\item[(5)] Implement a \texttt{first\_tour} function that uses the
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   337
  \texttt{first}-function from (4), and searches recursively for single tour.
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   338
  As there might not be such a tour at all, the \texttt{first\_tour} function
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   339
  needs to return a value of type
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   340
  \texttt{Option[Path]}.\\\mbox{}\hfill[1 Mark]  
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   341
\end{itemize}
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   342
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   343
\noindent
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   344
\textbf{Testing:} The \texttt{first\_tour} function will be called with board
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   345
sizes of up to $8 \times 8$.
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   346
\bigskip
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   347
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   348
%%\newpage
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   349
\subsubsection*{Task 2 (file knight2.scala)}
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   350
307
3c7ac7836e4f updated
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   351
\noindent
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   352
As you should have seen in the earlier parts, a naive search for tours beyond
145
d306102fd33b updated
Christian Urban <urbanc@in.tum.de>
parents: 144
diff changeset
   353
$8 \times 8$ boards and also searching for closed tours even on small
329
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   354
boards takes too much time. There is a heuristics, called \emph{Warnsdorf's
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   355
Rule} that can speed up finding a tour. This heuristics states that a
145
d306102fd33b updated
Christian Urban <urbanc@in.tum.de>
parents: 144
diff changeset
   356
knight is moved so that it always proceeds to the field from which the
48
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   357
knight will have the \underline{fewest} onward moves.  For example for
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   358
a knight on field $(1, 3)$, the field $(0, 1)$ has the fewest possible
7a6a75ea9738 updated
Christian Urban <urbanc@in.tum.de>
parents: 46
diff changeset
   359
onward moves, namely 2.
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   360
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   361
\chessboard[maxfield=g7,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   362
            pgfstyle= {[base,at={\pgfpoint{0pt}{-0.5ex}}]text},
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   363
            text = \small 3, markfield=Z5,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   364
            text = \small 7, markfield=b5,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   365
            text = \small 7, markfield=c4,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   366
            text = \small 7, markfield=c2,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   367
            text = \small 5, markfield=b1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   368
            text = \small 2, markfield=Z1,
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   369
            setpieces={Na3}]
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   370
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   371
\noindent
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   372
Warnsdorf's Rule states that the moves on the board above should be
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   373
tried in the order
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   374
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   375
\[
46
48d2cbe8ee5e updated
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   376
(0, 1), (0, 5), (2, 1), (2, 5), (3, 4), (3, 2)
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   377
\]
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   378
46
48d2cbe8ee5e updated
Christian Urban <urbanc@in.tum.de>
parents: 45
diff changeset
   379
\noindent
60
f099bcf9cff1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 59
diff changeset
   380
Whenever there are ties, the corresponding onward moves can be in any
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   381
order.  When calculating the number of onward moves for each field, we
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   382
do not count moves that revisit any field already visited.
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   383
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   384
\begin{itemize}
212
4bda49ec24da updated
Christian Urban <urbanc@in.tum.de>
parents: 202
diff changeset
   385
\item[(6)] Write a function \texttt{ordered\_moves} that calculates a list of
216
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   386
  onward moves like in (2) but orders them according to 
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   387
  Warnsdorf’s Rule. That means moves with the fewest legal onward moves
86
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents: 79
diff changeset
   388
  should come first (in order to be tried out first). \hfill[1 Mark]
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   389
  
329
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   390
\item[(7)] Implement a \texttt{first\_closed\_tour\_heuristics}
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   391
  function that searches for a single
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   392
  \textbf{closed} tour on a $6\times 6$ board. It should try out
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   393
  onward moves according to
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   394
  the \texttt{ordered\_moves} function from (6). It is more likely to find
50
9891c9fac37e updated
Christian Urban <urbanc@in.tum.de>
parents: 48
diff changeset
   395
  a solution when started in the middle of the board (that is
86
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents: 79
diff changeset
   396
  position $(dimension / 2, dimension / 2)$). \hfill[1 Mark]
45
8399976b77fe updated
Christian Urban <urbanc@in.tum.de>
parents: 42
diff changeset
   397
329
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   398
\item[(8)] Implement a \texttt{first\_tour\_heuristics} function
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 163
diff changeset
   399
  for boards up to
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   400
  $30\times 30$.  It is the same function as in (7) but searches for
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   401
  tours (not just closed tours). It might be called with any field on the
216
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   402
  board as starting field.\\
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   403
  %You have to be careful to write a
329
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   404
  %tail-recursive function of the \texttt{first\_tour\_heuristics} function
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   405
  %otherwise you will get problems with stack-overflows.\\
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   406
  \mbox{}\hfill[1 Mark]
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   407
\end{itemize}    
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   408
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   409
\subsubsection*{Task 3 (file knight3.scala)}
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   410
\begin{itemize}
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   411
\item[(9)] Implement a function \texttt{tour\_on\_mega\_board} which is
216
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   412
  the same function as in (8), \textbf{but} should be able to
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   413
  deal with boards up to
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   414
  $70\times 70$ \textbf{within 30 seconds} (on my laptop). This will be tested
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   415
  by starting from field $(0, 0)$. You have to be careful to
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   416
  write a tail-recursive function otherwise you will get problems
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   417
  with stack-overflows. Please observe the requirements about
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   418
  the submissions: no tricks involving \textbf{.par}.\medskip
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   419
216
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   420
  The timelimit of 30 seconds is with respect to the laptop on which the
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   421
  marking will happen. You can roughly estimate how well your
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   422
  implementation performs by running \texttt{knight3.jar} on your
216
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   423
  computer. For example the reference implementation shows
8c868feb917b updated
Christian Urban <urbanc@in.tum.de>
parents: 213
diff changeset
   424
  on my laptop:
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   425
  
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   426
  \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   427
$ scala -cp knight3.jar
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   428
  
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   429
scala> M4c.tour_on_mega_board(70, List((0, 0)))
213
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   430
Time needed: 9.484 secs.
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   431
...<<long_list>>...
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   432
\end{lstlisting}%$
f968188d4a9b updated
Christian Urban <urbanc@in.tum.de>
parents: 212
diff changeset
   433
145
d306102fd33b updated
Christian Urban <urbanc@in.tum.de>
parents: 144
diff changeset
   434
  \mbox{}\hfill[1 Mark]
430
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   435
\end{itemize}
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   436
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   437
\subsubsection*{Task 4 (file knight4.scala)}
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   438
\begin{itemize}
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   439
\item[(10)] In this task we want to solve the problem of finding a single
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   440
  tour (if there exists one) on what is sometimes called ``mutilated''
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   441
  chessboards, for example rectangular chessbords or chessboards where
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   442
  fields are missing. For this implement a search function
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   443
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   444
  \begin{center}
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   445
    \begin{tabular}{@{}l@{}}
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   446
    \texttt{def one\_tour\_pred(dim: Int, path: Path,}\\
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   447
      \texttt{\phantom{def one\_tour\_pred(}n: Int, f: Pos => Boolean): Option[Path]}
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   448
      \end{tabular}
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   449
  \end{center}
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   450
430
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   451
  which has, like before, the dimension and current path as arguments,
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   452
  and in addtion it takes an integer, which specifies the length of
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   453
  the longest path (or length of the path after which the search
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   454
  should backtrack), and a function from positions to Booleans. This
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   455
  function acts as a predicate in order to restrict which onward legal
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   456
  moves should be considered in the search. The function
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   457
  \texttt{one\_tour\_pred} should return a single tour
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   458
  (\texttt{Some}-case), if one or more tours exist, and \texttt{None}, if no
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   459
  tour exists. For example when called with 
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   460
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   461
  \begin{center}
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   462
  \texttt{one\_tour\_pred(7, List((0, 0)), 35, x => x.\_1 < 5)}
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   463
  \end{center}  
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   464
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   465
  we are looking for a tour starting from position \texttt{(0,0)} on a
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   466
  7 $\times$ 5 board, where the maximum length of the path is 35. The
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   467
  predicate \texttt{x => x.\_1 < 5} ensures that no position with an
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   468
  x-coordinate bigger than 4 is considered. One possible solution is
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   469
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   470
  \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   471
   0   13   22   33   28   11   20 
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   472
  23   32    1   12   21   34   27 
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   473
  14    7   16   29    2   19   10 
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   474
  31   24    5    8   17   26    3 
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   475
   6   15   30   25    4    9   18 
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   476
  -1   -1   -1   -1   -1   -1   -1 
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   477
  -1   -1   -1   -1   -1   -1   -1
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   478
\end{lstlisting}%$
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   479
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   480
where \texttt{print\_board} prints a \texttt{-1} for all fields that
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   481
have not been visited.
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   482
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   483
  \mbox{}\hfill[2 Marks]
274c865b3878 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   484
\end{itemize}
148
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   485
ead6089209ba updated
Christian Urban <urbanc@in.tum.de>
parents: 147
diff changeset
   486
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   487
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   488
\end{document}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   489
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   490
%%% Local Variables: 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   491
%%% mode: latex
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   492
%%% TeX-master: t
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   493
%%% End: