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
@@ -2,30 +2,32 @@
|
|
2
2
|
|
3
3
|
Determine if a triangle is equilateral, isosceles, or scalene.
|
4
4
|
|
5
|
-
An _equilateral_ triangle has all three sides the same length
|
5
|
+
An _equilateral_ triangle has all three sides the same length.
|
6
|
+
|
6
7
|
An _isosceles_ triangle has at least two sides the same length. (It is sometimes
|
7
8
|
specified as having exactly two sides the same length, but for the purposes of
|
8
|
-
this exercise we'll say at least two.)
|
9
|
+
this exercise we'll say at least two.)
|
10
|
+
|
9
11
|
A _scalene_ triangle has all sides of different lengths.
|
10
12
|
|
11
13
|
## Note
|
12
14
|
|
13
|
-
For a shape to be a triangle at all, all sides have to be of length > 0, and
|
14
|
-
the sum of the lengths of any two sides must be greater than or equal to the
|
15
|
+
For a shape to be a triangle at all, all sides have to be of length > 0, and
|
16
|
+
the sum of the lengths of any two sides must be greater than or equal to the
|
15
17
|
length of the third side. See [Triangle Inequality](https://en.wikipedia.org/wiki/Triangle_inequality).
|
16
18
|
|
17
19
|
## Dig Deeper
|
18
20
|
|
19
|
-
The case where the sum of the lengths of two sides _equals_ that of the
|
20
|
-
third is known as a _degenerate_ triangle - it has zero area and looks like
|
21
|
+
The case where the sum of the lengths of two sides _equals_ that of the
|
22
|
+
third is known as a _degenerate_ triangle - it has zero area and looks like
|
21
23
|
a single line. Feel free to add your own code/tests to check for degenerate triangles.
|
22
|
-
|
24
|
+
|
25
|
+
## Submitting Exercises
|
23
26
|
|
24
27
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
25
28
|
|
26
29
|
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`.
|
27
30
|
|
28
|
-
|
29
31
|
For more detailed information about running tests, code style and linting,
|
30
32
|
please see the [help page](http://exercism.io/languages/python).
|
31
33
|
|
@@ -11,7 +11,7 @@ Trinary numbers contain three symbols: 0, 1, and 2.
|
|
11
11
|
The last place in a trinary number is the 1's place. The second to last
|
12
12
|
is the 3's place, the third to last is the 9's place, etc.
|
13
13
|
|
14
|
-
```
|
14
|
+
```shell
|
15
15
|
# "102012"
|
16
16
|
1 0 2 0 1 2 # the number
|
17
17
|
1*3^5 + 0*3^4 + 2*3^3 + 0*3^2 + 1*3^1 + 2*3^0 # the value
|
@@ -21,13 +21,12 @@ 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
|
-
|
24
|
+
## Submitting Exercises
|
25
25
|
|
26
26
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
27
27
|
|
28
28
|
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`.
|
29
29
|
|
30
|
-
|
31
30
|
For more detailed information about running tests, code style and linting,
|
32
31
|
please see the [help page](http://exercism.io/languages/python).
|
33
32
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Output the lyrics to 'The Twelve Days of Christmas'.
|
4
4
|
|
5
|
-
```
|
5
|
+
```text
|
6
6
|
On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.
|
7
7
|
|
8
8
|
On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.
|
@@ -28,13 +28,12 @@ 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
|
-
|
31
|
+
## Submitting Exercises
|
32
32
|
|
33
33
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
34
34
|
|
35
35
|
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`.
|
36
36
|
|
37
|
-
|
38
37
|
For more detailed information about running tests, code style and linting,
|
39
38
|
please see the [help page](http://exercism.io/languages/python).
|
40
39
|
|
@@ -4,7 +4,7 @@ Given two buckets of different size, demonstrate how to measure an exact number
|
|
4
4
|
|
5
5
|
Since this mathematical problem is fairly subject to interpretation / individual approach, the tests have been written specifically to expect one overarching solution.
|
6
6
|
|
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!
|
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
10
|
- the size of bucket one, passed as a numeric value
|
@@ -17,9 +17,9 @@ Your program should determine:
|
|
17
17
|
- which bucket should end up with the desired number of liters (let's say this is bucket A) - expects a String (either 'one' or 'two')
|
18
18
|
- how many liters are left in the other bucket (bucket B) - expects a numeric value
|
19
19
|
|
20
|
-
Note: any time a change is made to either or both buckets counts as one (1) move.
|
20
|
+
Note: any time a change is made to either or both buckets counts as one (1) move.
|
21
21
|
|
22
|
-
Example:
|
22
|
+
Example:
|
23
23
|
Bucket one can hold up to 7 liters, and bucket two can hold up to 11 liters. Let's say bucket one, at a given step, is holding 7 liters, and bucket two is holding 8 liters (7,8). If you empty bucket one and make no change to bucket two, leaving you with 0 liters and 8 liters respectively (0,8), that counts as one "move". Instead, if you had poured from bucket one into bucket two until bucket two was full, leaving you with 4 liters in bucket one and 11 liters in bucket two (4,11), that would count as only one "move" as well.
|
24
24
|
|
25
25
|
To conclude, the only valid moves are:
|
@@ -29,13 +29,12 @@ 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
|
-
|
32
|
+
## Submitting Exercises
|
33
33
|
|
34
34
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
35
35
|
|
36
36
|
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`.
|
37
37
|
|
38
|
-
|
39
38
|
For more detailed information about running tests, code style and linting,
|
40
39
|
please see the [help page](http://exercism.io/languages/python).
|
41
40
|
|
@@ -8,6 +8,8 @@ import unittest
|
|
8
8
|
from two_bucket import two_bucket
|
9
9
|
|
10
10
|
|
11
|
+
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0
|
12
|
+
|
11
13
|
class TwoBucketTest(unittest.TestCase):
|
12
14
|
def test_bucket_one_size_3_bucket_two_size_5_start_with_bucket_one(self):
|
13
15
|
self.assertEqual(two_bucket(3, 5, 1, "one"), (4, "one", 5))
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# Two
|
1
|
+
# Two Fer
|
2
2
|
|
3
3
|
`Two-fer` or `2-fer` is short for two for one. One for you and one for me.
|
4
4
|
|
5
|
-
```
|
5
|
+
```text
|
6
6
|
"One for X, one for me."
|
7
7
|
```
|
8
8
|
|
@@ -11,13 +11,12 @@ 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
|
-
|
14
|
+
## Submitting Exercises
|
15
15
|
|
16
16
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
17
17
|
|
18
18
|
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`.
|
19
19
|
|
20
|
-
|
21
20
|
For more detailed information about running tests, code style and linting,
|
22
21
|
please see the [help page](http://exercism.io/languages/python).
|
23
22
|
|
@@ -26,4 +25,4 @@ please see the [help page](http://exercism.io/languages/python).
|
|
26
25
|
This is an exercise to introduce users to basic programming constructs, just after hello World. [https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer)
|
27
26
|
|
28
27
|
## Submitting Incomplete Solutions
|
29
|
-
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
28
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -2,13 +2,16 @@ import unittest
|
|
2
2
|
|
3
3
|
import two_fer
|
4
4
|
|
5
|
+
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
|
6
|
+
|
5
7
|
|
6
8
|
class Two_Fer_test(unittest.TestCase):
|
7
9
|
def test_empty(self):
|
8
10
|
self.assertEqual(two_fer.two_fer(), 'One for you, one for me.')
|
9
11
|
|
10
|
-
def
|
11
|
-
self.assertEqual(two_fer.two_fer("
|
12
|
+
def test_alice(self):
|
13
|
+
self.assertEqual(two_fer.two_fer("Alice"),
|
14
|
+
"One for Alice, one for me.")
|
12
15
|
|
13
16
|
def test_bob(self):
|
14
17
|
self.assertEqual(two_fer.two_fer("Bob"), "One for Bob, one for me.")
|
@@ -5,18 +5,17 @@ Implement variable length quantity encoding and decoding.
|
|
5
5
|
The goal of this exercise is to implement [VLQ](https://en.wikipedia.org/wiki/Variable-length_quantity) encoding/decoding.
|
6
6
|
|
7
7
|
In short, the goal of this encoding is to encode integer values in a way that would save bytes.
|
8
|
-
Only the first 7 bits of each byte is significant (right-justified; sort of like an ASCII byte).
|
9
|
-
So, if you have a 32-bit value, you have to unpack it into a series of 7-bit bytes.
|
10
|
-
Of course, you will have a variable number of bytes depending upon your integer.
|
8
|
+
Only the first 7 bits of each byte is significant (right-justified; sort of like an ASCII byte).
|
9
|
+
So, if you have a 32-bit value, you have to unpack it into a series of 7-bit bytes.
|
10
|
+
Of course, you will have a variable number of bytes depending upon your integer.
|
11
11
|
To indicate which is the last byte of the series, you leave bit #7 clear.
|
12
|
-
In all of the preceding bytes, you set bit #7.
|
12
|
+
In all of the preceding bytes, you set bit #7.
|
13
13
|
|
14
|
-
So, if an integer is between `0-127`, it can be represented as one byte.
|
14
|
+
So, if an integer is between `0-127`, it can be represented as one byte.
|
15
15
|
Although VLQ can deal with numbers of arbitrary sizes, for this exercise we will restrict ourselves to only numbers that fit in a 32-bit unsigned integer.
|
16
16
|
Here are examples of integers as 32-bit values, and the variable length quantities that they translate to:
|
17
17
|
|
18
|
-
|
19
|
-
```
|
18
|
+
```text
|
20
19
|
NUMBER VARIABLE QUANTITY
|
21
20
|
00000000 00
|
22
21
|
00000040 40
|
@@ -32,13 +31,12 @@ Here are examples of integers as 32-bit values, and the variable length quantiti
|
|
32
31
|
0FFFFFFF FF FF FF 7F
|
33
32
|
```
|
34
33
|
|
35
|
-
|
34
|
+
## Submitting Exercises
|
36
35
|
|
37
36
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
38
37
|
|
39
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`.
|
40
39
|
|
41
|
-
|
42
40
|
For more detailed information about running tests, code style and linting,
|
43
41
|
please see the [help page](http://exercism.io/languages/python).
|
44
42
|
|
@@ -4,21 +4,19 @@ Given a phrase, count the occurrences of each word in that phrase.
|
|
4
4
|
|
5
5
|
For example for the input `"olly olly in come free"`
|
6
6
|
|
7
|
-
```
|
7
|
+
```text
|
8
8
|
olly: 2
|
9
9
|
in: 1
|
10
10
|
come: 1
|
11
11
|
free: 1
|
12
12
|
```
|
13
13
|
|
14
|
-
|
15
|
-
### Submitting Exercises
|
14
|
+
## Submitting Exercises
|
16
15
|
|
17
16
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
18
17
|
|
19
18
|
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
19
|
|
21
|
-
|
22
20
|
For more detailed information about running tests, code style and linting,
|
23
21
|
please see the [help page](http://exercism.io/languages/python).
|
24
22
|
|
@@ -5,7 +5,7 @@ words in them.
|
|
5
5
|
|
6
6
|
For example:
|
7
7
|
|
8
|
-
```
|
8
|
+
```text
|
9
9
|
jefblpepre
|
10
10
|
camdcimgtc
|
11
11
|
oivokprjsm
|
@@ -26,13 +26,12 @@ vertical and diagonal.
|
|
26
26
|
Given a puzzle and a list of words return the location of the first and last
|
27
27
|
letter of each word.
|
28
28
|
|
29
|
-
|
29
|
+
## Submitting Exercises
|
30
30
|
|
31
31
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
32
32
|
|
33
33
|
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`.
|
34
34
|
|
35
|
-
|
36
35
|
For more detailed information about running tests, code style and linting,
|
37
36
|
please see the [help page](http://exercism.io/languages/python).
|
38
37
|
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
Parse and evaluate simple math word problems returning the answer as an integer.
|
4
4
|
|
5
|
-
|
6
5
|
## Iteration 1 — Addition
|
7
6
|
|
8
7
|
Add two numbers together.
|
@@ -13,7 +12,6 @@ Evaluates to 18.
|
|
13
12
|
|
14
13
|
Handle large numbers and negative numbers.
|
15
14
|
|
16
|
-
|
17
15
|
## Iteration 2 — Subtraction, Multiplication and Division
|
18
16
|
|
19
17
|
Now, perform the other three operations.
|
@@ -30,7 +28,6 @@ Now, perform the other three operations.
|
|
30
28
|
|
31
29
|
5
|
32
30
|
|
33
|
-
|
34
31
|
## Iteration 3 — Multiple Operations
|
35
32
|
|
36
33
|
Handle a set of operations, in sequence.
|
@@ -46,7 +43,6 @@ left-to-right, _ignoring the typical order of operations._
|
|
46
43
|
|
47
44
|
15 (i.e. not 9)
|
48
45
|
|
49
|
-
|
50
46
|
## Bonus — Exponentials
|
51
47
|
|
52
48
|
If you'd like, handle exponentials.
|
@@ -55,14 +51,12 @@ If you'd like, handle exponentials.
|
|
55
51
|
|
56
52
|
32
|
57
53
|
|
58
|
-
|
59
|
-
### Submitting Exercises
|
54
|
+
## Submitting Exercises
|
60
55
|
|
61
56
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
62
57
|
|
63
58
|
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`.
|
64
59
|
|
65
|
-
|
66
60
|
For more detailed information about running tests, code style and linting,
|
67
61
|
please see the [help page](http://exercism.io/languages/python).
|
68
62
|
|
@@ -14,19 +14,19 @@ VALID_OPERATIONS = {"plus": add, "minus": sub,
|
|
14
14
|
def calculate(stmt):
|
15
15
|
if not (stmt.startswith("What is ") and stmt.endswith("?")):
|
16
16
|
raise ValueError("Ill-formed question")
|
17
|
-
|
18
|
-
if not
|
17
|
+
words = stmt[8:-1].strip().lower().split()
|
18
|
+
if not words:
|
19
19
|
raise ValueError("Ill-formed question")
|
20
|
-
|
20
|
+
words.reverse()
|
21
21
|
try:
|
22
|
-
op1 = int(
|
22
|
+
op1 = int(words.pop())
|
23
23
|
except ValueError:
|
24
24
|
raise ValueError("Ill-formed question")
|
25
|
-
while
|
26
|
-
oprt = [
|
27
|
-
while
|
25
|
+
while words:
|
26
|
+
oprt = [words.pop()]
|
27
|
+
while words:
|
28
28
|
try:
|
29
|
-
next_tk =
|
29
|
+
next_tk = words.pop()
|
30
30
|
op2 = int(next_tk)
|
31
31
|
break
|
32
32
|
except ValueError:
|
@@ -3,54 +3,62 @@ import unittest
|
|
3
3
|
from wordy import calculate
|
4
4
|
|
5
5
|
|
6
|
+
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0
|
7
|
+
|
6
8
|
class WordyTest(unittest.TestCase):
|
7
|
-
def
|
8
|
-
self.assertEqual(calculate("What is
|
9
|
+
def test_addition(self):
|
10
|
+
self.assertEqual(calculate("What is 1 plus 1?"), 2)
|
9
11
|
|
10
|
-
def
|
11
|
-
self.assertEqual(calculate("What is
|
12
|
+
def test_more_addition(self):
|
13
|
+
self.assertEqual(calculate("What is 53 plus 2?"), 55)
|
12
14
|
|
13
|
-
def
|
14
|
-
self.assertEqual(calculate("What is
|
15
|
+
def test_addition_with_negative_numbers(self):
|
16
|
+
self.assertEqual(calculate("What is -1 plus -10?"), -11)
|
15
17
|
|
16
|
-
def
|
17
|
-
self.assertEqual(calculate("What is
|
18
|
+
def test_large_addition(self):
|
19
|
+
self.assertEqual(calculate("What is 123 plus 45678?"), 45801)
|
18
20
|
|
19
|
-
def
|
20
|
-
self.assertEqual(calculate("What is
|
21
|
+
def test_subtraction(self):
|
22
|
+
self.assertEqual(calculate("What is 4 minus -12?"), 16)
|
21
23
|
|
22
|
-
def
|
23
|
-
self.assertEqual(calculate("What is
|
24
|
+
def test_multiplication(self):
|
25
|
+
self.assertEqual(calculate("What is -3 multiplied by 25?"), -75)
|
24
26
|
|
25
|
-
def
|
26
|
-
self.assertEqual(calculate("What is
|
27
|
+
def test_division(self):
|
28
|
+
self.assertEqual(calculate("What is 33 divided by -3?"), -11)
|
27
29
|
|
28
|
-
def
|
29
|
-
self.assertEqual(calculate("What is
|
30
|
+
def test_multiple_addition(self):
|
31
|
+
self.assertEqual(calculate("What is 1 plus 1 plus 1?"), 3)
|
30
32
|
|
31
|
-
def
|
32
|
-
self.assertEqual(calculate("What is 1 plus
|
33
|
+
def test_addition_then_subtraction(self):
|
34
|
+
self.assertEqual(calculate("What is 1 plus 5 minus -2?"), 8)
|
33
35
|
|
34
|
-
def
|
35
|
-
self.assertEqual(calculate("What is
|
36
|
+
def test_multiple_subtraction(self):
|
37
|
+
self.assertEqual(calculate("What is 20 minus 4 minus 13?"), 3)
|
36
38
|
|
37
|
-
def
|
38
|
-
self.assertEqual(calculate("What is
|
39
|
+
def test_subtraction_then_addition(self):
|
40
|
+
self.assertEqual(calculate("What is 17 minus 6 plus 3?"), 14)
|
39
41
|
|
40
|
-
def
|
42
|
+
def test_multiple_multiplication(self):
|
41
43
|
self.assertEqual(
|
42
44
|
calculate("What is 2 multiplied by -2 multiplied by 3?"), -12)
|
43
45
|
|
44
|
-
def
|
46
|
+
def test_addition_then_multiplication(self):
|
45
47
|
self.assertEqual(calculate("What is -3 plus 7 multiplied by -2?"), -8)
|
46
48
|
|
47
|
-
def
|
49
|
+
def test_multiple_division(self):
|
48
50
|
self.assertEqual(
|
49
|
-
calculate("What is -
|
51
|
+
calculate("What is -12 divided by 2 divided by -3?"), 2)
|
50
52
|
|
51
|
-
def
|
53
|
+
def test_unknown_operation(self):
|
52
54
|
with self.assertRaises(ValueError):
|
53
|
-
calculate("What is
|
55
|
+
calculate("What is 52 cubed?")
|
56
|
+
|
57
|
+
def test_non_math_question(self):
|
58
|
+
with self.assertRaises(ValueError):
|
59
|
+
calculate("Who is the President of the United States?")
|
60
|
+
|
61
|
+
# Additional tests for this track
|
54
62
|
|
55
63
|
def test_missing_operation(self):
|
56
64
|
with self.assertRaises(ValueError):
|
@@ -60,10 +68,6 @@ class WordyTest(unittest.TestCase):
|
|
60
68
|
with self.assertRaises(ValueError):
|
61
69
|
calculate("What is 7 plus multiplied by -2?")
|
62
70
|
|
63
|
-
def test_irrelevant_question(self):
|
64
|
-
with self.assertRaises(ValueError):
|
65
|
-
calculate("Which is greater, 3 or 2?")
|
66
|
-
|
67
71
|
|
68
72
|
if __name__ == '__main__':
|
69
73
|
unittest.main()
|