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.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/custom-set/canonical-data.json +8 -1
  4. data/tracks/c/README.md +2 -44
  5. data/tracks/c/docs/CONTRIBUTING.md +93 -0
  6. data/tracks/c/docs/C_STYLE_GUIDE.md +1 -1
  7. data/tracks/clojure/config.json +27 -0
  8. data/tracks/clojure/exercises/accumulate/project.clj +1 -1
  9. data/tracks/clojure/exercises/acronym/project.clj +1 -1
  10. data/tracks/clojure/exercises/all-your-base/project.clj +1 -1
  11. data/tracks/clojure/exercises/allergies/project.clj +1 -1
  12. data/tracks/clojure/exercises/anagram/project.clj +1 -1
  13. data/tracks/clojure/exercises/atbash-cipher/project.clj +1 -1
  14. data/tracks/clojure/exercises/bank-account/project.clj +1 -1
  15. data/tracks/clojure/exercises/beer-song/project.clj +1 -1
  16. data/tracks/clojure/exercises/binary/project.clj +1 -1
  17. data/tracks/clojure/exercises/binary-search/project.clj +1 -1
  18. data/tracks/clojure/exercises/binary-search-tree/project.clj +1 -1
  19. data/tracks/clojure/exercises/bob/project.clj +1 -1
  20. data/tracks/clojure/exercises/bracket-push/project.clj +1 -1
  21. data/tracks/clojure/exercises/change/project.clj +1 -1
  22. data/tracks/clojure/exercises/clock/project.clj +1 -1
  23. data/tracks/clojure/exercises/collatz-conjecture/project.clj +1 -1
  24. data/tracks/clojure/exercises/complex-numbers/project.clj +1 -1
  25. data/tracks/clojure/exercises/crypto-square/project.clj +1 -1
  26. data/tracks/clojure/exercises/diamond/README.md +51 -0
  27. data/tracks/clojure/exercises/diamond/project.clj +4 -0
  28. data/tracks/clojure/exercises/diamond/src/example.clj +22 -0
  29. data/tracks/clojure/exercises/diamond/test/diamond_test.clj +79 -0
  30. data/tracks/clojure/exercises/difference-of-squares/project.clj +1 -1
  31. data/tracks/clojure/exercises/etl/project.clj +1 -1
  32. data/tracks/clojure/exercises/flatten-array/project.clj +1 -1
  33. data/tracks/clojure/exercises/gigasecond/project.clj +1 -1
  34. data/tracks/clojure/exercises/grade-school/project.clj +1 -1
  35. data/tracks/clojure/exercises/grains/project.clj +1 -1
  36. data/tracks/clojure/exercises/hamming/project.clj +1 -1
  37. data/tracks/clojure/exercises/hello-world/project.clj +1 -1
  38. data/tracks/clojure/exercises/hexadecimal/project.clj +1 -1
  39. data/tracks/clojure/exercises/isogram/project.clj +1 -1
  40. data/tracks/clojure/exercises/kindergarten-garden/project.clj +1 -1
  41. data/tracks/clojure/exercises/largest-series-product/project.clj +1 -1
  42. data/tracks/clojure/exercises/leap/project.clj +1 -1
  43. data/tracks/clojure/exercises/luhn/project.clj +1 -1
  44. data/tracks/clojure/exercises/meetup/project.clj +1 -1
  45. data/tracks/clojure/exercises/minesweeper/project.clj +1 -1
  46. data/tracks/clojure/exercises/nth-prime/project.clj +1 -1
  47. data/tracks/clojure/exercises/nucleotide-count/project.clj +1 -1
  48. data/tracks/clojure/exercises/octal/project.clj +1 -1
  49. data/tracks/clojure/exercises/pascals-triangle/project.clj +1 -1
  50. data/tracks/clojure/exercises/perfect-numbers/project.clj +1 -1
  51. data/tracks/clojure/exercises/phone-number/project.clj +1 -1
  52. data/tracks/clojure/exercises/pig-latin/project.clj +1 -1
  53. data/tracks/clojure/exercises/prime-factors/project.clj +1 -1
  54. data/tracks/clojure/exercises/protein-translation/README.md +40 -0
  55. data/tracks/clojure/exercises/protein-translation/project.clj +4 -0
  56. data/tracks/clojure/exercises/protein-translation/src/example.clj +19 -0
  57. data/tracks/clojure/exercises/protein-translation/test/protein_translation_test.clj +36 -0
  58. data/tracks/clojure/exercises/queen-attack/project.clj +1 -1
  59. data/tracks/clojure/exercises/raindrops/project.clj +1 -1
  60. data/tracks/clojure/exercises/rna-transcription/project.clj +1 -1
  61. data/tracks/clojure/exercises/robot-name/project.clj +1 -1
  62. data/tracks/clojure/exercises/robot-simulator/project.clj +1 -1
  63. data/tracks/clojure/exercises/roman-numerals/project.clj +1 -1
  64. data/tracks/clojure/exercises/rotational-cipher/project.clj +1 -1
  65. data/tracks/clojure/exercises/run-length-encoding/README.md +36 -0
  66. data/tracks/clojure/exercises/run-length-encoding/project.clj +4 -0
  67. data/tracks/clojure/exercises/run-length-encoding/src/example.clj +20 -0
  68. data/tracks/clojure/exercises/run-length-encoding/src/run_length_encoding.clj +11 -0
  69. data/tracks/clojure/exercises/run-length-encoding/test/run_length_encoding_test.clj +57 -0
  70. data/tracks/clojure/exercises/scrabble-score/project.clj +1 -1
  71. data/tracks/clojure/exercises/secret-handshake/project.clj +1 -1
  72. data/tracks/clojure/exercises/series/project.clj +1 -1
  73. data/tracks/clojure/exercises/sieve/project.clj +1 -1
  74. data/tracks/clojure/exercises/space-age/project.clj +1 -1
  75. data/tracks/clojure/exercises/spiral-matrix/project.clj +1 -1
  76. data/tracks/clojure/exercises/strain/project.clj +1 -1
  77. data/tracks/clojure/exercises/sublist/project.clj +1 -1
  78. data/tracks/clojure/exercises/sum-of-multiples/project.clj +1 -1
  79. data/tracks/clojure/exercises/triangle/project.clj +1 -1
  80. data/tracks/clojure/exercises/trinary/project.clj +1 -1
  81. data/tracks/clojure/exercises/word-count/project.clj +1 -1
  82. data/tracks/clojure/exercises/wordy/project.clj +1 -1
  83. data/tracks/clojure/project.clj +2 -2
  84. data/tracks/ecmascript/config.json +10 -15
  85. data/tracks/ecmascript/docs/TESTS.md +15 -0
  86. data/tracks/ecmascript/exercises/complex-numbers/README.md +68 -0
  87. data/tracks/ecmascript/exercises/complex-numbers/complex-numbers.spec.js +216 -0
  88. data/tracks/ecmascript/exercises/complex-numbers/example.js +43 -0
  89. data/tracks/ecmascript/exercises/{transpose → complex-numbers}/package.json +2 -2
  90. data/tracks/elixir/config.json +22 -1
  91. data/tracks/elixir/exercises/isbn-verifier/README.md +80 -0
  92. data/tracks/elixir/exercises/isbn-verifier/example.exs +36 -0
  93. data/tracks/elixir/exercises/isbn-verifier/isbn_verifier.exs +18 -0
  94. data/tracks/elixir/exercises/isbn-verifier/isbn_verifier_test.exs +75 -0
  95. data/tracks/elixir/exercises/spiral-matrix/README.md +65 -0
  96. data/tracks/elixir/exercises/spiral-matrix/example.exs +27 -0
  97. data/tracks/elixir/exercises/spiral-matrix/spiral.exs +9 -0
  98. data/tracks/elixir/exercises/spiral-matrix/spiral_test.exs +58 -0
  99. data/tracks/erlang/config.json +10 -0
  100. data/tracks/erlang/exercises/complex-numbers/HINTS.md +2 -0
  101. data/tracks/erlang/exercises/complex-numbers/README.md +85 -0
  102. data/tracks/erlang/exercises/complex-numbers/include/exercism.hrl +11 -0
  103. data/tracks/erlang/exercises/complex-numbers/rebar.config +30 -0
  104. data/tracks/erlang/exercises/complex-numbers/src/complex_numbers.app.src +9 -0
  105. data/tracks/erlang/exercises/complex-numbers/src/complex_numbers.erl +29 -0
  106. data/tracks/erlang/exercises/complex-numbers/src/example.erl +44 -0
  107. data/tracks/erlang/exercises/complex-numbers/test/complex_numbers_tests.erl +152 -0
  108. data/tracks/erlang/testgen/src/tgen.erl +1 -1
  109. data/tracks/erlang/testgen/src/tgen_complex-numbers.erl +75 -0
  110. data/tracks/java/config.json +10 -5
  111. data/tracks/javascript/config.json +13 -0
  112. data/tracks/javascript/exercises/isbn-verifier/README.md +66 -0
  113. data/tracks/javascript/exercises/isbn-verifier/example.js +24 -0
  114. data/tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js +68 -0
  115. data/tracks/perl6/config/maintainers.json +4 -4
  116. data/tracks/perl6/config.json +21 -21
  117. data/tracks/php/README.md +1 -0
  118. data/tracks/python/config/maintainers.json +3 -3
  119. data/tracks/python/exercises/alphametics/alphametics_test.py +6 -6
  120. data/tracks/python/exercises/queen-attack/queen_attack_test.py +60 -40
  121. data/tracks/sml/config.json +13 -2
  122. data/tracks/sml/exercises/flatten-array/{HINTS.md → .meta/hints.md} +0 -0
  123. data/tracks/sml/exercises/nth-prime/{HINTS.md → .meta/hints.md} +0 -0
  124. data/tracks/sml/exercises/pig-latin/README.md +54 -0
  125. data/tracks/sml/exercises/pig-latin/example.sml +23 -0
  126. data/tracks/sml/exercises/pig-latin/pig-latin.sml +2 -0
  127. data/tracks/sml/exercises/pig-latin/test.sml +90 -0
  128. data/tracks/sml/exercises/pig-latin/testlib.sml +159 -0
  129. data/tracks/typescript/config.json +16 -0
  130. data/tracks/typescript/exercises/ocr-numbers/README.md +110 -0
  131. data/tracks/typescript/exercises/ocr-numbers/ocr-numbers.example.ts +92 -0
  132. data/tracks/typescript/exercises/ocr-numbers/ocr-numbers.test.ts +155 -0
  133. data/tracks/typescript/exercises/ocr-numbers/ocr-numbers.ts +3 -0
  134. data/tracks/typescript/exercises/ocr-numbers/package.json +36 -0
  135. data/tracks/typescript/exercises/ocr-numbers/tsconfig.json +22 -0
  136. data/tracks/typescript/exercises/ocr-numbers/tslint.json +127 -0
  137. data/tracks/typescript/exercises/ocr-numbers/yarn.lock +2624 -0
  138. metadata +55 -8
  139. data/tracks/ecmascript/exercises/transpose/README.md +0 -94
  140. data/tracks/ecmascript/exercises/transpose/example.js +0 -12
  141. data/tracks/ecmascript/exercises/transpose/transpose.spec.js +0 -67
@@ -1,4 +1,4 @@
1
1
  (defproject leap "0.1.0-SNAPSHOT"
2
2
  :description "leap exercise."
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/leap"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/leap"
4
4
  :dependencies [[org.clojure/clojure "1.8.0"]])
@@ -1,4 +1,4 @@
1
1
  (defproject luhn "0.1.0-SNAPSHOT"
2
2
  :description "luhn exercise."
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/luhn"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/luhn"
4
4
  :dependencies [[org.clojure/clojure "1.8.0"]])
@@ -1,4 +1,4 @@
1
1
  (defproject meetup "0.1.0-SNAPSHOT"
2
2
  :description "meetup exercise."
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/meetup"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/meetup"
4
4
  :dependencies [[org.clojure/clojure "1.8.0"]])
@@ -1,4 +1,4 @@
1
1
  (defproject minesweeper "0.1.0-SNAPSHOT"
2
2
  :description "minesweeper exercise."
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/minesweeper"
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/xclojure/tree/master/exercises/nth-prime"
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/xclojure/tree/master/exercises/nucleotide-count"
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 octal "0.1.0-SNAPSHOT"
2
2
  :description "octal exercise."
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/octal"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/octal"
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/xclojure/tree/master/exercises/pascals-triangle"
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/xclojure/tree/master/exercises/perfect-numbers"
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/xclojure/tree/master/exercises/phone-number"
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/xclojure/tree/master/exercises/pig-latin"
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/xclojure/tree/master/exercises/prime-factors"
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,4 @@
1
+ (defproject protein-translation "0.1.0-SNAPSHOT"
2
+ :description "protein translation exercise."
3
+ :url "https://github.com/exercism/xclojure/tree/master/exercises/protein-translation"
4
+ :dependencies [[org.clojure/clojure "1.8.0"]])
@@ -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/xclojure/tree/master/exercises/queen-attack"
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/xclojure/tree/master/exercises/raindrops"
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/xclojure/tree/master/exercises/rna-transcription"
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/xclojure/tree/master/exercises/robot-name"
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/xclojure/tree/master/exercises/robot-simulator"
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/xclojure/tree/master/exercises/roman-numerals"
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/xclojure/tree/master/exercises/rotational-cipher"
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,4 @@
1
+ (defproject run-length-encoding "0.1.0-SNAPSHOT"
2
+ :description "run-length-encoding exercise."
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/run-length-encoding"
4
+ :dependencies [[org.clojure/clojure "1.8.0"]])
@@ -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,11 @@
1
+ (ns run-length-encoding)
2
+
3
+ (defn run-length-encode
4
+ "encodes a string with run-length-encoding"
5
+ [s]
6
+ )
7
+
8
+ (defn run-length-decode
9
+ "decodes a run-length-encoded string"
10
+ [s]
11
+ )
@@ -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/xclojure/tree/master/exercises/scrabble-score"
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/xclojure/tree/master/exercises/secret-handshake"
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 series "0.1.0-SNAPSHOT"
2
2
  :description "series exercise"
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/series"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/series"
4
4
  :dependencies [[org.clojure/clojure "1.8.0"]])
@@ -1,4 +1,4 @@
1
1
  (defproject sieve "0.1.0-SNAPSHOT"
2
2
  :description "sieve exercise."
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/sieve"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/sieve"
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/xclojure/tree/master/exercises/space-age"
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/xclojure/tree/master/exercises/spiral-matrix"
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 strain "0.1.0-SNAPSHOT"
2
2
  :description "strain exercise."
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/strain"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/strain"
4
4
  :dependencies [[org.clojure/clojure "1.8.0"]])
@@ -1,4 +1,4 @@
1
1
  (defproject sublist "0.1.0-SNAPSHOT"
2
2
  :description "sublist exercise."
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/sublist"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/sublist"
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/xclojure/tree/master/exercises/sum-of-multiples"
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/xclojure/tree/master/exercises/triangle"
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 trinary "0.1.0-SNAPSHOT"
2
2
  :description "trinary exercise."
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/trinary"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/trinary"
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/xclojure/tree/master/exercises/word-count"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/word-count"
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 "wordy exercise."
3
- :url "https://github.com/exercism/xclojure/tree/master/exercises/wordy"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/wordy"
4
4
  :dependencies [[org.clojure/clojure "1.8.0"]])
@@ -1,6 +1,6 @@
1
- (defproject xclojure "0.1.0"
1
+ (defproject clojure "0.1.0"
2
2
  :description "Exercism Exercises in Clojure"
3
- :url "https://github.com/exercism/xclojure"
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.