trackler 2.2.1.57 → 2.2.1.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/custom-set/canonical-data.json +8 -1
- data/tracks/c/README.md +2 -44
- data/tracks/c/docs/CONTRIBUTING.md +93 -0
- data/tracks/c/docs/C_STYLE_GUIDE.md +1 -1
- data/tracks/clojure/config.json +27 -0
- data/tracks/clojure/exercises/accumulate/project.clj +1 -1
- data/tracks/clojure/exercises/acronym/project.clj +1 -1
- data/tracks/clojure/exercises/all-your-base/project.clj +1 -1
- data/tracks/clojure/exercises/allergies/project.clj +1 -1
- data/tracks/clojure/exercises/anagram/project.clj +1 -1
- data/tracks/clojure/exercises/atbash-cipher/project.clj +1 -1
- data/tracks/clojure/exercises/bank-account/project.clj +1 -1
- data/tracks/clojure/exercises/beer-song/project.clj +1 -1
- data/tracks/clojure/exercises/binary/project.clj +1 -1
- data/tracks/clojure/exercises/binary-search/project.clj +1 -1
- data/tracks/clojure/exercises/binary-search-tree/project.clj +1 -1
- data/tracks/clojure/exercises/bob/project.clj +1 -1
- data/tracks/clojure/exercises/bracket-push/project.clj +1 -1
- data/tracks/clojure/exercises/change/project.clj +1 -1
- data/tracks/clojure/exercises/clock/project.clj +1 -1
- data/tracks/clojure/exercises/collatz-conjecture/project.clj +1 -1
- data/tracks/clojure/exercises/complex-numbers/project.clj +1 -1
- data/tracks/clojure/exercises/crypto-square/project.clj +1 -1
- data/tracks/clojure/exercises/diamond/README.md +51 -0
- data/tracks/clojure/exercises/diamond/project.clj +4 -0
- data/tracks/clojure/exercises/diamond/src/example.clj +22 -0
- data/tracks/clojure/exercises/diamond/test/diamond_test.clj +79 -0
- data/tracks/clojure/exercises/difference-of-squares/project.clj +1 -1
- data/tracks/clojure/exercises/etl/project.clj +1 -1
- data/tracks/clojure/exercises/flatten-array/project.clj +1 -1
- data/tracks/clojure/exercises/gigasecond/project.clj +1 -1
- data/tracks/clojure/exercises/grade-school/project.clj +1 -1
- data/tracks/clojure/exercises/grains/project.clj +1 -1
- data/tracks/clojure/exercises/hamming/project.clj +1 -1
- data/tracks/clojure/exercises/hello-world/project.clj +1 -1
- data/tracks/clojure/exercises/hexadecimal/project.clj +1 -1
- data/tracks/clojure/exercises/isogram/project.clj +1 -1
- data/tracks/clojure/exercises/kindergarten-garden/project.clj +1 -1
- data/tracks/clojure/exercises/largest-series-product/project.clj +1 -1
- data/tracks/clojure/exercises/leap/project.clj +1 -1
- data/tracks/clojure/exercises/luhn/project.clj +1 -1
- data/tracks/clojure/exercises/meetup/project.clj +1 -1
- data/tracks/clojure/exercises/minesweeper/project.clj +1 -1
- data/tracks/clojure/exercises/nth-prime/project.clj +1 -1
- data/tracks/clojure/exercises/nucleotide-count/project.clj +1 -1
- data/tracks/clojure/exercises/octal/project.clj +1 -1
- data/tracks/clojure/exercises/pascals-triangle/project.clj +1 -1
- data/tracks/clojure/exercises/perfect-numbers/project.clj +1 -1
- data/tracks/clojure/exercises/phone-number/project.clj +1 -1
- data/tracks/clojure/exercises/pig-latin/project.clj +1 -1
- data/tracks/clojure/exercises/prime-factors/project.clj +1 -1
- data/tracks/clojure/exercises/protein-translation/README.md +40 -0
- data/tracks/clojure/exercises/protein-translation/project.clj +4 -0
- data/tracks/clojure/exercises/protein-translation/src/example.clj +19 -0
- data/tracks/clojure/exercises/protein-translation/test/protein_translation_test.clj +36 -0
- data/tracks/clojure/exercises/queen-attack/project.clj +1 -1
- data/tracks/clojure/exercises/raindrops/project.clj +1 -1
- data/tracks/clojure/exercises/rna-transcription/project.clj +1 -1
- data/tracks/clojure/exercises/robot-name/project.clj +1 -1
- data/tracks/clojure/exercises/robot-simulator/project.clj +1 -1
- data/tracks/clojure/exercises/roman-numerals/project.clj +1 -1
- data/tracks/clojure/exercises/rotational-cipher/project.clj +1 -1
- data/tracks/clojure/exercises/run-length-encoding/README.md +36 -0
- data/tracks/clojure/exercises/run-length-encoding/project.clj +4 -0
- data/tracks/clojure/exercises/run-length-encoding/src/example.clj +20 -0
- data/tracks/clojure/exercises/run-length-encoding/src/run_length_encoding.clj +11 -0
- data/tracks/clojure/exercises/run-length-encoding/test/run_length_encoding_test.clj +57 -0
- data/tracks/clojure/exercises/scrabble-score/project.clj +1 -1
- data/tracks/clojure/exercises/secret-handshake/project.clj +1 -1
- data/tracks/clojure/exercises/series/project.clj +1 -1
- data/tracks/clojure/exercises/sieve/project.clj +1 -1
- data/tracks/clojure/exercises/space-age/project.clj +1 -1
- data/tracks/clojure/exercises/spiral-matrix/project.clj +1 -1
- data/tracks/clojure/exercises/strain/project.clj +1 -1
- data/tracks/clojure/exercises/sublist/project.clj +1 -1
- data/tracks/clojure/exercises/sum-of-multiples/project.clj +1 -1
- data/tracks/clojure/exercises/triangle/project.clj +1 -1
- data/tracks/clojure/exercises/trinary/project.clj +1 -1
- data/tracks/clojure/exercises/word-count/project.clj +1 -1
- data/tracks/clojure/exercises/wordy/project.clj +1 -1
- data/tracks/clojure/project.clj +2 -2
- data/tracks/ecmascript/config.json +10 -15
- data/tracks/ecmascript/docs/TESTS.md +15 -0
- data/tracks/ecmascript/exercises/complex-numbers/README.md +68 -0
- data/tracks/ecmascript/exercises/complex-numbers/complex-numbers.spec.js +216 -0
- data/tracks/ecmascript/exercises/complex-numbers/example.js +43 -0
- data/tracks/ecmascript/exercises/{transpose → complex-numbers}/package.json +2 -2
- data/tracks/elixir/config.json +22 -1
- data/tracks/elixir/exercises/isbn-verifier/README.md +80 -0
- data/tracks/elixir/exercises/isbn-verifier/example.exs +36 -0
- data/tracks/elixir/exercises/isbn-verifier/isbn_verifier.exs +18 -0
- data/tracks/elixir/exercises/isbn-verifier/isbn_verifier_test.exs +75 -0
- data/tracks/elixir/exercises/spiral-matrix/README.md +65 -0
- data/tracks/elixir/exercises/spiral-matrix/example.exs +27 -0
- data/tracks/elixir/exercises/spiral-matrix/spiral.exs +9 -0
- data/tracks/elixir/exercises/spiral-matrix/spiral_test.exs +58 -0
- data/tracks/erlang/config.json +10 -0
- data/tracks/erlang/exercises/complex-numbers/HINTS.md +2 -0
- data/tracks/erlang/exercises/complex-numbers/README.md +85 -0
- data/tracks/erlang/exercises/complex-numbers/include/exercism.hrl +11 -0
- data/tracks/erlang/exercises/complex-numbers/rebar.config +30 -0
- data/tracks/erlang/exercises/complex-numbers/src/complex_numbers.app.src +9 -0
- data/tracks/erlang/exercises/complex-numbers/src/complex_numbers.erl +29 -0
- data/tracks/erlang/exercises/complex-numbers/src/example.erl +44 -0
- data/tracks/erlang/exercises/complex-numbers/test/complex_numbers_tests.erl +152 -0
- data/tracks/erlang/testgen/src/tgen.erl +1 -1
- data/tracks/erlang/testgen/src/tgen_complex-numbers.erl +75 -0
- data/tracks/java/config.json +10 -5
- data/tracks/javascript/config.json +13 -0
- data/tracks/javascript/exercises/isbn-verifier/README.md +66 -0
- data/tracks/javascript/exercises/isbn-verifier/example.js +24 -0
- data/tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js +68 -0
- data/tracks/perl6/config/maintainers.json +4 -4
- data/tracks/perl6/config.json +21 -21
- data/tracks/php/README.md +1 -0
- data/tracks/python/config/maintainers.json +3 -3
- data/tracks/python/exercises/alphametics/alphametics_test.py +6 -6
- data/tracks/python/exercises/queen-attack/queen_attack_test.py +60 -40
- data/tracks/sml/config.json +13 -2
- data/tracks/sml/exercises/flatten-array/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/sml/exercises/nth-prime/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/sml/exercises/pig-latin/README.md +54 -0
- data/tracks/sml/exercises/pig-latin/example.sml +23 -0
- data/tracks/sml/exercises/pig-latin/pig-latin.sml +2 -0
- data/tracks/sml/exercises/pig-latin/test.sml +90 -0
- data/tracks/sml/exercises/pig-latin/testlib.sml +159 -0
- data/tracks/typescript/config.json +16 -0
- data/tracks/typescript/exercises/ocr-numbers/README.md +110 -0
- data/tracks/typescript/exercises/ocr-numbers/ocr-numbers.example.ts +92 -0
- data/tracks/typescript/exercises/ocr-numbers/ocr-numbers.test.ts +155 -0
- data/tracks/typescript/exercises/ocr-numbers/ocr-numbers.ts +3 -0
- data/tracks/typescript/exercises/ocr-numbers/package.json +36 -0
- data/tracks/typescript/exercises/ocr-numbers/tsconfig.json +22 -0
- data/tracks/typescript/exercises/ocr-numbers/tslint.json +127 -0
- data/tracks/typescript/exercises/ocr-numbers/yarn.lock +2624 -0
- metadata +55 -8
- data/tracks/ecmascript/exercises/transpose/README.md +0 -94
- data/tracks/ecmascript/exercises/transpose/example.js +0 -12
- data/tracks/ecmascript/exercises/transpose/transpose.spec.js +0 -67
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject minesweeper "0.1.0-SNAPSHOT"
|
2
2
|
:description "minesweeper exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/minesweeper"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject nth-prime "0.1.0-SNAPSHOT"
|
2
2
|
:description "nth-prime exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/nth-prime"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject nucleotide-count "0.1.0-SNAPSHOT"
|
2
2
|
:description "nucleotide-count exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/nucleotide-count"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject pascals-triangle "0.1.0-SNAPSHOT"
|
2
2
|
:description "pascal's triangle exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/pascals-triangle"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject perfect-numbers "0.1.0-SNAPSHOT"
|
2
2
|
:description "perfect-numbers exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/perfect-numbers"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject phone-number "0.1.0-SNAPSHOT"
|
2
2
|
:description "phone-number exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/phone-number"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject pig-latin "0.1.0-SNAPSHOT"
|
2
2
|
:description "pig latin exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/pig-latin"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject prime-factors "0.1.0-SNAPSHOT"
|
2
2
|
:description "prime-factors exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/prime-factors"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Translate RNA sequences into proteins.
|
2
|
+
|
3
|
+
RNA can be broken into three nucleotide sequences called codons, and then translated to a polypeptide like so:
|
4
|
+
|
5
|
+
RNA: `"AUGUUUUCU"` => translates to
|
6
|
+
|
7
|
+
Codons: `"AUG", "UUU", "UCU"`
|
8
|
+
=> which become a polypeptide with the following sequence =>
|
9
|
+
|
10
|
+
Protein: `"Methionine", "Phenylalanine", "Serine"`
|
11
|
+
|
12
|
+
There are 64 codons which in turn correspond to 20 amino acids; however, all of the codon sequences and resulting amino acids are not important in this exercise. If it works for one codon, the program should work for all of them.
|
13
|
+
However, feel free to expand the list in the test suite to include them all.
|
14
|
+
|
15
|
+
There are also three terminating codons (also known as 'STOP' codons); if any of these codons are encountered (by the ribosome), all translation ends and the protein is terminated.
|
16
|
+
|
17
|
+
All subsequent codons after are ignored, like this:
|
18
|
+
|
19
|
+
RNA: `"AUGUUUUCUUAAAUG"` =>
|
20
|
+
|
21
|
+
Codons: `"AUG", "UUU", "UCU", "UAG", "AUG"` =>
|
22
|
+
|
23
|
+
Protein: `"Methionine", "Phenylalanine", "Serine"`
|
24
|
+
|
25
|
+
Note the stop codon terminates the translation and the final methionine is not translated into the protein sequence.
|
26
|
+
|
27
|
+
Below are the codons and resulting Amino Acids needed for the exercise.
|
28
|
+
|
29
|
+
Codon | Protein
|
30
|
+
:--- | :---
|
31
|
+
AUG | Methionine
|
32
|
+
UUU, UUC | Phenylalanine
|
33
|
+
UUA, UUG | Leucine
|
34
|
+
UCU, UCC, UCA, UCG | Serine
|
35
|
+
UAU, UAC | Tyrosine
|
36
|
+
UGU, UGC | Cysteine
|
37
|
+
UGG | Tryptophan
|
38
|
+
UAA, UAG, UGA | STOP
|
39
|
+
|
40
|
+
Learn more about [protein translation on Wikipedia](http://en.wikipedia.org/wiki/Translation_(biology))
|
@@ -0,0 +1,19 @@
|
|
1
|
+
(ns protein-translation)
|
2
|
+
|
3
|
+
(defn translate-codon [codon]
|
4
|
+
(case codon
|
5
|
+
"AUG" "Methionine"
|
6
|
+
("UUU" "UUC") "Phenylalanine"
|
7
|
+
("UUA" "UUG") "Leucine"
|
8
|
+
("UCU" "UCC" "UCA" "UCG") "Serine"
|
9
|
+
("UAU" "UAC") "Tyrosine"
|
10
|
+
("UGU" "UGC") "Cysteine"
|
11
|
+
"UGG" "Tryptophan"
|
12
|
+
("UAA" "UAG" "UGA") "STOP"))
|
13
|
+
|
14
|
+
(defn translate-rna [rna]
|
15
|
+
(->> rna
|
16
|
+
(partition 3)
|
17
|
+
(map (partial apply str))
|
18
|
+
(map translate-codon)
|
19
|
+
(take-while #(not= "STOP" %))))
|
@@ -0,0 +1,36 @@
|
|
1
|
+
(ns protein-translation-test
|
2
|
+
(:require [clojure.test :refer [deftest is are]]
|
3
|
+
protein-translation))
|
4
|
+
|
5
|
+
(deftest AUG-translates-to-Methionine
|
6
|
+
(is (= "Methionine" (protein-translation/translate-codon "AUG"))))
|
7
|
+
|
8
|
+
(deftest UGG-translates-to-Tryptophan
|
9
|
+
(is (= "Tryptophan" (protein-translation/translate-codon "UGG"))))
|
10
|
+
|
11
|
+
(deftest identifies-Phenylalanine-codons
|
12
|
+
(are [codon] (= "Phenylalanine" (protein-translation/translate-codon codon)) "UUU" "UUC"))
|
13
|
+
|
14
|
+
(deftest identifies-Leucine-codons
|
15
|
+
(are [codon] (= "Leucine" (protein-translation/translate-codon codon)) "UUA" "UUG"))
|
16
|
+
|
17
|
+
(deftest identiefies-Serine-codons
|
18
|
+
(are [codon] (= "Serine" (protein-translation/translate-codon codon)) "UCU" "UCC" "UCA" "UCG"))
|
19
|
+
|
20
|
+
(deftest identiefies-Tyrosine-codons
|
21
|
+
(are [codon] (= "Tyrosine" (protein-translation/translate-codon codon)) "UAU" "UAC"))
|
22
|
+
|
23
|
+
(deftest identifies-Cysteine-codons
|
24
|
+
(are [codon] (= "Cysteine" (protein-translation/translate-codon codon)) "UGU" "UGC"))
|
25
|
+
|
26
|
+
(deftest identifies-stop-codons
|
27
|
+
(are [codon] (= "STOP" (protein-translation/translate-codon codon)) "UAA" "UAG" "UGA"))
|
28
|
+
|
29
|
+
(deftest translates-rna-strand-into-correct-protein
|
30
|
+
(is (= ["Methionine" "Phenylalanine" "Tryptophan"] (protein-translation/translate-rna "AUGUUUUGG"))))
|
31
|
+
|
32
|
+
(deftest stops-translation-if-stop-codon-present
|
33
|
+
(is (= ["Methionine" "Phenylalanine"] (protein-translation/translate-rna "AUGUUUUAA"))))
|
34
|
+
|
35
|
+
(deftest stops-translation-of-longer-strand
|
36
|
+
(is (= ["Tryptophan" "Cysteine" "Tyrosine"] (protein-translation/translate-rna "UGGUGUUAUUAAUGGUUU"))))
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject queen-attack "0.1.0-SNAPSHOT"
|
2
2
|
:description "queen-attack exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/queen-attack"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject raindrops "0.1.0-SNAPSHOT"
|
2
2
|
:description "raindrops exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/raindrops"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject rna-transcription "0.1.0-SNAPSHOT"
|
2
2
|
:description "rna-transcription exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/rna-transcription"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject robot-name "0.1.0-SNAPSHOT"
|
2
2
|
:description "robot-name exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/robot-name"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject robot-simulator "0.1.0-SNAPSHOT"
|
2
2
|
:description "robot-simulator exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/robot-simulator"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject roman-numerals "0.1.0-SNAPSHOT"
|
2
2
|
:description "roman-numerals exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/roman-numerals"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject rotational-cipher "0.1.0-SNAPSHOT"
|
2
2
|
:description "rotational cipher exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/rotational-cipher"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Run Length Encoding
|
2
|
+
|
3
|
+
Implement run-length encoding and decoding.
|
4
|
+
|
5
|
+
Run-length encoding (RLE) is a simple form of data compression, where runs
|
6
|
+
(consecutive data elements) are replaced by just one data value and count.
|
7
|
+
|
8
|
+
For example we can represent the original 53 characters with only 13.
|
9
|
+
|
10
|
+
```text
|
11
|
+
"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" -> "12WB12W3B24WB"
|
12
|
+
```
|
13
|
+
|
14
|
+
RLE allows the original data to be perfectly reconstructed from
|
15
|
+
the compressed data, which makes it a lossless data compression.
|
16
|
+
|
17
|
+
```text
|
18
|
+
"AABCCCDEEEE" -> "2AB3CD4E" -> "AABCCCDEEEE"
|
19
|
+
```
|
20
|
+
|
21
|
+
For simplicity, you can assume that the unencoded string will only contain
|
22
|
+
the letters A through Z (either lower or upper case) and whitespace. This way
|
23
|
+
data to be encoded will never contain any numbers and numbers inside data to
|
24
|
+
be decoded always represent the count for the following character.
|
25
|
+
|
26
|
+
## General help
|
27
|
+
|
28
|
+
For more detailed information about running tests, code style and linting,
|
29
|
+
please see the [help page](http://exercism.io/languages/clojure).
|
30
|
+
|
31
|
+
## Source
|
32
|
+
|
33
|
+
Wikipedia [https://en.wikipedia.org/wiki/Run-length_encoding](https://en.wikipedia.org/wiki/Run-length_encoding)
|
34
|
+
|
35
|
+
## Submitting Incomplete Solutions
|
36
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
(ns run-length-encoding)
|
2
|
+
|
3
|
+
(defn run-length-encode
|
4
|
+
"encodes a string with run-length-encoding"
|
5
|
+
[s]
|
6
|
+
(apply str
|
7
|
+
(for
|
8
|
+
[ x (partition-by identity s)]
|
9
|
+
(str
|
10
|
+
(when-not (= 1 (count x)) (count x)) (first x)))))
|
11
|
+
|
12
|
+
(defn run-length-decode
|
13
|
+
"decodes a run-length-encoded string"
|
14
|
+
[s]
|
15
|
+
(->> s
|
16
|
+
(re-seq #"[0-9]+.|[a-zA-Z\s]")
|
17
|
+
(map #(if (= (count %) 1) (str "1" %) %))
|
18
|
+
(map #(list (Integer. (reduce str "" (butlast %))) (str (last %))))
|
19
|
+
(map #(apply str (repeat (first %) (second %))))
|
20
|
+
(reduce str)))
|
@@ -0,0 +1,57 @@
|
|
1
|
+
(ns run-length-encoding-test
|
2
|
+
(:require [clojure.test :refer :all]
|
3
|
+
[run-length-encoding :as rle]))
|
4
|
+
|
5
|
+
;;Tests for run-length-encoding exercise
|
6
|
+
|
7
|
+
(deftest encode-empty-string
|
8
|
+
(testing "encode an empty string"
|
9
|
+
(is (= (rle/run-length-encode "") ""))))
|
10
|
+
|
11
|
+
(deftest encode-single-characters-without-count
|
12
|
+
(testing "encode single characters without count"
|
13
|
+
(is (= (rle/run-length-encode "XYZ") "XYZ"))))
|
14
|
+
|
15
|
+
(deftest encode-string-with-no-single-characters
|
16
|
+
(testing "encode string with no single characters"
|
17
|
+
(is (= (rle/run-length-encode "AABBBCCCC") "2A3B4C"))))
|
18
|
+
|
19
|
+
(deftest encode-string-with-single-and-mixed-characters
|
20
|
+
(testing "encode string with single and mixed characters"
|
21
|
+
(is (= (rle/run-length-encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB") "12WB12W3B24WB"))))
|
22
|
+
|
23
|
+
(deftest encode-multiple-whitespace
|
24
|
+
(testing "encode string with whitespace characters mixed in it"
|
25
|
+
(is (= (rle/run-length-encode " hsqq qww ") "2 hs2q q2w2 "))))
|
26
|
+
|
27
|
+
(deftest encode-lowercase
|
28
|
+
(testing "encode string with lowercase characters"
|
29
|
+
(is (= (rle/run-length-encode "aabbbcccc") "2a3b4c"))))
|
30
|
+
|
31
|
+
(deftest decode-empty-string
|
32
|
+
(testing "decode empty string"
|
33
|
+
(is (= (rle/run-length-decode "") ""))))
|
34
|
+
|
35
|
+
(deftest decode-single-characters
|
36
|
+
(testing "decode string with single characters only"
|
37
|
+
(is (= (rle/run-length-decode "XYZ") "XYZ"))))
|
38
|
+
|
39
|
+
(deftest decode-no-single-characters
|
40
|
+
(testing "decode string with no single characters"
|
41
|
+
(is (= (rle/run-length-decode "2A3B4C") "AABBBCCCC"))))
|
42
|
+
|
43
|
+
(deftest decode-single-and-repeated-characters
|
44
|
+
(testing "decode string with single and repeated characters"
|
45
|
+
(is (= (rle/run-length-decode "12WB12W3B24WB") "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"))))
|
46
|
+
|
47
|
+
(deftest decode-lowercase
|
48
|
+
(testing "decode string with lowercase characters"
|
49
|
+
(is (= (rle/run-length-decode "2a3b4c") "aabbbcccc"))))
|
50
|
+
|
51
|
+
(deftest decode-mixed-whitespace
|
52
|
+
(testing "decode string with mixed whitespace characters in it"
|
53
|
+
(is (= (rle/run-length-decode "2 hs2q q2w2 ") " hsqq qww "))))
|
54
|
+
|
55
|
+
(deftest consistency
|
56
|
+
(testing "Encode a string and then decode it. Should return the same one."
|
57
|
+
(is (= (rle/run-length-decode (rle/run-length-encode "zzz ZZ zZ")) "zzz ZZ zZ"))))
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject scrabble-score "0.1.0-SNAPSHOT"
|
2
2
|
:description "scrabble-score exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/scrabble-score"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject secret-handshake "0.1.0-SNAPSHOT"
|
2
2
|
:description "secret-handshake exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/secret-handshake"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject space-age "0.1.0-SNAPSHOT"
|
2
2
|
:description "space-age exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/space-age"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject spiral-matrix "0.1.0-SNAPSHOT"
|
2
2
|
:description "spiral-matrix exercise"
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/spiral-matrix"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject sum-of-multiples "0.1.0-SNAPSHOT"
|
2
2
|
:description "sum-of-multiples exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/sum-of-multiples"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject triangle "0.1.0-SNAPSHOT"
|
2
2
|
:description "triangle exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/triangle"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
@@ -1,4 +1,4 @@
|
|
1
1
|
(defproject word-count "0.1.0-SNAPSHOT"
|
2
2
|
:description "word-count exercise."
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure/tree/master/exercises/word-count"
|
4
4
|
:dependencies [[org.clojure/clojure "1.8.0"]])
|
data/tracks/clojure/project.clj
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
(defproject
|
1
|
+
(defproject clojure "0.1.0"
|
2
2
|
:description "Exercism Exercises in Clojure"
|
3
|
-
:url "https://github.com/exercism/
|
3
|
+
:url "https://github.com/exercism/clojure"
|
4
4
|
:test-paths ["_test"]
|
5
5
|
:source-paths ["_src"]
|
6
6
|
:aliases {"generate" ["run" "-m" "generator"]}
|
@@ -1133,6 +1133,16 @@
|
|
1133
1133
|
"Regular expressions"
|
1134
1134
|
]
|
1135
1135
|
},
|
1136
|
+
{
|
1137
|
+
"uuid": "a0eecb1c-0dd1-4180-1d19-c6ab92bc23ca163ee56",
|
1138
|
+
"slug": "complex-numbers",
|
1139
|
+
"core": false,
|
1140
|
+
"unlocked_by": "space-age",
|
1141
|
+
"difficulty": 4,
|
1142
|
+
"topics": [
|
1143
|
+
"Mathematics"
|
1144
|
+
]
|
1145
|
+
},
|
1136
1146
|
{
|
1137
1147
|
"uuid": "213ea396-0c25-e480-4e76-5876975bdd54ac4890c",
|
1138
1148
|
"slug": "isbn-verifier",
|
@@ -1146,21 +1156,6 @@
|
|
1146
1156
|
"regular_expressions"
|
1147
1157
|
]
|
1148
1158
|
},
|
1149
|
-
{
|
1150
|
-
"uuid": "9c140fb7-cc8b-411b-b613-a0e0081a9c3f",
|
1151
|
-
"slug": "transpose",
|
1152
|
-
"core": false,
|
1153
|
-
"unlocked_by": "matrix",
|
1154
|
-
"difficulty": 1,
|
1155
|
-
"topics": [
|
1156
|
-
"loops",
|
1157
|
-
"arrays",
|
1158
|
-
"lists",
|
1159
|
-
"matrices",
|
1160
|
-
"strings",
|
1161
|
-
"text_formatting"
|
1162
|
-
]
|
1163
|
-
},
|
1164
1159
|
{
|
1165
1160
|
"uuid": "775ae0ec-8db7-4568-a188-963931cf5ee1",
|
1166
1161
|
"slug": "protein-translation",
|
@@ -24,6 +24,21 @@ You can also run Jest in "watch" mode, which will re-run your tests automaticall
|
|
24
24
|
$ npm run watch
|
25
25
|
```
|
26
26
|
|
27
|
+
## Understanding Skip Tests
|
28
|
+
|
29
|
+
The skip method instructs the test suite to not run a test, this function could be used also under the aliases: `it.skip(name, fn) or xit(name, fn) or xtest(name, fn)`
|
30
|
+
|
31
|
+
- Why they are skipped ?
|
32
|
+
So as to enable users to concentrate on one test at a time and enable one by one as they evolve the solution.
|
33
|
+
|
34
|
+
- How to enable them ?
|
35
|
+
Change xtest to test.
|
36
|
+
|
37
|
+
```javascript
|
38
|
+
test('title cased phrases', () => {
|
39
|
+
expect(Acronyms.parse('Portable Network Graphics')).toEqual('PNG');
|
40
|
+
});
|
41
|
+
```
|
27
42
|
|
28
43
|
## Making Your First ECMAScript 2015 Module
|
29
44
|
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Complex numbers
|
2
|
+
|
3
|
+
A complex number is a number in the form `a + b * i` where `a` and `b` are real and `i` satisfies `i^2 = -1`.
|
4
|
+
|
5
|
+
`a` is called the real part and `b` is called the imaginary part of `z`.
|
6
|
+
The conjugate of the number `a + b * i` is the number `a - b * i`.
|
7
|
+
The absolute value of a complex number `z = a + b * i` is a real number `|z| = sqrt(a^2 + b^2)`. The square of the absolute value `|z|^2` is the result of multiplication of `z` by its complex conjugate.
|
8
|
+
|
9
|
+
The sum/difference of two complex numbers involves adding/subtracting their real and imaginary parts separately:
|
10
|
+
`(a + i * b) + (c + i * d) = (a + c) + (b + d) * i`,
|
11
|
+
`(a + i * b) - (c + i * d) = (a - c) + (b - d) * i`.
|
12
|
+
|
13
|
+
Multiplication result is by definition
|
14
|
+
`(a + i * b) * (c + i * d) = (a * c - b * d) + (b * c + a * d) * i`.
|
15
|
+
|
16
|
+
The reciprocal of a non-zero complex number is
|
17
|
+
`1 / (a + i * b) = a/(a^2 + b^2) - b/(a^2 + b^2) * i`.
|
18
|
+
|
19
|
+
Dividing a complex number `a + i * b` by another `c + i * d` gives:
|
20
|
+
`(a + i * b) / (c + i * d) = (a * c + b * d)/(c^2 + d^2) + (b * c - a * d)/(c^2 + d^2) * i`.
|
21
|
+
|
22
|
+
Exponent of a complex number can be expressed as
|
23
|
+
`exp(a + i * b) = exp(a) * exp(i * b)`,
|
24
|
+
and the last term is given by Euler's formula `exp(i * b) = cos(b) + i * sin(b)`.
|
25
|
+
|
26
|
+
|
27
|
+
Implement the following operations:
|
28
|
+
- addition, subtraction, multiplication and division of two complex numbers,
|
29
|
+
- conjugate, absolute value, exponent of a given complex number.
|
30
|
+
|
31
|
+
|
32
|
+
Assume the programming language you are using does not have an implementation of complex numbers.
|
33
|
+
|
34
|
+
## Setup
|
35
|
+
|
36
|
+
Go through the setup instructions for ECMAScript to
|
37
|
+
install the necessary dependencies:
|
38
|
+
|
39
|
+
http://exercism.io/languages/ecmascript/installation
|
40
|
+
|
41
|
+
## Requirements
|
42
|
+
|
43
|
+
Install assignment dependencies:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
$ npm install
|
47
|
+
```
|
48
|
+
|
49
|
+
## Making the test suite pass
|
50
|
+
|
51
|
+
Execute the tests with:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
$ npm test
|
55
|
+
```
|
56
|
+
|
57
|
+
In the test suites all tests but the first have been skipped.
|
58
|
+
|
59
|
+
Once you get a test passing, you can enable the next one by
|
60
|
+
changing `xtest` to `test`.
|
61
|
+
|
62
|
+
|
63
|
+
## Source
|
64
|
+
|
65
|
+
Wikipedia [https://en.wikipedia.org/wiki/Complex_number](https://en.wikipedia.org/wiki/Complex_number)
|
66
|
+
|
67
|
+
## Submitting Incomplete Solutions
|
68
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|