This course has already ended.
You cannot submit this assignment

You need to sign in and enrol to submit exercises.

Assignment 19

2 points

Use the function imdbMovie to identify the 150th best movie ever according to IMDb. Here, we number the movies in the everyday fashion from one upwards, so the two movies picked out above are the third and first on the list, respectively.

Enter the name of the 150th best movie here:

3 points

The function imdbBestDirectors also uses the top-movies list. It sorts movie directors by how many of their movies appear on the list and returns a string containing a list of directors. The function expects to be given a single integer parameter that serves as the lower limit for inclusion. For instance, given the parameter value 2, the return value will include only those directors who have at least two movies in the Top 250.

Use imdbBestDirectors to discover who has the most movies on the list. Enter the name of the director here. (Actually, there’s a tie between two directors. Pick either of them.)

3 points

Use the function imdbBestBetween to determine the best movie of the 1950s according to IMDb. The function expects two integer parameters: a starting year and an ending year. It returns the name of the highest-ranking movie within the given interval. The interval includes the two years you pass as parameters.

Enter the highest-rated movie of the nineteen-fifties here:

3 points

For a change, let’s use strings as parameters and experiment with a function named editDistance. This function computes the Levenshtein distance between its two string parameters.

../_images/levenshtein-en.png

The Levenshtein distance is an integer that indicates how many single-character insertions, deletions, or substitutions it takes to turn one string into another. For example, the Levenshtein distance between the strings "beginner" and "engineer" is three, because we can’t manage with fewer operations than this:

  1. Add a single n to "beginner" to get "benginner".

  2. Remove the b to get "enginner".

  3. Substitute one letter with another to get "engineer".

(Levenshtein distance has applications beyond spell checking. For instance, in computational genetics, it can be used for comparing DNA sequences. The genome of an organism can be represented as a string whose letters — such as A, G, C, and T — correspond to different constituents of DNA.)

Call the editDistance function, which too is defined in package o1. You’ll need to pass in two parameters of type String: the two strings to be compared. Use string literals enclosed in double quotation marks. Remember the comma.

Experiment with the function freely. Use different parameter values. In the field below, please report the Levenshtein distance between the strings "democrat" and "republican".

Posting submission...

Earned points

0 / 11

Exercise info

Assignment category
Graded
Your submissions
0 / 5
Deadline
Wednesday, 14 September 2022, 18:00
Late submission deadline
Saturday, 15 April 2023, 12:00 (-100%)
Group size
1-2
Total number of submitters
1003