cws/main_cw02.tex
changeset 458 d9f8245d0861
parent 445 b73e7ce91c10
child 459 d59404a41d5f
equal deleted inserted replaced
457:9cf317975ae7 458:d9f8245d0861
   112 \item[(1)] Implement the function \pcode{get_wordle_list} which takes an
   112 \item[(1)] Implement the function \pcode{get_wordle_list} which takes an
   113   URL-string as argument and requests the corresponding file. The function should
   113   URL-string as argument and requests the corresponding file. The function should
   114   return the word list appropriately broken up into lines.
   114   return the word list appropriately broken up into lines.
   115   The result should be a list of strings (the lines in the file). In case
   115   The result should be a list of strings (the lines in the file). In case
   116   the url does not produce a file, return the empty list.
   116   the url does not produce a file, return the empty list.
       
   117 
       
   118   \textcolor{red}{
       
   119     In what follows we will use \texttt{secrets} to refer  to the list of words listed
       
   120     in \texttt{wordle.txt}.  
       
   121   }
   117   \mbox{}\hfill [0.5 Marks]
   122   \mbox{}\hfill [0.5 Marks]
   118 
   123 
   119 \item[(2)] Implement a polymorphic function \pcode{removeN}, which removes $n$ occurrences of an
   124 \item[(2)] Implement a polymorphic function \pcode{removeN}, which removes $n$ occurrences of an
   120   element from a list (if this element is less than $n$ times present, then remove all occurrences).
   125   element from a list (if this element is less than $n$ times present, then remove all occurrences).
   121   For example
   126   For example
   259   \mbox{}\hfill [1 Mark]
   264   \mbox{}\hfill [1 Mark]
   260 
   265 
   261 \item[(7)] In this task we want to use the output of \pcode{evil}, rank each string in the
   266 \item[(7)] In this task we want to use the output of \pcode{evil}, rank each string in the
   262   generated set and then filter out the strings that are ranked highest (the ones with the most obscure letters).
   267   generated set and then filter out the strings that are ranked highest (the ones with the most obscure letters).
   263   This list of strings often contains only a single word, but in general there might be more (see below).
   268   This list of strings often contains only a single word, but in general there might be more (see below).
   264   First implement a function \pcode{rank} that takes a frequency map (from 6) and a string as arguments and
   269   First implement a function \pcode{rank} that takes a frequency map (from 6) and a string as arguments.
       
   270   \textcolor{red}{In the testcases, the frequency map is generated for all words in \texttt{secrets}, that is the
       
   271   whole list in \texttt{wordle.txt}.} The function  
   265   generates a rank by summing up all frequencies of the letters in the string. For example
   272   generates a rank by summing up all frequencies of the letters in the string. For example
   266 
   273 
   267 \begin{lstlisting}[numbers=none]
   274 \begin{lstlisting}[numbers=none]
   268 rank(frequencies(secrets), "adobe") => 4.673604687018193
   275 rank(frequencies(secrets), "adobe") => 4.673604687018193
   269 rank(frequencies(secrets), "gaffe") => 4.745205057045945
   276 rank(frequencies(secrets), "gaffe") => 4.745205057045945