-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Instructions | ||
|
||
Your task is to change the data format of letters and their point values in the game. | ||
|
||
Currently, letters are stored in groups based on their score, in a one-to-many mapping. | ||
|
||
- 1 point: "A", "E", "I", "O", "U", "L", "N", "R", "S", "T", | ||
- 2 points: "D", "G", | ||
- 3 points: "B", "C", "M", "P", | ||
- 4 points: "F", "H", "V", "W", "Y", | ||
- 5 points: "K", | ||
- 8 points: "J", "X", | ||
- 10 points: "Q", "Z", | ||
|
||
This needs to be changed to store each individual letter with its score in a one-to-one mapping. | ||
|
||
- "a" is worth 1 point. | ||
- "b" is worth 3 points. | ||
- "c" is worth 3 points. | ||
- "d" is worth 2 points. | ||
- etc. | ||
|
||
As part of this change, the team has also decided to change the letters to be lower-case rather than upper-case. | ||
|
||
~~~~exercism/note | ||
If you want to look at how the data was previously structured and how it needs to change, take a look at the examples in the test suite. | ||
~~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Introduction | ||
|
||
You work for a company that makes an online multiplayer game called Lexiconia. | ||
|
||
To play the game, each player is given 13 letters, which they must rearrange to create words. | ||
Different letters have different point values, since it's easier to create words with some letters than others. | ||
|
||
The game was originally launched in English, but it is very popular, and now the company wants to expand to other languages as well. | ||
|
||
Different languages need to support different point values for letters. | ||
The point values are determined by how often letters are used, compared to other letters in that language. | ||
|
||
For example, the letter 'C' is quite common in English, and is only worth 3 points. | ||
But in Norwegian it's a very rare letter, and is worth 10 points. | ||
|
||
To make it easier to add new languages, your team needs to change the way letters and their point values are stored in the game. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"authors": [ | ||
"BNAndras" | ||
], | ||
"files": { | ||
"solution": [ | ||
"etl.wren" | ||
], | ||
"test": [ | ||
"etl.spec.wren" | ||
], | ||
"example": [ | ||
".meta/proof.ci.wren" | ||
] | ||
}, | ||
"blurb": "Change the data format for scoring a game to more easily add other languages.", | ||
"source": "Based on an exercise by the JumpstartLab team for students at The Turing School of Software and Design.", | ||
"source_url": "https://turing.edu" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class Etl { | ||
static toLowerUnsafe(str) { | ||
return str.codePoints.map(Fn.new { |cp| String.fromCodePoint(cp + 32) }).join() | ||
} | ||
|
||
static transform(legacy) { | ||
var results = {} | ||
for (pair in legacy) { | ||
for (letter in pair.value) { | ||
var lowered = toLowerUnsafe(letter) | ||
results[lowered] = pair.key | ||
} | ||
} | ||
|
||
return results | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 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. | ||
|
||
[78a7a9f9-4490-4a47-8ee9-5a38bb47d28f] | ||
description = "single letter" | ||
|
||
[60dbd000-451d-44c7-bdbb-97c73ac1f497] | ||
description = "single score with multiple letters" | ||
|
||
[f5c5de0c-301f-4fdd-a0e5-df97d4214f54] | ||
description = "multiple scores with multiple letters" | ||
|
||
[5db8ea89-ecb4-4dcd-902f-2b418cc87b9d] | ||
description = "multiple scores with differing numbers of letters" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Exercism | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import "./etl" for Etl | ||
import "wren-testie/testie" for Testie, Expect | ||
|
||
Testie.test("ETL") { |do, skip| | ||
do.test("single letter") { | ||
var legacy = { 1: ["A"] } | ||
var actual = Etl.transform(legacy) | ||
var expected = { "a": 1 } | ||
Expect.value(actual).toEqual(expected) | ||
} | ||
|
||
skip.test("single score with multiple letters") { | ||
var legacy = { 1: ["A", "E", "I", "O", "U"] } | ||
var actual = Etl.transform(legacy) | ||
var expected = { "a": 1, "e": 1, "i": 1, "o": 1, "u": 1 } | ||
Expect.value(actual).toEqual(expected) | ||
} | ||
|
||
skip.test("multiple scores with multiple letters") { | ||
var legacy = { 1: ["A", "E"], 2: ["D", "G"] } | ||
var actual = Etl.transform(legacy) | ||
var expected = { "a": 1, "d": 2, "e": 1, "g": 2 } | ||
Expect.value(actual).toEqual(expected) | ||
} | ||
|
||
skip.test("multiple scores with differing numbers of letters") { | ||
var legacy = { | ||
1: ["A", "E", "I", "O", "U", "L", "N", "R", "S", "T"], | ||
2: ["D", "G"], | ||
3: ["B", "C", "M", "P"], | ||
4: ["F", "H", "V", "W", "Y"], | ||
5: ["K"], | ||
8: ["J", "X"], | ||
10: ["Q", "Z"] | ||
} | ||
var actual = Etl.transform(legacy) | ||
var expected = { | ||
"a": 1, "b": 3, "c": 3, "d": 2, "e": 1, "f": 4, "g": 2, "h": 4, | ||
"i": 1, "j": 8, "k": 5, "l": 1, "m": 3, "n": 1, "o": 1, "p": 3, | ||
"q": 10, "r": 1, "s": 1, "t": 1, "u": 1, "v": 4, "w": 4, "x": 8, | ||
"y": 4, "z": 10 | ||
} | ||
Expect.value(actual).toEqual(expected) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Etl { | ||
static transform(legacy) { | ||
Fiber.abort("Remove this statement and implement this function") | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import "wren-package" for WrenPackage, Dependency | ||
import "os" for Process | ||
|
||
class Package is WrenPackage { | ||
construct new() {} | ||
name { "exercism/etl" } | ||
dependencies { | ||
return [ | ||
Dependency.new("wren-testie", "0.3.0", "https://github.com/joshgoebel/wren-testie.git") | ||
] | ||
} | ||
} | ||
|
||
Package.new().default() |