trackler 2.2.1.61 → 2.2.1.62
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/forth/canonical-data.json +1 -7
- data/problem-specifications/exercises/meetup/description.md +16 -12
- data/problem-specifications/exercises/sum-of-multiples/description.md +3 -3
- data/tracks/c/config.json +14 -1
- data/tracks/c/exercises/anagram/src/anagram.h +19 -4
- data/tracks/c/exercises/anagram/src/example.c +27 -40
- data/tracks/c/exercises/anagram/test/test_anagram.c +100 -152
- data/tracks/c/exercises/sublist/README.md +53 -0
- data/tracks/c/exercises/sublist/makefile +15 -0
- data/tracks/c/exercises/sublist/src/example.c +63 -0
- data/tracks/c/exercises/sublist/src/sublist.h +17 -0
- data/tracks/c/exercises/sublist/test/test_sublist.c +243 -0
- data/tracks/c/exercises/sublist/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/sublist/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/sublist/test/vendor/unity_internals.h +701 -0
- data/tracks/ecmascript/config.json +56 -0
- data/tracks/ecmascript/exercises/rectangles/README.md +95 -0
- data/tracks/ecmascript/exercises/rectangles/example.js +38 -0
- data/tracks/ecmascript/exercises/rectangles/package.json +72 -0
- data/tracks/ecmascript/exercises/rectangles/rectangles.spec.js +147 -0
- data/tracks/ecmascript/exercises/rotational-cipher/README.md +66 -0
- data/tracks/ecmascript/exercises/rotational-cipher/example.js +16 -0
- data/tracks/ecmascript/exercises/rotational-cipher/package.json +72 -0
- data/tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js +73 -0
- data/tracks/ecmascript/exercises/spiral-matrix/README.md +59 -0
- data/tracks/ecmascript/exercises/spiral-matrix/example.js +26 -0
- data/tracks/ecmascript/exercises/spiral-matrix/package.json +72 -0
- data/tracks/ecmascript/exercises/spiral-matrix/spiral-matrix.spec.js +55 -0
- data/tracks/ecmascript/exercises/transpose/README.md +94 -0
- data/tracks/ecmascript/exercises/transpose/example.js +12 -0
- data/tracks/ecmascript/exercises/transpose/package.json +71 -0
- data/tracks/ecmascript/exercises/transpose/transpose.spec.js +121 -0
- data/tracks/go/exercises/allergies/.meta/gen.go +88 -0
- data/tracks/go/exercises/allergies/allergies_test.go +19 -46
- data/tracks/go/exercises/allergies/cases_test.go +60 -0
- data/tracks/go/exercises/bob/bob.go +0 -2
- data/tracks/go/exercises/forth/cases_test.go +2 -7
- data/tracks/go/exercises/nucleotide-count/nucleotide_count.go +0 -2
- data/tracks/go/exercises/pangram/.meta/gen.go +54 -0
- data/tracks/go/exercises/pangram/cases_test.go +62 -0
- data/tracks/go/exercises/pangram/example.go +3 -5
- data/tracks/go/exercises/pangram/pangram_test.go +3 -24
- data/tracks/go/exercises/rna-transcription/rna_transcription.go +0 -2
- data/tracks/go/exercises/robot-name/bonus_example.go +0 -2
- data/tracks/java/exercises/acronym/.meta/src/reference/java/Acronym.java +3 -3
- data/tracks/lfe/config.json +4 -3
- data/tracks/perl6/docs/SNIPPET.txt +8 -3
- data/tracks/perl6/exercises/allergies/Allergies.pm6 +1 -1
- data/tracks/perl6/exercises/allergies/Example.pm6 +1 -1
- data/tracks/perl6/exercises/allergies/allergies.t +10 -2
- data/tracks/perl6/exercises/allergies/example.yaml +10 -2
- data/tracks/perl6/exercises/leap/Example.pm6 +1 -1
- data/tracks/perl6/exercises/leap/Leap.pm6 +1 -1
- data/tracks/perl6/exercises/leap/example.yaml +10 -2
- data/tracks/perl6/exercises/leap/leap.t +10 -2
- data/tracks/perl6/exercises/luhn/Example.pm6 +1 -1
- data/tracks/perl6/exercises/luhn/Luhn.pm6 +1 -1
- data/tracks/perl6/exercises/luhn/example.yaml +10 -2
- data/tracks/perl6/exercises/luhn/luhn.t +10 -2
- data/tracks/perl6/exercises/pangram/Example.pm6 +1 -1
- data/tracks/perl6/exercises/pangram/Pangram.pm6 +1 -1
- data/tracks/perl6/exercises/pangram/example.yaml +12 -6
- data/tracks/perl6/exercises/pangram/pangram.t +9 -3
- data/tracks/python/config.json +38 -0
- data/tracks/python/exercises/complex-numbers/complex_numbers_test.py +81 -66
- data/tracks/python/exercises/connect/README.md +44 -0
- data/tracks/python/exercises/connect/connect.py +7 -0
- data/tracks/python/exercises/connect/connect_test.py +118 -0
- data/tracks/python/exercises/connect/example.py +61 -0
- data/tracks/python/exercises/go-counting/README.md +44 -0
- data/tracks/python/exercises/go-counting/example.py +62 -0
- data/tracks/python/exercises/go-counting/go_counting.py +38 -0
- data/tracks/python/exercises/go-counting/go_counting_test.py +92 -0
- data/tracks/python/exercises/parallel-letter-frequency/README.md +24 -0
- data/tracks/python/exercises/parallel-letter-frequency/example.py +56 -0
- data/tracks/python/exercises/parallel-letter-frequency/parallel_letter_frequency.py +2 -0
- data/tracks/python/exercises/parallel-letter-frequency/parallel_letter_frequency_test.py +61 -0
- data/tracks/python/exercises/strain/README.md +3 -1
- data/tracks/python/exercises/strain/strain.py +2 -2
- data/tracks/rust/.travis.yml +1 -0
- data/tracks/rust/README.md +2 -0
- data/tracks/rust/_test/check-exercises.sh +41 -54
- data/tracks/rust/_test/ensure-readmes-are-updated.sh +40 -0
- data/tracks/rust/bin/test-exercise +84 -0
- data/tracks/rust/exercises/alphametics/.meta/test-in-release-mode +2 -0
- data/tracks/rust/exercises/alphametics/src/lib.rs +1 -1
- data/tracks/rust/exercises/dominoes/README.md +3 -3
- data/tracks/rust/exercises/isbn-verifier/README.md +3 -2
- data/tracks/rust/exercises/nucleotide-count/README.md +2 -2
- data/tracks/rust/exercises/perfect-numbers/src/lib.rs +10 -0
- data/tracks/rust/exercises/phone-number/README.md +1 -1
- data/tracks/rust/exercises/pythagorean-triplet/src/lib.rs +3 -0
- data/tracks/rust/exercises/rectangles/README.md +9 -9
- data/tracks/rust/exercises/two-bucket/README.md +7 -7
- data/tracks/typescript/config.json +16 -0
- data/tracks/typescript/exercises/diamond/README.md +84 -0
- data/tracks/typescript/exercises/diamond/diamond.example.ts +51 -0
- data/tracks/typescript/exercises/diamond/diamond.test.ts +35 -0
- data/tracks/typescript/exercises/diamond/diamond.ts +0 -0
- data/tracks/typescript/exercises/diamond/package.json +36 -0
- data/tracks/typescript/exercises/diamond/tsconfig.json +22 -0
- data/tracks/typescript/exercises/diamond/tslint.json +127 -0
- data/tracks/typescript/exercises/diamond/yarn.lock +2624 -0
- metadata +53 -2
@@ -9,7 +9,9 @@ For example, given the collection of numbers:
|
|
9
9
|
|
10
10
|
- 1, 2, 3, 4, 5
|
11
11
|
|
12
|
-
And the predicate:
|
12
|
+
And the predicate:
|
13
|
+
|
14
|
+
Note: _a predicate P(x) will be true or false, depending on whether x belongs to a set._ [Wikipedia - Predicate](https://en.wikipedia.org/wiki/Predicate_(mathematical_logic)))
|
13
15
|
|
14
16
|
- is the number even?
|
15
17
|
|
data/tracks/rust/.travis.yml
CHANGED
data/tracks/rust/README.md
CHANGED
@@ -92,6 +92,8 @@ Note that:
|
|
92
92
|
- An exercise may contain `.meta/hints.md`. This is optional and will appear after the normal exercise
|
93
93
|
instructions if present. Rust is different in many ways from other languages. This is a place where the differences required for Rust are explained. If it is a large change, you may want to call this out as a comment at the top of `src/lib.rs`, so the user recognises to read this section before starting.
|
94
94
|
|
95
|
+
- If the test suite is appreciably sped up by running in release mode, and there is reason to be confident that the example implementation does not contain any overflow errors, consider adding a file `.meta/test-in-release-mode`. This should contain brief comments explaining the situation.
|
96
|
+
|
95
97
|
- `README.md` may be [regenerated](https://github.com/exercism/docs/blob/master/maintaining-a-track/regenerating-exercise-readmes.md) from Exercism data. The generator will use the `description.md` from the exercise directory in the [problem-specifications repository](https://github.com/exercism/problem-specifications/tree/master/exercises), then any hints in `.meta/hints.md`, then the [Rust-specific instructions](https://github.com/exercism/rust/blob/master/config/exercise-readme-insert.md). The `## Source` section comes from the `metadata.yml` in the same directory. Convention is that the description of the source remains text and the link is both name and hyperlink of the markdown link.
|
96
98
|
|
97
99
|
- Be sure to add the exercise to an appropriate place in the `config.json` file. The position in the file determines the order exercises are sent. Generate a unique UUID for the exercise. Current difficuly levels in use are 1, 4, 7 and 10.
|
@@ -1,73 +1,60 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
+
# test for existence and executability of the test-exercise script
|
4
|
+
# this depends on that
|
5
|
+
if [ ! -f "./bin/test-exercise" ]; then
|
6
|
+
echo "bin/test-exercise does not exist"
|
7
|
+
exit 1
|
8
|
+
fi
|
9
|
+
if [ ! -x "./bin/test-exercise" ]; then
|
10
|
+
echo "bin/test-exercise does not have its executable bit set"
|
11
|
+
exit 1
|
12
|
+
fi
|
13
|
+
|
3
14
|
# In DENYWARNINGS mode, do not set -e so that we run all tests.
|
4
15
|
# This allows us to see all warnings.
|
5
16
|
if [ -z "$DENYWARNINGS" ]; then
|
6
17
|
set -e
|
7
18
|
fi
|
8
19
|
|
20
|
+
# can't benchmark with a stable compiler; to bench, use
|
21
|
+
# $ BENCHMARK=1 rustup run nightly _test/check-exercises.sh
|
9
22
|
if [ -n "$BENCHMARK" ]; then
|
10
23
|
files=exercises/*/benches
|
11
24
|
else
|
12
25
|
files=exercises/*/tests
|
13
26
|
fi
|
14
27
|
|
15
|
-
|
16
|
-
mkdir "${tmp}exercises"
|
17
|
-
|
18
|
-
exitcode=0
|
19
|
-
|
28
|
+
return_code=0
|
20
29
|
# An exercise worth testing is defined here as any top level directory with
|
21
30
|
# a 'tests' directory
|
22
31
|
for exercise in $files; do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
cargo bench
|
50
|
-
elif [ -n "$DENYWARNINGS" ]; then
|
51
|
-
sed -i -e '1i #![deny(warnings)]' src/lib.rs
|
52
|
-
|
53
|
-
# No-run mode so we see no test output.
|
54
|
-
# Quiet mode so we see no compile output
|
55
|
-
# (such as "Compiling"/"Downloading").
|
56
|
-
# Compiler errors will still be shown though.
|
57
|
-
# Both flags are necessary to keep things quiet.
|
58
|
-
cargo test --quiet --no-run
|
59
|
-
else
|
60
|
-
# Run the test and get the status
|
61
|
-
cargo test
|
62
|
-
fi
|
63
|
-
)
|
64
|
-
|
65
|
-
status=$?
|
66
|
-
|
67
|
-
if [ $status -ne 0 ]
|
68
|
-
then
|
69
|
-
exitcode=1
|
70
|
-
fi
|
32
|
+
# This assumes that exercises are only one directory deep
|
33
|
+
# and that the primary module is named the same as the directory
|
34
|
+
directory=$(dirname "${exercise}")
|
35
|
+
|
36
|
+
release=""
|
37
|
+
if [ -z "$BENCHMARK" -a -f "$directory/.meta/test-in-release-mode" ]; then
|
38
|
+
release="--release"
|
39
|
+
fi
|
40
|
+
|
41
|
+
if [ -n "$DENYWARNINGS" ]; then
|
42
|
+
# No-run mode so we see no test output.
|
43
|
+
# Quiet mode so we see no compile output
|
44
|
+
# (such as "Compiling"/"Downloading").
|
45
|
+
# Compiler errors will still be shown though.
|
46
|
+
# Both flags are necessary to keep things quiet.
|
47
|
+
./bin/test-exercise $directory --quiet --no-run
|
48
|
+
return_code=$(($return_code | $?))
|
49
|
+
else
|
50
|
+
# Run the test and get the status
|
51
|
+
# We use release mode here because, while it somewhat increases
|
52
|
+
# the compile time for all exercises, it substantially improves
|
53
|
+
# the runtime for certain exercises such as alphametics.
|
54
|
+
# Overall this should be an improvement.
|
55
|
+
./bin/test-exercise $directory $release
|
56
|
+
return_code=$(($return_code | $?))
|
57
|
+
fi
|
71
58
|
done
|
72
59
|
|
73
|
-
exit $
|
60
|
+
exit $return_code
|
@@ -0,0 +1,40 @@
|
|
1
|
+
if [ ! -x bin/configlet ]; then
|
2
|
+
echo "Improper configuration; configlet should exist in bin/ when this script is run"
|
3
|
+
echo "Ping a Rust track maintainer to fix this"
|
4
|
+
exit 1
|
5
|
+
fi
|
6
|
+
|
7
|
+
if [ ! -d "problem-specifications" ]; then
|
8
|
+
git clone https://github.com/exercism/problem-specifications.git problem-specifications
|
9
|
+
fi
|
10
|
+
|
11
|
+
newline=$'\n '
|
12
|
+
|
13
|
+
missing_readmes=""
|
14
|
+
wrong_readmes=""
|
15
|
+
for exercise in $(git diff --name-only master..$(git rev-parse --abbrev-ref HEAD) | grep exercises/ | cut -d'/' -f2 -s | sort -fu); do
|
16
|
+
echo "Checking readme for $exercise"
|
17
|
+
readme_path="exercises/${exercise}/README.md"
|
18
|
+
if [ ! -f $readme_path ]; then
|
19
|
+
missing_readmes="$missing_readmes$newline$exercise"
|
20
|
+
else
|
21
|
+
existing_readme_checksum=$(md5sum $readme_path | cut -d' ' -f1)
|
22
|
+
# generate the new README
|
23
|
+
bin/configlet generate . --only "$exercise" --spec-path "problem-specifications"
|
24
|
+
generated_readme_checksum=$(md5sum $readme_path | cut -d' ' -f1)
|
25
|
+
|
26
|
+
if [ $existing_readme_checksum != $generated_readme_checksum ]; then
|
27
|
+
wrong_readmes="$wrong_readmes$newline$exercise"
|
28
|
+
fi
|
29
|
+
fi
|
30
|
+
done
|
31
|
+
|
32
|
+
if [ -n "$missing_readmes" ]; then
|
33
|
+
echo "Exercises missing README.md:$missing_readmes"
|
34
|
+
fi
|
35
|
+
if [ -n "$wrong_readmes" ]; then
|
36
|
+
echo "Exercises with out-of-date README.md:$wrong_readmes"
|
37
|
+
fi
|
38
|
+
if [ -n "$missing_readmes" -o -n "$wrong_readmes" ]; then
|
39
|
+
exit 1
|
40
|
+
fi
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# Test an exercise
|
3
|
+
|
4
|
+
# which exercise are we testing right now?
|
5
|
+
# if we were passed an argument, that should be the
|
6
|
+
# exercise directory. Otherwise, assume we're in
|
7
|
+
# it currently.
|
8
|
+
if [ $# -ge 1 ]; then
|
9
|
+
exercise=$1
|
10
|
+
# if this script is called with arguments, it will pass through
|
11
|
+
# any beyond the first to cargo. Note that we can only get a
|
12
|
+
# free default argument if no arguments at all were passed,
|
13
|
+
# so if you are in the exercise directory and want to pass any
|
14
|
+
# arguments to cargo, you need to include the local path first.
|
15
|
+
# I.e. to test in release mode:
|
16
|
+
# $ test-exercise . --release
|
17
|
+
shift 1
|
18
|
+
else
|
19
|
+
exercise='.'
|
20
|
+
fi
|
21
|
+
|
22
|
+
# what cargo command will we use?
|
23
|
+
if [ -n "$BENCHMARK" ]; then
|
24
|
+
command="bench"
|
25
|
+
else
|
26
|
+
command="test"
|
27
|
+
fi
|
28
|
+
|
29
|
+
declare -a preserve_files=("src/lib.rs" "Cargo.toml" "Cargo.lock")
|
30
|
+
declare -a preserve_dirs=("tests")
|
31
|
+
|
32
|
+
# reset instructions
|
33
|
+
reset () {
|
34
|
+
for file in ${preserve_files[@]}; do
|
35
|
+
if [ -f "$exercise/$file.orig" ]; then
|
36
|
+
mv -f "$exercise/$file.orig" "$exercise/$file"
|
37
|
+
fi
|
38
|
+
done
|
39
|
+
for dir in ${preserve_dirs[@]}; do
|
40
|
+
if [ -d "$exercise/$dir.orig" ]; then
|
41
|
+
rm -rf "$exercise/$dir"
|
42
|
+
mv "$exercise/$dir.orig" "$exercise/$dir"
|
43
|
+
fi
|
44
|
+
done
|
45
|
+
}
|
46
|
+
|
47
|
+
# cause the reset to execute when the script exits normally or is killed
|
48
|
+
trap reset EXIT INT TERM
|
49
|
+
|
50
|
+
# preserve the files and directories we care about
|
51
|
+
for file in ${preserve_files[@]}; do
|
52
|
+
if [ -f "$exercise/$file" ]; then
|
53
|
+
cp "$exercise/$file" "$exercise/$file.orig"
|
54
|
+
fi
|
55
|
+
done
|
56
|
+
for dir in ${preserve_dirs[@]}; do
|
57
|
+
if [ -d "$exercise/$dir" ]; then
|
58
|
+
cp -r "$exercise/$dir" "$exercise/$dir.orig"
|
59
|
+
fi
|
60
|
+
done
|
61
|
+
|
62
|
+
# Move example files to where Cargo expects them
|
63
|
+
cp -f "$exercise/example.rs" "$exercise/src/lib.rs"
|
64
|
+
if [ -f "$exercise/Cargo-example.toml" ]; then
|
65
|
+
cp -f "$exercise/Cargo-example.toml" "$exercise/Cargo.toml"
|
66
|
+
fi
|
67
|
+
|
68
|
+
# If deny warnings, insert a deny warnings compiler directive in the header
|
69
|
+
if [ -n "$DENYWARNINGS" ]; then
|
70
|
+
sed -i -e '1i #![deny(warnings)]' "$exercise/src/lib.rs"
|
71
|
+
fi
|
72
|
+
|
73
|
+
# eliminate #[ignore] lines from tests
|
74
|
+
for test in "$exercise/tests/*.rs"; do
|
75
|
+
sed -i '/\[ignore\]/d' $test
|
76
|
+
done
|
77
|
+
|
78
|
+
# run tests from within exercise directory
|
79
|
+
# (use subshell so we auto-reset to current pwd after)
|
80
|
+
(
|
81
|
+
cd $exercise
|
82
|
+
# this is the last command; its exit code is what's passed on
|
83
|
+
cargo $command "$@"
|
84
|
+
)
|
@@ -7,10 +7,10 @@ correct domino chain (the dots on one half of a stone match the dots on the
|
|
7
7
|
neighbouring half of an adjacent stone) and that dots on the halfs of the stones
|
8
8
|
which don't have a neighbour (the first and last stone) match each other.
|
9
9
|
|
10
|
-
For example given the stones `
|
11
|
-
like `
|
10
|
+
For example given the stones `[2|1]`, `[2|3]` and `[1|3]` you should compute something
|
11
|
+
like `[1|2] [2|3] [3|1]` or `[3|2] [2|1] [1|3]` or `[1|3] [3|2] [2|1]` etc, where the first and last numbers are the same.
|
12
12
|
|
13
|
-
For stones
|
13
|
+
For stones `[1|2]`, `[4|1]` and `[2|3]` the resulting chain is not valid: `[4|1] [1|2] [2|3]`'s first and last numbers are not the same. 4 != 3
|
14
14
|
|
15
15
|
Some test cases may use duplicate stones in a chain solution, assume that multiple Domino sets are being used.
|
16
16
|
|
@@ -54,7 +54,7 @@ to pass again. The test file is located in the `tests` directory. You can
|
|
54
54
|
also remove the ignore flag from all the tests to get them to run all at once
|
55
55
|
if you wish.
|
56
56
|
|
57
|
-
Make sure to read the [
|
57
|
+
Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
|
58
58
|
haven't already, it will help you with organizing your files.
|
59
59
|
|
60
60
|
## Feedback, Issues, Pull Requests
|
@@ -64,7 +64,8 @@ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is th
|
|
64
64
|
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).
|
65
65
|
|
66
66
|
[help-page]: http://exercism.io/languages/rust
|
67
|
-
[
|
67
|
+
[modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
|
68
|
+
[cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
|
68
69
|
|
69
70
|
## Source
|
70
71
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Given a single stranded DNA string, compute how many times each nucleotide occurs in the string.
|
4
4
|
|
5
|
-
The genetic language of every living thing on the planet is DNA.
|
6
|
-
DNA is a large molecule that is built from an extremely long sequence of individual elements called nucleotides.
|
5
|
+
The genetic language of every living thing on the planet is DNA.
|
6
|
+
DNA is a large molecule that is built from an extremely long sequence of individual elements called nucleotides.
|
7
7
|
4 types exist in DNA and these differ only slightly and can be represented as the following symbols: 'A' for adenine, 'C' for cytosine, 'G' for guanine, and 'T' thymine.
|
8
8
|
|
9
9
|
Here is an analogy:
|
@@ -14,7 +14,7 @@ The format is usually represented as
|
|
14
14
|
|
15
15
|
where `N` is any digit from 2 through 9 and `X` is any digit from 0 through 9.
|
16
16
|
|
17
|
-
Your task is to clean up differently
|
17
|
+
Your task is to clean up differently formatted telephone numbers by removing punctuation and the country code (1) if present.
|
18
18
|
|
19
19
|
For example, the inputs
|
20
20
|
- `+1 (613)-995-0253`
|
@@ -37,27 +37,27 @@ The above diagram contains 6 rectangles:
|
|
37
37
|
```
|
38
38
|
|
39
39
|
```text
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
+--+
|
43
43
|
| |
|
44
44
|
+--+
|
45
45
|
```
|
46
46
|
|
47
47
|
```text
|
48
|
-
|
49
|
-
|
48
|
+
|
49
|
+
|
50
50
|
+--+
|
51
51
|
| |
|
52
52
|
+--+
|
53
53
|
```
|
54
54
|
|
55
55
|
```text
|
56
|
-
|
57
|
-
++
|
58
|
-
++
|
59
|
-
|
60
|
-
|
56
|
+
|
57
|
+
++
|
58
|
+
++
|
59
|
+
|
60
|
+
|
61
61
|
```
|
62
62
|
|
63
63
|
You may assume that the input is always a proper rectangle (i.e. the length of
|
@@ -7,15 +7,15 @@ Since this mathematical problem is fairly subject to interpretation / individual
|
|
7
7
|
To help, the tests provide you with which bucket to fill first. That means, when starting with the larger bucket full, you are NOT allowed at any point to have the smaller bucket full and the larger bucket empty (aka, the opposite starting point); that would defeat the purpose of comparing both approaches!
|
8
8
|
|
9
9
|
Your program will take as input:
|
10
|
-
- the size of bucket one
|
11
|
-
- the size of bucket two
|
12
|
-
- the desired number of liters to reach
|
13
|
-
- which bucket to fill first,
|
10
|
+
- the size of bucket one
|
11
|
+
- the size of bucket two
|
12
|
+
- the desired number of liters to reach
|
13
|
+
- which bucket to fill first, either bucket one or bucket two
|
14
14
|
|
15
15
|
Your program should determine:
|
16
|
-
- the total number of "moves" it should take to reach the desired number of liters, including the first fill
|
17
|
-
- which bucket should end up with the desired number of liters (let's say this is bucket A) -
|
18
|
-
- how many liters are left in the other bucket (bucket B)
|
16
|
+
- the total number of "moves" it should take to reach the desired number of liters, including the first fill
|
17
|
+
- which bucket should end up with the desired number of liters (let's say this is bucket A) - either bucket one or bucket two
|
18
|
+
- how many liters are left in the other bucket (bucket B)
|
19
19
|
|
20
20
|
Note: any time a change is made to either or both buckets counts as one (1) move.
|
21
21
|
|
@@ -509,6 +509,22 @@
|
|
509
509
|
],
|
510
510
|
"unlocked_by": "matrix",
|
511
511
|
"uuid": "61f0964f-0779-446d-bd6b-6bb988414302"
|
512
|
+
},
|
513
|
+
{
|
514
|
+
"uuid": "2331a447-054d-4a80-52d7-fe2d667baaafcd3fc58",
|
515
|
+
"slug": "diamond",
|
516
|
+
"core": false,
|
517
|
+
"unlocked_by": "pascals-triangle",
|
518
|
+
"difficulty": 5,
|
519
|
+
"topics": [
|
520
|
+
"Control-flow (conditionals)",
|
521
|
+
"Control-flow (loops)",
|
522
|
+
"Arrays",
|
523
|
+
"Parsing",
|
524
|
+
"Games",
|
525
|
+
"Exception handling",
|
526
|
+
"Text formatting"
|
527
|
+
]
|
512
528
|
}
|
513
529
|
],
|
514
530
|
"foregone": [],
|