trackler 2.2.1.53 → 2.2.1.54
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/nth-prime/canonical-data.json +2 -7
- data/problem-specifications/exercises/zebra-puzzle/canonical-data.json +16 -0
- data/tracks/c/config.json +11 -1
- data/tracks/c/docs/C_STYLE_GUIDE.md +142 -0
- data/tracks/c/exercises/collatz-conjecture/README.md +65 -0
- data/tracks/c/exercises/collatz-conjecture/makefile +15 -0
- data/tracks/c/exercises/collatz-conjecture/src/collatz_conjecture.h +8 -0
- data/tracks/c/exercises/collatz-conjecture/src/example.c +23 -0
- data/tracks/c/exercises/collatz-conjecture/test/test_collatz_conjecture.c +48 -0
- data/tracks/c/exercises/collatz-conjecture/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/collatz-conjecture/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/collatz-conjecture/test/vendor/unity_internals.h +701 -0
- data/tracks/cfml/tasks/GenerateReadme.cfc +5 -5
- data/tracks/erlang/testgen/src/testgen.erl +99 -17
- data/tracks/erlang/testgen/src/tg_file_tools.erl +3 -3
- data/tracks/erlang/testgen/src/tgen.erl +15 -7
- data/tracks/haskell/config.json +15 -3
- data/tracks/java/scripts/canonical_data_check.sh +1 -1
- data/tracks/javascript/config.json +12 -0
- data/tracks/javascript/exercises/difference-of-squares/README.md +1 -1
- data/tracks/javascript/exercises/sum-of-multiples/README.md +1 -1
- data/tracks/javascript/exercises/zipper/README.md +55 -0
- data/tracks/javascript/exercises/zipper/example.js +100 -0
- data/tracks/javascript/exercises/zipper/zipper.spec.js +77 -0
- data/tracks/julia/config.json +12 -0
- data/tracks/julia/exercises/triangle/README.md +30 -0
- data/tracks/julia/exercises/triangle/example.jl +25 -0
- data/tracks/julia/exercises/triangle/runtests.jl +64 -0
- data/tracks/julia/exercises/triangle/triangle.jl +8 -0
- data/tracks/kotlin/exercises/leap/.meta/version +1 -1
- data/tracks/kotlin/exercises/leap/src/test/kotlin/LeapTest.kt +1 -1
- data/tracks/kotlin/scripts/canonical_data_check.sh +1 -1
- data/tracks/perl6/bin/README.md +1 -4
- data/tracks/perl6/bin/exercise-gen.pl6 +3 -4
- data/tracks/perl6/exercises/accumulate/example.yaml +2 -2
- data/tracks/perl6/exercises/all-your-base/example.yaml +9 -9
- data/tracks/perl6/exercises/allergies/example.yaml +7 -7
- data/tracks/perl6/exercises/anagram/example.yaml +3 -3
- data/tracks/perl6/exercises/atbash-cipher/example.yaml +3 -3
- data/tracks/perl6/exercises/bob/example.yaml +4 -4
- data/tracks/perl6/exercises/clock/example.yaml +6 -6
- data/tracks/perl6/exercises/flatten-array/example.yaml +4 -4
- data/tracks/perl6/exercises/grade-school/example.yaml +6 -6
- data/tracks/perl6/exercises/grains/example.yaml +3 -3
- data/tracks/perl6/exercises/hello-world/example.yaml +5 -5
- data/tracks/perl6/exercises/leap/example.yaml +4 -4
- data/tracks/perl6/exercises/linked-list/example.yaml +14 -14
- data/tracks/perl6/exercises/luhn/example.yaml +3 -3
- data/tracks/perl6/exercises/phone-number/example.yaml +3 -3
- data/tracks/perl6/exercises/raindrops/example.yaml +3 -3
- data/tracks/perl6/exercises/rna-transcription/example.yaml +3 -3
- data/tracks/perl6/exercises/robot-name/example.yaml +8 -8
- data/tracks/perl6/exercises/scrabble-score/example.yaml +3 -3
- data/tracks/perl6/exercises/space-age/example.yaml +8 -8
- data/tracks/perl6/exercises/word-count/example.yaml +3 -3
- data/tracks/perl6/exercises/wordy/example.yaml +3 -3
- data/tracks/python/config.json +14 -0
- data/tracks/python/config/maintainers.json +30 -0
- data/tracks/python/docs/EXERCISE_README_INSERT.md +1 -2
- data/tracks/python/exercises/accumulate/README.md +1 -5
- data/tracks/python/exercises/acronym/README.md +1 -3
- data/tracks/python/exercises/all-your-base/README.md +2 -3
- data/tracks/python/exercises/all-your-base/all_your_base_test.py +13 -13
- data/tracks/python/exercises/allergies/README.md +1 -3
- data/tracks/python/exercises/alphametics/README.md +3 -4
- data/tracks/python/exercises/anagram/README.md +1 -2
- data/tracks/python/exercises/atbash-cipher/README.md +3 -3
- data/tracks/python/exercises/beer-song/README.md +2 -3
- data/tracks/python/exercises/binary-search/README.md +1 -2
- data/tracks/python/exercises/binary/README.md +3 -2
- data/tracks/python/exercises/bob/README.md +1 -2
- data/tracks/python/exercises/book-store/README.md +6 -7
- data/tracks/python/exercises/bracket-push/README.md +1 -2
- data/tracks/python/exercises/change/README.md +2 -3
- data/tracks/python/exercises/circular-buffer/README.md +14 -8
- data/tracks/python/exercises/clock/README.md +1 -2
- data/tracks/python/exercises/clock/clock_test.py +2 -0
- data/tracks/python/exercises/collatz-conjecture/.meta/hints.md +3 -0
- data/tracks/python/exercises/collatz-conjecture/README.md +6 -19
- data/tracks/python/exercises/complex-numbers/README.md +28 -2
- data/tracks/python/exercises/crypto-square/README.md +11 -10
- data/tracks/python/exercises/diamond/README.md +7 -8
- data/tracks/python/exercises/difference-of-squares/README.md +1 -2
- data/tracks/python/exercises/diffie-hellman/.meta/hints.md +1 -1
- data/tracks/python/exercises/diffie-hellman/README.md +3 -2
- data/tracks/python/exercises/error-handling/.meta/hints.md +8 -0
- data/tracks/python/exercises/error-handling/README.md +10 -2
- data/tracks/python/exercises/error-handling/error_handling_test.py +15 -3
- data/tracks/python/exercises/etl/README.md +3 -2
- data/tracks/python/exercises/flatten-array/README.md +2 -4
- data/tracks/python/exercises/food-chain/README.md +3 -4
- data/tracks/python/exercises/forth/README.md +2 -6
- data/tracks/python/exercises/gigasecond/README.md +1 -2
- data/tracks/python/exercises/grade-school/README.md +1 -3
- data/tracks/python/exercises/grains/README.md +1 -3
- data/tracks/python/exercises/grep/README.md +13 -14
- data/tracks/python/exercises/hamming/README.md +1 -2
- data/tracks/python/exercises/hamming/hamming_test.py +6 -6
- data/tracks/python/exercises/hello-world/README.md +1 -2
- data/tracks/python/exercises/hexadecimal/README.md +1 -2
- data/tracks/python/exercises/hexadecimal/example.py +6 -6
- data/tracks/python/exercises/house/README.md +2 -4
- data/tracks/python/exercises/isogram/README.md +3 -3
- data/tracks/python/exercises/kindergarten-garden/README.md +14 -15
- data/tracks/python/exercises/largest-series-product/README.md +1 -2
- data/tracks/python/exercises/leap/README.md +2 -3
- data/tracks/python/exercises/linked-list/README.md +11 -12
- data/tracks/python/exercises/list-ops/README.md +1 -2
- data/tracks/python/exercises/luhn/README.md +8 -9
- data/tracks/python/exercises/markdown/README.md +1 -6
- data/tracks/python/exercises/matrix/README.md +7 -6
- data/tracks/python/exercises/meetup/README.md +2 -4
- data/tracks/python/exercises/minesweeper/README.md +1 -2
- data/tracks/python/exercises/nth-prime/README.md +1 -2
- data/tracks/python/exercises/nucleotide-count/README.md +9 -24
- data/tracks/python/exercises/ocr-numbers/README.md +6 -7
- data/tracks/python/exercises/octal/README.md +7 -4
- data/tracks/python/exercises/palindrome-products/README.md +16 -18
- data/tracks/python/exercises/pangram/README.md +2 -3
- data/tracks/python/exercises/pascals-triangle/README.md +2 -3
- data/tracks/python/exercises/perfect-numbers/README.md +3 -4
- data/tracks/python/exercises/phone-number/README.md +4 -4
- data/tracks/python/exercises/pig-latin/README.md +1 -2
- data/tracks/python/exercises/point-mutations/README.md +1 -2
- data/tracks/python/exercises/poker/README.md +1 -2
- data/tracks/python/exercises/prime-factors/README.md +1 -2
- data/tracks/python/exercises/protein-translation/README.md +5 -7
- data/tracks/python/exercises/proverb/README.md +12 -11
- data/tracks/python/exercises/pythagorean-triplet/README.md +4 -5
- data/tracks/python/exercises/queen-attack/README.md +2 -3
- data/tracks/python/exercises/rail-fence-cipher/README.md +13 -9
- data/tracks/python/exercises/raindrops/README.md +1 -2
- data/tracks/python/exercises/rectangles/README.md +8 -9
- data/tracks/python/exercises/rectangles/example.py +3 -3
- data/tracks/python/exercises/rna-transcription/README.md +1 -2
- data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +4 -3
- data/tracks/python/exercises/robot-name/README.md +1 -2
- data/tracks/python/exercises/robot-simulator/README.md +1 -2
- data/tracks/python/exercises/roman-numerals/README.md +2 -3
- data/tracks/python/exercises/rotational-cipher/README.md +3 -3
- data/tracks/python/exercises/run-length-encoding/README.md +5 -6
- data/tracks/python/exercises/run-length-encoding/example.py +2 -2
- data/tracks/python/exercises/saddle-points/README.md +2 -3
- data/tracks/python/exercises/say/README.md +1 -2
- data/tracks/python/exercises/scale-generator/README.md +1 -3
- data/tracks/python/exercises/scrabble-score/README.md +4 -3
- data/tracks/python/exercises/secret-handshake/README.md +2 -3
- data/tracks/python/exercises/series/README.md +1 -2
- data/tracks/python/exercises/sieve/README.md +1 -2
- data/tracks/python/exercises/simple-cipher/README.md +3 -4
- data/tracks/python/exercises/space-age/README.md +2 -3
- data/tracks/python/exercises/space-age/space_age_test.py +18 -29
- data/tracks/python/exercises/strain/README.md +1 -2
- data/tracks/python/exercises/sublist/README.md +1 -2
- data/tracks/python/exercises/sum-of-multiples/README.md +1 -5
- data/tracks/python/exercises/tournament/README.md +6 -7
- data/tracks/python/exercises/transpose/README.md +8 -9
- data/tracks/python/exercises/tree-building/README.md +25 -0
- data/tracks/python/exercises/tree-building/example.py +46 -0
- data/tracks/python/exercises/tree-building/tree_building.py +50 -0
- data/tracks/python/exercises/tree-building/tree_building_test.py +183 -0
- data/tracks/python/exercises/triangle/README.md +10 -8
- data/tracks/python/exercises/trinary/README.md +2 -3
- data/tracks/python/exercises/twelve-days/README.md +2 -3
- data/tracks/python/exercises/two-bucket/README.md +4 -5
- data/tracks/python/exercises/two-bucket/two_bucket_test.py +2 -0
- data/tracks/python/exercises/two-fer/README.md +4 -5
- data/tracks/python/exercises/two-fer/two_fer_test.py +5 -2
- data/tracks/python/exercises/variable-length-quantity/README.md +7 -9
- data/tracks/python/exercises/word-count/README.md +2 -4
- data/tracks/python/exercises/word-search/README.md +2 -3
- data/tracks/python/exercises/wordy/README.md +1 -7
- data/tracks/python/exercises/wordy/example.py +8 -8
- data/tracks/python/exercises/wordy/wordy_test.py +36 -32
- data/tracks/python/exercises/zebra-puzzle/README.md +1 -2
- data/tracks/python/requirements-travis.txt +1 -1
- data/tracks/ruby/config.json +11 -0
- data/tracks/ruby/docs/TESTS.md +6 -0
- data/tracks/ruby/exercises/pangram/.meta/.version +1 -1
- data/tracks/ruby/exercises/pangram/.meta/solutions/pangram.rb +1 -1
- data/tracks/ruby/exercises/pangram/pangram_test.rb +11 -4
- data/tracks/ruby/exercises/two-fer/.meta/.version +1 -0
- data/tracks/ruby/exercises/two-fer/.meta/generator/two_fer_case.rb +12 -0
- data/tracks/ruby/exercises/two-fer/.meta/solutions/two_fer.rb +9 -0
- data/tracks/ruby/exercises/two-fer/README.md +69 -0
- data/tracks/ruby/exercises/two-fer/two_fer_test.rb +42 -0
- data/tracks/rust/config.json +12 -0
- data/tracks/rust/exercises/binary-search/.meta/hints.md +38 -0
- data/tracks/rust/exercises/binary-search/Cargo.lock +4 -0
- data/tracks/rust/exercises/binary-search/Cargo.toml +6 -0
- data/tracks/rust/exercises/binary-search/README.md +113 -0
- data/tracks/rust/exercises/binary-search/example.rs +29 -0
- data/tracks/rust/exercises/binary-search/src/lib.rs +0 -0
- data/tracks/rust/exercises/binary-search/tests/binary-search.rs +96 -0
- data/tracks/typescript/common/package.json +6 -6
- data/tracks/typescript/common/yarn.lock +929 -610
- data/tracks/typescript/exercises/acronym/package.json +6 -6
- data/tracks/typescript/exercises/acronym/yarn.lock +929 -610
- data/tracks/typescript/exercises/anagram/package.json +6 -6
- data/tracks/typescript/exercises/anagram/yarn.lock +929 -610
- data/tracks/typescript/exercises/beer-song/package.json +6 -6
- data/tracks/typescript/exercises/beer-song/yarn.lock +929 -610
- data/tracks/typescript/exercises/binary-search-tree/package.json +6 -6
- data/tracks/typescript/exercises/binary-search-tree/yarn.lock +929 -610
- data/tracks/typescript/exercises/binary-search/package.json +6 -6
- data/tracks/typescript/exercises/binary-search/yarn.lock +929 -610
- data/tracks/typescript/exercises/bob/package.json +6 -6
- data/tracks/typescript/exercises/bob/yarn.lock +929 -610
- data/tracks/typescript/exercises/circular-buffer/package.json +6 -6
- data/tracks/typescript/exercises/circular-buffer/yarn.lock +929 -610
- data/tracks/typescript/exercises/clock/package.json +6 -6
- data/tracks/typescript/exercises/clock/yarn.lock +929 -610
- data/tracks/typescript/exercises/difference-of-squares/package.json +6 -6
- data/tracks/typescript/exercises/difference-of-squares/yarn.lock +929 -610
- data/tracks/typescript/exercises/etl/package.json +6 -6
- data/tracks/typescript/exercises/etl/yarn.lock +929 -610
- data/tracks/typescript/exercises/food-chain/package.json +6 -6
- data/tracks/typescript/exercises/food-chain/yarn.lock +929 -610
- data/tracks/typescript/exercises/gigasecond/package.json +6 -6
- data/tracks/typescript/exercises/gigasecond/yarn.lock +929 -610
- data/tracks/typescript/exercises/grade-school/package.json +6 -6
- data/tracks/typescript/exercises/grade-school/yarn.lock +929 -610
- data/tracks/typescript/exercises/hamming/package.json +6 -6
- data/tracks/typescript/exercises/hamming/yarn.lock +929 -610
- data/tracks/typescript/exercises/hello-world/README.md +354 -0
- data/tracks/typescript/exercises/hello-world/package.json +6 -6
- data/tracks/typescript/exercises/hello-world/yarn.lock +929 -610
- data/tracks/typescript/exercises/largest-series-product/package.json +6 -6
- data/tracks/typescript/exercises/largest-series-product/yarn.lock +929 -610
- data/tracks/typescript/exercises/leap/package.json +6 -6
- data/tracks/typescript/exercises/leap/yarn.lock +929 -610
- data/tracks/typescript/exercises/linked-list/package.json +6 -6
- data/tracks/typescript/exercises/linked-list/yarn.lock +929 -610
- data/tracks/typescript/exercises/nth-prime/package.json +6 -6
- data/tracks/typescript/exercises/nth-prime/yarn.lock +929 -610
- data/tracks/typescript/exercises/pangram/package.json +6 -6
- data/tracks/typescript/exercises/pangram/yarn.lock +929 -610
- data/tracks/typescript/exercises/pascals-triangle/package.json +6 -6
- data/tracks/typescript/exercises/pascals-triangle/yarn.lock +929 -610
- data/tracks/typescript/exercises/phone-number/package.json +6 -6
- data/tracks/typescript/exercises/phone-number/yarn.lock +929 -610
- data/tracks/typescript/exercises/prime-factors/package.json +6 -6
- data/tracks/typescript/exercises/prime-factors/yarn.lock +929 -610
- data/tracks/typescript/exercises/raindrops/package.json +6 -6
- data/tracks/typescript/exercises/raindrops/yarn.lock +929 -610
- data/tracks/typescript/exercises/rna-transcription/package.json +6 -6
- data/tracks/typescript/exercises/rna-transcription/yarn.lock +929 -610
- data/tracks/typescript/exercises/robot-name/package.json +6 -6
- data/tracks/typescript/exercises/robot-name/yarn.lock +929 -610
- data/tracks/typescript/exercises/robot-simulator/package.json +6 -6
- data/tracks/typescript/exercises/robot-simulator/yarn.lock +929 -610
- data/tracks/typescript/exercises/rotational-cipher/package.json +6 -6
- data/tracks/typescript/exercises/rotational-cipher/yarn.lock +929 -610
- data/tracks/typescript/exercises/say/package.json +6 -6
- data/tracks/typescript/exercises/say/yarn.lock +929 -610
- data/tracks/typescript/exercises/scrabble-score/package.json +6 -6
- data/tracks/typescript/exercises/scrabble-score/yarn.lock +929 -610
- data/tracks/typescript/exercises/series/package.json +6 -6
- data/tracks/typescript/exercises/series/yarn.lock +929 -610
- data/tracks/typescript/exercises/space-age/package.json +6 -6
- data/tracks/typescript/exercises/space-age/yarn.lock +929 -610
- data/tracks/typescript/exercises/strain/package.json +6 -6
- data/tracks/typescript/exercises/strain/yarn.lock +929 -610
- data/tracks/typescript/exercises/sum-of-multiples/package.json +6 -6
- data/tracks/typescript/exercises/sum-of-multiples/yarn.lock +929 -610
- data/tracks/typescript/exercises/triangle/package.json +6 -6
- data/tracks/typescript/exercises/triangle/yarn.lock +929 -610
- data/tracks/typescript/exercises/word-count/package.json +6 -6
- data/tracks/typescript/exercises/word-count/yarn.lock +929 -610
- data/tracks/typescript/exercises/wordy/package.json +6 -6
- data/tracks/typescript/exercises/wordy/yarn.lock +929 -610
- metadata +37 -2
@@ -3,20 +3,20 @@
|
|
3
3
|
To try and encourage more sales of different books from a popular 5 book
|
4
4
|
series, a bookshop has decided to offer discounts on multiple book purchases.
|
5
5
|
|
6
|
-
One copy of any of the five books costs $8.
|
6
|
+
One copy of any of the five books costs $8.
|
7
7
|
|
8
8
|
If, however, you buy two different books, you get a 5%
|
9
9
|
discount on those two books.
|
10
10
|
|
11
|
-
If you buy 3 different books, you get a 10% discount.
|
11
|
+
If you buy 3 different books, you get a 10% discount.
|
12
12
|
|
13
13
|
If you buy 4 different books, you get a 20% discount.
|
14
14
|
|
15
|
-
If you buy all 5, you get a 25% discount.
|
15
|
+
If you buy all 5, you get a 25% discount.
|
16
16
|
|
17
17
|
Note: that if you buy four books, of which 3 are
|
18
18
|
different titles, you get a 10% discount on the 3 that
|
19
|
-
form part of a set, but the fourth book still costs $8.
|
19
|
+
form part of a set, but the fourth book still costs $8.
|
20
20
|
|
21
21
|
Your mission is to write a piece of code to calculate the
|
22
22
|
price of any conceivable shopping basket (containing only
|
@@ -30,7 +30,7 @@ For example, how much does this basket of books cost?
|
|
30
30
|
- 2 copies of the third book
|
31
31
|
- 1 copy of the fourth book
|
32
32
|
- 1 copy of the fifth book
|
33
|
-
|
33
|
+
|
34
34
|
One way of grouping these 8 books is:
|
35
35
|
|
36
36
|
- 1 group of 5 --> 25% discount (1st,2nd,3rd,4th,5th)
|
@@ -67,13 +67,12 @@ For a total of $51.20
|
|
67
67
|
|
68
68
|
And $51.20 is the price with the biggest discount.
|
69
69
|
|
70
|
-
|
70
|
+
## Submitting Exercises
|
71
71
|
|
72
72
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
73
73
|
|
74
74
|
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`.
|
75
75
|
|
76
|
-
|
77
76
|
For more detailed information about running tests, code style and linting,
|
78
77
|
please see the [help page](http://exercism.io/languages/python).
|
79
78
|
|
@@ -3,13 +3,12 @@
|
|
3
3
|
Given a string containing brackets `[]`, braces `{}` and parentheses `()`,
|
4
4
|
verify that all the pairs are matched and nested correctly.
|
5
5
|
|
6
|
-
|
6
|
+
## Submitting Exercises
|
7
7
|
|
8
8
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
9
9
|
|
10
10
|
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`.
|
11
11
|
|
12
|
-
|
13
12
|
For more detailed information about running tests, code style and linting,
|
14
13
|
please see the [help page](http://exercism.io/languages/python).
|
15
14
|
|
@@ -16,19 +16,18 @@ that the sum of the coins' value would equal the correct amount of change.
|
|
16
16
|
- Can you ask for negative change?
|
17
17
|
- Can you ask for a change value smaller than the smallest coin value?
|
18
18
|
|
19
|
-
|
19
|
+
## Submitting Exercises
|
20
20
|
|
21
21
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
22
22
|
|
23
23
|
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`.
|
24
24
|
|
25
|
-
|
26
25
|
For more detailed information about running tests, code style and linting,
|
27
26
|
please see the [help page](http://exercism.io/languages/python).
|
28
27
|
|
29
28
|
## Source
|
30
29
|
|
31
|
-
Software Craftsmanship - Kata
|
30
|
+
Software Craftsmanship - Coin Change Kata [https://web.archive.org/web/20130115115225/http://craftsmanship.sv.cmu.edu:80/exercises/coin-change-kata](https://web.archive.org/web/20130115115225/http://craftsmanship.sv.cmu.edu:80/exercises/coin-change-kata)
|
32
31
|
|
33
32
|
## Submitting Incomplete Solutions
|
34
33
|
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -31,25 +31,31 @@ If the buffer has 7 elements then it is completely full:
|
|
31
31
|
When the buffer is full an error will be raised, alerting the client
|
32
32
|
that further writes are blocked until a slot becomes free.
|
33
33
|
|
34
|
-
|
35
|
-
this case, two more elements — A & B —
|
36
|
-
3 & 4:
|
34
|
+
When the buffer is full, the client can opt to overwrite the oldest
|
35
|
+
data with a forced write. In this case, two more elements — A & B —
|
36
|
+
are added and they overwrite the 3 & 4:
|
37
37
|
|
38
38
|
[6][7][8][9][A][B][5]
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
buffer
|
40
|
+
3 & 4 have been replaced by A & B making 5 now the oldest data in the
|
41
|
+
buffer. Finally, if two elements are removed then what would be
|
42
|
+
returned is 5 & 6 yielding the buffer:
|
43
43
|
|
44
44
|
[ ][7][8][9][A][B][ ]
|
45
45
|
|
46
|
-
|
46
|
+
Because there is space available, if the client again uses overwrite
|
47
|
+
to store C & D then the space where 5 & 6 were stored previously will
|
48
|
+
be used not the location of 7 & 8. 7 is still the oldest element and
|
49
|
+
the buffer is once again full.
|
50
|
+
|
51
|
+
[D][7][8][9][A][B][C]
|
52
|
+
|
53
|
+
## Submitting Exercises
|
47
54
|
|
48
55
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
49
56
|
|
50
57
|
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`.
|
51
58
|
|
52
|
-
|
53
59
|
For more detailed information about running tests, code style and linting,
|
54
60
|
please see the [help page](http://exercism.io/languages/python).
|
55
61
|
|
@@ -6,13 +6,12 @@ You should be able to add and subtract minutes to it.
|
|
6
6
|
|
7
7
|
Two clocks that represent the same time should be equal to each other.
|
8
8
|
|
9
|
-
|
9
|
+
## Submitting Exercises
|
10
10
|
|
11
11
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
12
12
|
|
13
13
|
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`.
|
14
14
|
|
15
|
-
|
16
15
|
For more detailed information about running tests, code style and linting,
|
17
16
|
please see the [help page](http://exercism.io/languages/python).
|
18
17
|
|
@@ -9,25 +9,8 @@ always reach 1 eventually.
|
|
9
9
|
|
10
10
|
Given a number n, return the number of steps required to reach 1.
|
11
11
|
|
12
|
-
(Keep in mind that the Conjecture is only concerned with strictly positive
|
13
|
-
integers, so your solution should return `None` if given 0 or a negative
|
14
|
-
integer.)
|
15
|
-
|
16
12
|
## Examples
|
17
13
|
|
18
|
-
Starting with n = 3, the steps would be as follows:
|
19
|
-
|
20
|
-
0. 3
|
21
|
-
1. 10
|
22
|
-
2. 5
|
23
|
-
3. 16
|
24
|
-
4. 8
|
25
|
-
5. 4
|
26
|
-
6. 2
|
27
|
-
7. 1
|
28
|
-
|
29
|
-
Resulting in 7 steps. So for input n = 3, the return value would be 7.
|
30
|
-
|
31
14
|
Starting with n = 12, the steps would be as follows:
|
32
15
|
|
33
16
|
0. 12
|
@@ -43,13 +26,17 @@ Starting with n = 12, the steps would be as follows:
|
|
43
26
|
|
44
27
|
Resulting in 9 steps. So for input n = 12, the return value would be 9.
|
45
28
|
|
46
|
-
|
29
|
+
## Notes
|
30
|
+
|
31
|
+
The Collatz Conjecture is only concerned with strictly positive integers, so your solution should raise a `ValueError` with a meaningful message if given 0 or a negative integer.
|
32
|
+
|
33
|
+
|
34
|
+
## Submitting Exercises
|
47
35
|
|
48
36
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
49
37
|
|
50
38
|
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`.
|
51
39
|
|
52
|
-
|
53
40
|
For more detailed information about running tests, code style and linting,
|
54
41
|
please see the [help page](http://exercism.io/languages/python).
|
55
42
|
|
@@ -2,15 +2,41 @@
|
|
2
2
|
|
3
3
|
A complex number is a number in the form `a + b * i` where `a` and `b` are real and `i` satisfies `i^2 = -1`.
|
4
4
|
|
5
|
+
`a` is called the real part and `b` is called the imaginary part of `z`.
|
6
|
+
The conjugate of the number `a + b * i` is the number `a - b * i`.
|
7
|
+
The absolute value of a complex number `z = a + b * i` is a real number `|z| = sqrt(a^2 + b^2)`. The square of the absolute value `|z|^2` is the result of multiplication of `z` by its complex conjugate.
|
8
|
+
|
9
|
+
The sum/difference of two complex numbers involves adding/subtracting their real and imaginary parts separately:
|
10
|
+
`(a + i * b) + (c + i * d) = (a + c) + (b + d) * i`,
|
11
|
+
`(a + i * b) - (c + i * d) = (a - c) + (b - d) * i`.
|
12
|
+
|
13
|
+
Multiplication result is by definition
|
14
|
+
`(a + i * b) * (c + i * d) = (a * c - b * d) + (b * c + a * d) * i`.
|
15
|
+
|
16
|
+
The reciprocal of a non-zero complex number is
|
17
|
+
`1 / (a + i * b) = a/(a^2 + b^2) - b/(a^2 + b^2) * i`.
|
18
|
+
|
19
|
+
Dividing a complex number `a + i * b` by another `c + i * d` gives:
|
20
|
+
`(a + i * b) / (c + i * d) = (a * c + b * d)/(c^2 + d^2) + (b * c - a * d)/(c^2 + d^2) * i`.
|
21
|
+
|
22
|
+
Exponent of a complex number can be expressed as
|
23
|
+
`exp(a + i * b) = exp(a) * exp(i * b)`,
|
24
|
+
and the last term is given by Euler's formula `exp(i * b) = cos(b) + i * sin(b)`.
|
25
|
+
|
26
|
+
|
27
|
+
Implement the following operations:
|
28
|
+
- addition, subtraction, multiplication and division of two complex numbers,
|
29
|
+
- conjugate, absolute value, exponent of a given complex number.
|
30
|
+
|
31
|
+
|
5
32
|
Assume the programming language you are using does not have an implementation of complex numbers.
|
6
33
|
|
7
|
-
|
34
|
+
## Submitting Exercises
|
8
35
|
|
9
36
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
10
37
|
|
11
38
|
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`.
|
12
39
|
|
13
|
-
|
14
40
|
For more detailed information about running tests, code style and linting,
|
15
41
|
please see the [help page](http://exercism.io/languages/python).
|
16
42
|
|
@@ -26,7 +26,7 @@ and `r` is the number of rows.
|
|
26
26
|
Our normalized text is 54 characters long, dictating a rectangle with
|
27
27
|
`c = 8` and `r = 7`:
|
28
28
|
|
29
|
-
```
|
29
|
+
```text
|
30
30
|
ifmanwas
|
31
31
|
meanttos
|
32
32
|
tayonthe
|
@@ -41,22 +41,24 @@ right.
|
|
41
41
|
|
42
42
|
The message above is coded as:
|
43
43
|
|
44
|
-
```
|
44
|
+
```text
|
45
45
|
imtgdvsfearwermayoogoanouuiontnnlvtwttddesaohghnsseoau
|
46
46
|
```
|
47
47
|
|
48
|
-
Output the encoded text in chunks. Phrases that fill perfect
|
49
|
-
`(r X
|
50
|
-
|
48
|
+
Output the encoded text in chunks. Phrases that fill perfect rectangles
|
49
|
+
`(r X c)` should be output `c` chunks of `r` length, separated by spaces.
|
50
|
+
Phrases that do not fill perfect rectangles will have `n` empty spaces.
|
51
|
+
Those spaces should be distributed evenly, added to the end of the last
|
52
|
+
`n` chunks.
|
51
53
|
|
52
|
-
```
|
53
|
-
imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn
|
54
|
+
```text
|
55
|
+
imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau
|
54
56
|
```
|
55
57
|
|
56
58
|
Notice that were we to stack these, we could visually decode the
|
57
59
|
cyphertext back in to the original message:
|
58
60
|
|
59
|
-
```
|
61
|
+
```text
|
60
62
|
imtgdvs
|
61
63
|
fearwer
|
62
64
|
mayoogo
|
@@ -67,13 +69,12 @@ aohghn
|
|
67
69
|
sseoau
|
68
70
|
```
|
69
71
|
|
70
|
-
|
72
|
+
## Submitting Exercises
|
71
73
|
|
72
74
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
73
75
|
|
74
76
|
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`.
|
75
77
|
|
76
|
-
|
77
78
|
For more detailed information about running tests, code style and linting,
|
78
79
|
please see the [help page](http://exercism.io/languages/python).
|
79
80
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Diamond
|
2
2
|
|
3
|
-
The diamond kata takes as its input a letter, and outputs it in a diamond
|
4
|
-
shape. Given a letter, it prints a diamond starting with 'A', with the
|
3
|
+
The diamond kata takes as its input a letter, and outputs it in a diamond
|
4
|
+
shape. Given a letter, it prints a diamond starting with 'A', with the
|
5
5
|
supplied letter at the widest point.
|
6
6
|
|
7
7
|
## Requirements
|
@@ -15,7 +15,7 @@ supplied letter at the widest point.
|
|
15
15
|
* The diamond has a square shape (width equals height).
|
16
16
|
* The letters form a diamond shape.
|
17
17
|
* The top half has the letters in ascending order.
|
18
|
-
* The bottom half has the letters in descending order.
|
18
|
+
* The bottom half has the letters in descending order.
|
19
19
|
* The four corners (containing the spaces) are triangles.
|
20
20
|
|
21
21
|
## Examples
|
@@ -24,13 +24,13 @@ In the following examples, spaces are indicated by `·` characters.
|
|
24
24
|
|
25
25
|
Diamond for letter 'A':
|
26
26
|
|
27
|
-
```
|
27
|
+
```text
|
28
28
|
A
|
29
29
|
```
|
30
30
|
|
31
31
|
Diamond for letter 'C':
|
32
32
|
|
33
|
-
```
|
33
|
+
```text
|
34
34
|
··A··
|
35
35
|
·B·B·
|
36
36
|
C···C
|
@@ -40,7 +40,7 @@ C···C
|
|
40
40
|
|
41
41
|
Diamond for letter 'E':
|
42
42
|
|
43
|
-
```
|
43
|
+
```text
|
44
44
|
····A····
|
45
45
|
···B·B···
|
46
46
|
··C···C··
|
@@ -52,13 +52,12 @@ E·······E
|
|
52
52
|
····A····
|
53
53
|
```
|
54
54
|
|
55
|
-
|
55
|
+
## Submitting Exercises
|
56
56
|
|
57
57
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
58
58
|
|
59
59
|
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`.
|
60
60
|
|
61
|
-
|
62
61
|
For more detailed information about running tests, code style and linting,
|
63
62
|
please see the [help page](http://exercism.io/languages/python).
|
64
63
|
|
@@ -12,13 +12,12 @@ Hence the difference between the square of the sum of the first
|
|
12
12
|
ten natural numbers and the sum of the squares of the first ten
|
13
13
|
natural numbers is 3025 - 385 = 2640.
|
14
14
|
|
15
|
-
|
15
|
+
## Submitting Exercises
|
16
16
|
|
17
17
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
18
18
|
|
19
19
|
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`.
|
20
20
|
|
21
|
-
|
22
21
|
For more detailed information about running tests, code style and linting,
|
23
22
|
please see the [help page](http://exercism.io/languages/python).
|
24
23
|
|
@@ -13,4 +13,4 @@ For this reason, in version 3.6, Python introduced the `secrets` module, which g
|
|
13
13
|
cryptographically strong random numbers that provide the greater security required for cryptography.
|
14
14
|
|
15
15
|
Since this is only an exercise, `random` is fine to use, but note that **it would be
|
16
|
-
very insecure if actually used for cryptography.**
|
16
|
+
very insecure if actually used for cryptography.**
|
@@ -54,15 +54,16 @@ cryptographically strong random numbers that provide the greater security requir
|
|
54
54
|
Since this is only an exercise, `random` is fine to use, but note that **it would be
|
55
55
|
very insecure if actually used for cryptography.**
|
56
56
|
|
57
|
-
|
57
|
+
|
58
|
+
## Submitting Exercises
|
58
59
|
|
59
60
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
60
61
|
|
61
62
|
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`.
|
62
63
|
|
63
|
-
|
64
64
|
For more detailed information about running tests, code style and linting,
|
65
65
|
please see the [help page](http://exercism.io/languages/python).
|
66
|
+
|
66
67
|
## Source
|
67
68
|
|
68
69
|
Wikipedia, 1024 bit key from www.cryptopp.com/wiki. [http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange](http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
## Hints
|
2
|
+
|
3
|
+
For the `filelike_objects_are_closed_on_exception` function, the `filelike_object`
|
4
|
+
will be an instance of a custom `FileLike` class defined in the test suite. This
|
5
|
+
class implements the following methods:
|
6
|
+
- `open` and `close`, for explicit opening and closing.
|
7
|
+
- `__enter__` and `__exit__`, for implicit opening and closing.
|
8
|
+
- `do_something`, which may or may not throw an `Exception`.
|
@@ -9,13 +9,21 @@ This exercise requires you to handle various errors. Because error handling
|
|
9
9
|
is rather programming language specific you'll have to refer to the tests
|
10
10
|
for your track to see what's exactly required.
|
11
11
|
|
12
|
-
|
12
|
+
## Hints
|
13
|
+
|
14
|
+
For the `filelike_objects_are_closed_on_exception` function, the `filelike_object`
|
15
|
+
will be an instance of a custom `FileLike` class defined in the test suite. This
|
16
|
+
class implements the following methods:
|
17
|
+
- `open` and `close`, for explicit opening and closing.
|
18
|
+
- `__enter__` and `__exit__`, for implicit opening and closing.
|
19
|
+
- `do_something`, which may or may not throw an `Exception`.
|
20
|
+
|
21
|
+
## Submitting Exercises
|
13
22
|
|
14
23
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
15
24
|
|
16
25
|
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`.
|
17
26
|
|
18
|
-
|
19
27
|
For more detailed information about running tests, code style and linting,
|
20
28
|
please see the [help page](http://exercism.io/languages/python).
|
21
29
|
|
@@ -4,10 +4,11 @@ import error_handling as er
|
|
4
4
|
|
5
5
|
|
6
6
|
class FileLike(object):
|
7
|
-
def __init__(self):
|
7
|
+
def __init__(self, fail_something=True):
|
8
8
|
self.is_open = False
|
9
9
|
self.was_open = False
|
10
10
|
self.did_something = False
|
11
|
+
self.fail_something = fail_something
|
11
12
|
|
12
13
|
def open(self):
|
13
14
|
self.was_open = False
|
@@ -26,7 +27,8 @@ class FileLike(object):
|
|
26
27
|
|
27
28
|
def do_something(self):
|
28
29
|
self.did_something = True
|
29
|
-
|
30
|
+
if self.fail_something:
|
31
|
+
raise Exception()
|
30
32
|
|
31
33
|
|
32
34
|
class ErrorHandlingTest(unittest.TestCase):
|
@@ -51,7 +53,7 @@ class ErrorHandlingTest(unittest.TestCase):
|
|
51
53
|
'Invalid input should not be successful')
|
52
54
|
|
53
55
|
def test_filelike_objects_are_closed_on_exception(self):
|
54
|
-
filelike_object = FileLike()
|
56
|
+
filelike_object = FileLike(fail_something=True)
|
55
57
|
with self.assertRaises(Exception):
|
56
58
|
er.filelike_objects_are_closed_on_exception(filelike_object)
|
57
59
|
self.assertIs(filelike_object.is_open, False,
|
@@ -61,6 +63,16 @@ class ErrorHandlingTest(unittest.TestCase):
|
|
61
63
|
self.assertIs(filelike_object.did_something, True,
|
62
64
|
'filelike_object should call do_something()')
|
63
65
|
|
66
|
+
def test_filelike_objects_are_closed_without_exception(self):
|
67
|
+
filelike_object = FileLike(fail_something=False)
|
68
|
+
er.filelike_objects_are_closed_on_exception(filelike_object)
|
69
|
+
self.assertIs(filelike_object.is_open, False,
|
70
|
+
'filelike_object should be closed')
|
71
|
+
self.assertIs(filelike_object.was_open, True,
|
72
|
+
'filelike_object should have been opened')
|
73
|
+
self.assertIs(filelike_object.did_something, True,
|
74
|
+
'filelike_object should call do_something()')
|
75
|
+
|
64
76
|
|
65
77
|
if __name__ == '__main__':
|
66
78
|
unittest.main()
|