Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@
"prerequisites": [],
"difficulty": 4
},
{
"slug": "scrabble-score",
"name": "Scrabble Score",
"uuid": "36ace4af-c2e3-4685-ae41-74e14f3605f2",
"practices": [],
"prerequisites": [],
"difficulty": 4
},
{
"slug": "spiral-matrix",
"name": "Spiral Matrix",
Expand Down
25 changes: 25 additions & 0 deletions exercises/practice/scrabble-score/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Instructions

Your task is to compute a word's Scrabble score by summing the values of its letters.

The letters are valued as follows:

| Letter | Value |
| ---------------------------- | ----- |
| A, E, I, O, U, L, N, R, S, T | 1 |
| D, G | 2 |
| B, C, M, P | 3 |
| F, H, V, W, Y | 4 |
| K | 5 |
| J, X | 8 |
| Q, Z | 10 |

For example, the word "cabbage" is worth 14 points:

- 3 points for C
- 1 point for A
- 3 points for B
- 3 points for B
- 1 point for A
- 2 points for G
- 1 point for E
7 changes: 7 additions & 0 deletions exercises/practice/scrabble-score/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Introduction

[Scrabble][wikipedia] is a word game where players place letter tiles on a board to form words.
Each letter has a value.
A word's score is the sum of its letters' values.

[wikipedia]: https://en.wikipedia.org/wiki/Scrabble
21 changes: 21 additions & 0 deletions exercises/practice/scrabble-score/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"authors": [
"IsaacG"
],
"files": {
"solution": [
"scrabble_score.gd"
],
"test": [
"scrabble_score_test.gd",
"run_tests",
"lib/test_runner.gd"
],
"example": [
".meta/example.gd"
]
},
"blurb": "Given a word, compute the Scrabble score for that word.",
"source": "Inspired by the Extreme Startup game",
"source_url": "https://github.com/rchatley/extreme_startup"
}
13 changes: 13 additions & 0 deletions exercises/practice/scrabble-score/.meta/example.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var SCORES = {
'A': 1, 'E': 1, 'I': 1, 'O': 1, 'U': 1,
'L': 1, 'N': 1, 'R': 1, 'S': 1, 'T': 1,
'D': 2, 'G': 2, 'B': 3, 'C': 3, 'M': 3, 'P': 3,
'F': 4, 'H': 4, 'V': 4, 'W': 4, 'Y': 4,
'K': 5, 'J': 8, 'X': 8, 'Q': 10, 'Z': 10,
}

func score(word: String) -> int:
var out: int = 0
for char in word.to_upper():
out += SCORES[char]
return out
8 changes: 8 additions & 0 deletions exercises/practice/scrabble-score/.meta/template.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% for case in cases %}
func test_{{ case.func_name }}(solution_script):
var got = solution_script.{{ case.property }}({{ case.given | togdscript }})
var want = {{ case.expected | togdscript }}
return [got, want]

{% endfor %}

43 changes: 43 additions & 0 deletions exercises/practice/scrabble-score/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[f46cda29-1ca5-4ef2-bd45-388a767e3db2]
description = "lowercase letter"

[f7794b49-f13e-45d1-a933-4e48459b2201]
description = "uppercase letter"

[eaba9c76-f9fa-49c9-a1b0-d1ba3a5b31fa]
description = "valuable letter"

[f3c8c94e-bb48-4da2-b09f-e832e103151e]
description = "short word"

[71e3d8fa-900d-4548-930e-68e7067c4615]
description = "short, valuable word"

[d3088ad9-570c-4b51-8764-c75d5a430e99]
description = "medium word"

[fa20c572-ad86-400a-8511-64512daac352]
description = "medium, valuable word"

[9336f0ba-9c2b-4fa0-bd1c-2e2d328cf967]
description = "long, mixed-case word"

[1e34e2c3-e444-4ea7-b598-3c2b46fd2c10]
description = "english-like word"

[4efe3169-b3b6-4334-8bae-ff4ef24a7e4f]
description = "empty input"

[3b305c1c-f260-4e15-a5b5-cb7d3ea7c3d7]
description = "entire alphabet available"
Loading
Loading