trackler 2.2.1.55 → 2.2.1.56

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/CONTRIBUTING.md +1 -1
  4. data/problem-specifications/exercises/phone-number/description.md +1 -1
  5. data/tracks/clojure/config.json +9 -1
  6. data/tracks/clojure/exercises/complex-numbers/README.md +37 -0
  7. data/tracks/clojure/exercises/complex-numbers/project.clj +4 -0
  8. data/tracks/clojure/exercises/complex-numbers/src/complex_numbers.clj +17 -0
  9. data/tracks/clojure/exercises/complex-numbers/src/example.clj +20 -0
  10. data/tracks/clojure/exercises/complex-numbers/test/complex_numbers_test.clj +141 -0
  11. data/tracks/dart/exercises/hello-world/lib/example.dart +3 -1
  12. data/tracks/dart/exercises/hello-world/lib/hello_world.dart +1 -1
  13. data/tracks/dart/exercises/hello-world/test/hello_world_test.dart +2 -16
  14. data/tracks/dart/exercises/leap/test/leap_test.dart +1 -1
  15. data/tracks/dart/tool/create-exercise +35 -25
  16. data/tracks/ecmascript/config.json +13 -0
  17. data/tracks/ecmascript/exercises/accumulate/README.md +1 -1
  18. data/tracks/ecmascript/exercises/acronym/README.md +1 -1
  19. data/tracks/ecmascript/exercises/all-your-base/README.md +1 -1
  20. data/tracks/ecmascript/exercises/allergies/README.md +1 -1
  21. data/tracks/ecmascript/exercises/alphametics/README.md +1 -1
  22. data/tracks/ecmascript/exercises/anagram/README.md +1 -1
  23. data/tracks/ecmascript/exercises/atbash-cipher/README.md +1 -1
  24. data/tracks/ecmascript/exercises/beer-song/README.md +1 -1
  25. data/tracks/ecmascript/exercises/binary-search-tree/README.md +1 -1
  26. data/tracks/ecmascript/exercises/binary-search/README.md +1 -1
  27. data/tracks/ecmascript/exercises/binary/README.md +1 -1
  28. data/tracks/ecmascript/exercises/bob/README.md +1 -1
  29. data/tracks/ecmascript/exercises/bowling/README.md +1 -1
  30. data/tracks/ecmascript/exercises/bracket-push/README.md +1 -1
  31. data/tracks/ecmascript/exercises/change/README.md +1 -1
  32. data/tracks/ecmascript/exercises/circular-buffer/README.md +1 -1
  33. data/tracks/ecmascript/exercises/clock/README.md +1 -1
  34. data/tracks/ecmascript/exercises/collatz-conjecture/README.md +1 -1
  35. data/tracks/ecmascript/exercises/connect/README.md +1 -1
  36. data/tracks/ecmascript/exercises/crypto-square/README.md +1 -1
  37. data/tracks/ecmascript/exercises/custom-set/README.md +1 -1
  38. data/tracks/ecmascript/exercises/diamond/README.md +1 -1
  39. data/tracks/ecmascript/exercises/difference-of-squares/README.md +1 -1
  40. data/tracks/ecmascript/exercises/diffie-hellman/README.md +1 -1
  41. data/tracks/ecmascript/exercises/etl/README.md +1 -1
  42. data/tracks/ecmascript/exercises/flatten-array/README.md +1 -1
  43. data/tracks/ecmascript/exercises/food-chain/README.md +1 -1
  44. data/tracks/ecmascript/exercises/gigasecond/README.md +1 -1
  45. data/tracks/ecmascript/exercises/grade-school/README.md +1 -1
  46. data/tracks/ecmascript/exercises/grains/README.md +1 -1
  47. data/tracks/ecmascript/exercises/hamming/README.md +1 -1
  48. data/tracks/ecmascript/exercises/hello-world/README.md +1 -1
  49. data/tracks/ecmascript/exercises/hexadecimal/README.md +1 -1
  50. data/tracks/ecmascript/exercises/isbn-verifier/README.md +1 -1
  51. data/tracks/ecmascript/exercises/isogram/README.md +1 -1
  52. data/tracks/ecmascript/exercises/kindergarten-garden/README.md +1 -1
  53. data/tracks/ecmascript/exercises/largest-series-product/README.md +1 -1
  54. data/tracks/ecmascript/exercises/leap/README.md +1 -1
  55. data/tracks/ecmascript/exercises/linked-list/README.md +1 -1
  56. data/tracks/ecmascript/exercises/list-ops/README.md +1 -1
  57. data/tracks/ecmascript/exercises/luhn/README.md +1 -1
  58. data/tracks/ecmascript/exercises/matrix/README.md +1 -1
  59. data/tracks/ecmascript/exercises/meetup/README.md +1 -1
  60. data/tracks/ecmascript/exercises/minesweeper/README.md +1 -1
  61. data/tracks/ecmascript/exercises/nth-prime/README.md +1 -1
  62. data/tracks/ecmascript/exercises/ocr-numbers/README.md +1 -1
  63. data/tracks/ecmascript/exercises/octal/README.md +1 -1
  64. data/tracks/ecmascript/exercises/palindrome-products/README.md +1 -1
  65. data/tracks/ecmascript/exercises/pangram/README.md +1 -1
  66. data/tracks/ecmascript/exercises/pascals-triangle/README.md +1 -1
  67. data/tracks/ecmascript/exercises/perfect-numbers/README.md +1 -1
  68. data/tracks/ecmascript/exercises/phone-number/README.md +1 -1
  69. data/tracks/ecmascript/exercises/pig-latin/README.md +1 -1
  70. data/tracks/ecmascript/exercises/prime-factors/README.md +1 -1
  71. data/tracks/ecmascript/exercises/protein-translation/README.md +78 -0
  72. data/tracks/ecmascript/exercises/protein-translation/example.js +45 -0
  73. data/tracks/ecmascript/exercises/protein-translation/package.json +71 -0
  74. data/tracks/ecmascript/exercises/protein-translation/protein-translation.spec.js +59 -0
  75. data/tracks/ecmascript/exercises/proverb/README.md +1 -1
  76. data/tracks/ecmascript/exercises/pythagorean-triplet/README.md +1 -1
  77. data/tracks/ecmascript/exercises/queen-attack/README.md +1 -1
  78. data/tracks/ecmascript/exercises/raindrops/README.md +1 -1
  79. data/tracks/ecmascript/exercises/rna-transcription/README.md +1 -1
  80. data/tracks/ecmascript/exercises/robot-name/README.md +1 -1
  81. data/tracks/ecmascript/exercises/robot-simulator/README.md +1 -1
  82. data/tracks/ecmascript/exercises/roman-numerals/README.md +1 -1
  83. data/tracks/ecmascript/exercises/run-length-encoding/README.md +1 -1
  84. data/tracks/ecmascript/exercises/saddle-points/README.md +1 -1
  85. data/tracks/ecmascript/exercises/say/README.md +1 -1
  86. data/tracks/ecmascript/exercises/scrabble-score/README.md +1 -1
  87. data/tracks/ecmascript/exercises/secret-handshake/README.md +1 -1
  88. data/tracks/ecmascript/exercises/series/README.md +1 -1
  89. data/tracks/ecmascript/exercises/sieve/README.md +1 -1
  90. data/tracks/ecmascript/exercises/simple-cipher/README.md +1 -1
  91. data/tracks/ecmascript/exercises/simple-linked-list/README.md +1 -1
  92. data/tracks/ecmascript/exercises/space-age/README.md +1 -1
  93. data/tracks/ecmascript/exercises/strain/README.md +1 -1
  94. data/tracks/ecmascript/exercises/sublist/README.md +1 -1
  95. data/tracks/ecmascript/exercises/sum-of-multiples/README.md +1 -1
  96. data/tracks/ecmascript/exercises/transpose/README.md +1 -1
  97. data/tracks/ecmascript/exercises/triangle/README.md +1 -1
  98. data/tracks/ecmascript/exercises/trinary/README.md +1 -1
  99. data/tracks/ecmascript/exercises/twelve-days/README.md +1 -1
  100. data/tracks/ecmascript/exercises/two-bucket/README.md +1 -1
  101. data/tracks/ecmascript/exercises/two-fer/README.md +1 -1
  102. data/tracks/ecmascript/exercises/word-count/README.md +1 -1
  103. data/tracks/ecmascript/exercises/word-search/README.md +1 -1
  104. data/tracks/ecmascript/exercises/wordy/README.md +1 -1
  105. data/tracks/erlang/exercises/bob/src/bob.erl +4 -4
  106. data/tracks/erlang/exercises/bob/src/example.erl +30 -15
  107. data/tracks/erlang/exercises/bob/test/bob_tests.erl +84 -45
  108. data/tracks/erlang/exercises/collatz-conjecture/test/collatz_conjecture_tests.erl +2 -0
  109. data/tracks/erlang/exercises/hamming/src/example.erl +10 -10
  110. data/tracks/erlang/exercises/hamming/src/hamming.erl +4 -4
  111. data/tracks/erlang/exercises/hamming/test/hamming_tests.erl +54 -13
  112. data/tracks/erlang/exercises/hello-world/test/hello_world_tests.erl +2 -0
  113. data/tracks/erlang/exercises/leap/test/leap_tests.erl +2 -0
  114. data/tracks/erlang/exercises/rna-transcription/src/example.erl +6 -2
  115. data/tracks/erlang/exercises/rna-transcription/src/rna_transcription.erl +3 -3
  116. data/tracks/erlang/exercises/rna-transcription/test/rna_transcription_tests.erl +24 -14
  117. data/tracks/erlang/testgen/src/tgen.erl +1 -0
  118. data/tracks/erlang/testgen/src/tgen_bob.erl +29 -0
  119. data/tracks/erlang/testgen/src/tgen_hamming.erl +41 -0
  120. data/tracks/erlang/testgen/src/tgen_rna-transcription.erl +38 -0
  121. data/tracks/fsharp/exercises/etl/Etl.fs +2 -2
  122. data/tracks/fsharp/exercises/etl/EtlTest.fs +72 -29
  123. data/tracks/fsharp/exercises/etl/Example.fs +10 -5
  124. data/tracks/fsharp/exercises/nth-prime/NthPrimeTest.fs +1 -1
  125. data/tracks/fsharp/exercises/nucleotide-count/Example.fs +7 -3
  126. data/tracks/fsharp/exercises/nucleotide-count/NucleotideCount.fs +1 -3
  127. data/tracks/fsharp/exercises/nucleotide-count/NucleotideCountTest.fs +51 -33
  128. data/tracks/fsharp/generators/Generators.fs +48 -2
  129. data/tracks/gnu-apl/README.md +49 -14
  130. data/tracks/python/exercises/flatten-array/flatten_array_test.py +18 -11
  131. data/tracks/python/exercises/pig-latin/example.py +2 -1
  132. data/tracks/python/exercises/pig-latin/pig_latin_test.py +10 -4
  133. metadata +14 -2
@@ -25,7 +25,7 @@ in the input; the digits need not be *numerically consecutive*.
25
25
  Go through the setup instructions for ECMAScript to
26
26
  install the necessary dependencies:
27
27
 
28
- http://exercism.io/languages/ecmascript
28
+ http://exercism.io/languages/ecmascript/installation
29
29
 
30
30
  ## Requirements
31
31
 
@@ -32,7 +32,7 @@ correct list of primes.
32
32
  Go through the setup instructions for ECMAScript to
33
33
  install the necessary dependencies:
34
34
 
35
- http://exercism.io/languages/ecmascript
35
+ http://exercism.io/languages/ecmascript/installation
36
36
 
37
37
  ## Requirements
38
38
 
@@ -88,7 +88,7 @@ on Wikipedia][dh] for one of the first implementations of this scheme.
88
88
  Go through the setup instructions for ECMAScript to
89
89
  install the necessary dependencies:
90
90
 
91
- http://exercism.io/languages/ecmascript
91
+ http://exercism.io/languages/ecmascript/installation
92
92
 
93
93
  ## Requirements
94
94
 
@@ -26,7 +26,7 @@ implement your own abstract data type.
26
26
  Go through the setup instructions for ECMAScript to
27
27
  install the necessary dependencies:
28
28
 
29
- http://exercism.io/languages/ecmascript
29
+ http://exercism.io/languages/ecmascript/installation
30
30
 
31
31
  ## Requirements
32
32
 
@@ -22,7 +22,7 @@ youtube video](http://www.youtube.com/watch?v=Z_2gbGXzFbs).
22
22
  Go through the setup instructions for ECMAScript to
23
23
  install the necessary dependencies:
24
24
 
25
- http://exercism.io/languages/ecmascript
25
+ http://exercism.io/languages/ecmascript/installation
26
26
 
27
27
  ## Requirements
28
28
 
@@ -38,7 +38,7 @@ basic tools instead.
38
38
  Go through the setup instructions for ECMAScript to
39
39
  install the necessary dependencies:
40
40
 
41
- http://exercism.io/languages/ecmascript
41
+ http://exercism.io/languages/ecmascript/installation
42
42
 
43
43
  ## Requirements
44
44
 
@@ -22,7 +22,7 @@ Examples:
22
22
  Go through the setup instructions for ECMAScript to
23
23
  install the necessary dependencies:
24
24
 
25
- http://exercism.io/languages/ecmascript
25
+ http://exercism.io/languages/ecmascript/installation
26
26
 
27
27
  ## Requirements
28
28
 
@@ -16,7 +16,7 @@ up to but not including that number.
16
16
  Go through the setup instructions for ECMAScript to
17
17
  install the necessary dependencies:
18
18
 
19
- http://exercism.io/languages/ecmascript
19
+ http://exercism.io/languages/ecmascript/installation
20
20
 
21
21
  ## Requirements
22
22
 
@@ -63,7 +63,7 @@ the corresponding output row should contain the spaces in its right-most column(
63
63
  Go through the setup instructions for ECMAScript to
64
64
  install the necessary dependencies:
65
65
 
66
- http://exercism.io/languages/ecmascript
66
+ http://exercism.io/languages/ecmascript/installation
67
67
 
68
68
  ## Requirements
69
69
 
@@ -24,7 +24,7 @@ a single line. Feel free to add your own code/tests to check for degenerate tria
24
24
  Go through the setup instructions for ECMAScript to
25
25
  install the necessary dependencies:
26
26
 
27
- http://exercism.io/languages/ecmascript
27
+ http://exercism.io/languages/ecmascript/installation
28
28
 
29
29
  ## Requirements
30
30
 
@@ -26,7 +26,7 @@ conversion, pretend it doesn't exist and implement it yourself.
26
26
  Go through the setup instructions for ECMAScript to
27
27
  install the necessary dependencies:
28
28
 
29
- http://exercism.io/languages/ecmascript
29
+ http://exercism.io/languages/ecmascript/installation
30
30
 
31
31
  ## Requirements
32
32
 
@@ -34,7 +34,7 @@ On the twelfth day of Christmas my true love gave to me, twelve Drummers Drummin
34
34
  Go through the setup instructions for ECMAScript to
35
35
  install the necessary dependencies:
36
36
 
37
- http://exercism.io/languages/ecmascript
37
+ http://exercism.io/languages/ecmascript/installation
38
38
 
39
39
  ## Requirements
40
40
 
@@ -34,7 +34,7 @@ Written with <3 at [Fullstack Academy](http://www.fullstackacademy.com/) by [Lin
34
34
  Go through the setup instructions for ECMAScript to
35
35
  install the necessary dependencies:
36
36
 
37
- http://exercism.io/languages/ecmascript
37
+ http://exercism.io/languages/ecmascript/installation
38
38
 
39
39
  ## Requirements
40
40
 
@@ -17,7 +17,7 @@ If the given name is "Alice", the result should be "One for Alice, one for me."
17
17
  Go through the setup instructions for ECMAScript to
18
18
  install the necessary dependencies:
19
19
 
20
- http://exercism.io/languages/ecmascript
20
+ http://exercism.io/languages/ecmascript/installation
21
21
 
22
22
  ## Requirements
23
23
 
@@ -17,7 +17,7 @@ free: 1
17
17
  Go through the setup instructions for ECMAScript to
18
18
  install the necessary dependencies:
19
19
 
20
- http://exercism.io/languages/ecmascript
20
+ http://exercism.io/languages/ecmascript/installation
21
21
 
22
22
  ## Requirements
23
23
 
@@ -31,7 +31,7 @@ letter of each word.
31
31
  Go through the setup instructions for ECMAScript to
32
32
  install the necessary dependencies:
33
33
 
34
- http://exercism.io/languages/ecmascript
34
+ http://exercism.io/languages/ecmascript/installation
35
35
 
36
36
  ## Requirements
37
37
 
@@ -61,7 +61,7 @@ If you'd like, handle exponentials.
61
61
  Go through the setup instructions for ECMAScript to
62
62
  install the necessary dependencies:
63
63
 
64
- http://exercism.io/languages/ecmascript
64
+ http://exercism.io/languages/ecmascript/installation
65
65
 
66
66
  ## Requirements
67
67
 
@@ -1,8 +1,8 @@
1
1
  -module(bob).
2
2
 
3
- -export([response_for/1, test_version/0]).
3
+ -export([response/1, test_version/0]).
4
4
 
5
- response_for(String) ->
6
- undefined.
7
5
 
8
- test_version() -> 1.
6
+ response(String) -> undefined.
7
+
8
+ test_version() -> 2.
@@ -1,33 +1,48 @@
1
1
  -module(example).
2
2
 
3
- -export([response_for/1, test_version/0]).
3
+ -export([response/1, test_version/0]).
4
4
 
5
- -spec response_for(string()) -> string().
6
- response_for(String) ->
5
+ -spec response(string()) -> string().
6
+ response(String) ->
7
7
  first_match(
8
- String,
9
- [{fun is_all_spaces/1, "Fine. Be that way!"},
8
+ trim(String),
9
+ [{fun is_silent/1, "Fine. Be that way!"},
10
10
  {fun is_shouting/1, "Whoa, chill out!"},
11
11
  {fun is_question/1, "Sure."},
12
12
  {fun (_) -> true end, "Whatever."}]).
13
13
 
14
14
  test_version() ->
15
- 1.
15
+ 2.
16
16
 
17
17
 
18
18
 
19
19
  first_match(S, [{F, Res} | Fs]) ->
20
- case F(S) of
21
- true -> Res;
22
- false -> first_match(S, Fs)
23
- end.
20
+ case F(S) of
21
+ true -> Res;
22
+ false -> first_match(S, Fs)
23
+ end.
24
24
 
25
25
  is_shouting(String) ->
26
- lists:any(fun (C) -> C >= $A andalso C =< $Z end, String) andalso
27
- string:to_upper(String) =:= String.
26
+ lists:any(fun (C) -> C >= $A andalso C =< $Z end, String) andalso
27
+ string:to_upper(String) =:= String.
28
28
 
29
29
  is_question(String) ->
30
- lists:last(String) =:= $?.
30
+ lists:last(String) =:= $?.
31
31
 
32
- is_all_spaces(String) ->
33
- re:run(String, "^(\\h|\\v)*$", [unicode]) =/= nomatch.
32
+ is_silent("") -> true;
33
+ is_silent(_) -> false.
34
+
35
+ trim(String) ->
36
+ trim_left(trim_right(String)).
37
+
38
+ trim_left("") -> "";
39
+ trim_left([$\s|T]) -> trim_left(T);
40
+ trim_left([$\t|T]) -> trim_left(T);
41
+ trim_left([$\n|T]) -> trim_left(T);
42
+ trim_left([$\r|T]) -> trim_left(T);
43
+ trim_left(S) -> S.
44
+
45
+ trim_right(S) ->
46
+ S1 = lists:reverse(S),
47
+ S2 = trim_left(S1),
48
+ lists:reverse(S2).
@@ -1,71 +1,110 @@
1
1
  -module(bob_tests).
2
2
 
3
+ % This file is automatically generated from the exercises canonical data.
4
+
3
5
  -define(TESTED_MODULE, (sut(bob))).
4
- -define(TEST_VERSION, 1).
6
+ -define(TEST_VERSION, 2).
5
7
  -include("exercism.hrl").
6
8
 
7
- responds_to_something_test() ->
8
- bob_responds("Tom-ay-to, tom-aaaah-to.", "Whatever.").
9
9
 
10
- responds_to_shouts_test() ->
11
- bob_responds("WATCH OUT!", "Whoa, chill out!").
10
+ stating_something_test() ->
11
+ ?assertMatch("Whatever.",
12
+ ?TESTED_MODULE:response("Tom-ay-to, tom-aaaah-to.")).
13
+
14
+ shouting_test() ->
15
+ ?assertMatch("Whoa, chill out!",
16
+ ?TESTED_MODULE:response("WATCH OUT!")).
17
+
18
+ shouting_gibberish_test() ->
19
+ ?assertMatch("Whoa, chill out!",
20
+ ?TESTED_MODULE:response("FCECDFCAAB")).
21
+
22
+ asking_a_question_test() ->
23
+ ?assertMatch("Sure.",
24
+ ?TESTED_MODULE:response("Does this cryogenic chamber make me "
25
+ "look fat?")).
26
+
27
+ asking_a_numeric_question_test() ->
28
+ ?assertMatch("Sure.",
29
+ ?TESTED_MODULE:response("You are, what, like 15?")).
12
30
 
13
- responds_to_questions_test() ->
14
- bob_responds("Does this cryogenic chamber make me look fat?", "Sure.").
31
+ asking_gibberish_test() ->
32
+ ?assertMatch("Sure.",
33
+ ?TESTED_MODULE:response("fffbbcbeab?")).
15
34
 
16
- responds_to_forceful_talking_test() ->
17
- bob_responds("Let's go make out behind the gym!", "Whatever.").
35
+ talking_forcefully_test() ->
36
+ ?assertMatch("Whatever.",
37
+ ?TESTED_MODULE:response("Let's go make out behind the gym!")).
18
38
 
19
- responds_to_acronyms_test() ->
20
- bob_responds("It's OK if you don't want to go to the DMV.", "Whatever.").
39
+ using_acronyms_in_regular_speech_test() ->
40
+ ?assertMatch("Whatever.",
41
+ ?TESTED_MODULE:response("It's OK if you don't want to go to the "
42
+ "DMV.")).
21
43
 
22
- responds_to_forceful_questions_test() ->
23
- bob_responds("WHAT THE HELL WERE YOU THINKING?", "Whoa, chill out!").
44
+ forceful_question_test() ->
45
+ ?assertMatch("Whoa, chill out!",
46
+ ?TESTED_MODULE:response("WHAT THE HELL WERE YOU THINKING?")).
24
47
 
25
- responds_to_shouting_with_special_characters_test() ->
26
- bob_responds("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!",
27
- "Whoa, chill out!").
48
+ shouting_numbers_test() ->
49
+ ?assertMatch("Whoa, chill out!",
50
+ ?TESTED_MODULE:response("1, 2, 3 GO!")).
28
51
 
29
- responds_to_shouting_numbers_test() ->
30
- bob_responds("1, 2, 3, GO!", "Whoa, chill out!").
52
+ only_numbers_test() ->
53
+ ?assertMatch("Whatever.",
54
+ ?TESTED_MODULE:response("1, 2, 3")).
31
55
 
32
- responds_to_shouting_with_no_exclamation_mark_test() ->
33
- bob_responds("I HATE YOU", "Whoa, chill out!").
56
+ question_with_only_numbers_test() ->
57
+ ?assertMatch("Sure.", ?TESTED_MODULE:response("4?")).
34
58
 
35
- responds_to_statement_containing_question_mark_test() ->
36
- bob_responds("Ending with ? means a question", "Whatever.").
59
+ shouting_with_special_characters_test() ->
60
+ ?assertMatch("Whoa, chill out!",
61
+ ?TESTED_MODULE:response("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")).
37
62
 
38
- responds_to_silence_test() ->
39
- bob_responds("", "Fine. Be that way!").
63
+ shouting_with_no_exclamation_mark_test() ->
64
+ ?assertMatch("Whoa, chill out!",
65
+ ?TESTED_MODULE:response("I HATE YOU")).
40
66
 
41
- responds_to_prolonged_silence_test() ->
42
- bob_responds(" ", "Fine. Be that way!").
67
+ statement_containing_question_mark_test() ->
68
+ ?assertMatch("Whatever.",
69
+ ?TESTED_MODULE:response("Ending with ? means a question.")).
43
70
 
71
+ non_letters_with_question_test() ->
72
+ ?assertMatch("Sure.", ?TESTED_MODULE:response(":) ?")).
44
73
 
45
- responds_to_non_letters_with_question_test() ->
46
- bob_responds(":) ?", "Sure.").
74
+ prattling_on_test() ->
75
+ ?assertMatch("Sure.",
76
+ ?TESTED_MODULE:response("Wait! Hang on. Are you going to be OK?")).
47
77
 
48
- responds_to_multiple_line_questions_test() ->
49
- bob_responds("\nDoes this cryogenic chamber make me look fat? \nno",
50
- "Whatever.").
78
+ silence_test() ->
79
+ ?assertMatch("Fine. Be that way!",
80
+ ?TESTED_MODULE:response([])).
51
81
 
52
- %% This one is especially challenging in Erlang, hint: use the re module.
82
+ prolonged_silence_test() ->
83
+ ?assertMatch("Fine. Be that way!",
84
+ ?TESTED_MODULE:response(" ")).
53
85
 
54
- %%responds_to_other_whitespace_test() ->
55
- %% bob_responds("\n\r \t\v\xA0\x{2002}",
56
- %% "Fine. Be that way!").
86
+ alternate_silence_test() ->
87
+ ?assertMatch("Fine. Be that way!",
88
+ ?TESTED_MODULE:response("\t\t\t\t\t\t\t\t\t\t")).
57
89
 
58
- responds_to_only_numbers_test() ->
59
- bob_responds("1, 2, 3", "Whatever.").
90
+ multiple_line_question_test() ->
91
+ ?assertMatch("Whatever.",
92
+ ?TESTED_MODULE:response("\nDoes this cryogenic chamber make me "
93
+ "look fat?\nno")).
60
94
 
61
- responds_to_question_with_only_numbers_test() ->
62
- bob_responds("4?", "Sure.").
95
+ starting_with_whitespace_test() ->
96
+ ?assertMatch("Whatever.",
97
+ ?TESTED_MODULE:response(" hmmmmmmm...")).
63
98
 
64
- responds_to_unicode_shout_test() ->
65
- bob_responds("\xdcML\xc4\xdcTS!", "Whoa, chill out!").
99
+ ending_with_whitespace_test() ->
100
+ ?assertMatch("Sure.",
101
+ ?TESTED_MODULE:response("Okay if like my spacebar quite a bit? ")).
66
102
 
67
- responds_to_unicode_non_shout_test() ->
68
- bob_responds("\xdcML\xe4\xdcTS!", "Whatever.").
103
+ other_whitespace_test() ->
104
+ ?assertMatch("Fine. Be that way!",
105
+ ?TESTED_MODULE:response("\n\r \t")).
69
106
 
70
- bob_responds(Question, Answer) ->
71
- ?assertEqual(Answer, ?TESTED_MODULE:response_for(Question)).
107
+ non_question_ending_with_whitespace_test() ->
108
+ ?assertMatch("Whatever.",
109
+ ?TESTED_MODULE:response("This is a statement ending with whitespace "
110
+ " ")).
@@ -1,5 +1,7 @@
1
1
  -module(collatz_conjecture_tests).
2
2
 
3
+ % This file is automatically generated from the exercises canonical data.
4
+
3
5
  -define(TESTED_MODULE, (sut(collatz_conjecture))).
4
6
  -define(TEST_VERSION, 2).
5
7
  -include("exercism.hrl").
@@ -1,15 +1,15 @@
1
1
  -module(example).
2
2
 
3
- -export([hamming_distance/2, test_version/0]).
3
+ -export([distance/2, test_version/0]).
4
4
 
5
- hamming_distance(From, To) ->
6
- Comparisons = lists:zipwith(fun(X,Y) -> case X =:= Y of
7
- true -> 0;
8
- false -> 1
9
- end
10
- end,
11
- From, To),
12
- lists:sum(Comparisons).
5
+ distance(Strand1, Strand2) ->
6
+ walk(Strand1, Strand2, 0).
13
7
 
14
8
  test_version() ->
15
- 1.
9
+ 2.
10
+
11
+
12
+ walk([], [], Dist) -> Dist;
13
+ walk([A|As], [A|Bs], Dist) -> walk(As, Bs, Dist);
14
+ walk([_|As], [_|Bs], Dist) -> walk(As, Bs, Dist + 1);
15
+ walk(_, _, _) -> {error, "left and right strands must be of equal length"}.
@@ -1,8 +1,8 @@
1
1
  -module(hamming).
2
2
 
3
- -export([hamming_distance/2, test_version/0]).
3
+ -export([distance/2, test_version/0]).
4
4
 
5
- hamming_distance(From, To) ->
6
- undefined.
7
5
 
8
- test_version() -> 1.
6
+ distance(Strand1, Strand2) -> undefined.
7
+
8
+ test_version() -> 2.