trackler 2.2.1.74 → 2.2.1.75
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fixtures/tracks/fruit/docs/something.md +0 -0
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/README.md +8 -4
- data/problem-specifications/exercises/acronym/canonical-data.json +19 -7
- data/problem-specifications/exercises/all-your-base/canonical-data.json +106 -64
- data/problem-specifications/exercises/allergies/canonical-data.json +37 -13
- data/tracks/c/config.json +176 -176
- data/tracks/clojure/config.json +17 -1
- data/tracks/clojure/exercises/isbn-verifier/README.md +43 -0
- data/tracks/clojure/exercises/isbn-verifier/project.clj +4 -0
- data/tracks/clojure/exercises/isbn-verifier/src/example.clj +17 -0
- data/tracks/clojure/exercises/isbn-verifier/src/isbn_verifier.clj +3 -0
- data/tracks/clojure/exercises/isbn-verifier/test/isbn_verifier_test.clj +42 -0
- data/tracks/clojure/exercises/proverb/README.md +15 -0
- data/tracks/clojure/exercises/proverb/project.clj +4 -0
- data/tracks/clojure/exercises/proverb/src/example.clj +15 -0
- data/tracks/clojure/exercises/proverb/src/proverb.clj +3 -0
- data/tracks/clojure/exercises/proverb/test/proverb_test.clj +14 -0
- data/tracks/common-lisp/docs/LEARNING.md +4 -3
- data/tracks/common-lisp/docs/RESOURCES.md +11 -0
- data/tracks/delphi/.gitignore +1 -0
- data/tracks/delphi/config.json +24 -0
- data/tracks/delphi/docs/INSTALLATION.md +1 -1
- data/tracks/delphi/exercises/isbn-verifier/ISBNVerifier.dpr +60 -0
- data/tracks/delphi/exercises/isbn-verifier/README.md +68 -0
- data/tracks/delphi/exercises/isbn-verifier/uISBNVerifierExample.pas +46 -0
- data/tracks/delphi/exercises/isbn-verifier/uTestISBNVerifier.pas +136 -0
- data/tracks/delphi/exercises/secret-handshake/README.md +56 -0
- data/tracks/delphi/exercises/secret-handshake/SecretHandshake.dpr +60 -0
- data/tracks/delphi/exercises/secret-handshake/uSecretHandshakeExample.pas +56 -0
- data/tracks/delphi/exercises/secret-handshake/uTestSecretHandshake.pas +215 -0
- data/tracks/ecmascript/docs/ABOUT.md +13 -9
- data/tracks/factor/exercises/two-fer/README.md +1 -1
- data/tracks/fsharp/docs/RESOURCES.md +1 -1
- data/tracks/fsharp/generators/{Input.fs → CanonicalData.fs} +5 -10
- data/tracks/fsharp/generators/Exercise.fs +11 -10
- data/tracks/fsharp/generators/{Output.fs → Formatting.fs} +2 -56
- data/tracks/fsharp/generators/Generators.fs +93 -93
- data/tracks/fsharp/generators/Generators.fsproj +9 -4
- data/tracks/fsharp/generators/Options.fs +1 -1
- data/tracks/fsharp/generators/Program.fs +3 -3
- data/tracks/fsharp/generators/Rendering.fs +57 -0
- data/tracks/go/exercises/all-your-base/.meta/gen.go +80 -0
- data/tracks/go/exercises/all-your-base/.meta/hints.md +13 -0
- data/tracks/go/exercises/all-your-base/README.md +16 -1
- data/tracks/go/exercises/all-your-base/all_your_base_test.go +12 -163
- data/tracks/go/exercises/all-your-base/cases_test.go +183 -0
- data/tracks/go/exercises/all-your-base/example.go +25 -29
- data/tracks/java/CONTRIBUTING.md +1 -1
- data/tracks/java/POLICIES.md +15 -1
- data/tracks/java/exercises/flatten-array/.meta/hints.md +58 -0
- data/tracks/java/exercises/flatten-array/README.md +62 -0
- data/tracks/java/exercises/hamming/src/main/java/Hamming.java +1 -1
- data/tracks/java/exercises/matrix/.meta/src/reference/java/Matrix.java +6 -6
- data/tracks/java/exercises/meetup/.meta/src/reference/java/Meetup.java +2 -2
- data/tracks/java/exercises/meetup/.meta/src/reference/java/MeetupSchedule.java +1 -1
- data/tracks/java/exercises/meetup/src/main/java/MeetupSchedule.java +1 -1
- data/tracks/java/exercises/pig-latin/.meta/hints.md +58 -0
- data/tracks/java/exercises/pig-latin/README.md +61 -0
- data/tracks/java/exercises/reverse-string/src/main/java/ReverseString.java +2 -2
- data/tracks/java/exercises/secret-handshake/README.md +1 -1
- data/tracks/javascript/.eslintignore +0 -3
- data/tracks/javascript/exercises/food-chain/example.js +50 -37
- data/tracks/javascript/exercises/octal/example.js +1 -1
- data/tracks/javascript/exercises/robot-name/robot-name.spec.js +7 -7
- data/tracks/javascript/package-lock.json +1846 -0
- data/tracks/python/docs/EXERCISE_README_INSERT.md +15 -0
- data/tracks/python/exercises/accumulate/README.md +15 -0
- data/tracks/python/exercises/acronym/README.md +15 -0
- data/tracks/python/exercises/all-your-base/README.md +15 -0
- data/tracks/python/exercises/all-your-base/all_your_base_test.py +19 -9
- data/tracks/python/exercises/allergies/README.md +15 -0
- data/tracks/python/exercises/alphametics/README.md +15 -0
- data/tracks/python/exercises/anagram/README.md +15 -0
- data/tracks/python/exercises/atbash-cipher/README.md +15 -0
- data/tracks/python/exercises/beer-song/README.md +16 -1
- data/tracks/python/exercises/binary-search-tree/README.md +16 -2
- data/tracks/python/exercises/binary-search/README.md +15 -0
- data/tracks/python/exercises/binary-search/binary_search_test.py +14 -4
- data/tracks/python/exercises/binary/README.md +15 -0
- data/tracks/python/exercises/binary/binary_test.py +14 -4
- data/tracks/python/exercises/bob/README.md +15 -0
- data/tracks/python/exercises/book-store/README.md +15 -0
- data/tracks/python/exercises/bracket-push/README.md +15 -0
- data/tracks/python/exercises/change/README.md +15 -0
- data/tracks/python/exercises/circular-buffer/README.md +15 -0
- data/tracks/python/exercises/circular-buffer/circular_buffer_test.py +15 -5
- data/tracks/python/exercises/circular-buffer/example.py +2 -2
- data/tracks/python/exercises/clock/README.md +15 -0
- data/tracks/python/exercises/collatz-conjecture/.meta/hints.md +1 -1
- data/tracks/python/exercises/collatz-conjecture/README.md +15 -0
- data/tracks/python/exercises/complex-numbers/README.md +15 -0
- data/tracks/python/exercises/connect/README.md +18 -3
- data/tracks/python/exercises/crypto-square/README.md +15 -0
- data/tracks/python/exercises/diamond/README.md +15 -0
- data/tracks/python/exercises/difference-of-squares/README.md +15 -0
- data/tracks/python/exercises/diffie-hellman/README.md +14 -0
- data/tracks/python/exercises/dominoes/README.md +16 -1
- data/tracks/python/exercises/error-handling/README.md +17 -0
- data/tracks/python/exercises/error-handling/error_handling_test.py +13 -3
- data/tracks/python/exercises/error-handling/example.py +1 -1
- data/tracks/python/exercises/etl/README.md +16 -1
- data/tracks/python/exercises/flatten-array/README.md +15 -0
- data/tracks/python/exercises/food-chain/README.md +15 -0
- data/tracks/python/exercises/forth/README.md +15 -0
- data/tracks/python/exercises/forth/example.py +7 -9
- data/tracks/python/exercises/forth/forth_test.py +107 -17
- data/tracks/python/exercises/gigasecond/README.md +15 -0
- data/tracks/python/exercises/go-counting/README.md +21 -3
- data/tracks/python/exercises/grade-school/README.md +15 -0
- data/tracks/python/exercises/grains/README.md +15 -0
- data/tracks/python/exercises/grains/grains_test.py +16 -6
- data/tracks/python/exercises/grep/README.md +15 -0
- data/tracks/python/exercises/hamming/README.md +15 -0
- data/tracks/python/exercises/hamming/hamming_test.py +12 -2
- data/tracks/python/exercises/hello-world/README.md +15 -0
- data/tracks/python/exercises/hexadecimal/README.md +15 -0
- data/tracks/python/exercises/hexadecimal/hexadecimal_test.py +11 -1
- data/tracks/python/exercises/house/README.md +16 -1
- data/tracks/python/exercises/isogram/README.md +15 -0
- data/tracks/python/exercises/kindergarten-garden/README.md +18 -3
- data/tracks/python/exercises/largest-series-product/README.md +15 -0
- data/tracks/python/exercises/largest-series-product/largest_series_product_test.py +14 -4
- data/tracks/python/exercises/leap/README.md +15 -0
- data/tracks/python/exercises/linked-list/README.md +15 -0
- data/tracks/python/exercises/list-ops/README.md +15 -0
- data/tracks/python/exercises/luhn/README.md +15 -0
- data/tracks/python/exercises/markdown/README.md +18 -0
- data/tracks/python/exercises/matrix/README.md +15 -0
- data/tracks/python/exercises/meetup/README.md +31 -12
- data/tracks/python/exercises/meetup/meetup_test.py +11 -1
- data/tracks/python/exercises/minesweeper/README.md +15 -0
- data/tracks/python/exercises/minesweeper/minesweeper_test.py +12 -2
- data/tracks/python/exercises/nth-prime/README.md +15 -0
- data/tracks/python/exercises/nth-prime/nth_prime_test.py +11 -1
- data/tracks/python/exercises/nucleotide-count/README.md +17 -2
- data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +11 -1
- data/tracks/python/exercises/ocr-numbers/README.md +16 -1
- data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +12 -2
- data/tracks/python/exercises/octal/README.md +15 -0
- data/tracks/python/exercises/octal/octal_test.py +16 -3
- data/tracks/python/exercises/palindrome-products/README.md +16 -1
- data/tracks/python/exercises/pangram/README.md +15 -0
- data/tracks/python/exercises/pascals-triangle/README.md +16 -1
- data/tracks/python/exercises/perfect-numbers/README.md +15 -0
- data/tracks/python/exercises/perfect-numbers/perfect_numbers_test.py +13 -3
- data/tracks/python/exercises/phone-number/README.md +16 -2
- data/tracks/python/exercises/phone-number/example.py +1 -1
- data/tracks/python/exercises/phone-number/phone_number_test.py +17 -7
- data/tracks/python/exercises/pig-latin/README.md +15 -0
- data/tracks/python/exercises/point-mutations/README.md +15 -0
- data/tracks/python/exercises/poker/README.md +15 -0
- data/tracks/python/exercises/pov/README.md +20 -2
- data/tracks/python/exercises/pov/example.py +2 -2
- data/tracks/python/exercises/pov/pov_test.py +15 -5
- data/tracks/python/exercises/prime-factors/README.md +15 -0
- data/tracks/python/exercises/protein-translation/README.md +15 -0
- data/tracks/python/exercises/protein-translation/protein_translation_test.py +10 -0
- data/tracks/python/exercises/proverb/README.md +14 -0
- data/tracks/python/exercises/pythagorean-triplet/README.md +15 -0
- data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet_test.py +11 -1
- data/tracks/python/exercises/queen-attack/README.md +15 -0
- data/tracks/python/exercises/queen-attack/queen_attack_test.py +17 -7
- data/tracks/python/exercises/rail-fence-cipher/README.md +15 -0
- data/tracks/python/exercises/raindrops/README.md +15 -0
- data/tracks/python/exercises/react/README.md +15 -1
- data/tracks/python/exercises/rectangles/README.md +24 -9
- data/tracks/python/exercises/rna-transcription/.meta/hints.md +1 -0
- data/tracks/python/exercises/rna-transcription/README.md +18 -5
- data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +13 -3
- data/tracks/python/exercises/robot-name/README.md +15 -0
- data/tracks/python/exercises/robot-simulator/README.md +15 -0
- data/tracks/python/exercises/roman-numerals/README.md +15 -0
- data/tracks/python/exercises/rotational-cipher/README.md +15 -0
- data/tracks/python/exercises/run-length-encoding/README.md +15 -0
- data/tracks/python/exercises/saddle-points/README.md +15 -0
- data/tracks/python/exercises/saddle-points/saddle_points_test.py +11 -1
- data/tracks/python/exercises/say/README.md +15 -0
- data/tracks/python/exercises/say/say_test.py +12 -2
- data/tracks/python/exercises/scale-generator/README.md +15 -0
- data/tracks/python/exercises/scale-generator/example.py +3 -3
- data/tracks/python/exercises/scale-generator/scale_generator_test.py +11 -1
- data/tracks/python/exercises/scrabble-score/README.md +15 -0
- data/tracks/python/exercises/secret-handshake/README.md +16 -1
- data/tracks/python/exercises/series/README.md +15 -0
- data/tracks/python/exercises/series/series_test.py +12 -2
- data/tracks/python/exercises/sieve/README.md +15 -0
- data/tracks/python/exercises/simple-cipher/.meta/hints.md +6 -6
- data/tracks/python/exercises/simple-cipher/README.md +17 -1
- data/tracks/python/exercises/simple-cipher/simple_cipher_test.py +12 -2
- data/tracks/python/exercises/simple-linked-list/{hints.md → .meta/hints.md} +10 -10
- data/tracks/python/exercises/simple-linked-list/README.md +16 -0
- data/tracks/python/exercises/simple-linked-list/example.py +2 -2
- data/tracks/python/exercises/simple-linked-list/simple_linked_list_test.py +13 -3
- data/tracks/python/exercises/space-age/README.md +15 -0
- data/tracks/python/exercises/strain/README.md +16 -3
- data/tracks/python/exercises/sublist/README.md +15 -0
- data/tracks/python/exercises/sum-of-multiples/README.md +18 -3
- data/tracks/python/exercises/tournament/README.md +15 -0
- data/tracks/python/exercises/transpose/README.md +15 -0
- data/tracks/python/exercises/tree-building/README.md +30 -0
- data/tracks/python/exercises/tree-building/example.py +3 -5
- data/tracks/python/exercises/tree-building/tree_building_test.py +16 -6
- data/tracks/python/exercises/triangle/README.md +15 -0
- data/tracks/python/exercises/triangle/example.py +1 -1
- data/tracks/python/exercises/triangle/triangle_test.py +15 -5
- data/tracks/python/exercises/trinary/README.md +15 -0
- data/tracks/python/exercises/twelve-days/README.md +15 -0
- data/tracks/python/exercises/two-bucket/README.md +22 -7
- data/tracks/python/exercises/two-fer/README.md +16 -0
- data/tracks/python/exercises/variable-length-quantity/README.md +15 -0
- data/tracks/python/exercises/variable-length-quantity/variable_length_quantity_test.py +12 -2
- data/tracks/python/exercises/word-count/README.md +15 -0
- data/tracks/python/exercises/word-search/README.md +15 -0
- data/tracks/python/exercises/wordy/README.md +15 -0
- data/tracks/python/exercises/wordy/wordy_test.py +14 -4
- data/tracks/python/exercises/zebra-puzzle/README.md +15 -0
- data/tracks/python/exercises/zipper/README.md +16 -3
- data/tracks/rust/config.json +11 -0
- data/tracks/rust/exercises/saddle-points/.gitignore +8 -0
- data/tracks/rust/exercises/saddle-points/Cargo.toml +5 -0
- data/tracks/rust/exercises/saddle-points/README.md +66 -0
- data/tracks/rust/exercises/saddle-points/example.rs +24 -0
- data/tracks/rust/exercises/saddle-points/src/lib.rs +3 -0
- data/tracks/rust/exercises/saddle-points/tests/saddle-points.rs +60 -0
- metadata +38 -5
@@ -17,6 +17,21 @@ There exists exactly one Pythagorean triplet for which a + b + c = 1000.
|
|
17
17
|
|
18
18
|
Find the product a * b * c.
|
19
19
|
|
20
|
+
## Exception messages
|
21
|
+
|
22
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
23
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
24
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
25
|
+
a message.
|
26
|
+
|
27
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
28
|
+
`raise Exception`, you shold write:
|
29
|
+
|
30
|
+
```python
|
31
|
+
raise Exception("Meaningful message indicating the source of the error")
|
32
|
+
```
|
33
|
+
|
34
|
+
|
20
35
|
## Submitting Exercises
|
21
36
|
|
22
37
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -80,9 +80,19 @@ class PythagoreanTripletTest(unittest.TestCase):
|
|
80
80
|
self.assertIs(is_triplet((924, 43, 925)), True)
|
81
81
|
|
82
82
|
def test_odd_number(self):
|
83
|
-
with self.
|
83
|
+
with self.assertRaisesWithMessage(ValueError):
|
84
84
|
primitive_triplets(5)
|
85
85
|
|
86
|
+
# Utility functions
|
87
|
+
def setUp(self):
|
88
|
+
try:
|
89
|
+
self.assertRaisesRegex = self.assertRaisesRegexp
|
90
|
+
except AttributeError:
|
91
|
+
pass
|
92
|
+
|
93
|
+
def assertRaisesWithMessage(self, exception):
|
94
|
+
return self.assertRaisesRegex(exception, r".+")
|
95
|
+
|
86
96
|
|
87
97
|
if __name__ == '__main__':
|
88
98
|
unittest.main()
|
@@ -26,6 +26,21 @@ You'd also be able to answer whether the queens can attack each other.
|
|
26
26
|
In this case, that answer would be yes, they can, because both pieces
|
27
27
|
share a diagonal.
|
28
28
|
|
29
|
+
## Exception messages
|
30
|
+
|
31
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
32
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
33
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
34
|
+
a message.
|
35
|
+
|
36
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
37
|
+
`raise Exception`, you shold write:
|
38
|
+
|
39
|
+
```python
|
40
|
+
raise Exception("Meaningful message indicating the source of the error")
|
41
|
+
```
|
42
|
+
|
43
|
+
|
29
44
|
## Submitting Exercises
|
30
45
|
|
31
46
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -14,19 +14,19 @@ class QueenAttackTest(unittest.TestCase):
|
|
14
14
|
self.fail("Unexpected Exception")
|
15
15
|
|
16
16
|
def test_queen_negative_row(self):
|
17
|
-
with self.
|
17
|
+
with self.assertRaisesWithMessage(ValueError):
|
18
18
|
board((1, 1), (-2, 2))
|
19
19
|
|
20
20
|
def test_queen_invalid_row(self):
|
21
|
-
with self.
|
21
|
+
with self.assertRaisesWithMessage(ValueError):
|
22
22
|
board((1, 1), (8, 4))
|
23
23
|
|
24
24
|
def test_queen_negative_column(self):
|
25
|
-
with self.
|
25
|
+
with self.assertRaisesWithMessage(ValueError):
|
26
26
|
board((1, 1), (2, -2))
|
27
27
|
|
28
28
|
def test_queen_invalid_column(self):
|
29
|
-
with self.
|
29
|
+
with self.assertRaisesWithMessage(ValueError):
|
30
30
|
board((1, 1), (4, 8))
|
31
31
|
|
32
32
|
def test_attack_false(self):
|
@@ -55,15 +55,15 @@ class QueenAttackTest(unittest.TestCase):
|
|
55
55
|
# If either board or can_attack are called with an invalid board position
|
56
56
|
# they should raise a ValueError with a meaningful error message.
|
57
57
|
def test_invalid_position_can_attack(self):
|
58
|
-
with self.
|
58
|
+
with self.assertRaisesWithMessage(ValueError):
|
59
59
|
can_attack((0, 0), (7, 8))
|
60
60
|
|
61
61
|
def test_queens_same_position_board(self):
|
62
|
-
with self.
|
62
|
+
with self.assertRaisesWithMessage(ValueError):
|
63
63
|
board((2, 2), (2, 2))
|
64
64
|
|
65
65
|
def test_queens_same_position_can_attack(self):
|
66
|
-
with self.
|
66
|
+
with self.assertRaisesWithMessage(ValueError):
|
67
67
|
can_attack((2, 2), (2, 2))
|
68
68
|
|
69
69
|
def test_board1(self):
|
@@ -88,6 +88,16 @@ class QueenAttackTest(unittest.TestCase):
|
|
88
88
|
'________']
|
89
89
|
self.assertEqual(board((0, 6), (1, 7)), ans)
|
90
90
|
|
91
|
+
# Utility functions
|
92
|
+
def setUp(self):
|
93
|
+
try:
|
94
|
+
self.assertRaisesRegex = self.assertRaisesRegexp
|
95
|
+
except AttributeError:
|
96
|
+
pass
|
97
|
+
|
98
|
+
def assertRaisesWithMessage(self, exception):
|
99
|
+
return self.assertRaisesRegex(exception, r".+")
|
100
|
+
|
91
101
|
|
92
102
|
if __name__ == '__main__':
|
93
103
|
unittest.main()
|
@@ -58,6 +58,21 @@ W . . . E . . . C . . . R . . . L . . . T . . . E
|
|
58
58
|
|
59
59
|
If you now read along the zig-zag shape you can read the original message.
|
60
60
|
|
61
|
+
## Exception messages
|
62
|
+
|
63
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
64
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
65
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
66
|
+
a message.
|
67
|
+
|
68
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
69
|
+
`raise Exception`, you shold write:
|
70
|
+
|
71
|
+
```python
|
72
|
+
raise Exception("Meaningful message indicating the source of the error")
|
73
|
+
```
|
74
|
+
|
75
|
+
|
61
76
|
## Submitting Exercises
|
62
77
|
|
63
78
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -17,6 +17,21 @@ Convert a number to a string, the contents of which depend on the number's facto
|
|
17
17
|
- 34 has four factors: 1, 2, 17, and 34.
|
18
18
|
- In raindrop-speak, this would be "34".
|
19
19
|
|
20
|
+
## Exception messages
|
21
|
+
|
22
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
23
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
24
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
25
|
+
a message.
|
26
|
+
|
27
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
28
|
+
`raise Exception`, you shold write:
|
29
|
+
|
30
|
+
```python
|
31
|
+
raise Exception("Meaningful message indicating the source of the error")
|
32
|
+
```
|
33
|
+
|
34
|
+
|
20
35
|
## Submitting Exercises
|
21
36
|
|
22
37
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -15,13 +15,27 @@ In addition, compute cells should allow for registering change notification
|
|
15
15
|
callbacks. Call a cell’s callbacks when the cell’s value in a new stable
|
16
16
|
state has changed from the previous stable state.
|
17
17
|
|
18
|
+
## Exception messages
|
19
|
+
|
20
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
21
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
22
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
23
|
+
a message.
|
24
|
+
|
25
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
26
|
+
`raise Exception`, you shold write:
|
27
|
+
|
28
|
+
```python
|
29
|
+
raise Exception("Meaningful message indicating the source of the error")
|
30
|
+
```
|
31
|
+
|
32
|
+
|
18
33
|
## Submitting Exercises
|
19
34
|
|
20
35
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
21
36
|
|
22
37
|
For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.
|
23
38
|
|
24
|
-
|
25
39
|
For more detailed information about running tests, code style and linting,
|
26
40
|
please see the [help page](http://exercism.io/languages/python).
|
27
41
|
|
@@ -37,32 +37,47 @@ The above diagram contains 6 rectangles:
|
|
37
37
|
```
|
38
38
|
|
39
39
|
```text
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
+--+
|
43
43
|
| |
|
44
44
|
+--+
|
45
45
|
```
|
46
46
|
|
47
47
|
```text
|
48
|
-
|
49
|
-
|
48
|
+
|
49
|
+
|
50
50
|
+--+
|
51
51
|
| |
|
52
52
|
+--+
|
53
53
|
```
|
54
54
|
|
55
55
|
```text
|
56
|
-
|
57
|
-
++
|
58
|
-
++
|
59
|
-
|
60
|
-
|
56
|
+
|
57
|
+
++
|
58
|
+
++
|
59
|
+
|
60
|
+
|
61
61
|
```
|
62
62
|
|
63
63
|
You may assume that the input is always a proper rectangle (i.e. the length of
|
64
64
|
every line equals the length of the first line).
|
65
65
|
|
66
|
+
## Exception messages
|
67
|
+
|
68
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
69
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
70
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
71
|
+
a message.
|
72
|
+
|
73
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
74
|
+
`raise Exception`, you shold write:
|
75
|
+
|
76
|
+
```python
|
77
|
+
raise Exception("Meaningful message indicating the source of the error")
|
78
|
+
```
|
79
|
+
|
80
|
+
|
66
81
|
## Submitting Exercises
|
67
82
|
|
68
83
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -0,0 +1 @@
|
|
1
|
+
Your function will need to be able to handle invalid inputs by raising a `ValueError` with a meaningful message.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# RNA Transcription
|
2
2
|
|
3
3
|
Given a DNA strand, return its RNA complement (per RNA transcription).
|
4
4
|
|
@@ -18,8 +18,23 @@ each nucleotide with its complement:
|
|
18
18
|
* `T` -> `A`
|
19
19
|
* `A` -> `U`
|
20
20
|
|
21
|
-
Your function will need to be able to handle invalid inputs by raising a
|
22
|
-
|
21
|
+
Your function will need to be able to handle invalid inputs by raising a `ValueError` with a meaningful message.
|
22
|
+
|
23
|
+
|
24
|
+
## Exception messages
|
25
|
+
|
26
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
27
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
28
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
29
|
+
a message.
|
30
|
+
|
31
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
32
|
+
`raise Exception`, you shold write:
|
33
|
+
|
34
|
+
```python
|
35
|
+
raise Exception("Meaningful message indicating the source of the error")
|
36
|
+
```
|
37
|
+
|
23
38
|
|
24
39
|
## Submitting Exercises
|
25
40
|
|
@@ -34,7 +49,5 @@ please see the [help page](http://exercism.io/languages/python).
|
|
34
49
|
|
35
50
|
Rosalind [http://rosalind.info/problems/rna](http://rosalind.info/problems/rna)
|
36
51
|
|
37
|
-
Note that in this problem we are finding the complement, so we also swap for the complementary bases - unlike the Rosalind problem which is just swapping T for U.
|
38
|
-
|
39
52
|
## Submitting Incomplete Solutions
|
40
53
|
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -23,17 +23,27 @@ class DNATests(unittest.TestCase):
|
|
23
23
|
self.assertEqual(to_rna('ACGTGGTCTTAA'), 'UGCACCAGAAUU')
|
24
24
|
|
25
25
|
def test_correctly_handles_single_invalid_input(self):
|
26
|
-
with self.
|
26
|
+
with self.assertRaisesWithMessage(ValueError):
|
27
27
|
to_rna('U')
|
28
28
|
|
29
29
|
def test_correctly_handles_completely_invalid_input(self):
|
30
|
-
with self.
|
30
|
+
with self.assertRaisesWithMessage(ValueError):
|
31
31
|
to_rna('XXX')
|
32
32
|
|
33
33
|
def test_correctly_handles_partially_invalid_input(self):
|
34
|
-
with self.
|
34
|
+
with self.assertRaisesWithMessage(ValueError):
|
35
35
|
to_rna('ACGTXXXCTTAA')
|
36
36
|
|
37
|
+
# Utility functions
|
38
|
+
def setUp(self):
|
39
|
+
try:
|
40
|
+
self.assertRaisesRegex = self.assertRaisesRegexp
|
41
|
+
except AttributeError:
|
42
|
+
pass
|
43
|
+
|
44
|
+
def assertRaisesWithMessage(self, exception):
|
45
|
+
return self.assertRaisesRegex(exception, r".+")
|
46
|
+
|
37
47
|
|
38
48
|
if __name__ == '__main__':
|
39
49
|
unittest.main()
|
@@ -15,6 +15,21 @@ The names must be random: they should not follow a predictable sequence.
|
|
15
15
|
Random names means a risk of collisions. Your solution must ensure that
|
16
16
|
every existing robot has a unique name.
|
17
17
|
|
18
|
+
## Exception messages
|
19
|
+
|
20
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
21
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
22
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
23
|
+
a message.
|
24
|
+
|
25
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
26
|
+
`raise Exception`, you shold write:
|
27
|
+
|
28
|
+
```python
|
29
|
+
raise Exception("Meaningful message indicating the source of the error")
|
30
|
+
```
|
31
|
+
|
32
|
+
|
18
33
|
## Submitting Exercises
|
19
34
|
|
20
35
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -27,6 +27,21 @@ direction it is pointing.
|
|
27
27
|
- Say a robot starts at {7, 3} facing north. Then running this stream
|
28
28
|
of instructions should leave it at {9, 4} facing west.
|
29
29
|
|
30
|
+
## Exception messages
|
31
|
+
|
32
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
33
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
34
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
35
|
+
a message.
|
36
|
+
|
37
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
38
|
+
`raise Exception`, you shold write:
|
39
|
+
|
40
|
+
```python
|
41
|
+
raise Exception("Meaningful message indicating the source of the error")
|
42
|
+
```
|
43
|
+
|
44
|
+
|
30
45
|
## Submitting Exercises
|
31
46
|
|
32
47
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -42,6 +42,21 @@ In Roman numerals 1990 is MCMXC:
|
|
42
42
|
|
43
43
|
See also: http://www.novaroma.org/via_romana/numbers.html
|
44
44
|
|
45
|
+
## Exception messages
|
46
|
+
|
47
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
48
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
49
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
50
|
+
a message.
|
51
|
+
|
52
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
53
|
+
`raise Exception`, you shold write:
|
54
|
+
|
55
|
+
```python
|
56
|
+
raise Exception("Meaningful message indicating the source of the error")
|
57
|
+
```
|
58
|
+
|
59
|
+
|
45
60
|
## Submitting Exercises
|
46
61
|
|
47
62
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -30,6 +30,21 @@ Ciphertext is written out in the same formatting as the input including spaces a
|
|
30
30
|
- ROT13 `The quick brown fox jumps over the lazy dog.` gives `Gur dhvpx oebja sbk whzcf bire gur ynml qbt.`
|
31
31
|
- ROT13 `Gur dhvpx oebja sbk whzcf bire gur ynml qbt.` gives `The quick brown fox jumps over the lazy dog.`
|
32
32
|
|
33
|
+
## Exception messages
|
34
|
+
|
35
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
36
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
37
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
38
|
+
a message.
|
39
|
+
|
40
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
41
|
+
`raise Exception`, you shold write:
|
42
|
+
|
43
|
+
```python
|
44
|
+
raise Exception("Meaningful message indicating the source of the error")
|
45
|
+
```
|
46
|
+
|
47
|
+
|
33
48
|
## Submitting Exercises
|
34
49
|
|
35
50
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -23,6 +23,21 @@ the letters A through Z (either lower or upper case) and whitespace. This way
|
|
23
23
|
data to be encoded will never contain any numbers and numbers inside data to
|
24
24
|
be decoded always represent the count for the following character.
|
25
25
|
|
26
|
+
## Exception messages
|
27
|
+
|
28
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
29
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
30
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
31
|
+
a message.
|
32
|
+
|
33
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
34
|
+
`raise Exception`, you shold write:
|
35
|
+
|
36
|
+
```python
|
37
|
+
raise Exception("Meaningful message indicating the source of the error")
|
38
|
+
```
|
39
|
+
|
40
|
+
|
26
41
|
## Submitting Exercises
|
27
42
|
|
28
43
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -26,6 +26,21 @@ saddle points for any given matrix.
|
|
26
26
|
Note that you may find other definitions of matrix saddle points online,
|
27
27
|
but the tests for this exercise follow the above unambiguous definition.
|
28
28
|
|
29
|
+
## Exception messages
|
30
|
+
|
31
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
32
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
33
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
34
|
+
a message.
|
35
|
+
|
36
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
37
|
+
`raise Exception`, you shold write:
|
38
|
+
|
39
|
+
```python
|
40
|
+
raise Exception("Meaningful message indicating the source of the error")
|
41
|
+
```
|
42
|
+
|
43
|
+
|
29
44
|
## Submitting Exercises
|
30
45
|
|
31
46
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|