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
@@ -25,13 +25,12 @@ drink different beverages and smoke different brands of cigarettes.
|
|
25
25
|
Which of the residents drinks water?
|
26
26
|
Who owns the zebra?
|
27
27
|
|
28
|
-
|
28
|
+
## Submitting Exercises
|
29
29
|
|
30
30
|
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
31
31
|
|
32
32
|
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`.
|
33
33
|
|
34
|
-
|
35
34
|
For more detailed information about running tests, code style and linting,
|
36
35
|
please see the [help page](http://exercism.io/languages/python).
|
37
36
|
|
data/tracks/ruby/config.json
CHANGED
@@ -886,6 +886,17 @@
|
|
886
886
|
"Logic"
|
887
887
|
]
|
888
888
|
},
|
889
|
+
{
|
890
|
+
"uuid": "b02a4214-0f1a-9480-2132-2ea3d5073dbfbec0aa4",
|
891
|
+
"slug": "two-fer",
|
892
|
+
"core": false,
|
893
|
+
"unlocked_by": null,
|
894
|
+
"difficulty": 1,
|
895
|
+
"topics": [
|
896
|
+
"Control-flow (conditionals)",
|
897
|
+
"Strings"
|
898
|
+
]
|
899
|
+
},
|
889
900
|
{
|
890
901
|
"uuid": "cae4e000-3aac-41f7-b727-f9cce12d058d",
|
891
902
|
"slug": "octal",
|
data/tracks/ruby/docs/TESTS.md
CHANGED
@@ -10,6 +10,12 @@ Only the first test will be executed, all the others have been made pending
|
|
10
10
|
using the `skip` method. Delete or comment the next `skip` as you get
|
11
11
|
each test passing.
|
12
12
|
|
13
|
+
## Understanding Skips
|
14
|
+
|
15
|
+
The `skip` method instructs the test suite to not run a test. This is commonly used to avoid running tests of unimplemented functionality, so you can focus on the part you are currently working on.
|
16
|
+
|
17
|
+
The test run summary will list the number of skipped tests. You should disable all of the skips before completing an exercise.
|
18
|
+
|
13
19
|
## Customizing Test Reporting
|
14
20
|
|
15
21
|
If you want color, execute the tests with:
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require_relative 'pangram'
|
3
3
|
|
4
|
-
# Common test data version: 1.
|
4
|
+
# Common test data version: 1.3.0 d79e13e
|
5
5
|
class PangramTest < Minitest::Test
|
6
6
|
def test_sentence_empty
|
7
7
|
# skip
|
@@ -10,6 +10,13 @@ class PangramTest < Minitest::Test
|
|
10
10
|
refute result, "Expected false, got: #{result.inspect}. #{phrase.inspect} is NOT a pangram"
|
11
11
|
end
|
12
12
|
|
13
|
+
def test_recognizes_a_perfect_lower_case_pangram
|
14
|
+
skip
|
15
|
+
phrase = 'abcdefghijklmnopqrstuvwxyz'
|
16
|
+
result = Pangram.pangram?(phrase)
|
17
|
+
assert result, "Expected true, got: #{result.inspect}. #{phrase.inspect} IS a pangram"
|
18
|
+
end
|
19
|
+
|
13
20
|
def test_pangram_with_only_lower_case
|
14
21
|
skip
|
15
22
|
phrase = 'the quick brown fox jumps over the lazy dog'
|
@@ -24,9 +31,9 @@ class PangramTest < Minitest::Test
|
|
24
31
|
refute result, "Expected false, got: #{result.inspect}. #{phrase.inspect} is NOT a pangram"
|
25
32
|
end
|
26
33
|
|
27
|
-
def
|
34
|
+
def test_another_missing_character_eg_h
|
28
35
|
skip
|
29
|
-
phrase = '
|
36
|
+
phrase = 'five boxing wizards jump quickly at it'
|
30
37
|
result = Pangram.pangram?(phrase)
|
31
38
|
refute result, "Expected false, got: #{result.inspect}. #{phrase.inspect} is NOT a pangram"
|
32
39
|
end
|
@@ -85,6 +92,6 @@ class PangramTest < Minitest::Test
|
|
85
92
|
|
86
93
|
def test_bookkeeping
|
87
94
|
skip
|
88
|
-
assert_equal
|
95
|
+
assert_equal 6, BookKeeping::VERSION
|
89
96
|
end
|
90
97
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
1
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Two Fer
|
2
|
+
|
3
|
+
`Two-fer` or `2-fer` is short for two for one. One for you and one for me.
|
4
|
+
|
5
|
+
```text
|
6
|
+
"One for X, one for me."
|
7
|
+
```
|
8
|
+
|
9
|
+
When X is a name or "you".
|
10
|
+
|
11
|
+
If the given name is "Alice", the result should be "One for Alice, one for me."
|
12
|
+
If no name is given, the result should be "One for you, one for me."
|
13
|
+
|
14
|
+
## Test-Driven Development
|
15
|
+
|
16
|
+
As programmers mature, they eventually want to test their code.
|
17
|
+
|
18
|
+
Here at Exercism we simulate [Test-Driven
|
19
|
+
Development](http://en.wikipedia.org/wiki/Test-driven_development) (TDD), where
|
20
|
+
you write your tests before writing any functionality. The simulation comes in
|
21
|
+
the form of a pre-written test suite, which will signal that you have solved
|
22
|
+
the problem.
|
23
|
+
|
24
|
+
It will also provide you with a safety net to explore other solutions without
|
25
|
+
breaking the functionality.
|
26
|
+
|
27
|
+
### A typical TDD workflow on Exercism:
|
28
|
+
|
29
|
+
1. Run the test file and pick one test that's failing.
|
30
|
+
2. Write some code to fix the test you picked.
|
31
|
+
3. Re-run the tests to confirm the test is now passing.
|
32
|
+
4. Repeat from step 1.
|
33
|
+
5. Submit your solution (`exercism submit /path/to/file`)
|
34
|
+
|
35
|
+
## Instructions
|
36
|
+
|
37
|
+
Submissions are encouraged to be general, within reason. Having said that, it's
|
38
|
+
also important not to over-engineer a solution.
|
39
|
+
|
40
|
+
It's important to remember that the goal is to make code as expressive and
|
41
|
+
readable as we can.
|
42
|
+
|
43
|
+
## Running the tests
|
44
|
+
|
45
|
+
For running the tests provided, you will need the Minitest gem. Open a terminal window and run the following command to install minitest:
|
46
|
+
|
47
|
+
`gem install minitest`
|
48
|
+
|
49
|
+
If you would like color output, you can require `'minitest/pride'` in the test file, or note the alternative instruction, below, for running the test file.
|
50
|
+
|
51
|
+
In order to run the test, you can run the test file from the exercise directory.
|
52
|
+
|
53
|
+
`ruby two_fer_test.rb`
|
54
|
+
|
55
|
+
To include color from the command line:
|
56
|
+
|
57
|
+
`ruby -r minitest/pride two_fer_test.rb`
|
58
|
+
|
59
|
+
## Further information
|
60
|
+
|
61
|
+
For more detailed information about the Ruby track, including how to get help if you're having trouble, please visit the exercism.io [Ruby language page](http://exercism.io/languages/ruby/about).
|
62
|
+
|
63
|
+
## Source
|
64
|
+
|
65
|
+
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)
|
66
|
+
|
67
|
+
## Submitting Incomplete Solutions
|
68
|
+
|
69
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative 'two_fer'
|
3
|
+
|
4
|
+
# Common test data version: 1.1.0 c080bdf
|
5
|
+
class TwoFerTest < Minitest::Test
|
6
|
+
def test_no_name_given
|
7
|
+
# skip
|
8
|
+
assert_equal "One for you, one for me.", TwoFer.two_fer
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_a_name_given
|
12
|
+
skip
|
13
|
+
assert_equal "One for Alice, one for me.", TwoFer.two_fer("Alice")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_another_name_given
|
17
|
+
skip
|
18
|
+
assert_equal "One for Bob, one for me.", TwoFer.two_fer("Bob")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Problems in exercism evolve over time, as we find better ways to ask
|
22
|
+
# questions.
|
23
|
+
# The version number refers to the version of the problem you solved,
|
24
|
+
# not your solution.
|
25
|
+
#
|
26
|
+
# Define a constant named VERSION inside of the top level BookKeeping
|
27
|
+
# module, which may be placed near the end of your file.
|
28
|
+
#
|
29
|
+
# In your file, it will look like this:
|
30
|
+
#
|
31
|
+
# module BookKeeping
|
32
|
+
# VERSION = 1 # Where the version number matches the one in the test.
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# If you are curious, read more about constants on RubyDoc:
|
36
|
+
# http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html
|
37
|
+
|
38
|
+
def test_bookkeeping
|
39
|
+
skip
|
40
|
+
assert_equal 1, BookKeeping::VERSION
|
41
|
+
end
|
42
|
+
end
|
data/tracks/rust/config.json
CHANGED
@@ -447,6 +447,18 @@
|
|
447
447
|
"Option"
|
448
448
|
]
|
449
449
|
},
|
450
|
+
{
|
451
|
+
"uuid": "dd74b65c-0d26-4821-9add-064e32e3a5bd",
|
452
|
+
"slug": "binary-search",
|
453
|
+
"core": false,
|
454
|
+
"unlocked_by": null,
|
455
|
+
"difficulty": 4,
|
456
|
+
"topics": [
|
457
|
+
"slices",
|
458
|
+
"trait (optional)",
|
459
|
+
"Option"
|
460
|
+
]
|
461
|
+
},
|
450
462
|
{
|
451
463
|
"uuid": "1beb8b0c-d06d-4569-80e5-866ed01a7a66",
|
452
464
|
"slug": "robot-simulator",
|
@@ -0,0 +1,38 @@
|
|
1
|
+
## Restrictions
|
2
|
+
|
3
|
+
Rust provides in its standard library already a
|
4
|
+
[binary search function](https://doc.rust-lang.org/std/primitive.slice.html#method.binary_search).
|
5
|
+
For this exercise you should not use this function but just other basic tools instead.
|
6
|
+
|
7
|
+
## Hints
|
8
|
+
|
9
|
+
[Slices](https://doc.rust-lang.org/book/second-edition/ch04-03-slices.html) have additionally to
|
10
|
+
the normal element access via indexing (slice[index]) many useful functions like
|
11
|
+
[split_at](https://doc.rust-lang.org/std/primitive.slice.html#method.split_at) or [getting
|
12
|
+
subslices](https://doc.rust-lang.org/std/primitive.slice.html#method.get) (slice[start..end]).
|
13
|
+
|
14
|
+
You can solve this exercise by just using boring old element access via indexing, but maybe the
|
15
|
+
other provided functions can make your code cleaner and safer.
|
16
|
+
|
17
|
+
## For bonus points
|
18
|
+
|
19
|
+
Did you get the tests passing and the code clean? If you want to, there
|
20
|
+
are some additional things you could try.
|
21
|
+
|
22
|
+
- Currently your find function will probably only work for slices of numbers,
|
23
|
+
but the Rust type system is flexible enough to create a find function which
|
24
|
+
works on all slices which contains elements which can be ordered.
|
25
|
+
- Additionally this find function can work not only on slices, but at the
|
26
|
+
same time also on a Vec or an Array.
|
27
|
+
|
28
|
+
You can find tests (commented out) for these bonus tasks in the test file.
|
29
|
+
|
30
|
+
Then please share your thoughts in a comment on the submission. Did this
|
31
|
+
experiment make the code better? Worse? Did you learn anything from it?
|
32
|
+
|
33
|
+
### Hints for Bonus Points
|
34
|
+
|
35
|
+
- To get your function working with all kind of elements which can be ordered,
|
36
|
+
have a look at the [Ord Trait](https://doc.rust-lang.org/std/cmp/trait.Ord.html).
|
37
|
+
- To get your function working directly on Vec and Array, you can use the
|
38
|
+
[AsRef Trait](https://doc.rust-lang.org/std/convert/trait.AsRef.html)
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# Binary Search
|
2
|
+
|
3
|
+
Implement a binary search algorithm.
|
4
|
+
|
5
|
+
Searching a sorted collection is a common task. A dictionary is a sorted
|
6
|
+
list of word definitions. Given a word, one can find its definition. A
|
7
|
+
telephone book is a sorted list of people's names, addresses, and
|
8
|
+
telephone numbers. Knowing someone's name allows one to quickly find
|
9
|
+
their telephone number and address.
|
10
|
+
|
11
|
+
If the list to be searched contains more than a few items (a dozen, say)
|
12
|
+
a binary search will require far fewer comparisons than a linear search,
|
13
|
+
but it imposes the requirement that the list be sorted.
|
14
|
+
|
15
|
+
In computer science, a binary search or half-interval search algorithm
|
16
|
+
finds the position of a specified input value (the search "key") within
|
17
|
+
an array sorted by key value.
|
18
|
+
|
19
|
+
In each step, the algorithm compares the search key value with the key
|
20
|
+
value of the middle element of the array.
|
21
|
+
|
22
|
+
If the keys match, then a matching element has been found and its index,
|
23
|
+
or position, is returned.
|
24
|
+
|
25
|
+
Otherwise, if the search key is less than the middle element's key, then
|
26
|
+
the algorithm repeats its action on the sub-array to the left of the
|
27
|
+
middle element or, if the search key is greater, on the sub-array to the
|
28
|
+
right.
|
29
|
+
|
30
|
+
If the remaining array to be searched is empty, then the key cannot be
|
31
|
+
found in the array and a special "not found" indication is returned.
|
32
|
+
|
33
|
+
A binary search halves the number of items to check with each iteration,
|
34
|
+
so locating an item (or determining its absence) takes logarithmic time.
|
35
|
+
A binary search is a dichotomic divide and conquer search algorithm.
|
36
|
+
|
37
|
+
## Restrictions
|
38
|
+
|
39
|
+
Rust provides in its standard library already a
|
40
|
+
[binary search function](https://doc.rust-lang.org/std/primitive.slice.html#method.binary_search).
|
41
|
+
For this exercise you should not use this function but just other basic tools instead.
|
42
|
+
|
43
|
+
## Hints
|
44
|
+
|
45
|
+
[Slices](https://doc.rust-lang.org/book/second-edition/ch04-03-slices.html) have additionally to
|
46
|
+
the normal element access via indexing (slice[index]) many useful functions like
|
47
|
+
[split_at](https://doc.rust-lang.org/std/primitive.slice.html#method.split_at) or [getting
|
48
|
+
subslices](https://doc.rust-lang.org/std/primitive.slice.html#method.get) (slice[start..end]).
|
49
|
+
|
50
|
+
You can solve this exercise by just using boring old element access via indexing, but maybe the
|
51
|
+
other provided functions can make your code cleaner and safer.
|
52
|
+
|
53
|
+
## For bonus points
|
54
|
+
|
55
|
+
Did you get the tests passing and the code clean? If you want to, there
|
56
|
+
are some additional things you could try.
|
57
|
+
|
58
|
+
- Currently your find function will probably only work for slices of numbers,
|
59
|
+
but the Rust type system is flexible enough to create a find function which
|
60
|
+
works on all slices which contains elements which can be ordered.
|
61
|
+
- Additionally this find function can work not only on slices, but at the
|
62
|
+
same time also on a Vec or an Array.
|
63
|
+
|
64
|
+
You can find tests (commented out) for these bonus tasks in the test file.
|
65
|
+
|
66
|
+
Then please share your thoughts in a comment on the submission. Did this
|
67
|
+
experiment make the code better? Worse? Did you learn anything from it?
|
68
|
+
|
69
|
+
### Hints for Bonus Points
|
70
|
+
|
71
|
+
- To get your function working with all kind of elements which can be ordered,
|
72
|
+
have a look at the [Ord Trait](https://doc.rust-lang.org/std/cmp/trait.Ord.html).
|
73
|
+
- To get your function working directly on Vec and Array, you can use the
|
74
|
+
[AsRef Trait](https://doc.rust-lang.org/std/convert/trait.AsRef.html)
|
75
|
+
|
76
|
+
|
77
|
+
## Rust Installation
|
78
|
+
|
79
|
+
Refer to the [exercism help page][help-page] for Rust installation and learning
|
80
|
+
resources.
|
81
|
+
|
82
|
+
## Writing the Code
|
83
|
+
|
84
|
+
Execute the tests with:
|
85
|
+
|
86
|
+
```bash
|
87
|
+
$ cargo test
|
88
|
+
```
|
89
|
+
|
90
|
+
All but the first test have been ignored. After you get the first test to
|
91
|
+
pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
|
92
|
+
to pass again. The test file is located in the `tests` directory. You can
|
93
|
+
also remove the ignore flag from all the tests to get them to run all at once
|
94
|
+
if you wish.
|
95
|
+
|
96
|
+
Make sure to read the [Crates and Modules](https://doc.rust-lang.org/stable/book/crates-and-modules.html) chapter if you
|
97
|
+
haven't already, it will help you with organizing your files.
|
98
|
+
|
99
|
+
## Feedback, Issues, Pull Requests
|
100
|
+
|
101
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
|
102
|
+
|
103
|
+
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
104
|
+
|
105
|
+
[help-page]: http://exercism.io/languages/rust
|
106
|
+
[crates-and-modules]: http://doc.rust-lang.org/stable/book/crates-and-modules.html
|
107
|
+
|
108
|
+
## Source
|
109
|
+
|
110
|
+
Wikipedia [http://en.wikipedia.org/wiki/Binary_search_algorithm](http://en.wikipedia.org/wiki/Binary_search_algorithm)
|
111
|
+
|
112
|
+
## Submitting Incomplete Solutions
|
113
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
use std::cmp::Ordering;
|
2
|
+
|
3
|
+
pub fn find<C, T>(elements: C, needle: T) -> Option<usize>
|
4
|
+
where
|
5
|
+
C: AsRef<[T]>,
|
6
|
+
T: Ord,
|
7
|
+
|
8
|
+
{
|
9
|
+
let mut base = 0usize;
|
10
|
+
let mut slice: &[T] = elements.as_ref();
|
11
|
+
|
12
|
+
loop {
|
13
|
+
let (head, tail) = slice.split_at(slice.len() >> 1);
|
14
|
+
if let Some(middle_element) = tail.first() {
|
15
|
+
match middle_element.cmp(&needle) {
|
16
|
+
Ordering::Less => {
|
17
|
+
base += head.len() + 1;
|
18
|
+
slice = &tail[1..];
|
19
|
+
}
|
20
|
+
Ordering::Greater => slice = head,
|
21
|
+
Ordering::Equal => {
|
22
|
+
return Some(base + head.len());
|
23
|
+
}
|
24
|
+
}
|
25
|
+
} else {
|
26
|
+
return None;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|