trackler 2.2.1.46 → 2.2.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/nucleotide-count/canonical-data.json +7 -7
  4. data/tracks/c/README.md +1 -1
  5. data/tracks/c/docs/SNIPPET.txt +2 -3
  6. data/tracks/c/exercises/acronym/test/test_acronym.c +8 -0
  7. data/tracks/c/exercises/all-your-base/test/test_all_your_base.c +8 -0
  8. data/tracks/c/exercises/allergies/test/test_allergies.c +8 -0
  9. data/tracks/c/exercises/anagram/test/test_anagram.c +8 -0
  10. data/tracks/c/exercises/atbash-cipher/test/test_atbash_cipher.c +8 -0
  11. data/tracks/c/exercises/beer-song/src/example.c +23 -22
  12. data/tracks/c/exercises/beer-song/src/example.h +3 -3
  13. data/tracks/c/exercises/beer-song/test/test_beer_song.c +8 -0
  14. data/tracks/c/exercises/binary-search/test/test_binary_search.c +8 -0
  15. data/tracks/c/exercises/binary/test/test_binary.c +8 -0
  16. data/tracks/c/exercises/bob/test/test_bob.c +8 -0
  17. data/tracks/c/exercises/clock/test/test_clock.c +8 -0
  18. data/tracks/c/exercises/difference-of-squares/test/test_difference_of_squares.c +8 -0
  19. data/tracks/c/exercises/gigasecond/test/test_gigasecond.c +8 -0
  20. data/tracks/c/exercises/grains/test/test_grains.c +8 -0
  21. data/tracks/c/exercises/hamming/test/test_hamming.c +8 -0
  22. data/tracks/c/exercises/hello-world/src/example.c +0 -2
  23. data/tracks/c/exercises/hello-world/test/test_hello_world.c +8 -0
  24. data/tracks/c/exercises/isogram/test/test_isogram.c +8 -0
  25. data/tracks/c/exercises/largest-series-product/test/test_largest_series_product.c +8 -0
  26. data/tracks/c/exercises/leap/test/test_leap.c +8 -0
  27. data/tracks/c/exercises/meetup/test/test_meetup.c +8 -0
  28. data/tracks/c/exercises/nth-prime/test/test_nth_prime.c +8 -0
  29. data/tracks/c/exercises/nucleotide-count/test/test_nucleotide_count.c +8 -0
  30. data/tracks/c/exercises/palindrome-products/test/test_palindrome_products.c +8 -0
  31. data/tracks/c/exercises/pangram/test/test_pangram.c +8 -0
  32. data/tracks/c/exercises/pascals-triangle/test/test_pascals_triangle.c +8 -0
  33. data/tracks/c/exercises/perfect-numbers/src/example.c +4 -4
  34. data/tracks/c/exercises/perfect-numbers/src/example.h +4 -4
  35. data/tracks/c/exercises/perfect-numbers/src/perfect_numbers.h +4 -4
  36. data/tracks/c/exercises/perfect-numbers/test/test_perfect_numbers.c +23 -13
  37. data/tracks/c/exercises/phone-number/test/test_phone_number.c +8 -0
  38. data/tracks/c/exercises/raindrops/test/test_raindrops.c +5 -1
  39. data/tracks/c/exercises/react/src/example.c +8 -8
  40. data/tracks/c/exercises/react/test/test_react.c +8 -0
  41. data/tracks/c/exercises/rna-transcription/test/test_rna_transcription.c +8 -0
  42. data/tracks/c/exercises/robot-simulator/src/example.c +12 -12
  43. data/tracks/c/exercises/robot-simulator/src/robot_simulator.h +11 -11
  44. data/tracks/c/exercises/robot-simulator/test/test_robot_simulator.c +33 -25
  45. data/tracks/c/exercises/roman-numerals/test/test_roman_numerals.c +8 -0
  46. data/tracks/c/exercises/scrabble-score/test/test_scrabble_score.c +8 -0
  47. data/tracks/c/exercises/series/test/test_series.c +8 -0
  48. data/tracks/c/exercises/sieve/test/test_sieve.c +8 -0
  49. data/tracks/c/exercises/space-age/src/example.h +8 -8
  50. data/tracks/c/exercises/space-age/test/test_space_age.c +16 -8
  51. data/tracks/c/exercises/sum-of-multiples/test/test_sum_of_multiples.c +8 -0
  52. data/tracks/c/exercises/triangle/test/test_triangle.c +8 -0
  53. data/tracks/c/exercises/word-count/test/test_word_count.c +8 -0
  54. data/tracks/cfml/config.json +8 -0
  55. data/tracks/cfml/exercises/anagram/.meta/HINTS.md +0 -0
  56. data/tracks/cfml/exercises/anagram/Anagram.cfc +13 -0
  57. data/tracks/cfml/exercises/anagram/AnagramTest.cfc +79 -0
  58. data/tracks/cfml/exercises/anagram/README.md +29 -0
  59. data/tracks/cfml/exercises/anagram/Solution.cfc +42 -0
  60. data/tracks/cfml/exercises/anagram/SolutionTest.cfc +7 -0
  61. data/tracks/cfml/exercises/anagram/TestRunner.cfc +103 -0
  62. data/tracks/cfml/exercises/anagram/box.json +8 -0
  63. data/tracks/cfml/exercises/anagram/index.cfm +37 -0
  64. data/tracks/common-lisp/config.json +5 -5
  65. data/tracks/csharp/exercises/two-bucket/Example.cs +53 -79
  66. data/tracks/csharp/exercises/two-bucket/TwoBucketTest.cs +2 -2
  67. data/tracks/csharp/generators/Exercises/QueenAttack.cs +3 -3
  68. data/tracks/dart/exercises/leap/test/leap_test.dart +1 -1
  69. data/tracks/delphi/exercises/hamming/uHammingTests.pas +2 -2
  70. data/tracks/delphi/exercises/leap/uLeapTests.pas +11 -38
  71. data/tracks/delphi/exercises/nucleotide-count/uNucleotideCountExample.pas +1 -1
  72. data/tracks/delphi/exercises/nucleotide-count/uNucleotideCountTest.pas +31 -55
  73. data/tracks/ecmascript/config.json +31 -0
  74. data/tracks/ecmascript/config/maintainers.json +5 -5
  75. data/tracks/ecmascript/exercises/accumulate/package.json +1 -1
  76. data/tracks/ecmascript/exercises/acronym/package.json +1 -1
  77. data/tracks/ecmascript/exercises/all-your-base/package.json +1 -1
  78. data/tracks/ecmascript/exercises/allergies/package.json +1 -1
  79. data/tracks/ecmascript/exercises/alphametics/package.json +1 -1
  80. data/tracks/ecmascript/exercises/anagram/package.json +1 -1
  81. data/tracks/ecmascript/exercises/atbash-cipher/package.json +1 -1
  82. data/tracks/ecmascript/exercises/beer-song/package.json +1 -1
  83. data/tracks/ecmascript/exercises/binary-search-tree/package.json +1 -1
  84. data/tracks/ecmascript/exercises/binary-search/package.json +1 -1
  85. data/tracks/ecmascript/exercises/binary/package.json +1 -1
  86. data/tracks/ecmascript/exercises/bob/package.json +1 -1
  87. data/tracks/ecmascript/exercises/bracket-push/package.json +1 -1
  88. data/tracks/ecmascript/exercises/circular-buffer/package.json +1 -1
  89. data/tracks/ecmascript/exercises/clock/package.json +1 -1
  90. data/tracks/ecmascript/exercises/collatz-conjecture/README.md +59 -0
  91. data/tracks/ecmascript/exercises/collatz-conjecture/collatz-conjecture.spec.js +31 -0
  92. data/tracks/ecmascript/exercises/collatz-conjecture/example.js +14 -0
  93. data/tracks/ecmascript/exercises/collatz-conjecture/package.json +69 -0
  94. data/tracks/ecmascript/exercises/connect/package.json +1 -1
  95. data/tracks/ecmascript/exercises/crypto-square/package.json +1 -1
  96. data/tracks/ecmascript/exercises/custom-set/package.json +1 -1
  97. data/tracks/ecmascript/exercises/diamond/package.json +1 -1
  98. data/tracks/ecmascript/exercises/difference-of-squares/package.json +1 -1
  99. data/tracks/ecmascript/exercises/diffie-hellman/package.json +1 -1
  100. data/tracks/ecmascript/exercises/etl/package.json +1 -1
  101. data/tracks/ecmascript/exercises/flatten-array/package.json +1 -1
  102. data/tracks/ecmascript/exercises/food-chain/package.json +1 -1
  103. data/tracks/ecmascript/exercises/gigasecond/package.json +1 -1
  104. data/tracks/ecmascript/exercises/grade-school/package.json +1 -1
  105. data/tracks/ecmascript/exercises/grains/package.json +1 -1
  106. data/tracks/ecmascript/exercises/hamming/package.json +1 -1
  107. data/tracks/ecmascript/exercises/hello-world/package.json +1 -1
  108. data/tracks/ecmascript/exercises/hexadecimal/package.json +1 -1
  109. data/tracks/ecmascript/exercises/isogram/package.json +1 -1
  110. data/tracks/ecmascript/exercises/kindergarten-garden/package.json +1 -1
  111. data/tracks/ecmascript/exercises/largest-series-product/package.json +1 -1
  112. data/tracks/ecmascript/exercises/leap/package.json +1 -1
  113. data/tracks/ecmascript/exercises/linked-list/package.json +1 -1
  114. data/tracks/ecmascript/exercises/list-ops/package.json +1 -1
  115. data/tracks/ecmascript/exercises/luhn/package.json +1 -1
  116. data/tracks/ecmascript/exercises/matrix/package.json +1 -1
  117. data/tracks/ecmascript/exercises/meetup/package.json +1 -1
  118. data/tracks/ecmascript/exercises/minesweeper/package.json +1 -1
  119. data/tracks/ecmascript/exercises/nth-prime/package.json +1 -1
  120. data/tracks/ecmascript/exercises/ocr-numbers/package.json +1 -1
  121. data/tracks/ecmascript/exercises/octal/package.json +1 -1
  122. data/tracks/ecmascript/exercises/palindrome-products/package.json +1 -1
  123. data/tracks/ecmascript/exercises/pangram/package.json +1 -1
  124. data/tracks/ecmascript/exercises/pascals-triangle/package.json +1 -1
  125. data/tracks/ecmascript/exercises/perfect-numbers/package.json +1 -1
  126. data/tracks/ecmascript/exercises/phone-number/package.json +1 -1
  127. data/tracks/ecmascript/exercises/pig-latin/package.json +1 -1
  128. data/tracks/ecmascript/exercises/prime-factors/package.json +1 -1
  129. data/tracks/ecmascript/exercises/proverb/package.json +1 -1
  130. data/tracks/ecmascript/exercises/pythagorean-triplet/package.json +1 -1
  131. data/tracks/ecmascript/exercises/queen-attack/package.json +1 -1
  132. data/tracks/ecmascript/exercises/raindrops/package.json +1 -1
  133. data/tracks/ecmascript/exercises/rna-transcription/package.json +1 -1
  134. data/tracks/ecmascript/exercises/robot-name/package.json +1 -1
  135. data/tracks/ecmascript/exercises/robot-simulator/package.json +1 -1
  136. data/tracks/ecmascript/exercises/roman-numerals/package.json +1 -1
  137. data/tracks/ecmascript/exercises/run-length-encoding/package.json +1 -1
  138. data/tracks/ecmascript/exercises/saddle-points/package.json +1 -1
  139. data/tracks/ecmascript/exercises/say/package.json +1 -1
  140. data/tracks/ecmascript/exercises/scrabble-score/package.json +1 -1
  141. data/tracks/ecmascript/exercises/secret-handshake/package.json +1 -1
  142. data/tracks/ecmascript/exercises/series/package.json +1 -1
  143. data/tracks/ecmascript/exercises/sieve/package.json +1 -1
  144. data/tracks/ecmascript/exercises/simple-cipher/package.json +1 -1
  145. data/tracks/ecmascript/exercises/simple-linked-list/package.json +1 -1
  146. data/tracks/ecmascript/exercises/space-age/package.json +1 -1
  147. data/tracks/ecmascript/exercises/strain/package.json +1 -1
  148. data/tracks/ecmascript/exercises/sublist/package.json +1 -1
  149. data/tracks/ecmascript/exercises/sum-of-multiples/package.json +1 -1
  150. data/tracks/ecmascript/exercises/triangle/package.json +1 -1
  151. data/tracks/ecmascript/exercises/trinary/package.json +1 -1
  152. data/tracks/ecmascript/exercises/twelve-days/package.json +1 -1
  153. data/tracks/ecmascript/exercises/two-bucket/package.json +1 -1
  154. data/tracks/ecmascript/exercises/word-count/package.json +1 -1
  155. data/tracks/ecmascript/exercises/word-search/README.md +58 -0
  156. data/tracks/ecmascript/exercises/word-search/example.js +146 -0
  157. data/tracks/ecmascript/exercises/word-search/package.json +69 -0
  158. data/tracks/ecmascript/exercises/word-search/word-search.spec.js +626 -0
  159. data/tracks/ecmascript/exercises/wordy/package.json +1 -1
  160. data/tracks/ecmascript/package.json +1 -1
  161. data/tracks/elixir/config.json +11 -0
  162. data/tracks/elixir/exercises/luhn/example.exs +26 -46
  163. data/tracks/elixir/exercises/luhn/luhn.exs +0 -13
  164. data/tracks/elixir/exercises/luhn/luhn_test.exs +44 -14
  165. data/tracks/elixir/exercises/transpose/README.md +101 -0
  166. data/tracks/elixir/exercises/transpose/example.exs +46 -0
  167. data/tracks/elixir/exercises/transpose/transpose.exs +22 -0
  168. data/tracks/elixir/exercises/transpose/transpose_test.exs +248 -0
  169. data/tracks/fsharp/exercises/grains/Example.fs +10 -2
  170. data/tracks/fsharp/exercises/grains/Grains.fs +2 -4
  171. data/tracks/fsharp/exercises/grains/GrainsTest.fs +52 -25
  172. data/tracks/fsharp/exercises/phone-number/Example.fs +11 -3
  173. data/tracks/fsharp/exercises/phone-number/PhoneNumber.fs +1 -1
  174. data/tracks/fsharp/exercises/phone-number/PhoneNumberTest.fs +32 -21
  175. data/tracks/fsharp/exercises/prime-factors/Example.fs +6 -13
  176. data/tracks/fsharp/exercises/prime-factors/PrimeFactors.fs +1 -1
  177. data/tracks/fsharp/exercises/prime-factors/PrimeFactorsTest.fs +23 -32
  178. data/tracks/fsharp/exercises/rail-fence-cipher/RailFenceCipherTest.fs +22 -13
  179. data/tracks/fsharp/generators/Exercise.fs +3 -4
  180. data/tracks/fsharp/generators/Generators.fs +31 -0
  181. data/tracks/gnu-apl/bin/run-all-tests +5 -2
  182. data/tracks/java/CONTRIBUTING.md +8 -0
  183. data/tracks/java/POLICIES.md +2 -2
  184. data/tracks/java/config.json +26 -4
  185. data/tracks/java/exercises/triangle/.meta/.version +1 -0
  186. data/tracks/java/exercises/triangle/.meta/src/reference/java/Triangle.java +1 -1
  187. data/tracks/java/exercises/triangle/src/test/java/TriangleTest.java +59 -40
  188. data/tracks/javascript/config.json +30 -0
  189. data/tracks/javascript/config/maintainers.json +8 -8
  190. data/tracks/javascript/exercises/change/example.js +6 -22
  191. data/tracks/javascript/exercises/collatz-conjecture/README.md +57 -0
  192. data/tracks/javascript/exercises/collatz-conjecture/collatz-conjecture.spec.js +37 -0
  193. data/tracks/javascript/exercises/collatz-conjecture/example.js +20 -0
  194. data/tracks/javascript/exercises/protein-translation/example.js +30 -31
  195. data/tracks/javascript/exercises/protein-translation/protein-translation.spec.js +60 -60
  196. data/tracks/javascript/exercises/transpose/README.md +89 -0
  197. data/tracks/javascript/exercises/transpose/example.js +17 -0
  198. data/tracks/javascript/exercises/transpose/transpose.spec.js +67 -0
  199. data/tracks/objective-c/config.json +283 -263
  200. data/tracks/objective-c/exercises/grains/GrainsExample.h +6 -0
  201. data/tracks/objective-c/exercises/grains/GrainsExample.m +19 -0
  202. data/tracks/objective-c/exercises/grains/GrainsTest.m +85 -0
  203. data/tracks/objective-c/exercises/nth-prime/NthPrimeExample.h +6 -0
  204. data/tracks/objective-c/exercises/nth-prime/NthPrimeExample.m +39 -0
  205. data/tracks/objective-c/exercises/nth-prime/NthPrimeTest.m +53 -0
  206. data/tracks/python/config.json +42 -11
  207. data/tracks/python/exercises/change/README.md +34 -0
  208. data/tracks/python/exercises/two-bucket/README.md +47 -0
  209. data/tracks/ruby/README.md +4 -1
  210. data/tracks/ruby/lib/generator/command_line.rb +3 -3
  211. data/tracks/ruby/lib/generator/command_line/generator_optparser.rb +3 -3
  212. data/tracks/ruby/test/generator/command_line/generator_optparser_test.rb +4 -4
  213. data/tracks/ruby/test/generator/command_line_test.rb +5 -5
  214. data/tracks/typescript/config.json +15 -0
  215. data/tracks/typescript/exercises/strain/README.md +60 -0
  216. data/tracks/typescript/exercises/strain/package.json +36 -0
  217. data/tracks/typescript/exercises/strain/strain.example.ts +23 -0
  218. data/tracks/typescript/exercises/strain/strain.test.ts +76 -0
  219. data/tracks/typescript/exercises/strain/strain.ts +0 -0
  220. data/tracks/typescript/exercises/strain/tsconfig.json +22 -0
  221. data/tracks/typescript/exercises/strain/tslint.json +127 -0
  222. data/tracks/typescript/exercises/strain/yarn.lock +2305 -0
  223. metadata +46 -3
  224. data/tracks/ecmascript/package-lock.json +0 -2835
@@ -0,0 +1,57 @@
1
+ # Collatz Conjecture
2
+
3
+ The Collatz Conjecture or 3x+1 problem can be summarized as follows:
4
+
5
+ Take any positive integer n. If n is even, divide n by 2 to get n / 2. If n is
6
+ odd, multiply n by 3 and add 1 to get 3n + 1. Repeat the process indefinitely.
7
+ The conjecture states that no matter which number you start with, you will
8
+ always reach 1 eventually.
9
+
10
+ Given a number n, return the number of steps required to reach 1.
11
+
12
+ ## Examples
13
+
14
+ Starting with n = 12, the steps would be as follows:
15
+
16
+ 0. 12
17
+ 1. 6
18
+ 2. 3
19
+ 3. 10
20
+ 4. 5
21
+ 5. 16
22
+ 6. 8
23
+ 7. 4
24
+ 8. 2
25
+ 9. 1
26
+
27
+ Resulting in 9 steps. So for input n = 12, the return value would be 9.
28
+
29
+ ## Setup
30
+
31
+ Go through the setup instructions for JavaScript to
32
+ install the necessary dependencies:
33
+
34
+ http://exercism.io/languages/javascript
35
+
36
+ ## Making the Test Suite Pass
37
+
38
+ Execute the tests with:
39
+
40
+ jasmine <exercise-name>.spec.js
41
+
42
+ Replace `<exercise-name>` with the name of the current exercise. E.g., to
43
+ test the Hello World exercise:
44
+
45
+ jasmine hello-world.spec.js
46
+
47
+ In many test suites all but the first test have been skipped.
48
+
49
+ Once you get a test passing, you can unskip the next one by
50
+ changing `xit` to `it`.
51
+
52
+ ## Source
53
+
54
+ An unsolved problem in mathematics named after mathematician Lothar Collatz [https://en.wikipedia.org/wiki/3x_%2B_1_problem](https://en.wikipedia.org/wiki/3x_%2B_1_problem)
55
+
56
+ ## Submitting Incomplete Solutions
57
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,37 @@
1
+ var CollatzConjecture = require('./collatz-conjecture');
2
+
3
+ describe('CollatzConjecture', function () {
4
+ var collatz = new CollatzConjecture();
5
+
6
+ it('test zero steps for one', function () {
7
+ var expected = 0;
8
+ expect(collatz.steps(1)).toEqual(expected);
9
+ });
10
+
11
+ xit('test divide if even steps', function () {
12
+ var expected = 4;
13
+ expect(collatz.steps(16)).toEqual(expected);
14
+ });
15
+
16
+ xit('test even and odd steps', function () {
17
+ var expected = 9;
18
+ expect(collatz.steps(12)).toEqual(expected);
19
+ });
20
+
21
+ xit('test large number of even and odd steps', function () {
22
+ var expected = 152;
23
+ expect(collatz.steps(1000000)).toEqual(expected);
24
+ });
25
+
26
+ xit('test zero is an error', function () {
27
+ expect(function () {
28
+ collatz.steps(0);
29
+ }).toThrow(new Error('Only positive numbers are allowed'));
30
+ });
31
+
32
+ xit('test negative value is an error', function () {
33
+ expect(function () {
34
+ collatz.steps(-1);
35
+ }).toThrow(new Error('Only positive numbers are allowed'));
36
+ });
37
+ });
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ function CollatzConjecture() {}
4
+
5
+ CollatzConjecture.prototype.steps = function (number) {
6
+ var count = 0;
7
+ if (number < 1) {
8
+ throw new Error('Only positive numbers are allowed');
9
+ }
10
+ getStepsCount(number);
11
+ function getStepsCount(n) {
12
+ if (n === 1) return 0;
13
+ var nextNumber = ( n % 2 === 0 ? n / 2 : 3 * n + 1);
14
+ count++;
15
+ return getStepsCount(nextNumber);
16
+ }
17
+ return count;
18
+ };
19
+
20
+ module.exports = CollatzConjecture;
@@ -6,16 +6,15 @@ function translate(rnaStrand) {
6
6
  var proteins = [];
7
7
 
8
8
  if (rnaStrand) {
9
- for (var i = 0; i < rnaStrand.length; i+=3) {
9
+ for (var i = 0; i < rnaStrand.length; i += 3) {
10
10
  var protein = getProtein(rnaStrand.substring(i, i + 3));
11
11
 
12
12
  if (protein) {
13
-
14
- if (protein === "STOP") {
13
+ if (protein === 'STOP') {
15
14
  break;
16
15
  }
17
16
 
18
- if (protein === "INVALID") {
17
+ if (protein === 'INVALID') {
19
18
  throw new Error('Invalid codon');
20
19
  }
21
20
 
@@ -29,40 +28,40 @@ function translate(rnaStrand) {
29
28
 
30
29
  function getProtein(codon) {
31
30
  switch (codon) {
32
- case "AUG":
33
- return "Methionine";
31
+ case 'AUG':
32
+ return 'Methionine';
34
33
 
35
- case "UUU":
36
- case "UUC":
37
- return "Phenylalanine";
34
+ case 'UUU':
35
+ case 'UUC':
36
+ return 'Phenylalanine';
38
37
 
39
- case "UUA":
40
- case "UUG":
41
- return "Leucine";
38
+ case 'UUA':
39
+ case 'UUG':
40
+ return 'Leucine';
42
41
 
43
- case "UCU":
44
- case "UCC":
45
- case "UCA":
46
- case "UCG":
47
- return "Serine";
42
+ case 'UCU':
43
+ case 'UCC':
44
+ case 'UCA':
45
+ case 'UCG':
46
+ return 'Serine';
48
47
 
49
- case "UAU":
50
- case "UAC":
51
- return "Tyrosine";
48
+ case 'UAU':
49
+ case 'UAC':
50
+ return 'Tyrosine';
52
51
 
53
- case "UGU":
54
- case "UGC":
55
- return "Cysteine";
52
+ case 'UGU':
53
+ case 'UGC':
54
+ return 'Cysteine';
56
55
 
57
- case "UGG":
58
- return "Tryptophan";
56
+ case 'UGG':
57
+ return 'Tryptophan';
59
58
 
60
- case "UAA":
61
- case "UAG":
62
- case "UGA":
63
- return "STOP";
59
+ case 'UAA':
60
+ case 'UAG':
61
+ case 'UGA':
62
+ return 'STOP';
64
63
 
65
- default:
66
- return "INVALID";
64
+ default:
65
+ return 'INVALID';
67
66
  }
68
67
  }
@@ -1,63 +1,63 @@
1
1
  var translate = require('./protein-translation');
2
2
 
3
- describe('ProteinTranslation', function() {
4
- it('Empty RNA has no proteins', function() {
5
- expect(translate()).toEqual([]);
6
- });
7
-
8
- xit('Methionine codon translates into protein', function () {
9
- expect(translate('AUG')).toEqual(["Methionine"]);
10
- });
11
-
12
- xit('Phenylalanine codons translate into protein', function () {
13
- expect(translate('UUUUUC')).toEqual(["Phenylalanine", "Phenylalanine"]);
14
- });
15
-
16
- xit('Leucine codons translate into protein', function () {
17
- expect(translate('UUAUUG')).toEqual(["Leucine", "Leucine"]);
18
- });
19
-
20
- xit('Serine codons translate into protein', function () {
21
- expect(translate('UCUUCCUCAUCG')).toEqual(["Serine", "Serine", "Serine", "Serine"]);
22
- });
23
-
24
- xit('Tyrosine codons translate into protein', function () {
25
- expect(translate('UAUUAC')).toEqual(["Tyrosine", "Tyrosine"]);
26
- });
27
-
28
- xit('Cysteine codons translate into protein', function() {
29
- expect(translate('UGUUGC')).toEqual(["Cysteine", "Cysteine"]);
30
- });
31
-
32
- xit('Tryptophan codon translates into protein', function () {
33
- expect(translate('UGG')).toEqual(["Tryptophan"]);
34
- });
35
-
36
- xit('Sequence starts with stop codon 1', function () {
37
- expect(translate('UAAUUUUUA')).toEqual([]);
38
- });
39
-
40
- xit('Sequence starts with stop codon 2', function () {
41
- expect(translate('UAGAUGUAU')).toEqual([]);
42
- });
43
-
44
- xit('Sequence starts with stop codon 3', function () {
45
- expect(translate('UGAUGU')).toEqual([]);
46
- });
47
-
48
- xit('Small RNA strand', function () {
49
- expect(translate('AUGUUUUCU')).toEqual(["Methionine", "Phenylalanine", "Serine"]);
50
- });
51
-
52
- xit('Stop codon ends translation', function () {
53
- expect(translate('AUGUUUUCUUAAAUG')).toEqual(["Methionine", "Phenylalanine", "Serine"]);
54
- });
55
-
56
- xit('Invalid codon throws error', function () {
57
- expect(
58
- function() {
59
- translate('LOL')
60
- }
61
- ).toThrow(new Error("Invalid codon"));
62
- })
3
+ describe('ProteinTranslation', function () {
4
+ it('Empty RNA has no proteins', function () {
5
+ expect(translate()).toEqual([]);
6
+ });
7
+
8
+ xit('Methionine codon translates into protein', function () {
9
+ expect(translate('AUG')).toEqual(['Methionine']);
10
+ });
11
+
12
+ xit('Phenylalanine codons translate into protein', function () {
13
+ expect(translate('UUUUUC')).toEqual(['Phenylalanine', 'Phenylalanine']);
14
+ });
15
+
16
+ xit('Leucine codons translate into protein', function () {
17
+ expect(translate('UUAUUG')).toEqual(['Leucine', 'Leucine']);
18
+ });
19
+
20
+ xit('Serine codons translate into protein', function () {
21
+ expect(translate('UCUUCCUCAUCG')).toEqual(['Serine', 'Serine', 'Serine', 'Serine']);
22
+ });
23
+
24
+ xit('Tyrosine codons translate into protein', function () {
25
+ expect(translate('UAUUAC')).toEqual(['Tyrosine', 'Tyrosine']);
26
+ });
27
+
28
+ xit('Cysteine codons translate into protein', function () {
29
+ expect(translate('UGUUGC')).toEqual(['Cysteine', 'Cysteine']);
30
+ });
31
+
32
+ xit('Tryptophan codon translates into protein', function () {
33
+ expect(translate('UGG')).toEqual(['Tryptophan']);
34
+ });
35
+
36
+ xit('Sequence starts with stop codon 1', function () {
37
+ expect(translate('UAAUUUUUA')).toEqual([]);
38
+ });
39
+
40
+ xit('Sequence starts with stop codon 2', function () {
41
+ expect(translate('UAGAUGUAU')).toEqual([]);
42
+ });
43
+
44
+ xit('Sequence starts with stop codon 3', function () {
45
+ expect(translate('UGAUGU')).toEqual([]);
46
+ });
47
+
48
+ xit('Small RNA strand', function () {
49
+ expect(translate('AUGUUUUCU')).toEqual(['Methionine', 'Phenylalanine', 'Serine']);
50
+ });
51
+
52
+ xit('Stop codon ends translation', function () {
53
+ expect(translate('AUGUUUUCUUAAAUG')).toEqual(['Methionine', 'Phenylalanine', 'Serine']);
54
+ });
55
+
56
+ xit('Invalid codon throws error', function () {
57
+ expect(
58
+ function () {
59
+ translate('LOL');
60
+ }
61
+ ).toThrow(new Error('Invalid codon'));
62
+ });
63
63
  });
@@ -0,0 +1,89 @@
1
+ # Transpose
2
+
3
+ Given an input text output it transposed.
4
+
5
+ Roughly explained, the transpose of a matrix:
6
+
7
+ ```text
8
+ ABC
9
+ DEF
10
+ ```
11
+
12
+ is given by:
13
+
14
+ ```text
15
+ AD
16
+ BE
17
+ CF
18
+ ```
19
+
20
+ Rows become columns and columns become rows. See <https://en.wikipedia.org/wiki/Transpose>.
21
+
22
+ If the input has rows of different lengths, this is to be solved as follows:
23
+
24
+ - Pad to the left with spaces.
25
+ - Don't pad to the right.
26
+
27
+ Therefore, transposing this matrix:
28
+
29
+ ```text
30
+ ABC
31
+ DE
32
+ ```
33
+
34
+ results in:
35
+
36
+ ```text
37
+ AD
38
+ BE
39
+ C
40
+ ```
41
+
42
+ And transposing:
43
+
44
+ ```text
45
+ AB
46
+ DEF
47
+ ```
48
+
49
+ results in:
50
+
51
+ ```text
52
+ AD
53
+ BE
54
+ F
55
+ ```
56
+
57
+ In general, all characters from the input should also be present in the transposed output.
58
+ That means that if a column in the input text contains only spaces on its bottom-most row(s),
59
+ the corresponding output row should contain the spaces in its right-most column(s).
60
+
61
+ ## Setup
62
+
63
+ Go through the setup instructions for JavaScript to
64
+ install the necessary dependencies:
65
+
66
+ http://exercism.io/languages/javascript
67
+
68
+ ## Making the Test Suite Pass
69
+
70
+ Execute the tests with:
71
+
72
+ jasmine <exercise-name>.spec.js
73
+
74
+ Replace `<exercise-name>` with the name of the current exercise. E.g., to
75
+ test the Hello World exercise:
76
+
77
+ jasmine hello-world.spec.js
78
+
79
+ In many test suites all but the first test have been skipped.
80
+
81
+ Once you get a test passing, you can unskip the next one by
82
+ changing `xit` to `it`.
83
+
84
+ ## Source
85
+
86
+ Reddit r/dailyprogrammer challenge #270 [Easy]. [https://www.reddit.com/r/dailyprogrammer/comments/4msu2x/challenge_270_easy_transpose_the_input_text](https://www.reddit.com/r/dailyprogrammer/comments/4msu2x/challenge_270_easy_transpose_the_input_text)
87
+
88
+ ## Submitting Incomplete Solutions
89
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ function transpose(text) {
4
+ return text.reduce(function (result, line, lineNo) {
5
+ line.split('').map(function (value, key) {
6
+ if (typeof result[key] === 'undefined') {
7
+ result[key] = new Array(lineNo + 1).join(' ');
8
+ }
9
+
10
+ result[key] += value;
11
+ });
12
+
13
+ return result;
14
+ }, []);
15
+ }
16
+
17
+ module.exports = transpose;
@@ -0,0 +1,67 @@
1
+ var transpose = require('./transpose');
2
+
3
+ describe('Transpose', function () {
4
+ it('test empty string', function () {
5
+ expect(transpose([])).toEqual([]);
6
+ });
7
+
8
+ xit('test two characters in a row', function () {
9
+ var input = ['A1'];
10
+ var expected = ['A', '1'];
11
+ expect(transpose(input)).toEqual(expected);
12
+ });
13
+
14
+ xit('test two characters in a column', function () {
15
+ var input = ['A', '1'];
16
+ var expected = ['A1'];
17
+ expect(transpose(input)).toEqual(expected);
18
+ });
19
+
20
+ xit('test simple', function () {
21
+ var input = ['ABC', '123'];
22
+ var expected = ['A1', 'B2', 'C3'];
23
+ expect(transpose(input)).toEqual(expected);
24
+ });
25
+
26
+ xit('test single line', function () {
27
+ var input = ['Single line.'];
28
+ var expected = ['S', 'i', 'n', 'g', 'l', 'e', ' ', 'l', 'i', 'n', 'e', '.'];
29
+ expect(transpose(input)).toEqual(expected);
30
+ });
31
+
32
+ xit('test first line longer than second line', function () {
33
+ var input = ['The fourth line.', 'The fifth line.'];
34
+ var expected = ['TT', 'hh', 'ee', ' ', 'ff', 'oi', 'uf', 'rt', 'th', 'h ', ' l', 'li', 'in', 'ne', 'e.', '.'];
35
+ expect(transpose(input)).toEqual(expected);
36
+ });
37
+
38
+ xit('test second line longer than first line', function () {
39
+ var input = ['The first line.', 'The second line.'];
40
+ var expected = ['TT', 'hh', 'ee', ' ', 'fs', 'ie', 'rc', 'so', 'tn', ' d', 'l ', 'il', 'ni', 'en', '.e', ' .'];
41
+ expect(transpose(input)).toEqual(expected);
42
+ });
43
+
44
+ xit('test square', function () {
45
+ var input = ['HEART', 'EMBER', 'ABUSE', 'RESIN', 'TREND'];
46
+ var expected = ['HEART', 'EMBER', 'ABUSE', 'RESIN', 'TREND'];
47
+ expect(transpose(input)).toEqual(expected);
48
+ });
49
+
50
+ xit('test rectangle', function () {
51
+ var input = ['FRACTURE', 'OUTLINED', 'BLOOMING', 'SEPTETTE'];
52
+ var expected = ['FOBS', 'RULE', 'ATOP', 'CLOT', 'TIME', 'UNIT', 'RENT', 'EDGE'];
53
+ expect(transpose(input)).toEqual(expected);
54
+ });
55
+
56
+ xit('test triangle', function () {
57
+ var input = ['T', 'EE', 'AAA', 'SSSS', 'EEEEE', 'RRRRRR'];
58
+ var expected = ['TEASER', ' EASER', ' ASER', ' SER', ' ER', ' R'];
59
+ expect(transpose(input)).toEqual(expected);
60
+ });
61
+
62
+ xit('test many lines', function () {
63
+ var input = ['Chor. Two households, both alike in dignity,', 'In fair Verona, where we lay our scene,', 'From ancient grudge break to new mutiny,', 'Where civil blood makes civil hands unclean.', 'From forth the fatal loins of these two foes', 'A pair of star-cross\'d lovers take their life;', 'Whose misadventur\'d piteous overthrows', 'Doth with their death bury their parents\' strife.', 'The fearful passage of their death-mark\'d love,', 'And the continuance of their parents\' rage,', 'Which, but their children\'s end, naught could remove,', 'Is now the two hours\' traffic of our stage;', 'The which if you with patient ears attend,', 'What here shall miss, our toil shall strive to mend.'];
64
+ var expected = ['CIFWFAWDTAWITW', 'hnrhr hohnhshh', 'o oeopotedi ea', 'rfmrmash cn t', '.a e ie fthow ', ' ia fr weh,whh', 'Trnco miae ie', 'w ciroitr btcr', 'oVivtfshfcuhhe', ' eeih a uote ', 'hrnl sdtln is', 'oot ttvh tttfh', 'un bhaeepihw a', 'saglernianeoyl', 'e,ro -trsui ol', 'h uofcu sarhu ', 'owddarrdan o m', 'lhg to\'egccuwi', 'deemasdaeehris', 'sr als t ists', ',ebk \'phool\'h,', ' reldi ffd ', 'bweso tb rtpo', 'oea ileutterau', 't kcnoorhhnatr', 'hl isvuyee\'fi ', ' atv es iisfet', 'ayoior trr ino', 'l lfsoh ecti', 'ion vedpn l', 'kuehtteieadoe ', 'erwaharrar,fas', ' nekt te rh', 'ismdsehphnnosa', 'ncuse ra-tau l', ' et tormsural', 'dniuthwea\'g t ', 'iennwesnr hsts', 'g,ycoitkrttet', 'n,l rs\'a anr', 'ief \'dgcgdi', 'taol eoe,v', 'yneisl,u;e', ',.sftol ', ' ervdt', ' ;ie o', ' f,r ', ' eem', ' .me', ' on', ' vd', ' e.', ' ,'];
65
+ expect(transpose(input)).toEqual(expected);
66
+ });
67
+ });