main_testing2/wordle_test6.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 02 Nov 2023 23:34:53 +0000
changeset 475 59e005dcf163
parent 437 d4d4669ad054
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
     3
def urbanmain() = {
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
     4
  import M2._
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
     5
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
     6
  import io.Source
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
     9
  def urban_get_wordle_list(url: String) : List[String] = {
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
    10
    Source.fromFile(url)("ISO-8859-1").getLines().toList
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
    11
  }
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
    12
  val urban_secrets = urban_get_wordle_list("wordle.txt")
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
    14
  //val urban_wordle_url = """https://nms.kcl.ac.uk/christian.urban/wordle.txt"""
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
    15
  //val urban_secrets = get_wordle_list(urban_wordle_url)
435
fda7c39f3b6a updated wordle testing
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
    17
  assert(frequencies(urban_secrets)('y') == 0.9680234350909651)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
    18
  assert(frequencies(urban_secrets)('e') == 0.897286463151403)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
    19
  assert(frequencies(urban_secrets)('z') == 0.9933086648165279)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 437
diff changeset
    20
}