--- a/cws/main_cw02.tex Thu Nov 02 13:53:37 2023 +0000
+++ b/cws/main_cw02.tex Thu Nov 02 23:34:53 2023 +0000
@@ -40,10 +40,10 @@
and apply an automated marking script to them.\medskip
\noindent
-In addition, the Scala part comes with reference
-implementations in form of \texttt{jar}-files. This allows you to run
-any test cases on your own computer. For example you can call Scala on
-the command line with the option \texttt{-cp wordle.jar} and then
+In addition, the Scala part comes with a reference
+implementation in form of \texttt{jar}-files. This allows you to run
+any test cases on your own computer. For example you can call \texttt{scala-cli} on
+the command line with the option \texttt{--extra-jars wordle.jar} and then
query any function from the template file. Say you want to find out
what the function \texttt{} produces: for this you just need
to prefix it with the object name \texttt{M2}. If you want to find out what
@@ -51,7 +51,7 @@
you would type something like:
\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
-$ scala -cp wordle.jar
+$ scala-cli --extra-jars wordle.jar
scala> val secretsURL =
| """https://nms.kcl.ac.uk/christian.urban/wordle.txt"""
@@ -115,10 +115,8 @@
The result should be a list of strings (the lines in the file). In case
the url does not produce a file, return the empty list.
- \textcolor{red}{
- In what follows we will use \texttt{secrets} to refer to the list of words listed
- in \texttt{wordle.txt}.
- }
+ In what follows we will use \texttt{secrets} to refer to the list of words listed
+ in \texttt{wordle.txt}.\\
\mbox{}\hfill [0.5 Marks]
\item[(2)] Implement a polymorphic function \pcode{removeN}, which removes $n$ occurrences of an
@@ -218,29 +216,8 @@
where \pcode{secrets} is the list generated under Task 1.
In all cases above the iscore of the resulting secrets is 0, but this does not need to be the case
-in general.
-
-\color{red}
- Note that the template gives as type for \texttt{evil}:
-
- \begin{center}
- \texttt{def evil(secrets: List[String], word: String) = ???}
- \end{center}
-
- where the return type is left unspecified. This return type is not needed when
- functions are not recursive---\texttt{evil} is meant to be just a wrapper that
- calls \texttt{lowest} with appropriate default arguments and returns whatever
- \texttt{lowest} returns. Therefore a return type is not needed. But a slightly
- more accurate template definition for \texttt{evil} is:\medskip\medskip
-
- \begin{minipage}{1.05\textwidth}
- \begin{center}
- \texttt{def evil(secrets: List[String], word: String) : List[String] = ???}
- \end{center}
- \end{minipage}\medskip\medskip
-
- where also the return type is explicitly given.\\\color{black}
- \mbox{}\hfill [1.5 Marks]
+in general.\\
+\mbox{}\hfill [1.5 Marks]
\item[(6)] The secrets generated in Task 5 are the ones with the lowest score
with respect to the word. You can think of these as the secrets that are furthest ``away'' from the
@@ -267,8 +244,8 @@
generated set and then filter out the strings that are ranked highest (the ones with the most obscure letters).
This list of strings often contains only a single word, but in general there might be more (see below).
First implement a function \pcode{rank} that takes a frequency map (from 6) and a string as arguments.
- \textcolor{red}{In the testcases, the frequency map is generated for all words in \texttt{secrets}, that is the
- whole list in \texttt{wordle.txt}.} The function
+ In the testcases, the frequency map is generated for all words in \texttt{secrets}, that is the
+ whole list in \texttt{wordle.txt}. The function
generates a rank by summing up all frequencies of the letters in the string. For example
\begin{lstlisting}[numbers=none]
@@ -277,13 +254,6 @@
rank(frequencies(secrets), "fuzzy") => 4.898735738513722
\end{lstlisting}
- \color{red}
- The return type for \texttt{rank} is \texttt{Double}:
-
- \begin{center}
- \texttt{def rank(frqs: Map[Char, Double], s: String) : Double = ???}
- \end{center}
- \color{black}
Finally, implement a function \pcode{ranked_evil} that selects from the output of \pcode{evil}
the string(s) which are highest ranked in evilness.
@@ -299,14 +269,6 @@
This means if the user types in "abbey" then the most evil word to choose as secret is ``whizz'' (according to
our calculations). This word has a zero \pcode{iscore} and the most obscure letters.
-\color{red}
- The return type for \texttt{ranked\_evil} is \texttt{List[String]}:
-
- \begin{center}
- \texttt{def ranked\_evil(secrets: List[String], word: String) : List[String] = ???}
- \end{center}
- \color{black}
-
%
%\color{red}
%\section*{Correction with \texttt{ranked\_evil}}