You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: data/course-revision/1511-22T3/scrambled_scrabble.mdx
+11-7Lines changed: 11 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,9 @@ Given a string with some spots filled with letters and the others hyphens, and a
14
14
15
15
The program should receive three lines of input:
16
16
17
-
1. The first is an integer $N$.
18
-
2. Next will be the target word of length $N$, with some letters filled in and hyphens where you insert other letters. You may assume that the target word will always contain at least one letter, i.e you will never be given a target word consisting of all hyphens.
19
-
3. Finally will be the letter bank of length $N$ in reverse alphabetical order.
17
+
1. The first is an integer N.
18
+
2. Next will be the target word of length N, with some letters filled in and hyphens where you insert other letters. You may assume that the target word will always contain at least one letter, i.e you will never be given a target word consisting of all hyphens.
19
+
3. Finally will be the letter bank of length N in reverse alphabetical order.
20
20
21
21
**Output Format**
22
22
@@ -25,10 +25,10 @@ If a word can be formed, print to stdout the value of the word. If a word cannot
25
25
## Assumptions/Restrictions/Clarifications
26
26
27
27
- Fortunately, the words we create do not have to be real English words. The bank of letters we are given will also be the same length as the length of word we are trying to create. Note that spots in the target word with hyphens are where we need to put our letters.
28
-
- Each letter will have a value corresponding to its position in the alphabet ($a=1$, $b=2$ etc.)
28
+
- Each letter will have a value corresponding to its position in the alphabet (a=1, b=2 etc.)
29
29
- Each consonant must be followed by a vowel and each vowel must be followed by a consonant. (“abed” is valid, “abcd” is not). Words can start with either a consonant or vowel.
30
30
- No letter from the letter bank can be used more than once. Note there may be duplicate letters in the letter bank, you can use both.
31
-
-$1 <=N<=1024$
31
+
-1 ≤ N ≤ 1024
32
32
33
33
The output from your program should look **exactly** like this:
The highest scoring words we can make are “azeciy” or “ayeciz”. Assume we use "azeciy" as our word, then we calculate the score as 1 + 26 + 5 + 3 + 9 + 25 = 69.
There are 3 spots we need to fill using two vowels and a consonant. There is only one vowel in the letter bank we were given, hence we cannot form a word.
59
+
60
+
## Solution
61
+
62
+
You can view the solution code to this problem [here](https://github.com/csesoc/comp1511-revision-t1-2022/blob/master/solutions/scrambled-scrabble/solution.c).
0 commit comments