Skip to content

Commit 12e692f

Browse files
meatball133BethanyG
authored andcommitted
Fixes
1 parent 85865aa commit 12e692f

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

exercises/practice/scrabble-score/.approaches/dictionary/content.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def score(word):
3434
return sum(LETTER_SCORES[letter.upper()] for letter in word)
3535
```
3636

37-
The code starts with initializing a constant that is a [dictionary][dictionary] that holds all the letters as different key and their respective score as a value.
38-
Then it defines a function that takes a word as an argument.
37+
The code starts with initializing a constant that is a [dictionary][dictionary] there each letter is a key and their respective score as a value.
38+
Then a function is defined that takes a word as an argument.
3939

4040
The function returns the built in function [`sum`][sum] that takes a [generator expression][generator-expersion] that iterates over the letters in the word.
4141
What a generator expression does is that it generates the values on the fly.

exercises/practice/scrabble-score/.approaches/enum/content.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class Scrabble(IntEnum):
1313
Q = Z = 10
1414

1515
def score(word):
16-
return sum(Scrabble[char.upper()] for char in word)
16+
return sum(Scrabble[character.upper()] for character in word)
1717
```
1818

1919
This approach uses an [`enum`][enum] to define the score of each letter.
20-
An `enum` or known as a enumerations is sets of named constant and is immutable.
21-
`enum` was added to python standard library also known as stdlib in python 3.4.
20+
An `enum` or known as an **enumeration** is sets of named constant and is immutable.
21+
`enum` was added to python standard library (_also known as stdlib_) in python 3.4.
2222

2323
This approach uses an [`intEnum`][int-enum] it works very similar to a normal `enum` but it has the added benefit that the values are integers.
2424
Thereby acts like integers.
@@ -29,13 +29,13 @@ Then you can define the `enum` class.
2929
The `enum` class is defined by using the [`class`][classes] keyword.
3030
Then you need to specify the name of the class.
3131

32-
After that is constant declared by giving the constant capital letters and the value is assigned by using the `=` operator.
32+
After that is the constant in the enum declared by giving the constant capital letters and the value is assigned by using the `=` operator.
3333
This approach works by giving all the letters as constants and then value of the constant is the score of the letter.
3434
After the `enum` is defined, the `score` function is defined.
3535

3636
The `score` function takes a word as a parameter.
37-
And uses the same [generator expression][generator-expersion] as the [dictionary approach][dictionary-approach].
38-
But instead of looking up the value in a dictionary it looks it up in the `enum` class.
37+
And uses the same [generator expression][generator-expersion] as the [dictionary approach][dictionary-approach] but with a slight modification.
38+
Which is that instead of looking up the value in a dictionary it looks it up in the `enum` class.
3939

4040
[classes]: https://docs.python.org/3/tutorial/classes.html
4141
[enum]: https://docs.python.org/3/library/enum.html

exercises/practice/scrabble-score/.approaches/introduction.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Introduction
22

33
There are various ways to solve `scrabble-score`.
4-
This approaches document shows different strategies to solve this exercise
4+
This approache document shows different strategies to solve this exercise.
55

66
## General guidance
77

88
The goal of this exercise is to write a function that calculates the scrabble score for a given word.
9-
The problem is that
9+
The problem is that the scrabble score is calculated by the sum of the scores of each letter in the word.
1010

1111
## Approach: Using a single dictionary
1212

@@ -51,7 +51,7 @@ For more information, check the [Dictionary Approach][dictionary-approach].
5151

5252
## Approach: Using two sequences
5353

54-
Using two sequences is an approach, it is fast.
54+
Using two sequences is an approach, it removes the need of using a nested data structure or a dictonary.
5555
Although the reason you might not want to do this is that it is hard to read.
5656

5757
```python
@@ -67,7 +67,7 @@ For more information, check the [Two Sequences Approach][two-sequences-approach]
6767
## Approach: Enum
6868

6969
Using an `enum` is an approach, it is short and easy to read.
70-
Although it is more complicated since it uses a class.
70+
Although it is more complicated since it uses a oop (object oriented programmering) elements.
7171

7272
```python
7373
from enum import IntEnum
@@ -82,10 +82,10 @@ class Scrabble(IntEnum):
8282
Q = Z = 10
8383

8484
def score(word):
85-
return sum(Scrabble[char.upper()] for char in word)
85+
return sum(Scrabble[letter.upper()] for letter in word)
8686
```
8787

88-
You can read more about how to achieve this optimization in: [Enum Approach][enum-approach].
88+
For more information, check the [Enum Approach][enum-approach].
8989

9090
## Approach: Using a nested tuple
9191

exercises/practice/scrabble-score/.approaches/nested-tuple/content.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ def score(word):
1515
return sum(score for character in word for letters, score in LETTERS_OF_SCORE if character.upper() in letters)
1616
```
1717

18-
The code starts with initializing a constant with a [tuple][tuple] of tuples.
19-
Inside of the inner tuples there is 2 values, the first value is a string of letters and the second value is the score of the letters.
18+
The code starts with initializing a constant with a [tuple][tuple] of tuples (_also known as a nested tuple_).
19+
Inside of the inner tuples there is 2 values, the first value is a string of letters and the second value is the score for the letters.
2020

21-
Then it defines a function that takes a word as an argument.
22-
The function returns a [generator expression][generator-expersion] similar to the [dictionary approach][dictionary-approach].
23-
The difference is that it uses a nested [for loop][for-loop] to iterate over the letters and the tuples.
24-
There we iterate over the characters in the word and then iterate over the tuples.
21+
Then a function is defined that takes a word as an argument.
22+
The function returns a [generator expression][generator-expersion] similar to the [dictionary approach][dictionary-approach] but has some slight modifcations.
23+
24+
The difference is that this one uses a nested [for loop][for-loop] to iterate over the letters and the tuples.
25+
We first iterate over the characters in the word and then iterate over the tuples.
26+
Which means that for each letter are we iterating over all of the tuples.
2527
There the tuple is unpacked into the letters and the score.
2628
You can read more about unpacking in the [concept:python/unpacking-and-multiple-assignment]().
2729

exercises/practice/scrabble-score/.approaches/two-sequences/content.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ def score(word):
88
return sum(SCORES[KEYS.index(letter.upper())] for letter in word)
99
```
1010

11-
This approach uses a string and a [list][list], both of these data types belongs to the data type [sequences][sequence].
12-
It has a constant with a string with letters and then it has a constant of a list with corresponding score for the same index as the string.
11+
This approach uses a string and a [list][list], both of these data types belongs to the parent data type [sequences][sequence].
12+
The code starts with defining a string constant with letters.
13+
Then another constant is definded which is a list with corresponding score for the same index as the string.
1314

1415
The `score` function takes a word as a parameter.
15-
And uses the same [generator expression][generator-expersion] as the [dictionary approach][dictionary-approach].
16+
And uses the same [generator expression][generator-expersion] as the [dictionary approach][dictionary-approach] with some slight modifications.
1617

17-
The difference is that instead of using a [dictionary][dictionary] and looked up the score inside.
18+
The difference is that instead of using a [dictionary][dictionary] and looking up the score inside of a dictonary.
1819
This approach gets the index of the letter in the KEYS constant and then then looks up the value for that index in SCORES list.
1920
Then takes that value and return that to the generator expression.
2021

0 commit comments

Comments
 (0)