trackler 2.2.1.85 → 2.2.1.86

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 (220) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/alphametics/canonical-data.json +29 -11
  4. data/problem-specifications/exercises/binary-search-tree/canonical-data.json +177 -0
  5. data/problem-specifications/package.json +2 -2
  6. data/problem-specifications/yarn.lock +61 -51
  7. data/tracks/bash/CONTRIBUTING.md +10 -6
  8. data/tracks/bash/README.md +1 -0
  9. data/tracks/bash/exercises/acronym/README.md +1 -1
  10. data/tracks/bash/exercises/anagram/README.md +1 -1
  11. data/tracks/bash/exercises/anagram/{anagram_tests.sh → anagram_test.sh} +0 -0
  12. data/tracks/bash/exercises/armstrong-numbers/armstrong_numbers_test.sh +25 -17
  13. data/tracks/bash/exercises/armstrong-numbers/example.sh +18 -12
  14. data/tracks/bash/exercises/atbash-cipher/README.md +1 -1
  15. data/tracks/bash/exercises/atbash-cipher/{atbash_cipher_tests.sh → atbash_cipher_test.sh} +0 -0
  16. data/tracks/bash/exercises/difference-of-squares/README.md +1 -1
  17. data/tracks/bash/exercises/gigasecond/README.md +1 -1
  18. data/tracks/bash/exercises/hamming/README.md +1 -1
  19. data/tracks/bash/exercises/hello-world/README.md +1 -1
  20. data/tracks/bash/exercises/leap/README.md +1 -1
  21. data/tracks/bash/exercises/luhn/README.md +1 -1
  22. data/tracks/bash/exercises/nucleotide-count/README.md +1 -1
  23. data/tracks/bash/exercises/pangram/README.md +1 -1
  24. data/tracks/bash/exercises/pangram/{pangram_tests.sh → pangram_test.sh} +0 -0
  25. data/tracks/bash/exercises/phone-number/README.md +1 -1
  26. data/tracks/bash/exercises/phone-number/{phone_number_tests.sh → phone_number_test.sh} +0 -0
  27. data/tracks/bash/exercises/raindrops/README.md +1 -1
  28. data/tracks/bash/exercises/rna-transcription/README.md +1 -1
  29. data/tracks/bash/exercises/triangle/example.sh +23 -4
  30. data/tracks/bash/exercises/triangle/triangle_test.sh +17 -0
  31. data/tracks/bash/exercises/two-fer/README.md +1 -1
  32. data/tracks/bash/exercises/word-count/README.md +1 -1
  33. data/tracks/c/config.json +11 -0
  34. data/tracks/c/exercises/complex-numbers/README.md +67 -0
  35. data/tracks/c/exercises/complex-numbers/makefile +27 -0
  36. data/tracks/c/exercises/complex-numbers/src/complex_numbers.c +46 -0
  37. data/tracks/c/exercises/complex-numbers/src/complex_numbers.h +19 -0
  38. data/tracks/c/exercises/complex-numbers/src/example.c +80 -0
  39. data/tracks/c/exercises/complex-numbers/test/test_complex_numbers.c +397 -0
  40. data/tracks/c/exercises/complex-numbers/test/vendor/unity.c +1300 -0
  41. data/tracks/c/exercises/complex-numbers/test/vendor/unity.h +274 -0
  42. data/tracks/c/exercises/complex-numbers/test/vendor/unity_internals.h +701 -0
  43. data/tracks/crystal/.github/stale.yml +18 -0
  44. data/tracks/csharp/exercises/bob/README.md +3 -2
  45. data/tracks/ecmascript/config.json +4 -4
  46. data/tracks/fsharp/exercises/bob/README.md +4 -2
  47. data/tracks/fsharp/exercises/react/ReactTest.fs +137 -74
  48. data/tracks/fsharp/generators/Generators.fs +76 -0
  49. data/tracks/go/exercises/tree-building/tree_test.go +15 -0
  50. data/tracks/haskell/.travis.yml +1 -1
  51. data/tracks/haskell/exercises/accumulate/stack.yaml +1 -1
  52. data/tracks/haskell/exercises/acronym/package.yaml +1 -1
  53. data/tracks/haskell/exercises/acronym/stack.yaml +1 -1
  54. data/tracks/haskell/exercises/all-your-base/package.yaml +1 -1
  55. data/tracks/haskell/exercises/all-your-base/stack.yaml +1 -1
  56. data/tracks/haskell/exercises/all-your-base/test/Tests.hs +6 -6
  57. data/tracks/haskell/exercises/allergies/package.yaml +1 -1
  58. data/tracks/haskell/exercises/allergies/stack.yaml +1 -1
  59. data/tracks/haskell/exercises/alphametics/stack.yaml +1 -1
  60. data/tracks/haskell/exercises/anagram/package.yaml +1 -1
  61. data/tracks/haskell/exercises/anagram/stack.yaml +1 -1
  62. data/tracks/haskell/exercises/atbash-cipher/package.yaml +1 -1
  63. data/tracks/haskell/exercises/atbash-cipher/stack.yaml +1 -1
  64. data/tracks/haskell/exercises/bank-account/stack.yaml +1 -1
  65. data/tracks/haskell/exercises/beer-song/stack.yaml +1 -1
  66. data/tracks/haskell/exercises/binary-search-tree/package.yaml +1 -1
  67. data/tracks/haskell/exercises/binary-search-tree/stack.yaml +1 -1
  68. data/tracks/haskell/exercises/binary-search-tree/test/Tests.hs +3 -0
  69. data/tracks/haskell/exercises/binary/stack.yaml +1 -1
  70. data/tracks/haskell/exercises/bob/package.yaml +1 -1
  71. data/tracks/haskell/exercises/bob/stack.yaml +1 -1
  72. data/tracks/haskell/exercises/bowling/stack.yaml +1 -1
  73. data/tracks/haskell/exercises/bracket-push/package.yaml +1 -1
  74. data/tracks/haskell/exercises/bracket-push/stack.yaml +1 -1
  75. data/tracks/haskell/exercises/change/package.yaml +1 -1
  76. data/tracks/haskell/exercises/change/stack.yaml +1 -1
  77. data/tracks/haskell/exercises/clock/stack.yaml +1 -1
  78. data/tracks/haskell/exercises/collatz-conjecture/package.yaml +1 -1
  79. data/tracks/haskell/exercises/collatz-conjecture/stack.yaml +1 -1
  80. data/tracks/haskell/exercises/complex-numbers/stack.yaml +1 -1
  81. data/tracks/haskell/exercises/connect/package.yaml +1 -1
  82. data/tracks/haskell/exercises/connect/stack.yaml +1 -1
  83. data/tracks/haskell/exercises/crypto-square/package.yaml +1 -1
  84. data/tracks/haskell/exercises/crypto-square/stack.yaml +1 -1
  85. data/tracks/haskell/exercises/custom-set/stack.yaml +1 -1
  86. data/tracks/haskell/exercises/diamond/package.yaml +1 -1
  87. data/tracks/haskell/exercises/diamond/stack.yaml +1 -1
  88. data/tracks/haskell/exercises/difference-of-squares/package.yaml +1 -1
  89. data/tracks/haskell/exercises/difference-of-squares/stack.yaml +1 -1
  90. data/tracks/haskell/exercises/dominoes/package.yaml +1 -1
  91. data/tracks/haskell/exercises/dominoes/stack.yaml +1 -1
  92. data/tracks/haskell/exercises/etl/stack.yaml +1 -1
  93. data/tracks/haskell/exercises/food-chain/stack.yaml +1 -1
  94. data/tracks/haskell/exercises/forth/stack.yaml +1 -1
  95. data/tracks/haskell/exercises/gigasecond/stack.yaml +1 -1
  96. data/tracks/haskell/exercises/go-counting/stack.yaml +1 -1
  97. data/tracks/haskell/exercises/grade-school/stack.yaml +1 -1
  98. data/tracks/haskell/exercises/grains/stack.yaml +1 -1
  99. data/tracks/haskell/exercises/hamming/stack.yaml +1 -1
  100. data/tracks/haskell/exercises/hello-world/stack.yaml +1 -1
  101. data/tracks/haskell/exercises/hexadecimal/stack.yaml +1 -1
  102. data/tracks/haskell/exercises/house/stack.yaml +1 -1
  103. data/tracks/haskell/exercises/isbn-verifier/examples/success-standard/src/IsbnVerifier.hs +1 -0
  104. data/tracks/haskell/exercises/isbn-verifier/package.yaml +1 -1
  105. data/tracks/haskell/exercises/isbn-verifier/stack.yaml +1 -1
  106. data/tracks/haskell/exercises/isbn-verifier/test/Tests.hs +4 -0
  107. data/tracks/haskell/exercises/isogram/stack.yaml +1 -1
  108. data/tracks/haskell/exercises/kindergarten-garden/stack.yaml +1 -1
  109. data/tracks/haskell/exercises/largest-series-product/stack.yaml +1 -1
  110. data/tracks/haskell/exercises/leap/stack.yaml +1 -1
  111. data/tracks/haskell/exercises/lens-person/stack.yaml +1 -1
  112. data/tracks/haskell/exercises/linked-list/stack.yaml +1 -1
  113. data/tracks/haskell/exercises/list-ops/stack.yaml +1 -1
  114. data/tracks/haskell/exercises/luhn/package.yaml +1 -1
  115. data/tracks/haskell/exercises/luhn/stack.yaml +1 -1
  116. data/tracks/haskell/exercises/luhn/test/Tests.hs +1 -1
  117. data/tracks/haskell/exercises/matrix/stack.yaml +1 -1
  118. data/tracks/haskell/exercises/meetup/package.yaml +1 -1
  119. data/tracks/haskell/exercises/meetup/stack.yaml +1 -1
  120. data/tracks/haskell/exercises/minesweeper/stack.yaml +1 -1
  121. data/tracks/haskell/exercises/nth-prime/stack.yaml +1 -1
  122. data/tracks/haskell/exercises/nucleotide-count/stack.yaml +1 -1
  123. data/tracks/haskell/exercises/ocr-numbers/stack.yaml +1 -1
  124. data/tracks/haskell/exercises/octal/stack.yaml +1 -1
  125. data/tracks/haskell/exercises/palindrome-products/stack.yaml +1 -1
  126. data/tracks/haskell/exercises/pangram/stack.yaml +1 -1
  127. data/tracks/haskell/exercises/parallel-letter-frequency/stack.yaml +1 -1
  128. data/tracks/haskell/exercises/pascals-triangle/stack.yaml +1 -1
  129. data/tracks/haskell/exercises/perfect-numbers/stack.yaml +1 -1
  130. data/tracks/haskell/exercises/phone-number/stack.yaml +1 -1
  131. data/tracks/haskell/exercises/pig-latin/stack.yaml +1 -1
  132. data/tracks/haskell/exercises/pov/stack.yaml +1 -1
  133. data/tracks/haskell/exercises/prime-factors/stack.yaml +1 -1
  134. data/tracks/haskell/exercises/pythagorean-triplet/stack.yaml +1 -1
  135. data/tracks/haskell/exercises/queen-attack/stack.yaml +1 -1
  136. data/tracks/haskell/exercises/rail-fence-cipher/package.yaml +1 -1
  137. data/tracks/haskell/exercises/rail-fence-cipher/stack.yaml +1 -1
  138. data/tracks/haskell/exercises/raindrops/stack.yaml +1 -1
  139. data/tracks/haskell/exercises/rna-transcription/package.yaml +1 -1
  140. data/tracks/haskell/exercises/rna-transcription/stack.yaml +1 -1
  141. data/tracks/haskell/exercises/rna-transcription/test/Tests.hs +0 -12
  142. data/tracks/haskell/exercises/robot-name/stack.yaml +1 -1
  143. data/tracks/haskell/exercises/robot-simulator/stack.yaml +1 -1
  144. data/tracks/haskell/exercises/roman-numerals/stack.yaml +1 -1
  145. data/tracks/haskell/exercises/rotational-cipher/stack.yaml +1 -1
  146. data/tracks/haskell/exercises/run-length-encoding/stack.yaml +1 -1
  147. data/tracks/haskell/exercises/saddle-points/stack.yaml +1 -1
  148. data/tracks/haskell/exercises/say/stack.yaml +1 -1
  149. data/tracks/haskell/exercises/scrabble-score/stack.yaml +1 -1
  150. data/tracks/haskell/exercises/secret-handshake/stack.yaml +1 -1
  151. data/tracks/haskell/exercises/series/stack.yaml +1 -1
  152. data/tracks/haskell/exercises/sgf-parsing/stack.yaml +1 -1
  153. data/tracks/haskell/exercises/sieve/stack.yaml +1 -1
  154. data/tracks/haskell/exercises/simple-cipher/stack.yaml +1 -1
  155. data/tracks/haskell/exercises/simple-linked-list/stack.yaml +1 -1
  156. data/tracks/haskell/exercises/space-age/stack.yaml +1 -1
  157. data/tracks/haskell/exercises/spiral-matrix/stack.yaml +1 -1
  158. data/tracks/haskell/exercises/strain/stack.yaml +1 -1
  159. data/tracks/haskell/exercises/sublist/stack.yaml +1 -1
  160. data/tracks/haskell/exercises/sum-of-multiples/stack.yaml +1 -1
  161. data/tracks/haskell/exercises/triangle/stack.yaml +1 -1
  162. data/tracks/haskell/exercises/trinary/stack.yaml +1 -1
  163. data/tracks/haskell/exercises/twelve-days/stack.yaml +1 -1
  164. data/tracks/haskell/exercises/word-count/stack.yaml +1 -1
  165. data/tracks/haskell/exercises/wordy/stack.yaml +1 -1
  166. data/tracks/haskell/exercises/zebra-puzzle/stack.yaml +1 -1
  167. data/tracks/haskell/exercises/zipper/stack.yaml +1 -1
  168. data/tracks/java/config.json +12 -0
  169. data/tracks/java/exercises/alphametics/.meta/src/reference/java/Alphametics.java +125 -0
  170. data/tracks/java/exercises/alphametics/.meta/src/reference/java/UnsolvablePuzzleException.java +2 -0
  171. data/tracks/java/exercises/alphametics/.meta/src/version +1 -0
  172. data/tracks/java/exercises/alphametics/README.md +47 -0
  173. data/tracks/java/exercises/alphametics/build.gradle +18 -0
  174. data/tracks/java/exercises/alphametics/src/main/java/.keep +0 -0
  175. data/tracks/java/exercises/alphametics/src/main/java/UnsolvablePuzzleException.java +2 -0
  176. data/tracks/java/exercises/alphametics/src/test/java/AlphameticsTest.java +150 -0
  177. data/tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java +5 -4
  178. data/tracks/java/exercises/beer-song/.meta/version +1 -0
  179. data/tracks/java/exercises/beer-song/src/test/java/BeerSongTest.java +24 -16
  180. data/tracks/java/exercises/binary-search/.meta/version +1 -0
  181. data/tracks/java/exercises/book-store/.meta/version +1 -0
  182. data/tracks/java/exercises/book-store/src/test/java/BookStoreTest.java +15 -8
  183. data/tracks/java/exercises/circular-buffer/.meta/version +1 -0
  184. data/tracks/java/exercises/list-ops/.meta/version +1 -1
  185. data/tracks/java/exercises/list-ops/src/test/java/ListOpsTest.java +1 -1
  186. data/tracks/java/exercises/nth-prime/.meta/version +1 -0
  187. data/tracks/java/exercises/settings.gradle +1 -0
  188. data/tracks/java/exercises/tournament/.meta/version +1 -0
  189. data/tracks/java/exercises/transpose/.meta/version +1 -0
  190. data/tracks/java/exercises/transpose/src/test/java/TransposeTest.java +29 -74
  191. data/tracks/java/exercises/wordy/.meta/version +1 -0
  192. data/tracks/javascript/.eslintignore +0 -1
  193. data/tracks/javascript/config.json +13 -3
  194. data/tracks/javascript/exercises/bowling/example.js +24 -10
  195. data/tracks/javascript/exercises/forth/README.md +56 -0
  196. data/tracks/javascript/exercises/forth/example.js +66 -0
  197. data/tracks/javascript/exercises/forth/forth.spec.js +259 -0
  198. data/tracks/lua/config.json +92 -81
  199. data/tracks/lua/exercises/accumulate/README.md +42 -0
  200. data/tracks/lua/exercises/beer-song/README.md +1 -1
  201. data/tracks/lua/exercises/bob/README.md +2 -0
  202. data/tracks/lua/exercises/crypto-square/README.md +6 -4
  203. data/tracks/lua/exercises/house/README.md +1 -1
  204. data/tracks/lua/exercises/isbn-verifier/README.md +25 -20
  205. data/tracks/lua/exercises/kindergarten-garden/README.md +3 -3
  206. data/tracks/lua/exercises/meetup/README.md +16 -12
  207. data/tracks/lua/exercises/nucleotide-count/README.md +2 -2
  208. data/tracks/lua/exercises/phone-number/README.md +1 -1
  209. data/tracks/lua/exercises/pov/README.md +0 -2
  210. data/tracks/lua/exercises/queen-attack/README.md +22 -22
  211. data/tracks/lua/exercises/rectangles/README.md +9 -9
  212. data/tracks/lua/exercises/reverse-string/README.md +23 -0
  213. data/tracks/lua/exercises/reverse-string/example.lua +7 -0
  214. data/tracks/lua/exercises/reverse-string/reverse-string_spec.lua +24 -0
  215. data/tracks/lua/exercises/secret-handshake/README.md +1 -1
  216. data/tracks/lua/exercises/space-age/README.md +1 -2
  217. data/tracks/lua/exercises/sum-of-multiples/README.md +3 -3
  218. data/tracks/perl6/exercises/two-fer/README.md +1 -1
  219. data/tracks/python/exercises/luhn/luhn_test.py +1 -1
  220. metadata +39 -6
@@ -63,11 +63,11 @@ Currently, you're interested in all of the `"cases"`. Each of these is a test c
63
63
  Implement each of the test cases (along with any comments or explanations you think are necessary for people who aren't sure of themselves). When in doubt, check out the other, already implemented exercises for an example. Here's an example of implementing the test case shown above.
64
64
 
65
65
  ```bash
66
- #!/bin/bash
66
+ #!/usr/bin/env bats
67
67
 
68
68
  @test 'Say Hi!' {
69
69
  run bash hello_world.sh
70
-
70
+
71
71
  [ "$status" -eq 0 ]
72
72
  [ "$output" = "Hello, World" ]
73
73
  }
@@ -77,6 +77,8 @@ Implement each of the test cases (along with any comments or explanations you th
77
77
 
78
78
  For each test you create, you should use the `description` value for the test case description. The `property` value is generally used by other languages to specify what the function to be run is called. Use your best judgement and check out how other exercises handle this. If there's just one property, you can just test the script as a whole. If there's multiple properties, consider testing those as either subcommands or flags (e.g. an exercise with an encode and a decode property could be handled by `run bash cyper.sh encode <argument>` or by `run bash cypher.sh -e <argument>`). You're the one writing the tests, so you decide. You'll get feedback when you open your pull request anyways, so don't stress too much about it.
79
79
 
80
+ For test cases that are expected to return `true` or `false` make sure you are expecting an output value. It is better to return `"true"` or `true`, to the console instead of just relying on the exit status in bash (0 for success, 1-255 for error). This will be consistent with the existing exercises and prevent possible issues in the future.
81
+
80
82
  You can check to see if your example script works by running `bats`.
81
83
 
82
84
  ```bash
@@ -85,7 +87,7 @@ $ bats hello_world_test.sh
85
87
 
86
88
  ### Implementing an Example Solution
87
89
 
88
- If you've been following along so far, your tests should fail. Go ahead and implement your solution in the `<your-exercise>.sh` file. Make sure your file has `#!/bin/bash` at the top.
90
+ If you've been following along so far, your tests should fail. Go ahead and implement your solution in the `<your-exercise>.sh` file. Make sure your file has `#!/usr/bin/env bash` ([shebang][shebang]) at the top.
89
91
 
90
92
  Keep running your test file against it until your tests all pass. This process should help ensure that both your tests *and* your example are ship shape!
91
93
 
@@ -178,10 +180,10 @@ It's possible to submit an incomplete solution so you can see how others have co
178
180
 
179
181
  ### Cleaning Up
180
182
 
181
- 20. If you've been practicing good version control throughout this process, you may have several commits. At this point, you're almost ready to submit your pull request, but you should rebase against the most recent upstream master branch.
183
+ If you've been practicing good version control throughout this process, you may have several commits. At this point, you're almost ready to submit your pull request, but you should rebase against the most recent upstream master branch.
182
184
 
183
185
  ```bash
184
- # Assuming you've alread 'git added' and 'git commited'
186
+ # Assuming you've already 'git added' and 'git commited'
185
187
  # If you don't already have the exercism/bash as your upstream remote:
186
188
  $ git remote add upstream https://github.com/exercism/bash.git
187
189
  # To get the most recent upstream version
@@ -190,7 +192,7 @@ $ git fetch upstream
190
192
  $ git rebase upstream/master
191
193
  ```
192
194
 
193
- 21. Now you're ready to sync up with Github and open your pull request!
195
+ Now you're ready to sync up with Github and open your pull request!
194
196
 
195
197
  ```bash
196
198
  $ git push --force-with-lease origin <your-branch-name>
@@ -199,3 +201,5 @@ $ git push --force-with-lease origin <your-branch-name>
199
201
  ![Create pull request](img/create-pr.png)
200
202
 
201
203
  Good luck, happy scripting, and thanks for your help!
204
+
205
+ [shebang]: https://en.wikipedia.org/wiki/Shebang_(Unix)
@@ -1,5 +1,6 @@
1
1
  # Exercism Bash Track
2
2
 
3
+ [![Build Status](https://travis-ci.org/exercism/bash.svg?branch=master)](https://travis-ci.org/exercism/bash)
3
4
  [![Gitter](https://badges.gitter.im/exercism/bash.svg)](https://gitter.im/exercism/bash?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
4
5
 
5
6
  Exercism Exercises in Bash
@@ -8,7 +8,7 @@ Help generate some jargon by writing a program that converts a long name like Po
8
8
 
9
9
  Run the tests with:
10
10
 
11
- bats whatever_test.sh
11
+ bats acronym_tests.sh
12
12
 
13
13
  ## Submitting Exercises
14
14
 
@@ -8,7 +8,7 @@ Given `"listen"` and a list of candidates like `"enlists" "google"
8
8
 
9
9
  Run the tests with:
10
10
 
11
- bats whatever_test.sh
11
+ bats anagram_test.sh
12
12
 
13
13
  ## Source
14
14
 
@@ -1,58 +1,66 @@
1
1
  #!/usr/bin/env bats
2
2
 
3
- @test 'Single digits are armstrong numbers' {
4
- #skip
5
- run ./armstrong_numbers.sh isarmstrong 5
3
+ @test 'Single digits are Armstrong numbers' {
4
+ # skip
5
+ run ./armstrong_numbers.sh is_armstrong 5
6
6
 
7
7
  [ "$status" -eq 0 ]
8
+ [ "$output" = "true" ]
8
9
  }
9
10
 
10
- @test 'There are no two digit armstrong numbers' {
11
+ @test 'There are no two digit Armstrong numbers' {
11
12
  skip
12
- run ./armstrong_numbers.sh isarmstrong 10
13
+ run ./armstrong_numbers.sh is_armstrong 10
13
14
 
14
15
  [ "$status" -eq 1 ]
16
+ [ "$output" = "false" ]
15
17
  }
16
18
 
17
- @test 'A three digit number that is an armstrong number' {
19
+ @test 'A three digit number that is an Armstrong number' {
18
20
  skip
19
- run ./armstrong_numbers.sh isarmstrong 153
21
+ run ./armstrong_numbers.sh is_armstrong 153
20
22
 
21
23
  [ "$status" -eq 0 ]
24
+ [ "$output" = "true" ]
22
25
  }
23
26
 
24
- @test 'A three digit number that is not an armstrong number' {
27
+ @test 'A three digit number that is not an Armstrong number' {
25
28
  skip
26
- run ./armstrong_numbers.sh isarmstrong 100
29
+ run ./armstrong_numbers.sh is_armstrong 100
27
30
 
28
31
  [ "$status" -eq 1 ]
32
+ [ "$output" = "false" ]
29
33
  }
30
34
 
31
- @test 'A four digit number that is an armstrong number' {
35
+ @test 'A four digit number that is an Armstrong number' {
32
36
  skip
33
- run ./armstrong_numbers.sh isarmstrong 9475
37
+ run ./armstrong_numbers.sh is_armstrong 9474
34
38
 
35
39
  [ "$status" -eq 0 ]
40
+ [ "$output" = "true" ]
36
41
  }
37
42
 
38
- @test 'A four digit number that is not an armstrong number' {
43
+ @test 'A four digit number that is not an Armstrong number' {
39
44
  skip
40
- run ./armstrong_numbers.sh isarmstrong 9475
45
+ run ./armstrong_numbers.sh is_armstrong 9475
41
46
 
42
47
  [ "$status" -eq 1 ]
48
+ [ "$output" = "false" ]
43
49
  }
44
50
 
45
- @test 'A seven digit number that is an armstrong number' {
51
+ @test 'A seven digit number that is an Armstrong number' {
46
52
  skip
47
- run ./armstrong_numbers.sh isarmstrong 9926315
53
+ run ./armstrong_numbers.sh is_armstrong 9926315
48
54
 
49
55
  [ "$status" -eq 0 ]
56
+ [ "$output" = "true" ]
50
57
  }
51
58
 
52
- @test 'A seven digit number that is not an armstrong number' {
59
+ @test 'A seven digit number that is not an Armstrong number' {
53
60
  skip
54
- run ./armstrong_numbers.sh isarmstrong 9926314
61
+ run ./armstrong_numbers.sh is_armstrong 9926314
55
62
 
56
63
  [ "$status" -eq 1 ]
64
+ [ "$output" = "false" ]
57
65
  }
58
66
 
@@ -1,19 +1,25 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- isarmstrong() {
3
+ is_armstrong() {
4
4
  sum=0
5
- item=$1
6
- while [ $item -ne 0 ]
7
- do
8
- rem=`expr $item % 10`
9
- cube=`expr $rem \* $rem \* $rem`
10
- sum=`expr $sum + $cube`
11
- item=`expr $item / 10`
5
+ number=$1
6
+ power=${#number}
7
+
8
+ index=1
9
+ while [ $index -le ${#number} ]; do
10
+ digit=$(echo ${number} | cut -c${index}-${index})
11
+ sum=$(expr $sum + $(($digit**$power)))
12
+
13
+ index=$(expr $index + 1)
12
14
  done
13
- if [ $sum -eq $num ]
14
- then
15
- return 0
15
+
16
+ if [ $sum -eq $number ]; then
17
+ echo "true"
18
+ exit 0
16
19
  else
17
- return 1
20
+ echo "false"
21
+ exit 1
18
22
  fi
19
23
  }
24
+
25
+ "$@"
@@ -31,7 +31,7 @@ things based on word boundaries.
31
31
  To run the tests:
32
32
 
33
33
  ```sh
34
- $ bats atbash_cipher_tests.sh
34
+ $ bats atbash_cipher_test.sh
35
35
  ```
36
36
 
37
37
  For more detailed info about the Bash track see the [help page](http://exercism.io/languages/bash).
@@ -14,7 +14,7 @@ natural numbers is 3025 - 385 = 2640.
14
14
 
15
15
  Run the tests with:
16
16
 
17
- bats whatever_test.sh
17
+ bats difference_of_squares_test.sh
18
18
 
19
19
  ## Source
20
20
 
@@ -6,7 +6,7 @@ A gigasecond is 10^9 (1,000,000,000) seconds.
6
6
 
7
7
  Run the tests with:
8
8
 
9
- bats whatever_test.sh
9
+ bats gigasecond_test.sh
10
10
 
11
11
  ## Source
12
12
 
@@ -37,7 +37,7 @@ of equal length differently.
37
37
 
38
38
  Run the tests with:
39
39
 
40
- bats whatever_test.sh
40
+ bats hamming_test.sh
41
41
 
42
42
  ## Source
43
43
 
@@ -56,7 +56,7 @@ seconds
56
56
 
57
57
  Run the tests with:
58
58
 
59
- bats whatever_test.sh
59
+ bats hello_world_test.sh
60
60
 
61
61
  ## Source
62
62
 
@@ -28,7 +28,7 @@ phenomenon, go watch [this youtube video][video].
28
28
 
29
29
  Run the tests with:
30
30
 
31
- bats whatever_test.sh
31
+ bats leap_test.sh
32
32
 
33
33
  ## Source
34
34
 
@@ -66,7 +66,7 @@ Sum the digits
66
66
 
67
67
  Run the tests with:
68
68
 
69
- bats whatever_test.sh
69
+ bats luhn_test.sh
70
70
 
71
71
  ## Source
72
72
 
@@ -28,7 +28,7 @@ about that for now.
28
28
 
29
29
  Run the tests with:
30
30
 
31
- bats whatever_test.sh
31
+ bats nucleotide_count_test.sh
32
32
 
33
33
  ## Source
34
34
 
@@ -10,7 +10,7 @@ insensitive. Input will not contain non-ASCII symbols.
10
10
 
11
11
  Run the tests with:
12
12
 
13
- bats whatever_test.sh
13
+ bats pangram_test.sh
14
14
 
15
15
  ## Source
16
16
 
@@ -29,7 +29,7 @@ should all produce the output
29
29
 
30
30
  Run the tests with:
31
31
 
32
- bats whatever_test.sh
32
+ bats phone_number_test.sh
33
33
 
34
34
  ## Source
35
35
 
@@ -19,7 +19,7 @@ Convert a number to a string, the contents of which depend on the number's facto
19
19
 
20
20
  Run the tests with:
21
21
 
22
- bats whatever_test.sh
22
+ bats raindrop_test.sh
23
23
 
24
24
  ## Source
25
25
 
@@ -20,7 +20,7 @@ each nucleotide with its complement:
20
20
 
21
21
  Run the tests with:
22
22
 
23
- bats whatever_test.sh
23
+ bats rna_transcription_test.sh
24
24
 
25
25
  ## Source
26
26
 
@@ -21,31 +21,50 @@ assert() {
21
21
  [[ $( echo $1 | bc -l ) -eq 1 ]]
22
22
  }
23
23
 
24
+ output() {
25
+ exit_code=$1
26
+
27
+ if [ $exit_code -eq 0 ]; then
28
+ echo "true"
29
+ else
30
+ echo "false"
31
+ fi
32
+
33
+ exit $exit_code
34
+ }
35
+
24
36
  valid_triangle() {
25
37
  # Takes three sides lengths (numeric) $1, $2, $3
26
38
  # If any side is zero, returns false
27
39
  assert "$1 == 0" || assert "$2 == 0" || assert "$3 == 0" && return 1
28
40
  # If triangle doesn't meet inequality requirement, returns false
29
41
  assert "$1 + $2 <= $3" || assert "$1 + $3 <= $2" || assert "$2 + $3 <= $1" && return 1
42
+
30
43
  return 0
31
44
  }
32
45
 
33
46
  if ! valid_triangle $s1 $s2 $s3; then
34
- echo "Sides do not meet triangle inequality requirement."
35
- echo "Given a <= b <= c and a, b, c != 0, a + b >= c"
36
- exit 1
47
+ # Sides do not meet triangle inequality requirement
48
+ # Given a <= b <= c and a, b, c != 0, a + b >= c
49
+ output 1
37
50
  fi
38
51
 
39
52
  equilateral() {
40
53
  assert "$1 == $2" && assert "$1 == $3"
54
+
55
+ output $?
41
56
  }
42
57
 
43
58
  isosceles() {
44
59
  assert "$1 == $2" || assert "$1 == $3" || assert "$2 == $3"
60
+
61
+ output $?
45
62
  }
46
-
63
+
47
64
  scalene() {
48
65
  assert "$1 != $2" && assert "$1 != $3" && assert "$2 != $3"
66
+
67
+ output $?
49
68
  }
50
69
 
51
70
  # Bash Ternary Operator:
@@ -6,6 +6,7 @@
6
6
  run bash triangle.sh equilateral 2 2 2
7
7
 
8
8
  [ "$status" -eq 0 ]
9
+ [ "$output" = "true" ]
9
10
  }
10
11
 
11
12
  @test "false if any side is unequal" {
@@ -13,6 +14,7 @@
13
14
  run bash triangle.sh equilateral 2 3 2
14
15
 
15
16
  [ "$status" -eq 1 ]
17
+ [ "$output" = "false" ]
16
18
  }
17
19
 
18
20
  @test "false if no side is equal" {
@@ -20,6 +22,7 @@
20
22
  run bash triangle.sh equilateral 5 4 6
21
23
 
22
24
  [ "$status" -eq 1 ]
25
+ [ "$output" = "false" ]
23
26
  }
24
27
 
25
28
  @test "all zero sides illegal, so the triangle is not equilateral" {
@@ -27,6 +30,7 @@
27
30
  run bash triangle.sh equilateral 0 0 0
28
31
 
29
32
  [ "$status" -eq 1 ]
33
+ [ "$output" = "false" ]
30
34
  }
31
35
 
32
36
  # BONUS: Deal with floating point numbers
@@ -35,6 +39,7 @@
35
39
  run bash triangle.sh equilateral 0.5 0.5 0.5
36
40
 
37
41
  [ "$status" -eq 0 ]
42
+ [ "$output" = "true" ]
38
43
  }
39
44
 
40
45
  # Test Isosceles
@@ -43,6 +48,7 @@
43
48
  run bash triangle.sh isosceles 3 4 4
44
49
 
45
50
  [ "$status" -eq 0 ]
51
+ [ "$output" = "true" ]
46
52
  }
47
53
 
48
54
  @test "true if first two sides are equal" {
@@ -50,6 +56,7 @@
50
56
  run bash triangle.sh isosceles 4 4 3
51
57
 
52
58
  [ "$status" -eq 0 ]
59
+ [ "$output" = "true" ]
53
60
  }
54
61
 
55
62
  @test "true if first and last sides are equal" {
@@ -57,6 +64,7 @@
57
64
  run bash triangle.sh isosceles 4 3 4
58
65
 
59
66
  [ "$status" -eq 0 ]
67
+ [ "$output" = "true" ]
60
68
  }
61
69
 
62
70
  @test "equilateral triangles are also isosceles" {
@@ -64,6 +72,7 @@
64
72
  run bash triangle.sh isosceles 4 4 4
65
73
 
66
74
  [ "$status" -eq 0 ]
75
+ [ "$output" = "true" ]
67
76
  }
68
77
 
69
78
  @test "false if no sides are equal" {
@@ -71,6 +80,7 @@
71
80
  run bash triangle.sh isosceles 2 3 4
72
81
 
73
82
  [ "$status" -eq 1 ]
83
+ [ "$output" = "false" ]
74
84
  }
75
85
 
76
86
  @test "sides that violate triangle inequality are not isosceles, even if two are equal" {
@@ -78,6 +88,7 @@
78
88
  run bash triangle.sh isosceles 1 1 3
79
89
 
80
90
  [ "$status" -eq 1 ]
91
+ [ "$output" = "false" ]
81
92
  }
82
93
 
83
94
  # BONUS: Deal with floating point numbers
@@ -86,6 +97,7 @@
86
97
  run bash triangle.sh isosceles 0.5 0.4 0.5
87
98
 
88
99
  [ "$status" -eq 0 ]
100
+ [ "$output" = "true" ]
89
101
  }
90
102
 
91
103
  # Test Scalene
@@ -94,6 +106,7 @@
94
106
  run bash triangle.sh scalene 5 4 6
95
107
 
96
108
  [ "$status" -eq 0 ]
109
+ [ "$output" = "true" ]
97
110
  }
98
111
 
99
112
  @test "false if all sides are equal" {
@@ -101,6 +114,7 @@
101
114
  run bash triangle.sh scalene 4 4 4
102
115
 
103
116
  [ "$status" -eq 1 ]
117
+ [ "$output" = "false" ]
104
118
  }
105
119
 
106
120
  @test "false if two sides are equal" {
@@ -108,6 +122,7 @@
108
122
  run bash triangle.sh scalene 4 4 3
109
123
 
110
124
  [ "$status" -eq 1 ]
125
+ [ "$output" = "false" ]
111
126
  }
112
127
 
113
128
  @test "sides that violate triangle inequality are not scalene even if they are all different" {
@@ -115,6 +130,7 @@
115
130
  run bash triangle.sh scalene 7 3 2
116
131
 
117
132
  [ "$status" -eq 1 ]
133
+ [ "$output" = "false" ]
118
134
  }
119
135
 
120
136
  # BONUS: Deal with floating point numbers
@@ -123,4 +139,5 @@
123
139
  run bash triangle.sh scalene 0.5 0.4 0.6
124
140
 
125
141
  [ "$status" -eq 0 ]
142
+ [ "$output" = "true" ]
126
143
  }