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
@@ -9,9 +9,7 @@ For example, given the collection of numbers:
|
|
9
9
|
|
10
10
|
- 1, 2, 3, 4, 5
|
11
11
|
|
12
|
-
And the predicate:
|
13
|
-
|
14
|
-
Note: _a predicate P(x) will be true or false, depending on whether x belongs to a set._ [Wikipedia - Predicate](https://en.wikipedia.org/wiki/Predicate_(mathematical_logic)))
|
12
|
+
And the predicate:
|
15
13
|
|
16
14
|
- is the number even?
|
17
15
|
|
@@ -35,6 +33,21 @@ Keep your hands off that filter/reject/whatchamacallit functionality
|
|
35
33
|
provided by your standard library! Solve this one yourself using other
|
36
34
|
basic tools instead.
|
37
35
|
|
36
|
+
## Exception messages
|
37
|
+
|
38
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
39
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
40
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
41
|
+
a message.
|
42
|
+
|
43
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
44
|
+
`raise Exception`, you shold write:
|
45
|
+
|
46
|
+
```python
|
47
|
+
raise Exception("Meaningful message indicating the source of the error")
|
48
|
+
```
|
49
|
+
|
50
|
+
|
38
51
|
## Submitting Exercises
|
39
52
|
|
40
53
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -17,6 +17,21 @@ Examples:
|
|
17
17
|
* A = [1, 2, 3, 4, 5], B = [2, 3, 4], A is a superlist of B
|
18
18
|
* A = [1, 2, 4], B = [1, 2, 3, 4, 5], A is not a superlist of, sublist of or equal to B
|
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.
|
@@ -1,13 +1,28 @@
|
|
1
1
|
# Sum Of Multiples
|
2
2
|
|
3
|
-
Given a number, find the sum of all the multiples of particular numbers up to
|
3
|
+
Given a number, find the sum of all the unique multiples of particular numbers up to
|
4
4
|
but not including that number.
|
5
5
|
|
6
|
-
If we list all the natural numbers
|
7
|
-
|
6
|
+
If we list all the natural numbers below 20 that are multiples of 3 or 5,
|
7
|
+
we get 3, 5, 6, 9, 10, 12, 15, and 18.
|
8
8
|
|
9
9
|
The sum of these multiples is 78.
|
10
10
|
|
11
|
+
## Exception messages
|
12
|
+
|
13
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
14
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
15
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
16
|
+
a message.
|
17
|
+
|
18
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
19
|
+
`raise Exception`, you shold write:
|
20
|
+
|
21
|
+
```python
|
22
|
+
raise Exception("Meaningful message indicating the source of the error")
|
23
|
+
```
|
24
|
+
|
25
|
+
|
11
26
|
## Submitting Exercises
|
12
27
|
|
13
28
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -64,6 +64,21 @@ Devastating Donkeys;Courageous Californians;draw
|
|
64
64
|
|
65
65
|
Means that the Devastating Donkeys and Courageous Californians tied.
|
66
66
|
|
67
|
+
## Exception messages
|
68
|
+
|
69
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
70
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
71
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
72
|
+
a message.
|
73
|
+
|
74
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
75
|
+
`raise Exception`, you shold write:
|
76
|
+
|
77
|
+
```python
|
78
|
+
raise Exception("Meaningful message indicating the source of the error")
|
79
|
+
```
|
80
|
+
|
81
|
+
|
67
82
|
## Submitting Exercises
|
68
83
|
|
69
84
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -58,6 +58,21 @@ In general, all characters from the input should also be present in the transpos
|
|
58
58
|
That means that if a column in the input text contains only spaces on its bottom-most row(s),
|
59
59
|
the corresponding output row should contain the spaces in its right-most column(s).
|
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.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# Tree Building
|
2
|
+
|
1
3
|
Refactor a tree building algorithm.
|
2
4
|
|
3
5
|
Some web-forums have a tree layout, so posts are presented as a tree. However
|
@@ -23,3 +25,31 @@ root (ID: 0, parent ID: 0)
|
|
23
25
|
| +-- grandchild3 (ID: 6, parent ID: 3)
|
24
26
|
+-- child3 (ID: 5, parent ID: 0)
|
25
27
|
```
|
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
|
+
|
44
|
+
## Submitting Exercises
|
45
|
+
|
46
|
+
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
47
|
+
|
48
|
+
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`.
|
49
|
+
|
50
|
+
For more detailed information about running tests, code style and linting,
|
51
|
+
please see the [help page](http://exercism.io/languages/python).
|
52
|
+
|
53
|
+
|
54
|
+
## Submitting Incomplete Solutions
|
55
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -15,11 +15,9 @@ class Node():
|
|
15
15
|
|
16
16
|
def validateRecord(record):
|
17
17
|
if record.equal_id() and record.record_id != 0:
|
18
|
-
|
19
|
-
raise ValueError
|
18
|
+
raise ValueError("Only root should have equal record and parent id")
|
20
19
|
elif not record.equal_id() and record.parent_id >= record.record_id:
|
21
|
-
|
22
|
-
raise ValueError
|
20
|
+
raise ValueError("Node record_id should be smaller than its parent_id")
|
23
21
|
|
24
22
|
|
25
23
|
def BuildTree(records):
|
@@ -36,7 +34,7 @@ def BuildTree(records):
|
|
36
34
|
|
37
35
|
for index, record_id in enumerate(ordered_id):
|
38
36
|
if index != record_id:
|
39
|
-
raise ValueError
|
37
|
+
raise ValueError("Record id is invalid or out of order")
|
40
38
|
if record_id == root_id:
|
41
39
|
root = node_dict[record_id]
|
42
40
|
else:
|
@@ -108,7 +108,7 @@ class TestBuildingTest(unittest.TestCase):
|
|
108
108
|
Record(1, 0)
|
109
109
|
]
|
110
110
|
# Root parent_id should be equal to record_id(0)
|
111
|
-
with self.
|
111
|
+
with self.assertRaisesWithMessage(ValueError):
|
112
112
|
BuildTree(records)
|
113
113
|
|
114
114
|
def test_no_root_node(self):
|
@@ -117,7 +117,7 @@ class TestBuildingTest(unittest.TestCase):
|
|
117
117
|
Record(2, 0)
|
118
118
|
]
|
119
119
|
# Record with record_id 0 (root) is missing
|
120
|
-
with self.
|
120
|
+
with self.assertRaisesWithMessage(ValueError):
|
121
121
|
BuildTree(records)
|
122
122
|
|
123
123
|
def test_non_continuous(self):
|
@@ -128,7 +128,7 @@ class TestBuildingTest(unittest.TestCase):
|
|
128
128
|
Record(0, 0)
|
129
129
|
]
|
130
130
|
# Record with record_id 3 is missing
|
131
|
-
with self.
|
131
|
+
with self.assertRaisesWithMessage(ValueError):
|
132
132
|
BuildTree(records)
|
133
133
|
|
134
134
|
def test_cycle_directly(self):
|
@@ -142,7 +142,7 @@ class TestBuildingTest(unittest.TestCase):
|
|
142
142
|
Record(6, 3)
|
143
143
|
]
|
144
144
|
# Cycle caused by Record 2 with parent_id pointing to itself
|
145
|
-
with self.
|
145
|
+
with self.assertRaisesWithMessage(ValueError):
|
146
146
|
BuildTree(records)
|
147
147
|
|
148
148
|
def test_cycle_indirectly(self):
|
@@ -156,7 +156,7 @@ class TestBuildingTest(unittest.TestCase):
|
|
156
156
|
Record(6, 3)
|
157
157
|
]
|
158
158
|
# Cycle caused by Record 2 with parent_id(6) greater than record_id(2)
|
159
|
-
with self.
|
159
|
+
with self.assertRaisesWithMessage(ValueError):
|
160
160
|
BuildTree(records)
|
161
161
|
|
162
162
|
def test_higher_id_parent_of_lower_id(self):
|
@@ -166,7 +166,7 @@ class TestBuildingTest(unittest.TestCase):
|
|
166
166
|
Record(1, 2)
|
167
167
|
]
|
168
168
|
# Record 1 have parent_id(2) greater than record_id(1)
|
169
|
-
with self.
|
169
|
+
with self.assertRaisesWithMessage(ValueError):
|
170
170
|
BuildTree(records)
|
171
171
|
|
172
172
|
def assert_node_is_branch(self, node, node_id, children_count):
|
@@ -178,6 +178,16 @@ class TestBuildingTest(unittest.TestCase):
|
|
178
178
|
self.assertEqual(node.node_id, node_id)
|
179
179
|
self.assertEqual(len(node.children), 0)
|
180
180
|
|
181
|
+
# Utility functions
|
182
|
+
def setUp(self):
|
183
|
+
try:
|
184
|
+
self.assertRaisesRegex = self.assertRaisesRegexp
|
185
|
+
except AttributeError:
|
186
|
+
pass
|
187
|
+
|
188
|
+
def assertRaisesWithMessage(self, exception):
|
189
|
+
return self.assertRaisesRegex(exception, r".+")
|
190
|
+
|
181
191
|
|
182
192
|
if __name__ == '__main__':
|
183
193
|
unittest.main()
|
@@ -22,6 +22,21 @@ The case where the sum of the lengths of two sides _equals_ that of the
|
|
22
22
|
third is known as a _degenerate_ triangle - it has zero area and looks like
|
23
23
|
a single line. Feel free to add your own code/tests to check for degenerate triangles.
|
24
24
|
|
25
|
+
## Exception messages
|
26
|
+
|
27
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
28
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
29
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
30
|
+
a message.
|
31
|
+
|
32
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
33
|
+
`raise Exception`, you shold write:
|
34
|
+
|
35
|
+
```python
|
36
|
+
raise Exception("Meaningful message indicating the source of the error")
|
37
|
+
```
|
38
|
+
|
39
|
+
|
25
40
|
## Submitting Exercises
|
26
41
|
|
27
42
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -7,7 +7,7 @@ class Triangle(object):
|
|
7
7
|
self.sides = (x, y, z)
|
8
8
|
|
9
9
|
if self._invalid_lengths() or self._violates_inequality():
|
10
|
-
raise TriangleError
|
10
|
+
raise TriangleError("Side lengths are invalid for a triangle")
|
11
11
|
|
12
12
|
def _invalid_lengths(self):
|
13
13
|
return any([side <= 0 for side in self.sides])
|
@@ -34,25 +34,35 @@ class TriangleTests(unittest.TestCase):
|
|
34
34
|
self.assertEqual(Triangle(0.4, 0.6, 0.3).kind(), "scalene")
|
35
35
|
|
36
36
|
def test_triangles_with_no_size_are_illegal(self):
|
37
|
-
with self.
|
37
|
+
with self.assertRaisesWithMessage(TriangleError):
|
38
38
|
Triangle(0, 0, 0)
|
39
39
|
|
40
40
|
def test_triangles_with_negative_sides_are_illegal(self):
|
41
|
-
with self.
|
41
|
+
with self.assertRaisesWithMessage(TriangleError):
|
42
42
|
Triangle(3, 4, -5)
|
43
43
|
|
44
44
|
def test_triangles_violating_triangle_inequality_are_illegal(self):
|
45
|
-
with self.
|
45
|
+
with self.assertRaisesWithMessage(TriangleError):
|
46
46
|
Triangle(1, 1, 3)
|
47
47
|
|
48
48
|
def test_triangles_violating_triangle_inequality_are_illegal_2(self):
|
49
|
-
with self.
|
49
|
+
with self.assertRaisesWithMessage(TriangleError):
|
50
50
|
Triangle(2, 4, 2)
|
51
51
|
|
52
52
|
def test_triangles_violating_triangle_inequality_are_illegal_3(self):
|
53
|
-
with self.
|
53
|
+
with self.assertRaisesWithMessage(TriangleError):
|
54
54
|
Triangle(7, 3, 2)
|
55
55
|
|
56
|
+
# Utility functions
|
57
|
+
def setUp(self):
|
58
|
+
try:
|
59
|
+
self.assertRaisesRegex = self.assertRaisesRegexp
|
60
|
+
except AttributeError:
|
61
|
+
pass
|
62
|
+
|
63
|
+
def assertRaisesWithMessage(self, exception):
|
64
|
+
return self.assertRaisesRegex(exception, r".+")
|
65
|
+
|
56
66
|
|
57
67
|
if __name__ == '__main__':
|
58
68
|
unittest.main()
|
@@ -21,6 +21,21 @@ is the 3's place, the third to last is the 9's place, etc.
|
|
21
21
|
If your language provides a method in the standard library to perform the
|
22
22
|
conversion, pretend it doesn't exist and implement it yourself.
|
23
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
|
+
|
38
|
+
|
24
39
|
## Submitting Exercises
|
25
40
|
|
26
41
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -28,6 +28,21 @@ On the eleventh day of Christmas my true love gave to me, eleven Pipers Piping,
|
|
28
28
|
On the twelfth day of Christmas my true love gave to me, twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
29
29
|
```
|
30
30
|
|
31
|
+
## Exception messages
|
32
|
+
|
33
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
34
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
35
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
36
|
+
a message.
|
37
|
+
|
38
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
39
|
+
`raise Exception`, you shold write:
|
40
|
+
|
41
|
+
```python
|
42
|
+
raise Exception("Meaningful message indicating the source of the error")
|
43
|
+
```
|
44
|
+
|
45
|
+
|
31
46
|
## Submitting Exercises
|
32
47
|
|
33
48
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -7,15 +7,15 @@ Since this mathematical problem is fairly subject to interpretation / individual
|
|
7
7
|
To help, the tests provide you with which bucket to fill first. That means, when starting with the larger bucket full, you are NOT allowed at any point to have the smaller bucket full and the larger bucket empty (aka, the opposite starting point); that would defeat the purpose of comparing both approaches!
|
8
8
|
|
9
9
|
Your program will take as input:
|
10
|
-
- the size of bucket one
|
11
|
-
- the size of bucket two
|
12
|
-
- the desired number of liters to reach
|
13
|
-
- which bucket to fill first,
|
10
|
+
- the size of bucket one
|
11
|
+
- the size of bucket two
|
12
|
+
- the desired number of liters to reach
|
13
|
+
- which bucket to fill first, either bucket one or bucket two
|
14
14
|
|
15
15
|
Your program should determine:
|
16
|
-
- the total number of "moves" it should take to reach the desired number of liters, including the first fill
|
17
|
-
- which bucket should end up with the desired number of liters (let's say this is bucket A) -
|
18
|
-
- how many liters are left in the other bucket (bucket B)
|
16
|
+
- the total number of "moves" it should take to reach the desired number of liters, including the first fill
|
17
|
+
- which bucket should end up with the desired number of liters (let's say this is bucket A) - either bucket one or bucket two
|
18
|
+
- how many liters are left in the other bucket (bucket B)
|
19
19
|
|
20
20
|
Note: any time a change is made to either or both buckets counts as one (1) move.
|
21
21
|
|
@@ -29,6 +29,21 @@ To conclude, the only valid moves are:
|
|
29
29
|
|
30
30
|
Written with <3 at [Fullstack Academy](http://www.fullstackacademy.com/) by [Lindsay](http://lindsaylevine.com).
|
31
31
|
|
32
|
+
## Exception messages
|
33
|
+
|
34
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
35
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
36
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
37
|
+
a message.
|
38
|
+
|
39
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
40
|
+
`raise Exception`, you shold write:
|
41
|
+
|
42
|
+
```python
|
43
|
+
raise Exception("Meaningful message indicating the source of the error")
|
44
|
+
```
|
45
|
+
|
46
|
+
|
32
47
|
## Submitting Exercises
|
33
48
|
|
34
49
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
@@ -11,6 +11,22 @@ When X is a name or "you".
|
|
11
11
|
If the given name is "Alice", the result should be "One for Alice, one for me."
|
12
12
|
If no name is given, the result should be "One for you, one for me."
|
13
13
|
|
14
|
+
|
15
|
+
## Exception messages
|
16
|
+
|
17
|
+
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
18
|
+
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
19
|
+
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
20
|
+
a message.
|
21
|
+
|
22
|
+
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
23
|
+
`raise Exception`, you shold write:
|
24
|
+
|
25
|
+
```python
|
26
|
+
raise Exception("Meaningful message indicating the source of the error")
|
27
|
+
```
|
28
|
+
|
29
|
+
|
14
30
|
## Submitting Exercises
|
15
31
|
|
16
32
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|