trackler 2.2.1.57 → 2.2.1.58

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/custom-set/canonical-data.json +8 -1
  4. data/tracks/c/README.md +2 -44
  5. data/tracks/c/docs/CONTRIBUTING.md +93 -0
  6. data/tracks/c/docs/C_STYLE_GUIDE.md +1 -1
  7. data/tracks/clojure/config.json +27 -0
  8. data/tracks/clojure/exercises/accumulate/project.clj +1 -1
  9. data/tracks/clojure/exercises/acronym/project.clj +1 -1
  10. data/tracks/clojure/exercises/all-your-base/project.clj +1 -1
  11. data/tracks/clojure/exercises/allergies/project.clj +1 -1
  12. data/tracks/clojure/exercises/anagram/project.clj +1 -1
  13. data/tracks/clojure/exercises/atbash-cipher/project.clj +1 -1
  14. data/tracks/clojure/exercises/bank-account/project.clj +1 -1
  15. data/tracks/clojure/exercises/beer-song/project.clj +1 -1
  16. data/tracks/clojure/exercises/binary/project.clj +1 -1
  17. data/tracks/clojure/exercises/binary-search/project.clj +1 -1
  18. data/tracks/clojure/exercises/binary-search-tree/project.clj +1 -1
  19. data/tracks/clojure/exercises/bob/project.clj +1 -1
  20. data/tracks/clojure/exercises/bracket-push/project.clj +1 -1
  21. data/tracks/clojure/exercises/change/project.clj +1 -1
  22. data/tracks/clojure/exercises/clock/project.clj +1 -1
  23. data/tracks/clojure/exercises/collatz-conjecture/project.clj +1 -1
  24. data/tracks/clojure/exercises/complex-numbers/project.clj +1 -1
  25. data/tracks/clojure/exercises/crypto-square/project.clj +1 -1
  26. data/tracks/clojure/exercises/diamond/README.md +51 -0
  27. data/tracks/clojure/exercises/diamond/project.clj +4 -0
  28. data/tracks/clojure/exercises/diamond/src/example.clj +22 -0
  29. data/tracks/clojure/exercises/diamond/test/diamond_test.clj +79 -0
  30. data/tracks/clojure/exercises/difference-of-squares/project.clj +1 -1
  31. data/tracks/clojure/exercises/etl/project.clj +1 -1
  32. data/tracks/clojure/exercises/flatten-array/project.clj +1 -1
  33. data/tracks/clojure/exercises/gigasecond/project.clj +1 -1
  34. data/tracks/clojure/exercises/grade-school/project.clj +1 -1
  35. data/tracks/clojure/exercises/grains/project.clj +1 -1
  36. data/tracks/clojure/exercises/hamming/project.clj +1 -1
  37. data/tracks/clojure/exercises/hello-world/project.clj +1 -1
  38. data/tracks/clojure/exercises/hexadecimal/project.clj +1 -1
  39. data/tracks/clojure/exercises/isogram/project.clj +1 -1
  40. data/tracks/clojure/exercises/kindergarten-garden/project.clj +1 -1
  41. data/tracks/clojure/exercises/largest-series-product/project.clj +1 -1
  42. data/tracks/clojure/exercises/leap/project.clj +1 -1
  43. data/tracks/clojure/exercises/luhn/project.clj +1 -1
  44. data/tracks/clojure/exercises/meetup/project.clj +1 -1
  45. data/tracks/clojure/exercises/minesweeper/project.clj +1 -1
  46. data/tracks/clojure/exercises/nth-prime/project.clj +1 -1
  47. data/tracks/clojure/exercises/nucleotide-count/project.clj +1 -1
  48. data/tracks/clojure/exercises/octal/project.clj +1 -1
  49. data/tracks/clojure/exercises/pascals-triangle/project.clj +1 -1
  50. data/tracks/clojure/exercises/perfect-numbers/project.clj +1 -1
  51. data/tracks/clojure/exercises/phone-number/project.clj +1 -1
  52. data/tracks/clojure/exercises/pig-latin/project.clj +1 -1
  53. data/tracks/clojure/exercises/prime-factors/project.clj +1 -1
  54. data/tracks/clojure/exercises/protein-translation/README.md +40 -0
  55. data/tracks/clojure/exercises/protein-translation/project.clj +4 -0
  56. data/tracks/clojure/exercises/protein-translation/src/example.clj +19 -0
  57. data/tracks/clojure/exercises/protein-translation/test/protein_translation_test.clj +36 -0
  58. data/tracks/clojure/exercises/queen-attack/project.clj +1 -1
  59. data/tracks/clojure/exercises/raindrops/project.clj +1 -1
  60. data/tracks/clojure/exercises/rna-transcription/project.clj +1 -1
  61. data/tracks/clojure/exercises/robot-name/project.clj +1 -1
  62. data/tracks/clojure/exercises/robot-simulator/project.clj +1 -1
  63. data/tracks/clojure/exercises/roman-numerals/project.clj +1 -1
  64. data/tracks/clojure/exercises/rotational-cipher/project.clj +1 -1
  65. data/tracks/clojure/exercises/run-length-encoding/README.md +36 -0
  66. data/tracks/clojure/exercises/run-length-encoding/project.clj +4 -0
  67. data/tracks/clojure/exercises/run-length-encoding/src/example.clj +20 -0
  68. data/tracks/clojure/exercises/run-length-encoding/src/run_length_encoding.clj +11 -0
  69. data/tracks/clojure/exercises/run-length-encoding/test/run_length_encoding_test.clj +57 -0
  70. data/tracks/clojure/exercises/scrabble-score/project.clj +1 -1
  71. data/tracks/clojure/exercises/secret-handshake/project.clj +1 -1
  72. data/tracks/clojure/exercises/series/project.clj +1 -1
  73. data/tracks/clojure/exercises/sieve/project.clj +1 -1
  74. data/tracks/clojure/exercises/space-age/project.clj +1 -1
  75. data/tracks/clojure/exercises/spiral-matrix/project.clj +1 -1
  76. data/tracks/clojure/exercises/strain/project.clj +1 -1
  77. data/tracks/clojure/exercises/sublist/project.clj +1 -1
  78. data/tracks/clojure/exercises/sum-of-multiples/project.clj +1 -1
  79. data/tracks/clojure/exercises/triangle/project.clj +1 -1
  80. data/tracks/clojure/exercises/trinary/project.clj +1 -1
  81. data/tracks/clojure/exercises/word-count/project.clj +1 -1
  82. data/tracks/clojure/exercises/wordy/project.clj +1 -1
  83. data/tracks/clojure/project.clj +2 -2
  84. data/tracks/ecmascript/config.json +10 -15
  85. data/tracks/ecmascript/docs/TESTS.md +15 -0
  86. data/tracks/ecmascript/exercises/complex-numbers/README.md +68 -0
  87. data/tracks/ecmascript/exercises/complex-numbers/complex-numbers.spec.js +216 -0
  88. data/tracks/ecmascript/exercises/complex-numbers/example.js +43 -0
  89. data/tracks/ecmascript/exercises/{transpose → complex-numbers}/package.json +2 -2
  90. data/tracks/elixir/config.json +22 -1
  91. data/tracks/elixir/exercises/isbn-verifier/README.md +80 -0
  92. data/tracks/elixir/exercises/isbn-verifier/example.exs +36 -0
  93. data/tracks/elixir/exercises/isbn-verifier/isbn_verifier.exs +18 -0
  94. data/tracks/elixir/exercises/isbn-verifier/isbn_verifier_test.exs +75 -0
  95. data/tracks/elixir/exercises/spiral-matrix/README.md +65 -0
  96. data/tracks/elixir/exercises/spiral-matrix/example.exs +27 -0
  97. data/tracks/elixir/exercises/spiral-matrix/spiral.exs +9 -0
  98. data/tracks/elixir/exercises/spiral-matrix/spiral_test.exs +58 -0
  99. data/tracks/erlang/config.json +10 -0
  100. data/tracks/erlang/exercises/complex-numbers/HINTS.md +2 -0
  101. data/tracks/erlang/exercises/complex-numbers/README.md +85 -0
  102. data/tracks/erlang/exercises/complex-numbers/include/exercism.hrl +11 -0
  103. data/tracks/erlang/exercises/complex-numbers/rebar.config +30 -0
  104. data/tracks/erlang/exercises/complex-numbers/src/complex_numbers.app.src +9 -0
  105. data/tracks/erlang/exercises/complex-numbers/src/complex_numbers.erl +29 -0
  106. data/tracks/erlang/exercises/complex-numbers/src/example.erl +44 -0
  107. data/tracks/erlang/exercises/complex-numbers/test/complex_numbers_tests.erl +152 -0
  108. data/tracks/erlang/testgen/src/tgen.erl +1 -1
  109. data/tracks/erlang/testgen/src/tgen_complex-numbers.erl +75 -0
  110. data/tracks/java/config.json +10 -5
  111. data/tracks/javascript/config.json +13 -0
  112. data/tracks/javascript/exercises/isbn-verifier/README.md +66 -0
  113. data/tracks/javascript/exercises/isbn-verifier/example.js +24 -0
  114. data/tracks/javascript/exercises/isbn-verifier/isbn-verifier.spec.js +68 -0
  115. data/tracks/perl6/config/maintainers.json +4 -4
  116. data/tracks/perl6/config.json +21 -21
  117. data/tracks/php/README.md +1 -0
  118. data/tracks/python/config/maintainers.json +3 -3
  119. data/tracks/python/exercises/alphametics/alphametics_test.py +6 -6
  120. data/tracks/python/exercises/queen-attack/queen_attack_test.py +60 -40
  121. data/tracks/sml/config.json +13 -2
  122. data/tracks/sml/exercises/flatten-array/{HINTS.md → .meta/hints.md} +0 -0
  123. data/tracks/sml/exercises/nth-prime/{HINTS.md → .meta/hints.md} +0 -0
  124. data/tracks/sml/exercises/pig-latin/README.md +54 -0
  125. data/tracks/sml/exercises/pig-latin/example.sml +23 -0
  126. data/tracks/sml/exercises/pig-latin/pig-latin.sml +2 -0
  127. data/tracks/sml/exercises/pig-latin/test.sml +90 -0
  128. data/tracks/sml/exercises/pig-latin/testlib.sml +159 -0
  129. data/tracks/typescript/config.json +16 -0
  130. data/tracks/typescript/exercises/ocr-numbers/README.md +110 -0
  131. data/tracks/typescript/exercises/ocr-numbers/ocr-numbers.example.ts +92 -0
  132. data/tracks/typescript/exercises/ocr-numbers/ocr-numbers.test.ts +155 -0
  133. data/tracks/typescript/exercises/ocr-numbers/ocr-numbers.ts +3 -0
  134. data/tracks/typescript/exercises/ocr-numbers/package.json +36 -0
  135. data/tracks/typescript/exercises/ocr-numbers/tsconfig.json +22 -0
  136. data/tracks/typescript/exercises/ocr-numbers/tslint.json +127 -0
  137. data/tracks/typescript/exercises/ocr-numbers/yarn.lock +2624 -0
  138. metadata +55 -8
  139. data/tracks/ecmascript/exercises/transpose/README.md +0 -94
  140. data/tracks/ecmascript/exercises/transpose/example.js +0 -12
  141. data/tracks/ecmascript/exercises/transpose/transpose.spec.js +0 -67
@@ -12,12 +12,12 @@
12
12
  },
13
13
  {
14
14
  "github_username": "mienaikage",
15
- "show_on_website": false,
15
+ "show_on_website": true,
16
16
  "alumnus": false,
17
17
  "name": null,
18
- "bio": null,
19
- "link_text": null,
20
- "link_url": null,
18
+ "bio": "My first adventure in coding was creating userscripts by trial and error (many errors...). Somewhere down the line I accidentally found myself employed in my first coding role as a Perl developer, after attempting pair programming in Haskell.",
19
+ "link_text": "dango.space",
20
+ "link_url": "http://dango.space/",
21
21
  "avatar_url": null
22
22
  }
23
23
  ],
@@ -33,7 +33,7 @@
33
33
  "slug": "leap",
34
34
  "core": false,
35
35
  "unlocked_by": null,
36
- "difficulty": 1,
36
+ "difficulty": 2,
37
37
  "topics": [
38
38
 
39
39
  ]
@@ -43,7 +43,7 @@
43
43
  "slug": "bob",
44
44
  "core": false,
45
45
  "unlocked_by": null,
46
- "difficulty": 1,
46
+ "difficulty": 3,
47
47
  "topics": [
48
48
 
49
49
  ]
@@ -63,7 +63,7 @@
63
63
  "slug": "phone-number",
64
64
  "core": false,
65
65
  "unlocked_by": null,
66
- "difficulty": 1,
66
+ "difficulty": 4,
67
67
  "topics": [
68
68
 
69
69
  ]
@@ -83,7 +83,7 @@
83
83
  "slug": "rna-transcription",
84
84
  "core": false,
85
85
  "unlocked_by": null,
86
- "difficulty": 1,
86
+ "difficulty": 2,
87
87
  "topics": [
88
88
 
89
89
  ]
@@ -103,7 +103,7 @@
103
103
  "slug": "clock",
104
104
  "core": false,
105
105
  "unlocked_by": null,
106
- "difficulty": 1,
106
+ "difficulty": 3,
107
107
  "topics": [
108
108
 
109
109
  ]
@@ -113,7 +113,7 @@
113
113
  "slug": "wordy",
114
114
  "core": false,
115
115
  "unlocked_by": null,
116
- "difficulty": 1,
116
+ "difficulty": 6,
117
117
  "topics": [
118
118
 
119
119
  ]
@@ -123,7 +123,7 @@
123
123
  "slug": "raindrops",
124
124
  "core": false,
125
125
  "unlocked_by": null,
126
- "difficulty": 1,
126
+ "difficulty": 3,
127
127
  "topics": [
128
128
 
129
129
  ]
@@ -133,7 +133,7 @@
133
133
  "slug": "scrabble-score",
134
134
  "core": false,
135
135
  "unlocked_by": null,
136
- "difficulty": 1,
136
+ "difficulty": 5,
137
137
  "topics": [
138
138
 
139
139
  ]
@@ -143,7 +143,7 @@
143
143
  "slug": "luhn",
144
144
  "core": false,
145
145
  "unlocked_by": null,
146
- "difficulty": 1,
146
+ "difficulty": 5,
147
147
  "topics": [
148
148
 
149
149
  ]
@@ -163,7 +163,7 @@
163
163
  "slug": "word-count",
164
164
  "core": false,
165
165
  "unlocked_by": null,
166
- "difficulty": 1,
166
+ "difficulty": 4,
167
167
  "topics": [
168
168
 
169
169
  ]
@@ -173,7 +173,7 @@
173
173
  "slug": "flatten-array",
174
174
  "core": false,
175
175
  "unlocked_by": null,
176
- "difficulty": 1,
176
+ "difficulty": 4,
177
177
  "topics": [
178
178
 
179
179
  ]
@@ -183,7 +183,7 @@
183
183
  "slug": "grade-school",
184
184
  "core": false,
185
185
  "unlocked_by": null,
186
- "difficulty": 1,
186
+ "difficulty": 4,
187
187
  "topics": [
188
188
 
189
189
  ]
@@ -193,7 +193,7 @@
193
193
  "slug": "accumulate",
194
194
  "core": false,
195
195
  "unlocked_by": null,
196
- "difficulty": 1,
196
+ "difficulty": 2,
197
197
  "topics": [
198
198
 
199
199
  ]
@@ -203,7 +203,7 @@
203
203
  "slug": "grains",
204
204
  "core": false,
205
205
  "unlocked_by": null,
206
- "difficulty": 1,
206
+ "difficulty": 3,
207
207
  "topics": [
208
208
 
209
209
  ]
@@ -213,7 +213,7 @@
213
213
  "slug": "all-your-base",
214
214
  "core": false,
215
215
  "unlocked_by": null,
216
- "difficulty": 1,
216
+ "difficulty": 6,
217
217
  "topics": [
218
218
 
219
219
  ]
@@ -223,7 +223,7 @@
223
223
  "slug": "anagram",
224
224
  "core": false,
225
225
  "unlocked_by": null,
226
- "difficulty": 1,
226
+ "difficulty": 5,
227
227
  "topics": [
228
228
 
229
229
  ]
@@ -233,7 +233,7 @@
233
233
  "slug": "robot-name",
234
234
  "core": false,
235
235
  "unlocked_by": null,
236
- "difficulty": 1,
236
+ "difficulty": 6,
237
237
  "topics": [
238
238
 
239
239
  ]
@@ -243,7 +243,7 @@
243
243
  "slug": "atbash-cipher",
244
244
  "core": false,
245
245
  "unlocked_by": null,
246
- "difficulty": 1,
246
+ "difficulty": 5,
247
247
  "topics": [
248
248
 
249
249
  ]
@@ -253,7 +253,7 @@
253
253
  "slug": "space-age",
254
254
  "core": false,
255
255
  "unlocked_by": null,
256
- "difficulty": 1,
256
+ "difficulty": 4,
257
257
  "topics": [
258
258
 
259
259
  ]
@@ -263,7 +263,7 @@
263
263
  "slug": "allergies",
264
264
  "core": false,
265
265
  "unlocked_by": null,
266
- "difficulty": 1,
266
+ "difficulty": 5,
267
267
  "topics": [
268
268
 
269
269
  ]
@@ -273,7 +273,7 @@
273
273
  "slug": "linked-list",
274
274
  "core": false,
275
275
  "unlocked_by": null,
276
- "difficulty": 1,
276
+ "difficulty": 6,
277
277
  "topics": [
278
278
 
279
279
  ]
data/tracks/php/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # PHP
2
2
 
3
3
  [![Build Status](https://travis-ci.org/exercism/php.svg?branch=master)](https://travis-ci.org/exercism/php)
4
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/68242198cd124a3ebcbdc291d0e0eda4)](https://www.codacy.com/app/borgogelli/php?utm_source=github.com&utm_medium=referral&utm_content=borgogelli/php&utm_campaign=Badge_Grade)
4
5
 
5
6
  Exercism exercises in PHP
6
7
 
@@ -12,10 +12,10 @@
12
12
  },
13
13
  {
14
14
  "github_username": "Dog",
15
- "show_on_website": false,
15
+ "show_on_website": true,
16
16
  "alumnus": false,
17
- "name": null,
18
- "bio": null,
17
+ "name": "Dog",
18
+ "bio": "I can not only fetch JSON, but parse it too.",
19
19
  "link_text": null,
20
20
  "link_url": null,
21
21
  "avatar_url": null
@@ -6,7 +6,7 @@ from alphametics import solve
6
6
  # Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0
7
7
 
8
8
  class TestAlphametics(unittest.TestCase):
9
- def test_puzzle_with_three_letters(self):
9
+ def test_puzzle_with_03_letters(self):
10
10
  self.assertEqual(solve("I + BB == ILL"), {"I": 1, "B": 9, "L": 0})
11
11
 
12
12
  def test_invalid_solution_must_have_unique_value_for_each_letter(self):
@@ -15,11 +15,11 @@ class TestAlphametics(unittest.TestCase):
15
15
  def test_invalid_leading_zero_solution(self):
16
16
  self.assertEqual(solve("ACA + DD == BD"), {})
17
17
 
18
- def test_puzzle_with_four_letters(self):
18
+ def test_puzzle_with_04_letters(self):
19
19
  self.assertEqual(
20
20
  solve("AS + A == MOM"), {"A": 9, "S": 2, "M": 1, "O": 0})
21
21
 
22
- def test_puzzle_with_six_letters(self):
22
+ def test_puzzle_with_06_letters(self):
23
23
  self.assertEqual(
24
24
  solve("NO + NO + TOO == LATE"),
25
25
  {"N": 7,
@@ -29,7 +29,7 @@ class TestAlphametics(unittest.TestCase):
29
29
  "A": 0,
30
30
  "E": 2})
31
31
 
32
- def test_puzzle_with_seven_letters(self):
32
+ def test_puzzle_with_07_letters(self):
33
33
  self.assertEqual(
34
34
  solve("HE + SEES + THE == LIGHT"),
35
35
  {"E": 4,
@@ -40,7 +40,7 @@ class TestAlphametics(unittest.TestCase):
40
40
  "S": 9,
41
41
  "T": 7})
42
42
 
43
- def test_puzzle_with_eight_letters(self):
43
+ def test_puzzle_with_08_letters(self):
44
44
  self.assertEqual(
45
45
  solve("SEND + MORE == MONEY"),
46
46
  {"S": 9,
@@ -52,7 +52,7 @@ class TestAlphametics(unittest.TestCase):
52
52
  "R": 8,
53
53
  "Y": 2})
54
54
 
55
- def test_puzzle_with_ten_letters(self):
55
+ def test_puzzle_with_10_letters(self):
56
56
  self.assertEqual(
57
57
  solve("AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE"),
58
58
  {"A": 5,
@@ -3,59 +3,57 @@ import unittest
3
3
  from queen_attack import board, can_attack
4
4
 
5
5
 
6
+ # Tests adapted from `problem-specifications//canonical-data.json` @ v2.0.0
7
+
6
8
  class QueenAttackTest(unittest.TestCase):
7
- def test_board1(self):
8
- ans = ['________',
9
- '________',
10
- '___W____',
11
- '________',
12
- '________',
13
- '______B_',
14
- '________',
15
- '________']
16
- self.assertEqual(board((2, 3), (5, 6)), ans)
17
9
 
18
- def test_board2(self):
19
- ans = ['______W_',
20
- '_______B',
21
- '________',
22
- '________',
23
- '________',
24
- '________',
25
- '________',
26
- '________']
27
- self.assertEqual(board((0, 6), (1, 7)), ans)
10
+ def test_queen_valid_position(self):
11
+ try:
12
+ board((1, 1), (2, 2))
13
+ except ValueError:
14
+ self.fail("Unexpected Exception")
28
15
 
29
- def test_attack_true1(self):
30
- self.assertIs(can_attack((2, 3), (5, 6)), True)
16
+ def test_queen_negative_row(self):
17
+ with self.assertRaises(ValueError):
18
+ board((1, 1), (-2, 2))
19
+
20
+ def test_queen_invalid_row(self):
21
+ with self.assertRaises(ValueError):
22
+ board((1, 1), (8, 4))
31
23
 
32
- def test_attack_true2(self):
33
- self.assertIs(can_attack((2, 6), (5, 3)), True)
24
+ def test_queen_negative_column(self):
25
+ with self.assertRaises(ValueError):
26
+ board((1, 1), (2, -2))
27
+
28
+ def test_queen_invalid_column(self):
29
+ with self.assertRaises(ValueError):
30
+ board((1, 1), (4, 8))
34
31
 
35
- def test_attack_true3(self):
36
- self.assertIs(can_attack((2, 4), (2, 7)), True)
32
+ def test_attack_false(self):
33
+ self.assertIs(can_attack((2, 4), (6, 6)), False)
37
34
 
38
- def test_attack_true4(self):
39
- self.assertIs(can_attack((5, 4), (2, 4)), True)
35
+ def test_attack_same_row(self):
36
+ self.assertIs(can_attack((2, 4), (2, 6)), True)
40
37
 
41
- def test_attack_true5(self):
42
- self.assertIs(can_attack((1, 1), (6, 6)), True)
38
+ def test_attack_same_column(self):
39
+ self.assertIs(can_attack((4, 5), (2, 5)), True)
43
40
 
44
- def test_attack_true6(self):
45
- self.assertIs(can_attack((0, 6), (1, 7)), True)
41
+ def test_attack_diagonal1(self):
42
+ self.assertIs(can_attack((2, 2), (0, 4)), True)
46
43
 
47
- def test_attack_false1(self):
48
- self.assertIs(can_attack((4, 2), (0, 5)), False)
44
+ def test_attack_diagonal2(self):
45
+ self.assertIs(can_attack((2, 2), (3, 1)), True)
49
46
 
50
- def test_attack_false2(self):
51
- self.assertIs(can_attack((2, 3), (4, 7)), False)
47
+ def test_attack_diagonal3(self):
48
+ self.assertIs(can_attack((2, 2), (1, 1)), True)
49
+
50
+ def test_attack_diagonal4(self):
51
+ self.assertIs(can_attack((2, 2), (5, 5)), True)
52
+
53
+ # Tests beyond this point are not part of the canonical data.
52
54
 
53
55
  # If either board or can_attack are called with an invalid board position
54
56
  # they should raise a ValueError with a meaningful error message.
55
- def test_invalid_position_board(self):
56
- with self.assertRaises(ValueError):
57
- board((0, 0), (7, 8))
58
-
59
57
  def test_invalid_position_can_attack(self):
60
58
  with self.assertRaises(ValueError):
61
59
  can_attack((0, 0), (7, 8))
@@ -68,6 +66,28 @@ class QueenAttackTest(unittest.TestCase):
68
66
  with self.assertRaises(ValueError):
69
67
  can_attack((2, 2), (2, 2))
70
68
 
69
+ def test_board1(self):
70
+ ans = ['________',
71
+ '________',
72
+ '___W____',
73
+ '________',
74
+ '________',
75
+ '______B_',
76
+ '________',
77
+ '________']
78
+ self.assertEqual(board((2, 3), (5, 6)), ans)
79
+
80
+ def test_board2(self):
81
+ ans = ['______W_',
82
+ '_______B',
83
+ '________',
84
+ '________',
85
+ '________',
86
+ '________',
87
+ '________',
88
+ '________']
89
+ self.assertEqual(board((0, 6), (1, 7)), ans)
90
+
71
91
 
72
92
  if __name__ == '__main__':
73
93
  unittest.main()
@@ -2,7 +2,7 @@
2
2
  "blurb": "Standard ML is a functional programming language with type inference and some side-effects.",
3
3
  "language": "Standard ML",
4
4
  "checklist_issue": 8,
5
- "active": false,
5
+ "active": true,
6
6
  "test_pattern": "test[.]sml$",
7
7
  "exercises": [
8
8
  {
@@ -237,7 +237,6 @@
237
237
  ]
238
238
  },
239
239
  {
240
-
241
240
  "uuid": "f7ea4ee6-cd34-4dc9-bd96-abcf940873f0",
242
241
  "slug": "diamond",
243
242
  "core": false,
@@ -249,6 +248,18 @@
249
248
  "text_formatting"
250
249
  ]
251
250
  },
251
+ {
252
+ "uuid": "c257cb38-ed8d-473f-b02a-5dd8131fdc63",
253
+ "slug": "pig-latin",
254
+ "core": false,
255
+ "unlocked_by": null,
256
+ "difficulty": 1,
257
+ "topics": [
258
+ "strings",
259
+ "lists",
260
+ "text_formatting"
261
+ ]
262
+ },
252
263
  {
253
264
  "uuid": "225cfd7d-81a3-4a58-b1aa-1de2e40e7a93",
254
265
  "slug": "binary",
@@ -0,0 +1,54 @@
1
+ # Pig Latin
2
+
3
+ Implement a program that translates from English to Pig Latin.
4
+
5
+ Pig Latin is a made-up children's language that's intended to be
6
+ confusing. It obeys a few simple rules (below), but when it's spoken
7
+ quickly it's really difficult for non-children (and non-native speakers)
8
+ to understand.
9
+
10
+ - **Rule 1**: If a word begins with a vowel sound, add an "ay" sound to
11
+ the end of the word.
12
+ - **Rule 2**: If a word begins with a consonant sound, move it to the
13
+ end of the word, and then add an "ay" sound to the end of the word.
14
+
15
+ There are a few more rules for edge cases, and there are regional
16
+ variants too.
17
+
18
+ See <http://en.wikipedia.org/wiki/Pig_latin> for more details.
19
+
20
+ ## Loading your exercise implementation in PolyML
21
+
22
+ ```
23
+ $ poly --use {exercise}.sml
24
+ ```
25
+
26
+ Or:
27
+
28
+ ```
29
+ $ poly
30
+ > use "{exercise}.sml";
31
+ ```
32
+
33
+ **Note:** You have to replace {exercise}.
34
+
35
+ ## Running the tests
36
+
37
+ ```
38
+ $ poly -q --use test.sml
39
+ ```
40
+
41
+ ## Feedback, Issues, Pull Requests
42
+
43
+ The [exercism/sml](https://github.com/exercism/sml) repository on
44
+ GitHub is the home for all of the Standard ML exercises.
45
+
46
+ If you have feedback about an exercise, or want to help implementing a new
47
+ one, head over there and create an issue. We'll do our best to help you!
48
+
49
+ ## Source
50
+
51
+ The Pig Latin exercise at Test First Teaching by Ultrasaurus [https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/](https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/)
52
+
53
+ ## Submitting Incomplete Solutions
54
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,23 @@
1
+ fun isVowelCluster #"a" _ = true
2
+ | isVowelCluster #"e" _ = true
3
+ | isVowelCluster #"i" _ = true
4
+ | isVowelCluster #"o" _ = true
5
+ | isVowelCluster #"u" _ = true
6
+ | isVowelCluster #"y" #"t" = true
7
+ | isVowelCluster #"x" #"r" = true
8
+ | isVowelCluster _ _ = false
9
+
10
+ fun isCluster #"q" #"u" = true
11
+ | isCluster _ _ = false
12
+
13
+ fun translate' [] = ""
14
+ | translate' [x] = Char.toString x ^ "ay"
15
+ | translate' [#"m", #"y"] = "ymay"
16
+ | translate' (word as (a::b::cs)) =
17
+ if isVowelCluster a b
18
+ then implode word ^ "ay"
19
+ else if isCluster a b
20
+ then translate' (cs @ [a, b])
21
+ else translate' (b :: cs @ [a])
22
+
23
+ fun translate words = String.concatWith " " (map (translate' o explode) (String.tokens Char.isSpace words))
@@ -0,0 +1,2 @@
1
+ fun translate (input: string): string =
2
+ raise Fail "'translate' is not implemented"
@@ -0,0 +1,90 @@
1
+ (* version 1.1.0 *)
2
+
3
+ use "testlib.sml";
4
+ use "pig-latin.sml";
5
+
6
+ infixr |>
7
+ fun x |> f = f x
8
+
9
+ val testsuite =
10
+ describe "pig-latin" [
11
+ describe "ay is added to words that start with vowels" [
12
+ test "word beginning with a"
13
+ (fn _ => translate ("apple") |> Expect.equalTo "appleay"),
14
+
15
+ test "word beginning with e"
16
+ (fn _ => translate ("ear") |> Expect.equalTo "earay"),
17
+
18
+ test "word beginning with i"
19
+ (fn _ => translate ("igloo") |> Expect.equalTo "iglooay"),
20
+
21
+ test "word beginning with o"
22
+ (fn _ => translate ("object") |> Expect.equalTo "objectay"),
23
+
24
+ test "word beginning with u"
25
+ (fn _ => translate ("under") |> Expect.equalTo "underay"),
26
+
27
+ test "word beginning with a vowel and followed by a qu"
28
+ (fn _ => translate ("equal") |> Expect.equalTo "equalay")
29
+ ],
30
+
31
+ describe "first letter and ay are moved to the end of words that start with consonants" [
32
+ test "word beginning with p"
33
+ (fn _ => translate ("pig") |> Expect.equalTo "igpay"),
34
+
35
+ test "word beginning with k"
36
+ (fn _ => translate ("koala") |> Expect.equalTo "oalakay"),
37
+
38
+ test "word beginning with x"
39
+ (fn _ => translate ("xenon") |> Expect.equalTo "enonxay"),
40
+
41
+ test "word beginning with q without a following u"
42
+ (fn _ => translate ("qat") |> Expect.equalTo "atqay")
43
+ ],
44
+
45
+ describe "some letter clusters are treated like a single consonant" [
46
+ test "word beginning with ch"
47
+ (fn _ => translate ("chair") |> Expect.equalTo "airchay"),
48
+
49
+ test "word beginning with qu"
50
+ (fn _ => translate ("queen") |> Expect.equalTo "eenquay"),
51
+
52
+ test "word beginning with qu and a preceding consonant"
53
+ (fn _ => translate ("square") |> Expect.equalTo "aresquay"),
54
+
55
+ test "word beginning with th"
56
+ (fn _ => translate ("therapy") |> Expect.equalTo "erapythay"),
57
+
58
+ test "word beginning with thr"
59
+ (fn _ => translate ("thrush") |> Expect.equalTo "ushthray"),
60
+
61
+ test "word beginning with sch"
62
+ (fn _ => translate ("school") |> Expect.equalTo "oolschay")
63
+ ],
64
+
65
+ describe "some letter clusters are treated like a single vowel" [
66
+ test "word beginning with yt"
67
+ (fn _ => translate ("yttria") |> Expect.equalTo "yttriaay"),
68
+
69
+ test "word beginning with xr"
70
+ (fn _ => translate ("xray") |> Expect.equalTo "xrayay")
71
+ ],
72
+
73
+ describe "position of y in a word determines if it is a consonant or a vowel" [
74
+ test "y is treated like a consonant at the beginning of a word"
75
+ (fn _ => translate ("yellow") |> Expect.equalTo "ellowyay"),
76
+
77
+ test "y is treated like a vowel at the end of a consonant cluster"
78
+ (fn _ => translate ("rhythm") |> Expect.equalTo "ythmrhay"),
79
+
80
+ test "y as second letter in two letter word"
81
+ (fn _ => translate ("my") |> Expect.equalTo "ymay")
82
+ ],
83
+
84
+ describe "phrases are translated" [
85
+ test "a whole phrase"
86
+ (fn _ => translate ("quick fast run") |> Expect.equalTo "ickquay astfay unray")
87
+ ]
88
+ ]
89
+
90
+ val _ = Test.run testsuite