|
1 // Resit about Evil Wordle |
|
2 //========================== |
|
3 |
|
4 |
|
5 object Resit { |
|
6 |
|
7 import io.Source |
|
8 import scala.util._ |
|
9 |
|
10 // ADD YOUR CODE BELOW |
|
11 //====================== |
|
12 |
|
13 |
|
14 //(1) |
|
15 def get_wordle_list(url: String) : List[String] = ??? |
|
16 |
|
17 // val secrets = get_wordle_list("https://nms.kcl.ac.uk/christian.urban/wordle.txt") |
|
18 // secrets.length // => 12972 |
|
19 // secrets.filter(_.length != 5) // => Nil |
|
20 |
|
21 //(2) |
|
22 def removeN[A](xs: List[A], elem: A, n: Int) : List[A] = ??? |
|
23 |
|
24 |
|
25 // removeN(List(1,2,3,2,1), 3, 1) // => List(1, 2, 2, 1) |
|
26 // removeN(List(1,2,3,2,1), 2, 1) // => List(1, 3, 2, 1) |
|
27 // removeN(List(1,2,3,2,1), 1, 1) // => List(2, 3, 2, 1) |
|
28 // removeN(List(1,2,3,2,1), 0, 2) // => List(1, 2, 3, 2, 1) |
|
29 |
|
30 // (3) |
|
31 abstract class Tip |
|
32 case object Absent extends Tip |
|
33 case object Present extends Tip |
|
34 case object Correct extends Tip |
|
35 |
|
36 |
|
37 def pool(secret: String, word: String) : List[Char] = ??? |
|
38 |
|
39 def aux(secret: List[Char], word: List[Char], pool: List[Char]) : List[Tip] = ??? |
|
40 |
|
41 def score(secret: String, word: String) : List[Tip] = ??? |
|
42 |
|
43 |
|
44 // score("chess", "caves") // => List(Correct, Absent, Absent, Present, Correct) |
|
45 // score("doses", "slide") // => List(Present, Absent, Absent, Present, Present) |
|
46 // score("chess", "swiss") // => List(Absent, Absent, Absent, Correct, Correct) |
|
47 // score("chess", "eexss") // => List(Present, Absent, Absent, Correct, Correct) |
|
48 |
|
49 // (4) |
|
50 def eval(t: Tip) : Int = ??? |
|
51 |
|
52 def iscore(secret: String, word: String) : Int = ??? |
|
53 |
|
54 //iscore("chess", "caves") // => 21 |
|
55 //iscore("chess", "swiss") // => 20 |
|
56 |
|
57 // (5) |
|
58 def lowest(secrets: List[String], word: String, current: Int, acc: List[String]) : List[String] = ??? |
|
59 |
|
60 def evil(secrets: List[String], word: String) : List[String] = ??? |
|
61 |
|
62 |
|
63 //evil(secrets, "stent").length |
|
64 //evil(secrets, "hexes").length |
|
65 //evil(secrets, "horse").length |
|
66 //evil(secrets, "hoise").length |
|
67 //evil(secrets, "house").length |
|
68 |
|
69 // (6) |
|
70 def frequencies(secrets: List[String]) : Map[Char, Double] = ??? |
|
71 |
|
72 // (7) |
|
73 def rank(frqs: Map[Char, Double], s: String) : Double = ??? |
|
74 |
|
75 def ranked_evil(secrets: List[String], word: String) : List[String] = ??? |
|
76 |
|
77 |
|
78 } |