cws/cw02.tex
author Christian Urban <urbanc@in.tum.de>
Thu, 03 Nov 2016 00:53:53 +0000
changeset 6 aae256985251
child 36 f5ed0fef41b3
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\documentclass{article}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
\usepackage{../style}
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}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
\begin{document}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
\setchessboard{smallboard,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
               showmover=false,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
               boardfontencoding=LSBC4,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
               hlabelformat=\arabic{ranklabel},
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
               vlabelformat=\arabic{filelabel}}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
\section*{Coursework 2 (Knight's Tour)}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
This coursework is worth XXX\% and is due on 21 November at 16:00. You
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
are asked to implement a Scala program that solves the \textit{knight's
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
  tour problem} on an $n\times n$ chessboard. This problem is about
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
finding a tour such that the knight visits every field on the
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
chessboard once. One a $5\times 5$ chessboard, a knight's tour
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
is as follows:
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
\chessboard[maxfield=e5, 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
            pgfstyle= {[base,at={\pgfpoint{0pt}{-0.5ex}}]text},
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
            text = \bf\small 24, markfield=a5,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
            text = \small 11, markfield=b5,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
            text = \small  6, markfield=c5,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
            text = \small 17, markfield=d5,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
            text = \small  0, markfield=e5,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
            text = \small 19, markfield=a4,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
            text = \small 16, markfield=b4,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
            text = \small 23, markfield=c4,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
            text = \small 12, markfield=d4,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
            text = \small  7, markfield=e4,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
            text = \small 10, markfield=a3,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
            text = \small  5, markfield=b3,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
            text = \small 18, markfield=c3,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
            text = \small  1, markfield=d3,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
            text = \small 22, markfield=e3,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
            text = \small 15, markfield=a2,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
            text = \small 20, markfield=b2,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
            text = \small  3, markfield=c2,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
            text = \small  8, markfield=d2,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
            text = \small 13, markfield=e2,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
            text = \small  4, markfield=a1,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
            text = \small  9, markfield=b1,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
            text = \small 14, markfield=c1,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
            text = \small 21, markfield=d1,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
            text = \small  2, markfield=e1
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
           ]
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
\noindent
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
The tour starts in the left-upper corner, then moves to field $(4,3)$,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
then $(5,1)$ and so on. A knight's tour is called \emph{closed}, if
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
the last step in the tour is within a knight's move to the beginning
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
of the tour. So the above knight's tour is not closed (that is it is
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
open) because the last step on field $(1, 5)$ is not within the reach
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
of the first step on $(5, 5)$. It turns out there is no closed
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
knight's tour on a $5\times 5$ board. But there is one on a $6\times
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
6$ board.
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
If you cannot remember how a knight moved in chess, below are all
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
potential moves indicated for two knights, one on field $(3, 3)$ and
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
another on $(8, 8)$:
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
\chessboard[color=blue!50,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
            linewidth=0.2em,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
            shortenstart=0.5ex,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
            shortenend=0.5ex,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
            markstyle=cross,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
            markfields={b5, d5, a4, e4, a2, e2, b1, d1},
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
            color=red!50,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
            markfields={g6, f7},
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
            setpieces={Nh8, Nc3}]
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
\subsubsection*{Disclaimer}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
It should be understood that the work you submit represents
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
your own effort. You have not copied from anyone else. An
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
exception is the Scala code I showed during the lectures or
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
uploaded to KEATS, which you can freely use.\bigskip
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
\subsubsection*{Task}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
The task is to implement a regular expression matcher based on
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
derivatives of regular expressions. The implementation should
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
be able to deal with the usual (basic) regular expressions
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
\noindent {\bf Important!} Your implementation should have
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
explicit cases for the basic regular expressions, but also
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
explicit cases for the extended regular expressions. That
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
means do not treat the extended regular expressions by just
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
translating them into the basic ones. See also Question 2,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
where you are asked to explicitly give the rules for
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
\textit{nullable} and \textit{der} for the extended regular
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
expressions.
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
\end{document}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
%%% Local Variables: 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
%%% mode: latex
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
%%% TeX-master: t
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
%%% End: