trackler 2.2.1.71 → 2.2.1.72

Sign up to get free protection for your applications and to get access to all the features.
Files changed (270) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/book-store/canonical-data.json +9 -2
  4. data/problem-specifications/exercises/word-count/canonical-data.json +9 -0
  5. data/tracks/bash/CONTRIBUTING.md +199 -0
  6. data/tracks/bash/config.json +24 -11
  7. data/tracks/bash/exercises/triangle/README.md +38 -0
  8. data/tracks/bash/exercises/triangle/example.sh +56 -0
  9. data/tracks/bash/exercises/triangle/triangle_test.sh +126 -0
  10. data/tracks/bash/img/canonical-data-example.png +0 -0
  11. data/tracks/bash/img/create-pr.png +0 -0
  12. data/tracks/bash/img/fork-repository.png +0 -0
  13. data/tracks/c/exercises/acronym/makefile +1 -1
  14. data/tracks/c/exercises/all-your-base/makefile +1 -1
  15. data/tracks/c/exercises/allergies/makefile +1 -1
  16. data/tracks/c/exercises/anagram/makefile +1 -1
  17. data/tracks/c/exercises/atbash-cipher/makefile +1 -1
  18. data/tracks/c/exercises/beer-song/makefile +1 -1
  19. data/tracks/c/exercises/binary-search/makefile +1 -1
  20. data/tracks/c/exercises/binary/makefile +1 -1
  21. data/tracks/c/exercises/bob/makefile +1 -1
  22. data/tracks/c/exercises/clock/makefile +1 -1
  23. data/tracks/c/exercises/collatz-conjecture/makefile +1 -1
  24. data/tracks/c/exercises/difference-of-squares/makefile +1 -1
  25. data/tracks/c/exercises/gigasecond/makefile +1 -1
  26. data/tracks/c/exercises/grains/makefile +1 -1
  27. data/tracks/c/exercises/hamming/makefile +1 -1
  28. data/tracks/c/exercises/hamming/test/test_hamming.c +2 -2
  29. data/tracks/c/exercises/hello-world/makefile +1 -1
  30. data/tracks/c/exercises/isogram/makefile +1 -1
  31. data/tracks/c/exercises/largest-series-product/makefile +1 -1
  32. data/tracks/c/exercises/leap/makefile +1 -1
  33. data/tracks/c/exercises/meetup/makefile +1 -1
  34. data/tracks/c/exercises/nth-prime/makefile +1 -1
  35. data/tracks/c/exercises/nucleotide-count/makefile +1 -1
  36. data/tracks/c/exercises/palindrome-products/makefile +1 -1
  37. data/tracks/c/exercises/pangram/makefile +1 -1
  38. data/tracks/c/exercises/pascals-triangle/makefile +1 -1
  39. data/tracks/c/exercises/perfect-numbers/makefile +1 -1
  40. data/tracks/c/exercises/phone-number/makefile +1 -1
  41. data/tracks/c/exercises/queen-attack/makefile +1 -1
  42. data/tracks/c/exercises/raindrops/makefile +1 -1
  43. data/tracks/c/exercises/react/makefile +1 -1
  44. data/tracks/c/exercises/rna-transcription/makefile +1 -1
  45. data/tracks/c/exercises/robot-simulator/makefile +1 -1
  46. data/tracks/c/exercises/roman-numerals/makefile +1 -1
  47. data/tracks/c/exercises/scrabble-score/makefile +1 -1
  48. data/tracks/c/exercises/series/makefile +1 -1
  49. data/tracks/c/exercises/sieve/makefile +1 -1
  50. data/tracks/c/exercises/space-age/makefile +1 -1
  51. data/tracks/c/exercises/sublist/makefile +1 -1
  52. data/tracks/c/exercises/sum-of-multiples/makefile +1 -1
  53. data/tracks/c/exercises/triangle/makefile +1 -1
  54. data/tracks/c/exercises/word-count/makefile +1 -1
  55. data/tracks/delphi/exercises/allergies/README.md +1 -1
  56. data/tracks/delphi/exercises/bank-account/README.md +1 -1
  57. data/tracks/delphi/exercises/beer-song/README.md +1 -1
  58. data/tracks/delphi/exercises/binary-search/README.md +1 -1
  59. data/tracks/delphi/exercises/bob/README.md +1 -1
  60. data/tracks/delphi/exercises/book-store/README.md +1 -1
  61. data/tracks/delphi/exercises/book-store/uBookStoreExample.pas +34 -14
  62. data/tracks/delphi/exercises/book-store/uBookStoreTests.pas +36 -1
  63. data/tracks/delphi/exercises/bowling/README.md +1 -1
  64. data/tracks/delphi/exercises/circular-buffer/README.md +1 -1
  65. data/tracks/delphi/exercises/clock/README.md +1 -1
  66. data/tracks/delphi/exercises/collatz-conjecture/README.md +1 -1
  67. data/tracks/delphi/exercises/etl/README.md +1 -1
  68. data/tracks/delphi/exercises/grains/README.md +1 -1
  69. data/tracks/delphi/exercises/hamming/README.md +1 -1
  70. data/tracks/delphi/exercises/hello-world/README.md +1 -1
  71. data/tracks/delphi/exercises/leap/README.md +1 -1
  72. data/tracks/delphi/exercises/minesweeper/README.md +1 -1
  73. data/tracks/delphi/exercises/nucleotide-count/README.md +1 -1
  74. data/tracks/delphi/exercises/perfect-numbers/README.md +1 -1
  75. data/tracks/delphi/exercises/phone-number/README.md +1 -1
  76. data/tracks/delphi/exercises/pig-latin/README.md +1 -1
  77. data/tracks/delphi/exercises/poker/README.md +1 -1
  78. data/tracks/delphi/exercises/raindrops/README.md +1 -1
  79. data/tracks/delphi/exercises/reverse-string/README.md +1 -1
  80. data/tracks/delphi/exercises/rna-transcription/README.md +1 -1
  81. data/tracks/delphi/exercises/roman-numerals/README.md +1 -1
  82. data/tracks/delphi/exercises/saddle-points/README.md +1 -1
  83. data/tracks/delphi/exercises/triangle/README.md +1 -1
  84. data/tracks/delphi/exercises/two-fer/README.md +1 -1
  85. data/tracks/delphi/exercises/wordy/README.md +1 -1
  86. data/tracks/ecmascript/.travis.yml +1 -1
  87. data/tracks/ecmascript/Makefile +4 -5
  88. data/tracks/ecmascript/README.md +2 -1
  89. data/tracks/ecmascript/config.json +12 -0
  90. data/tracks/ecmascript/exercises/change/package.json +5 -3
  91. data/tracks/ecmascript/exercises/protein-translation/package.json +2 -2
  92. data/tracks/ecmascript/exercises/react/README.md +41 -0
  93. data/tracks/ecmascript/exercises/react/example.js +101 -0
  94. data/tracks/ecmascript/exercises/react/package.json +71 -0
  95. data/tracks/ecmascript/exercises/react/react.spec.js +211 -0
  96. data/tracks/ecmascript/exercises/rectangles/package.json +1 -2
  97. data/tracks/ecmascript/exercises/rotational-cipher/package.json +1 -2
  98. data/tracks/ecmascript/exercises/spiral-matrix/package.json +1 -2
  99. data/tracks/ecmascript/exercises/transpose/package.json +2 -2
  100. data/tracks/erlang/docs/ABOUT.md +1 -1
  101. data/tracks/go/exercises/binary-search/.meta/gen.go +55 -0
  102. data/tracks/go/exercises/binary-search/binary_search_test.go +26 -167
  103. data/tracks/go/exercises/binary-search/cases_test.go +73 -0
  104. data/tracks/go/exercises/binary-search/example.go +8 -30
  105. data/tracks/go/exercises/nth-prime/.meta/gen.go +76 -0
  106. data/tracks/go/exercises/nth-prime/cases_test.go +43 -0
  107. data/tracks/go/exercises/nth-prime/nth_prime_test.go +4 -18
  108. data/tracks/go/exercises/prime-factors/.meta/gen.go +54 -0
  109. data/tracks/go/exercises/prime-factors/cases_test.go +48 -0
  110. data/tracks/go/exercises/prime-factors/prime_factors_test.go +4 -19
  111. data/tracks/groovy/config.json +13 -1
  112. data/tracks/groovy/exercises/linked-list/DoubleLinkedList.groovy +19 -0
  113. data/tracks/groovy/exercises/linked-list/DoubleLinkedListSpec.groovy +79 -0
  114. data/tracks/groovy/exercises/linked-list/Example.groovy +57 -0
  115. data/tracks/groovy/exercises/linked-list/README.md +49 -0
  116. data/tracks/java/bin/run-journey-test-from-ci.sh +1 -1
  117. data/tracks/java/config.json +10 -0
  118. data/tracks/java/config/maintainers.json +8 -1
  119. data/tracks/java/docs/MAINTAINING.md +3 -3
  120. data/tracks/java/exercises/accumulate/.meta/src/reference/java/Accumulate.java +2 -2
  121. data/tracks/java/exercises/binary/.meta/src/reference/java/Binary.java +3 -3
  122. data/tracks/java/exercises/circular-buffer/.meta/src/reference/java/BufferIOException.java +1 -1
  123. data/tracks/java/exercises/circular-buffer/.meta/src/reference/java/CircularBuffer.java +6 -6
  124. data/tracks/java/exercises/circular-buffer/src/main/java/BufferIOException.java +1 -1
  125. data/tracks/java/exercises/clock/.meta/src/reference/java/Clock.java +3 -3
  126. data/tracks/java/exercises/crypto-square/.meta/src/reference/java/Crypto.java +7 -7
  127. data/tracks/java/exercises/etl/.meta/src/reference/java/Etl.java +2 -2
  128. data/tracks/java/exercises/etl/src/main/java/Etl.java +2 -2
  129. data/tracks/java/exercises/kindergarten-garden/.meta/src/reference/java/KindergartenGarden.java +4 -4
  130. data/tracks/java/exercises/kindergarten-garden/.meta/src/reference/java/Plant.java +2 -2
  131. data/tracks/java/exercises/kindergarten-garden/src/main/java/Plant.java +2 -2
  132. data/tracks/java/exercises/nth-prime/.meta/src/reference/java/PrimeCalculator.java +2 -2
  133. data/tracks/java/exercises/reverse-string/.meta/src/reference/java/ReverseString.java +7 -0
  134. data/tracks/java/exercises/reverse-string/.meta/version +1 -0
  135. data/tracks/java/exercises/reverse-string/README.md +25 -0
  136. data/tracks/java/exercises/reverse-string/build.gradle +17 -0
  137. data/tracks/java/exercises/reverse-string/src/main/java/ReverseString.java +7 -0
  138. data/tracks/java/exercises/reverse-string/src/test/java/ReverseStringTest.java +37 -0
  139. data/tracks/java/exercises/run-length-encoding/.meta/src/reference/java/RunLengthEncoding.java +4 -4
  140. data/tracks/java/exercises/settings.gradle +1 -0
  141. data/tracks/kotlin/docs/RESOURCES.md +1 -1
  142. data/tracks/kotlin/exercises/accumulate/build.gradle +1 -1
  143. data/tracks/kotlin/exercises/acronym/build.gradle +1 -1
  144. data/tracks/kotlin/exercises/all-your-base/build.gradle +1 -1
  145. data/tracks/kotlin/exercises/allergies/build.gradle +1 -1
  146. data/tracks/kotlin/exercises/anagram/build.gradle +1 -1
  147. data/tracks/kotlin/exercises/atbash-cipher/build.gradle +1 -1
  148. data/tracks/kotlin/exercises/bank-account/build.gradle +1 -1
  149. data/tracks/kotlin/exercises/beer-song/build.gradle +1 -1
  150. data/tracks/kotlin/exercises/binary-search/build.gradle +1 -1
  151. data/tracks/kotlin/exercises/binary/build.gradle +1 -1
  152. data/tracks/kotlin/exercises/bob/build.gradle +1 -1
  153. data/tracks/kotlin/exercises/bracket-push/build.gradle +1 -1
  154. data/tracks/kotlin/exercises/change/build.gradle +1 -1
  155. data/tracks/kotlin/exercises/clock/build.gradle +1 -1
  156. data/tracks/kotlin/exercises/collatz-conjecture/build.gradle +1 -1
  157. data/tracks/kotlin/exercises/complex-numbers/build.gradle +1 -1
  158. data/tracks/kotlin/exercises/diamond/build.gradle +1 -1
  159. data/tracks/kotlin/exercises/difference-of-squares/build.gradle +1 -1
  160. data/tracks/kotlin/exercises/etl/build.gradle +1 -1
  161. data/tracks/kotlin/exercises/flatten-array/build.gradle +1 -1
  162. data/tracks/kotlin/exercises/forth/build.gradle +1 -1
  163. data/tracks/kotlin/exercises/gigasecond/build.gradle +1 -1
  164. data/tracks/kotlin/exercises/grade-school/build.gradle +1 -1
  165. data/tracks/kotlin/exercises/grains/build.gradle +1 -1
  166. data/tracks/kotlin/exercises/hamming/build.gradle +1 -1
  167. data/tracks/kotlin/exercises/hello-world/build.gradle +1 -1
  168. data/tracks/kotlin/exercises/hexadecimal/build.gradle +1 -1
  169. data/tracks/kotlin/exercises/isogram/build.gradle +1 -1
  170. data/tracks/kotlin/exercises/largest-series-product/build.gradle +1 -1
  171. data/tracks/kotlin/exercises/leap/build.gradle +1 -1
  172. data/tracks/kotlin/exercises/linked-list/build.gradle +1 -1
  173. data/tracks/kotlin/exercises/list-ops/build.gradle +1 -1
  174. data/tracks/kotlin/exercises/luhn/build.gradle +1 -1
  175. data/tracks/kotlin/exercises/meetup/build.gradle +1 -1
  176. data/tracks/kotlin/exercises/minesweeper/build.gradle +1 -1
  177. data/tracks/kotlin/exercises/nth-prime/build.gradle +1 -1
  178. data/tracks/kotlin/exercises/nucleotide-count/build.gradle +1 -1
  179. data/tracks/kotlin/exercises/pangram/build.gradle +1 -1
  180. data/tracks/kotlin/exercises/pascals-triangle/build.gradle +1 -1
  181. data/tracks/kotlin/exercises/perfect-numbers/build.gradle +1 -1
  182. data/tracks/kotlin/exercises/phone-number/build.gradle +1 -1
  183. data/tracks/kotlin/exercises/pig-latin/build.gradle +1 -1
  184. data/tracks/kotlin/exercises/prime-factors/build.gradle +1 -1
  185. data/tracks/kotlin/exercises/raindrops/build.gradle +1 -1
  186. data/tracks/kotlin/exercises/react/build.gradle +1 -1
  187. data/tracks/kotlin/exercises/rna-transcription/build.gradle +1 -1
  188. data/tracks/kotlin/exercises/robot-name/build.gradle +1 -1
  189. data/tracks/kotlin/exercises/robot-simulator/build.gradle +1 -1
  190. data/tracks/kotlin/exercises/roman-numerals/build.gradle +1 -1
  191. data/tracks/kotlin/exercises/rotational-cipher/build.gradle +1 -1
  192. data/tracks/kotlin/exercises/saddle-points/build.gradle +1 -1
  193. data/tracks/kotlin/exercises/say/build.gradle +1 -1
  194. data/tracks/kotlin/exercises/scrabble-score/build.gradle +1 -1
  195. data/tracks/kotlin/exercises/secret-handshake/build.gradle +1 -1
  196. data/tracks/kotlin/exercises/series/build.gradle +1 -1
  197. data/tracks/kotlin/exercises/sieve/build.gradle +1 -1
  198. data/tracks/kotlin/exercises/simple-cipher/README.md +4 -6
  199. data/tracks/kotlin/exercises/simple-cipher/build.gradle +1 -1
  200. data/tracks/kotlin/exercises/space-age/build.gradle +1 -1
  201. data/tracks/kotlin/exercises/spiral-matrix/build.gradle +1 -1
  202. data/tracks/kotlin/exercises/strain/build.gradle +1 -1
  203. data/tracks/kotlin/exercises/sublist/build.gradle +1 -1
  204. data/tracks/kotlin/exercises/sum-of-multiples/build.gradle +1 -1
  205. data/tracks/kotlin/exercises/triangle/build.gradle +1 -1
  206. data/tracks/kotlin/exercises/two-fer/build.gradle +1 -1
  207. data/tracks/kotlin/exercises/word-count/build.gradle +1 -1
  208. data/tracks/lua/.gitignore +1 -0
  209. data/tracks/lua/config.json +12 -0
  210. data/tracks/lua/exercises/isbn-verifier/README.md +52 -0
  211. data/tracks/lua/exercises/isbn-verifier/example.lua +16 -0
  212. data/tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua +55 -0
  213. data/tracks/ocaml/.travis-ci.sh +1 -1
  214. data/tracks/ocaml/.travis.yml +1 -1
  215. data/tracks/ocaml/README.md +1 -1
  216. data/tracks/perl6/config.json +10 -0
  217. data/tracks/perl6/exercises/acronym/Acronym.pm6 +4 -0
  218. data/tracks/perl6/exercises/acronym/Example.pm6 +5 -0
  219. data/tracks/perl6/exercises/acronym/README.md +33 -0
  220. data/tracks/perl6/exercises/acronym/acronym.t +96 -0
  221. data/tracks/perl6/exercises/acronym/example.yaml +19 -0
  222. data/tracks/perl6/exercises/word-count/Example.pm6 +1 -1
  223. data/tracks/perl6/exercises/word-count/WordCount.pm6 +1 -1
  224. data/tracks/perl6/exercises/word-count/example.yaml +2 -2
  225. data/tracks/perl6/exercises/word-count/word-count.t +11 -2
  226. data/tracks/pony/docs/RESOURCES.md +1 -1
  227. data/tracks/purescript/docs/INSTALLATION.md +1 -3
  228. data/tracks/python/config.json +1 -1
  229. data/tracks/r/exercises/word-count/test_word-count.R +5 -0
  230. data/tracks/ruby/README.md +73 -10
  231. data/tracks/rust/config.json +34 -0
  232. data/tracks/rust/exercises/book-store/Cargo.toml +1 -1
  233. data/tracks/rust/exercises/book-store/tests/book-store.rs +7 -0
  234. data/tracks/rust/exercises/diffie-hellman/.gitignore +9 -0
  235. data/tracks/rust/exercises/diffie-hellman/Cargo-example.toml +6 -0
  236. data/tracks/rust/exercises/diffie-hellman/Cargo.toml +5 -0
  237. data/tracks/rust/exercises/diffie-hellman/README.md +77 -0
  238. data/tracks/rust/exercises/diffie-hellman/example.rs +15 -0
  239. data/tracks/rust/exercises/diffie-hellman/src/lib.rs +11 -0
  240. data/tracks/rust/exercises/diffie-hellman/tests/diffie-hellman.rs +60 -0
  241. data/tracks/rust/exercises/macros/.gitignore +3 -0
  242. data/tracks/rust/exercises/macros/.meta/description.md +29 -0
  243. data/tracks/rust/exercises/macros/.meta/metadata.yml +3 -0
  244. data/tracks/rust/exercises/macros/Cargo.toml +6 -0
  245. data/tracks/rust/exercises/macros/README.md +70 -0
  246. data/tracks/rust/exercises/macros/example.rs +16 -0
  247. data/tracks/rust/exercises/macros/src/lib.rs +6 -0
  248. data/tracks/rust/exercises/macros/tests/macros.rs +62 -0
  249. data/tracks/rust/exercises/simple-linked-list/.gitignore +7 -0
  250. data/tracks/rust/exercises/simple-linked-list/.meta/hints.md +34 -0
  251. data/tracks/rust/exercises/simple-linked-list/Cargo.toml +5 -0
  252. data/tracks/rust/exercises/simple-linked-list/README.md +96 -0
  253. data/tracks/rust/exercises/simple-linked-list/example.rs +87 -0
  254. data/tracks/rust/exercises/simple-linked-list/src/lib.rs +46 -0
  255. data/tracks/rust/exercises/simple-linked-list/tests/simple-linked-list.rs +91 -0
  256. data/tracks/swift/.travis.yml +1 -1
  257. data/tracks/swift/config.json +24 -0
  258. data/tracks/swift/exercises/isbn-verifier/Package.swift +5 -0
  259. data/tracks/swift/exercises/isbn-verifier/README.md +39 -0
  260. data/tracks/swift/exercises/isbn-verifier/Sources/IsbnVerifier.swift +1 -0
  261. data/tracks/swift/exercises/isbn-verifier/Sources/IsbnVerifierExample.swift +35 -0
  262. data/tracks/swift/exercises/isbn-verifier/Tests/IsbnVerifierTests/IsbnVerifierTests.swift +75 -0
  263. data/tracks/swift/exercises/isbn-verifier/Tests/LinuxMain.swift +6 -0
  264. data/tracks/swift/exercises/two-fer/Package.swift +5 -0
  265. data/tracks/swift/exercises/two-fer/README.md +54 -0
  266. data/tracks/swift/exercises/two-fer/Sources/TwoFer.swift +1 -0
  267. data/tracks/swift/exercises/two-fer/Sources/TwoFerExample.swift +6 -0
  268. data/tracks/swift/exercises/two-fer/Tests/LinuxMain.swift +6 -0
  269. data/tracks/swift/exercises/two-fer/Tests/TwoFerTests/TwoFerTests.swift +25 -0
  270. metadata +71 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 035f344758e70ee0d97c2246e5cfdf0878ec339b
4
- data.tar.gz: 7b52f923df0cb958c251e599a75de951173521ee
3
+ metadata.gz: d3bd9240f0de766be65b492e5fe9bab8a3ceb6ef
4
+ data.tar.gz: 8cd5b56c4a4dabb98182c34e81d50b91458ddd4d
5
5
  SHA512:
6
- metadata.gz: cdbc6ff2470de2c426509584b99d3853b3f59c25f6942883f8902a3acc8baae255f23b8f202758f3ea646d63c98d11acec4cedf6c78d5c64731737390b0ebb99
7
- data.tar.gz: a47dc3a6adc5811139e22b25216924c2b669088bc12def99668fb36fec8cc69dbbb8571b4281981c5bdb427cb9373289e931c6df766732230dabafd286cb3cb8
6
+ metadata.gz: 8297750930c42b01dffe6903268abbf30d5a28648030cf0b973e4663b821c08e2555e99ed2bb94c4b126535da53b7fabd2293d8aa2907e53d92b3f8f60cca1e4
7
+ data.tar.gz: 2f41e6a9e8ff281e84587a7f934b6ea58c5f84c79b2102aa6fea886caaa9c35106283e5059498bd4cd808bdf16ed00cc17614fdc2c83290beea9fc859584d674
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.2.1.71"
2
+ VERSION = "2.2.1.72"
3
3
  end
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "exercise": "book-store",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "cases": [
5
5
  {
6
6
  "description": "Return the total basket price after applying the best discount.",
7
7
  "comments": [
8
8
  "Calculate lowest price for a shopping basket containing books only from ",
9
9
  "a single series. There is no discount advantage for having more than ",
10
- "one copy of any single book in a grouping."
10
+ "one copy of any single book in a grouping."
11
11
  ],
12
12
  "cases": [
13
13
  {
@@ -100,6 +100,13 @@
100
100
  "basket": [1,1,2,2,3,3,4,4,5,5,1,2],
101
101
  "targetgrouping": [[1,2,3,4,5],[1,2,3,4,5],[1,2]],
102
102
  "expected": 75.20
103
+ },
104
+ {
105
+ "property": "total",
106
+ "description": "Four groups of four are cheaper than two groups each of five and three",
107
+ "basket": [1,1,2,2,3,3,4,5,1,1,2,2,3,3,4,5],
108
+ "targetgrouping": [[1,2,3,4],[1,2,3,5],[1,2,3,4],[1,2,3,5]],
109
+ "expected": 102.4
103
110
  }
104
111
  ]
105
112
  }
@@ -111,6 +111,15 @@
111
111
  "large": 2,
112
112
  "and": 1
113
113
  }
114
+ },
115
+ {
116
+ "description": "multiple spaces not detected as a word",
117
+ "property": "countwords",
118
+ "input": " multiple whitespaces",
119
+ "expected": {
120
+ "multiple": 1,
121
+ "whitespaces": 1
122
+ }
114
123
  }
115
124
  ]
116
125
  }
@@ -0,0 +1,199 @@
1
+ # Contributing to the Bash Track
2
+
3
+ There are a lot of great resources for contributing to Exercism in general already. Check out the [docs](https://github.com/exercism/docs) repository for a larger overview and some more general purpose instructions.
4
+
5
+ A great way to get started contributing is [porting an exercise from another track](#porting-an-exercise-from-another-language)! It helps you get into the repository, learn your way around, and see how things are structured.
6
+
7
+ ## Getting Set Up
8
+
9
+ In order to run any of the test files (or examples, for that matter), you're going to need Bash. If you're on OSX or Linux, this shouldn't be a problem for you. Additionally, you'll need the Bash test runner that we're using: `bats`. This can be installed via your package manager. For more specifics, see the [tests page of this repository's docs](https://github.com/exercism/bash/blob/master/docs/TESTS.md).
10
+
11
+ ## Porting an Exercise from Another Language
12
+
13
+ Porting an exercise from another language is easy (ish)! You can follow this step-by-step guide (specific for this repository) to get it done.
14
+
15
+ ### Initial Setup
16
+
17
+ Fork the Bash repository on GitHub (which you are currently in).
18
+
19
+ ![Fork button](img/fork-repository.png)
20
+
21
+ Clone the repository to your computer.
22
+
23
+ ```bash
24
+ $ git clone https://github.com/<your-user-name>/bash.git
25
+ $ cd bash
26
+ ```
27
+
28
+ Look through the [list of exercises not yet implemented in Bash](http://exercism.io/languages/bash/todo). Once you've found one you like, make sure that someone's not already working on it by checking the [current open pull requests](https://github.com/exercism/bash/pulls). Also double check that the exercise isn't in the list of exercises already implemented in your freshly cloned repository: `path/to/bash/exercises`. Once you've selected an exercise you like, locate its *slug* (unique name) in [the master list of problem specifications](https://github.com/exercism/problem-specifications/tree/master/exercises).
29
+
30
+ Create a directory in your local `exercises` folder with that same slug name.
31
+
32
+ ```bash
33
+ # Optionally, but probably a good idea, create a new branch for your exercise
34
+ $ git checkout -b <your-slug-here>
35
+ # Create the new exercise directory
36
+ $ mkdir exercises/<your-slug-here>
37
+ ```
38
+
39
+ At the very least, you're going to need to create a `README.md`, a test file (`your_exercise_test.sh`), and an example file which, by convention, you should name `example.sh` when you're done. For ease of debugging, you can start by naming your file `your_exercise.sh`.
40
+
41
+ ```bash
42
+ $ touch README.md
43
+ $ touch <your-exercise>_test.sh
44
+ $ touch <your-exercise>.sh
45
+ ```
46
+
47
+ Ensure that both of the shell script files are executeable.
48
+
49
+ ```bash
50
+ $ chmod a+x <your-exercise>_test.sh <your-exercise>.sh
51
+ ```
52
+
53
+ Many, if not all, of the current exercises have *canonical data* about them that is the same accross all languages. This makes it so you don't have to come up with test cases or informative intro material yourself. You're welcome! Head over to your specific exercise page in the [master list](https://github.com/exercism/problem-specifications/tree/master/exercises) (same link as above). Specifically right now, you're interested in `canonical_data.json`.
54
+
55
+ ![Canonical data example](img/canonical-data-example.png)
56
+
57
+ Currently, you're interested in all of the `"cases"`. Each of these is a test case that you'll have to implement in the specific vernacular of our test-runner, `bats`. Check out [this repository's test documentation](https://github.com/exercism/bash/blob/master/docs/TESTS.md) if you missed the [Getting Set Up](#getting-set-up) section above.
58
+
59
+ ### Generating the Tests
60
+
61
+ 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.
62
+
63
+ ```bash
64
+ #!/bin/bash
65
+
66
+ @test 'Say Hi!' {
67
+ run bash hello_world.sh
68
+
69
+ [ "$status" -eq 0 ]
70
+ [ "$output" = "Hello, World" ]
71
+ }
72
+
73
+ # ... The rest of your tests
74
+ ```
75
+
76
+ 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.
77
+
78
+ You can check to see if your example script works by running `bats`.
79
+
80
+ ```bash
81
+ $ bats hello_world_test.sh
82
+ ```
83
+
84
+ ### Implementing an Example Solution
85
+
86
+ 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.
87
+
88
+ 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!
89
+
90
+ Once your tests and example are complete, rename `<your-exercise>.sh` to `example.sh` to match all the other exercises.
91
+
92
+ ### Updating the Config
93
+
94
+ Exercism makes heavy use of configuration files to automate things. Now that you're done with your solution, you can add your problem to `bash/config.json`. Check out the [configuration description](https://github.com/exercism/docs/blob/master/language-tracks/configuration/exercises.md) in the Exercism docs for more info on each item.
95
+
96
+ ```json
97
+ // config.json
98
+ {
99
+ "exercises": [
100
+ // ... All the other exercises
101
+ {
102
+ "core": false, // True or false, you decide
103
+ "unlocked_by": "leap", // If core is false, pick a core exercise that
104
+ // unlocks this one. Something similar, but easier
105
+ "difficulty": 1, // 1 == easy, 10 == impossible, you decide
106
+ "slug": "<your-exercise>",
107
+ "topics": [
108
+ "control_flow_conditionals",
109
+ "mathematics" // These can come from the topics list, linked below
110
+ ],
111
+ "uuid": "9ac0b041-a7aa-4b0c-952a-d38d35e2cd65" // see below
112
+ }
113
+ ]
114
+ }
115
+ ```
116
+
117
+ Possible topics that describe your exercise can come from the [topics master list](https://github.com/exercism/problem-specifications/blob/master/TOPICS.txt), but you're not limited to those.
118
+
119
+ In order to get the `uuid` and check your work, you'll need the configlet, which is a handy tool created to automate some of the more monotonous tasks involved with this. See the [configlet documentation](https://github.com/exercism/configlet) for more info. Make sure you have the most current configlet by running:
120
+
121
+ ```bash
122
+ $ bin/fetch-configlet
123
+ ```
124
+
125
+ Each exercise *for each language* needs a unique ID number — a `uuid`. The configley can help you generate one.
126
+
127
+ ```bash
128
+ $ bin/configlet uuid
129
+ ```
130
+
131
+ Copy/paste the generated value into the `uuid` field of your exercise. Once you're done, it's time to check your work. Run the configlet linter.
132
+
133
+ ```bash
134
+ $ bin/configlet lint .
135
+ # If for some reason you're not inside the project directory, instead use
136
+ $ bin/configlet lint path/to/bash
137
+ ```
138
+
139
+ Hopefully it says everything is OK!
140
+
141
+ ### Creating the README
142
+
143
+ There are two ways to create the README: generate it via the configlet, or manually create it. This guide covers them both.
144
+
145
+ #### Using the Configlet
146
+
147
+ The configlet has a generate command that uses Go templating and pulls from the repository's `config` directory as well as each exercise's `.meta` directory. Learn more in the [configlet docs](https://github.com/exercism/configlet). You should just be able to run:
148
+
149
+ ```bash
150
+ $ bin/configlet generate <your-exercise>
151
+ ```
152
+
153
+ This should auto-generate a nice README in your exercise directory. If it gives you any issues, no worries! You can always get it done by...
154
+
155
+ #### Doing It Manually
156
+
157
+ Use the `config/exercise_readme.go.tmpl` file as a guide. The README should look something like this:
158
+
159
+ ```markdown
160
+ # <Your Exercise Title>
161
+
162
+ ... Description copied from the master exercise repo (where you got your tests)
163
+
164
+ ... Any additional hints that need provided
165
+
166
+ ... Bash standard material, copied from `docs/EXERCISE_README_INSERT.md`
167
+
168
+ ## Source
169
+
170
+ ... Copy credits from the master exercise repo
171
+
172
+ ## Submitting Incomplete Solutions
173
+
174
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
175
+ ```
176
+
177
+ ### Cleaning Up
178
+
179
+ 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.
180
+
181
+ ```bash
182
+ # Assuming you've alread 'git added' and 'git commited'
183
+ # If you don't already have the exercism/bash as your upstream remote:
184
+ $ git remote add upstream https://github.com/exercism/bash.git
185
+ # To get the most recent upstream version
186
+ $ git fetch upstream
187
+ # Rebase onto the upstream
188
+ $ git rebase upstream/master
189
+ ```
190
+
191
+ 21. Now you're ready to sync up with Github and open your pull request!
192
+
193
+ ```bash
194
+ $ git push --force-with-lease origin <your-branch-name>
195
+ ```
196
+
197
+ ![Create pull request](img/create-pr.png)
198
+
199
+ Good luck, happy scripting, and thanks for your help!
@@ -66,6 +66,16 @@
66
66
  "unlocked_by": "leap",
67
67
  "uuid": "ca5139b4-8b2f-44ea-8d83-0b8ca7674436"
68
68
  },
69
+ {
70
+ "core": true,
71
+ "difficulty": 1,
72
+ "slug": "error-handling",
73
+ "topics": [
74
+ "error_handling",
75
+ "input_validation"
76
+ ],
77
+ "uuid": "b2b4ee35-108f-45ce-b294-c10d332e5579"
78
+ },
69
79
  {
70
80
  "core": true,
71
81
  "difficulty": 2,
@@ -152,16 +162,6 @@
152
162
  "unlocked_by": "pangram",
153
163
  "uuid": "9f9a1a49-472f-4a39-aa28-6aa17eeebdc7"
154
164
  },
155
- {
156
- "core": true,
157
- "difficulty": 1,
158
- "slug": "error-handling",
159
- "topics": [
160
- "error_handling",
161
- "input_validation"
162
- ],
163
- "uuid": "b2b4ee35-108f-45ce-b294-c10d332e5579"
164
- },
165
165
  {
166
166
  "core": false,
167
167
  "difficulty": 5,
@@ -173,8 +173,21 @@
173
173
  ],
174
174
  "unlocked_by": "hamming",
175
175
  "uuid": "03808072-0228-6580-7a9b-cc709a8a5b8c0e600b9"
176
+ },
177
+ {
178
+ "core": false,
179
+ "difficulty": 2,
180
+ "slug": "triangle",
181
+ "topics": [
182
+ "boolean_logic",
183
+ "input_validation",
184
+ "number_comparison",
185
+ "mathematics"
186
+ ],
187
+ "unlocked_by": "leap",
188
+ "uuid": "496e130a-063a-6380-19dc-179f05534717226bca1"
176
189
  }
177
190
  ],
178
191
  "foregone": [],
179
192
  "language": "Bash"
180
- }
193
+ }
@@ -0,0 +1,38 @@
1
+ # Triangle
2
+
3
+ Determine if a triangle is equilateral, isosceles, or scalene.
4
+
5
+ An _equilateral_ triangle has all three sides the same length.
6
+
7
+ An _isosceles_ triangle has at least two sides the same length. (It is sometimes
8
+ specified as having exactly two sides the same length, but for the purposes of
9
+ this exercise we'll say at least two.)
10
+
11
+ A _scalene_ triangle has all sides of different lengths.
12
+
13
+ ## Note
14
+
15
+ For a shape to be a triangle at all, all sides have to be of length > 0, and
16
+ the sum of the lengths of any two sides must be greater than or equal to the
17
+ length of the third side. See [Triangle Inequality](https://en.wikipedia.org/wiki/Triangle_inequality).
18
+
19
+ ## Dig Deeper
20
+
21
+ The case where the sum of the lengths of two sides _equals_ that of the
22
+ third is known as a _degenerate_ triangle - it has zero area and looks like
23
+ a single line. Feel free to add your own code/tests to check for degenerate triangles.
24
+
25
+ ## Tests
26
+
27
+ Run the tests with:
28
+
29
+ ```bash
30
+ bats triangle_test.sh
31
+ ```
32
+
33
+ ## Source
34
+
35
+ The [Ruby Koans](http://rubykoans.com) triangle project, parts 1 & 2
36
+
37
+ ## Submitting Incomplete Solutions
38
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,56 @@
1
+ #!/bin/bash
2
+ set -o errexit # Stop script on command error
3
+ set -o nounset # Error out if accessing undefined variable name
4
+ set -o pipefail # Error out if any step in a pipe errors out
5
+
6
+ if [[ $# -ne 4 ]]; then
7
+ echo "Usage: $0 [equilateral | isosceles | scalene] <s1> <s2> <s3>"
8
+ exit 2 # Improper inputs
9
+ fi
10
+
11
+ triangle_type=$1
12
+ s1=$2
13
+ s2=$3
14
+ s3=$4
15
+
16
+ assert() {
17
+ # Takes a numerical inequality in a string.
18
+ # Pipes it through to bc
19
+ # Float-proof numeric comparison :
20
+ [[ $( echo $1 | bc -l ) -eq 1 ]]
21
+ }
22
+
23
+ valid_triangle() {
24
+ # Takes three sides lengths (numeric) $1, $2, $3
25
+ # If any side is zero, returns false
26
+ assert "$1 == 0" || assert "$2 == 0" || assert "$3 == 0" && return 1
27
+ # If triangle doesn't meet inequality requirement, returns false
28
+ assert "$1 + $2 <= $3" || assert "$1 + $3 <= $2" || assert "$2 + $3 <= $1" && return 1
29
+ return 0
30
+ }
31
+
32
+ if ! valid_triangle $s1 $s2 $s3; then
33
+ echo "Sides do not meet triangle inequality requirement."
34
+ echo "Given a <= b <= c and a, b, c != 0, a + b >= c"
35
+ exit 1
36
+ fi
37
+
38
+ equilateral() {
39
+ assert "$1 == $2" && assert "$1 == $3"
40
+ }
41
+
42
+ isosceles() {
43
+ assert "$1 == $2" || assert "$1 == $3" || assert "$2 == $3"
44
+ }
45
+
46
+ scalene() {
47
+ assert "$1 != $2" && assert "$1 != $3" && assert "$2 != $3"
48
+ }
49
+
50
+ # Bash Ternary Operator:
51
+ # (boolean value/calculation) && action if true || action if false
52
+ # Works because of boolean shortcutting.
53
+ # If boolean clause is false, it doesn't evaluate the other side of &&
54
+ # If first thing is false, it evaluates the item after ||,
55
+ # but if first two are true, doesn't bother evaluating last part.
56
+ $triangle_type $s1 $s2 $s3 && exit 0 || exit 1
@@ -0,0 +1,126 @@
1
+ #!/bin/bash
2
+
3
+ # Test Equilateral
4
+ @test "true if all sides are equal" {
5
+ # skip
6
+ run bash triangle.sh equilateral 2 2 2
7
+
8
+ [ "$status" -eq 0 ]
9
+ }
10
+
11
+ @test "false if any side is unequal" {
12
+ skip
13
+ run bash triangle.sh equilateral 2 3 2
14
+
15
+ [ "$status" -eq 1 ]
16
+ }
17
+
18
+ @test "false if no side is equal" {
19
+ skip
20
+ run bash triangle.sh equilateral 5 4 6
21
+
22
+ [ "$status" -eq 1 ]
23
+ }
24
+
25
+ @test "all zero sides illegal, so the triangle is not equilateral" {
26
+ skip
27
+ run bash triangle.sh equilateral 0 0 0
28
+
29
+ [ "$status" -eq 1 ]
30
+ }
31
+
32
+ # BONUS: Deal with floating point numbers
33
+ @test "sides may be floats" {
34
+ skip
35
+ run bash triangle.sh equilateral 0.5 0.5 0.5
36
+
37
+ [ "$status" -eq 0 ]
38
+ }
39
+
40
+ # Test Isosceles
41
+ @test "true if last two sides are equal" {
42
+ skip
43
+ run bash triangle.sh isosceles 3 4 4
44
+
45
+ [ "$status" -eq 0 ]
46
+ }
47
+
48
+ @test "true if first two sides are equal" {
49
+ skip
50
+ run bash triangle.sh isosceles 4 4 3
51
+
52
+ [ "$status" -eq 0 ]
53
+ }
54
+
55
+ @test "true if first and last sides are equal" {
56
+ skip
57
+ run bash triangle.sh isosceles 4 3 4
58
+
59
+ [ "$status" -eq 0 ]
60
+ }
61
+
62
+ @test "equilateral triangles are also isosceles" {
63
+ skip
64
+ run bash triangle.sh isosceles 4 4 4
65
+
66
+ [ "$status" -eq 0 ]
67
+ }
68
+
69
+ @test "false if no sides are equal" {
70
+ skip
71
+ run bash triangle.sh isosceles 2 3 4
72
+
73
+ [ "$status" -eq 1 ]
74
+ }
75
+
76
+ @test "sides that violate triangle inequality are not isosceles, even if two are equal" {
77
+ skip
78
+ run bash triangle.sh isosceles 1 1 3
79
+
80
+ [ "$status" -eq 1 ]
81
+ }
82
+
83
+ # BONUS: Deal with floating point numbers
84
+ @test "isosceles sides may be floats" {
85
+ skip
86
+ run bash triangle.sh isosceles 0.5 0.4 0.5
87
+
88
+ [ "$status" -eq 0 ]
89
+ }
90
+
91
+ # Test Scalene
92
+ @test "true if no sides are equal" {
93
+ skip
94
+ run bash triangle.sh scalene 5 4 6
95
+
96
+ [ "$status" -eq 0 ]
97
+ }
98
+
99
+ @test "false if all sides are equal" {
100
+ skip
101
+ run bash triangle.sh scalene 4 4 4
102
+
103
+ [ "$status" -eq 1 ]
104
+ }
105
+
106
+ @test "false if two sides are equal" {
107
+ skip
108
+ run bash triangle.sh scalene 4 4 3
109
+
110
+ [ "$status" -eq 1 ]
111
+ }
112
+
113
+ @test "sides that violate triangle inequality are not scalene even if they are all different" {
114
+ skip
115
+ run bash triangle.sh scalene 7 3 2
116
+
117
+ [ "$status" -eq 1 ]
118
+ }
119
+
120
+ # BONUS: Deal with floating point numbers
121
+ @test "scalene sides may be floats" {
122
+ skip
123
+ run bash triangle.sh scalene 0.5 0.4 0.6
124
+
125
+ [ "$status" -eq 0 ]
126
+ }