This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
-
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
1 parent
aed9b4c
commit 10787e4
Showing
9 changed files
with
142 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": [ | ||
"ErikSchierboom" | ||
], | ||
"files": { | ||
"solution": [ | ||
"src/etl.cljs" | ||
], | ||
"test": [ | ||
"test/etl_test.cljs" | ||
], | ||
"example": [ | ||
".meta/src/example.cljs" | ||
] | ||
}, | ||
"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,8 @@ | ||
(ns etl | ||
(:require [clojure.string :refer [lower-case]])) | ||
|
||
(defn transform [extract] | ||
(into {} | ||
(for [[score letters] extract | ||
letter letters] | ||
[(lower-case letter) score]))) |
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,15 @@ | ||
# This is an auto-generated file. Regular comments will be removed when this | ||
# file is regenerated. Regenerating will not touch any manually added keys, | ||
# so comments can be added in 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,10 @@ | ||
{:deps | ||
{org.clojure/clojure {:mvn/version "1.10.1"} | ||
org.clojure/clojurescript {:mvn/version "1.10.773"}} | ||
|
||
:aliases | ||
{:test | ||
{:extra-paths ["test"] | ||
:extra-deps | ||
{olical/cljs-test-runner {:mvn/version "3.8.0"}} | ||
:main-opts ["-m" "cljs-test-runner.main"]}}} |
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,5 @@ | ||
(ns etl) | ||
|
||
(defn transform [source] ;; <- arglist goes here | ||
;; your code goes here | ||
) |
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,30 @@ | ||
(ns etl-test | ||
(:require [clojure.test :refer [deftest is]] | ||
etl)) | ||
|
||
(deftest transform-one-value | ||
(is (= {"world" 1} | ||
(etl/transform {1 ["WORLD"]})))) | ||
|
||
(deftest transform-more-values | ||
(is (= {"world" 1 "gschoolers" 1} | ||
(etl/transform {1 ["WORLD" "GSCHOOLERS"]})))) | ||
|
||
(deftest more-keys | ||
(is (= {"apple" 1 "artichoke" 1 "boat" 2 "ballerina" 2} | ||
(etl/transform {1 ["APPLE" "ARTICHOKE"], 2 ["BOAT" "BALLERINA"]})))) | ||
|
||
(deftest full-dataset | ||
(is (= {"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} | ||
(etl/transform {1 (re-seq #"\w" "AEIOULNRST") | ||
2 (re-seq #"\w" "DG") | ||
3 (re-seq #"\w" "BCMP") | ||
4 (re-seq #"\w" "FHVWY") | ||
5 (re-seq #"\w" "K") | ||
8 (re-seq #"\w" "JX") | ||
10 (re-seq #"\w" "QZ")})))) |