trackler 2.2.1.62 → 2.2.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/all-your-base/canonical-data.json +20 -29
- data/problem-specifications/exercises/forth/canonical-data.json +52 -5
- data/problem-specifications/exercises/isbn-verifier/canonical-data.json +15 -15
- data/problem-specifications/exercises/protein-translation/canonical-data.json +153 -0
- data/problem-specifications/exercises/reverse-string/canonical-data.json +39 -0
- data/problem-specifications/exercises/reverse-string/description.md +5 -0
- data/problem-specifications/exercises/reverse-string/metadata.yml +5 -0
- data/tracks/c/config.json +42 -41
- data/tracks/csharp/config.json +13 -0
- data/tracks/csharp/exercises/Exercises.sln +6 -0
- data/tracks/csharp/exercises/isbn-verifier/Example.cs +27 -0
- data/tracks/csharp/exercises/isbn-verifier/IsbnVerifier.cs +9 -0
- data/tracks/csharp/exercises/isbn-verifier/IsbnVerifier.csproj +19 -0
- data/tracks/csharp/exercises/isbn-verifier/IsbnVerifierTest.cs +84 -0
- data/tracks/csharp/exercises/isbn-verifier/README.md +40 -0
- data/tracks/csharp/generators/Exercises/IsbnVerifier.cs +15 -0
- data/tracks/delphi/config.json +28 -28
- data/tracks/erlang/config.json +10 -0
- data/tracks/erlang/exercises/accumulate/rebar.config +1 -1
- data/tracks/erlang/exercises/accumulate/test/accumulate_tests.erl +9 -7
- data/tracks/erlang/exercises/all-your-base/rebar.config +1 -1
- data/tracks/erlang/exercises/all-your-base/test/all_your_base_tests.erl +26 -24
- data/tracks/erlang/exercises/allergies/rebar.config +1 -1
- data/tracks/erlang/exercises/allergies/test/allergies_tests.erl +19 -17
- data/tracks/erlang/exercises/anagram/rebar.config +1 -3
- data/tracks/erlang/exercises/anagram/test/anagram_tests.erl +14 -12
- data/tracks/erlang/exercises/atbash-cipher/rebar.config +1 -1
- data/tracks/erlang/exercises/atbash-cipher/test/atbash_cipher_tests.erl +7 -5
- data/tracks/erlang/exercises/bank-account/rebar.config +1 -1
- data/tracks/erlang/exercises/bank-account/test/bank_account_tests.erl +52 -51
- data/tracks/erlang/exercises/beer-song/rebar.config +30 -0
- data/tracks/erlang/exercises/beer-song/test/beer_song_tests.erl +11 -10
- data/tracks/erlang/exercises/bob/rebar.config +1 -1
- data/tracks/erlang/exercises/bob/test/bob_tests.erl +33 -35
- data/tracks/erlang/exercises/circular-buffer/rebar.config +1 -1
- data/tracks/erlang/exercises/circular-buffer/test/circular_buffer_tests.erl +33 -32
- data/tracks/erlang/exercises/clock/rebar.config +1 -1
- data/tracks/erlang/exercises/clock/test/clock_tests.erl +57 -50
- data/tracks/erlang/exercises/collatz-conjecture/rebar.config +1 -1
- data/tracks/erlang/exercises/collatz-conjecture/test/collatz_conjecture_tests.erl +11 -9
- data/tracks/erlang/exercises/complex-numbers/rebar.config +1 -1
- data/tracks/erlang/exercises/complex-numbers/test/complex_numbers_tests.erl +102 -76
- data/tracks/erlang/exercises/custom-set/rebar.config +1 -1
- data/tracks/erlang/exercises/custom-set/test/custom_set_tests.erl +100 -109
- data/tracks/erlang/exercises/difference-of-squares/rebar.config +1 -1
- data/tracks/erlang/exercises/difference-of-squares/test/difference_of_squares_tests.erl +8 -7
- data/tracks/erlang/exercises/etl/rebar.config +1 -1
- data/tracks/erlang/exercises/etl/test/etl_tests.erl +6 -5
- data/tracks/erlang/exercises/gigasecond/rebar.config +1 -1
- data/tracks/erlang/exercises/gigasecond/test/gigasecond_tests.erl +9 -8
- data/tracks/erlang/exercises/grade-school/rebar.config +1 -1
- data/tracks/erlang/exercises/grade-school/test/grade_school_tests.erl +27 -23
- data/tracks/erlang/exercises/grains/rebar.config +1 -1
- data/tracks/erlang/exercises/grains/test/grains_tests.erl +7 -6
- data/tracks/erlang/exercises/hamming/rebar.config +1 -1
- data/tracks/erlang/exercises/hamming/test/hamming_tests.erl +20 -23
- data/tracks/erlang/exercises/hello-world/rebar.config +1 -1
- data/tracks/erlang/exercises/hello-world/test/hello_world_tests.erl +6 -4
- data/tracks/erlang/exercises/isogram/rebar.config +1 -1
- data/tracks/erlang/exercises/isogram/test/isogram_tests.erl +14 -12
- data/tracks/erlang/exercises/largest-series-product/rebar.config +1 -1
- data/tracks/erlang/exercises/largest-series-product/test/largest_series_product_tests.erl +22 -21
- data/tracks/erlang/exercises/leap/rebar.config +1 -1
- data/tracks/erlang/exercises/leap/test/leap_tests.erl +8 -7
- data/tracks/erlang/exercises/luhn/rebar.config +1 -1
- data/tracks/erlang/exercises/luhn/test/luhn_tests.erl +18 -16
- data/tracks/erlang/exercises/meetup/rebar.config +1 -1
- data/tracks/erlang/exercises/meetup/test/meetup_tests.erl +96 -95
- data/tracks/erlang/exercises/nucleotide-count/rebar.config +1 -1
- data/tracks/erlang/exercises/nucleotide-count/test/nucleotide_count_tests.erl +12 -11
- data/tracks/erlang/exercises/pangram/README.md +60 -0
- data/tracks/erlang/exercises/{accumulate → pangram}/include/exercism.hrl +0 -0
- data/tracks/erlang/exercises/{beer-song/rebar.conf → pangram/rebar.config} +0 -0
- data/tracks/erlang/exercises/pangram/src/example.erl +11 -0
- data/tracks/erlang/exercises/pangram/src/pangram.app.src +9 -0
- data/tracks/erlang/exercises/pangram/src/pangram.erl +8 -0
- data/tracks/erlang/exercises/pangram/test/pangram_tests.erl +38 -0
- data/tracks/erlang/exercises/parallel-letter-frequency/rebar.config +1 -1
- data/tracks/erlang/exercises/parallel-letter-frequency/test/parallel_letter_frequency_tests.erl +7 -6
- data/tracks/erlang/exercises/phone-number/rebar.config +1 -1
- data/tracks/erlang/exercises/phone-number/test/phone_number_tests.erl +13 -12
- data/tracks/erlang/exercises/rna-transcription/rebar.config +1 -1
- data/tracks/erlang/exercises/rna-transcription/test/rna_transcription_tests.erl +13 -11
- data/tracks/erlang/exercises/robot-simulator/rebar.config +1 -1
- data/tracks/erlang/exercises/robot-simulator/test/robot_simulator_tests.erl +70 -69
- data/tracks/erlang/exercises/roman-numerals/rebar.config +1 -1
- data/tracks/erlang/exercises/roman-numerals/test/roman_numerals_tests.erl +6 -5
- data/tracks/erlang/exercises/rotational-cipher/rebar.config +1 -8
- data/tracks/erlang/exercises/rotational-cipher/test/rotational_cipher_tests.erl +29 -27
- data/tracks/erlang/exercises/scrabble-score/rebar.config +1 -1
- data/tracks/erlang/exercises/scrabble-score/test/scrabble_score_tests.erl +6 -5
- data/tracks/erlang/exercises/series/rebar.config +1 -1
- data/tracks/erlang/exercises/series/test/series_tests.erl +6 -5
- data/tracks/erlang/exercises/sieve/rebar.config +1 -1
- data/tracks/erlang/exercises/sieve/test/sieve_tests.erl +10 -8
- data/tracks/erlang/exercises/space-age/rebar.config +1 -1
- data/tracks/erlang/exercises/space-age/test/space_age_tests.erl +20 -19
- data/tracks/erlang/exercises/spiral-matrix/rebar.config +1 -1
- data/tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl +12 -10
- data/tracks/erlang/exercises/strain/rebar.config +1 -1
- data/tracks/erlang/exercises/strain/test/strain_tests.erl +17 -16
- data/tracks/erlang/exercises/sum-of-multiples/rebar.config +1 -1
- data/tracks/erlang/exercises/sum-of-multiples/test/sum_of_multiples_tests.erl +16 -15
- data/tracks/erlang/exercises/triangle/rebar.config +1 -1
- data/tracks/erlang/exercises/triangle/test/triangle_tests.erl +20 -19
- data/tracks/erlang/exercises/two-fer/rebar.config +1 -1
- data/tracks/erlang/exercises/two-fer/test/two_fer_tests.erl +8 -7
- data/tracks/erlang/exercises/word-count/rebar.config +1 -1
- data/tracks/erlang/exercises/word-count/test/word_count_tests.erl +6 -5
- data/tracks/erlang/exercises/zipper/rebar.config +1 -1
- data/tracks/erlang/exercises/zipper/test/zipper_tests.erl +47 -46
- data/tracks/erlang/testgen/src/tgen.erl +8 -6
- data/tracks/erlang/testgen/src/tgen_bob.erl +1 -1
- data/tracks/erlang/testgen/src/tgen_collatz-conjecture.erl +2 -2
- data/tracks/erlang/testgen/src/tgen_complex-numbers.erl +11 -11
- data/tracks/erlang/testgen/src/tgen_custom-set.erl +14 -14
- data/tracks/erlang/testgen/src/tgen_hamming.erl +2 -2
- data/tracks/erlang/testgen/src/tgen_hello-world.erl +1 -1
- data/tracks/erlang/testgen/src/tgen_leap.erl +1 -1
- data/tracks/erlang/testgen/src/tgen_rna-transcription.erl +2 -2
- data/tracks/erlang/testgen/src/tgs.erl +6 -0
- data/tracks/fsharp/exercises/beer-song/BeerSong.fs +1 -5
- data/tracks/fsharp/exercises/beer-song/BeerSongTest.fs +342 -20
- data/tracks/fsharp/exercises/beer-song/Example.fs +16 -10
- data/tracks/fsharp/exercises/food-chain/Example.fs +1 -1
- data/tracks/fsharp/exercises/food-chain/FoodChain.fs +1 -3
- data/tracks/fsharp/exercises/food-chain/FoodChainTest.fs +11 -11
- data/tracks/fsharp/exercises/house/Example.fs +1 -1
- data/tracks/fsharp/exercises/house/House.fs +1 -3
- data/tracks/fsharp/exercises/house/HouseTest.fs +202 -202
- data/tracks/fsharp/exercises/proverb/Example.fs +9 -9
- data/tracks/fsharp/exercises/proverb/Proverb.fs +1 -3
- data/tracks/fsharp/exercises/proverb/ProverbTest.fs +50 -21
- data/tracks/fsharp/exercises/twelve-days/Example.fs +4 -4
- data/tracks/fsharp/exercises/twelve-days/TwelveDays.fs +2 -6
- data/tracks/fsharp/exercises/twelve-days/TwelveDaysTest.fs +81 -57
- data/tracks/fsharp/generators/Generators.fs +39 -15
- data/tracks/go/bin/run-generators +5 -1
- data/tracks/go/config.json +14 -2
- data/tracks/go/exercises/accumulate/example.go +2 -1
- data/tracks/go/exercises/zebra-puzzle/.meta/hints.md +24 -0
- data/tracks/go/exercises/zebra-puzzle/README.md +76 -0
- data/tracks/go/exercises/zebra-puzzle/example.go +256 -0
- data/tracks/go/exercises/zebra-puzzle/zebra_puzzle_test.go +18 -0
- data/tracks/haskell/exercises/forth/package.yaml +1 -1
- data/tracks/haskell/exercises/forth/test/Tests.hs +1 -4
- data/tracks/haskell/exercises/pascals-triangle/package.yaml +1 -1
- data/tracks/haskell/exercises/pascals-triangle/test/Tests.hs +22 -1
- data/tracks/java/POLICIES.md +3 -3
- data/tracks/java/config.json +21 -2
- data/tracks/java/exercises/atbash-cipher/.meta/src/reference/java/Atbash.java +12 -12
- data/tracks/java/exercises/protein-translation/.meta/src/reference/java/ProteinTranslator.java +47 -0
- data/tracks/java/exercises/protein-translation/.meta/version +1 -0
- data/tracks/java/exercises/protein-translation/README.md +58 -0
- data/tracks/java/exercises/protein-translation/build.gradle +18 -0
- data/tracks/java/exercises/protein-translation/src/main/java/ProteinTranslator.java +8 -0
- data/tracks/java/exercises/protein-translation/src/test/java/ProteinTranslatorTest.java +179 -0
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/javascript/.eslintignore +2 -2
- data/tracks/javascript/exercises/accumulate/example.js +1 -2
- data/tracks/javascript/exercises/grains/example.js +6 -3
- data/tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt +3 -3
- data/tracks/kotlin/exercises/beer-song/.meta/version +1 -1
- data/tracks/kotlin/exercises/beer-song/README.md +1 -1
- data/tracks/kotlin/exercises/beer-song/src/test/kotlin/BeerSongTest.kt +6 -6
- data/tracks/kotlin/exercises/forth/.meta/version +1 -1
- data/tracks/kotlin/exercises/forth/src/test/kotlin/ForthEvaluatorTest.kt +0 -7
- data/tracks/kotlin/exercises/meetup/README.md +16 -12
- data/tracks/kotlin/exercises/nth-prime/.meta/src/reference/kotlin/Prime.kt +7 -2
- data/tracks/kotlin/exercises/nth-prime/.meta/version +1 -1
- data/tracks/kotlin/exercises/nth-prime/src/test/kotlin/PrimeTest.kt +10 -1
- data/tracks/kotlin/exercises/nucleotide-count/README.md +2 -2
- data/tracks/kotlin/exercises/pascals-triangle/.meta/src/reference/kotlin/PascalsTriangle.kt +1 -1
- data/tracks/kotlin/exercises/pascals-triangle/.meta/version +1 -1
- data/tracks/kotlin/exercises/pascals-triangle/src/test/kotlin/PascalsTriangleTest.kt +58 -1
- data/tracks/kotlin/exercises/sum-of-multiples/README.md +3 -3
- data/tracks/ocaml/exercises/forth/test.ml +1 -3
- data/tracks/ocaml/exercises/rectangles/example.ml +11 -11
- data/tracks/php/exercises/bob/example.php +2 -2
- data/tracks/purescript/config.json +3 -3
- data/tracks/python/config.json +34 -22
- data/tracks/python/exercises/alphametics/example.py +90 -34
- data/tracks/python/exercises/ocr-numbers/example.py +18 -21
- data/tracks/python/exercises/ocr-numbers/ocr_numbers.py +1 -5
- data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +124 -106
- data/tracks/python/exercises/simple-linked-list/README.md +49 -0
- data/tracks/python/exercises/simple-linked-list/example.py +67 -0
- data/tracks/python/exercises/simple-linked-list/hints.md +10 -0
- data/tracks/python/exercises/simple-linked-list/simple_linked_list.py +33 -0
- data/tracks/python/exercises/simple-linked-list/simple_linked_list_test.py +112 -0
- data/tracks/rust/README.md +2 -0
- data/tracks/rust/bin/init_exercise.py +586 -0
- data/tracks/rust/config.json +20 -10
- data/tracks/rust/exercises/book-store/.gitignore +3 -0
- data/tracks/rust/exercises/book-store/Cargo-example.toml +7 -0
- data/tracks/rust/exercises/book-store/Cargo.toml +6 -0
- data/tracks/rust/exercises/book-store/README.md +107 -0
- data/tracks/rust/exercises/book-store/example.rs +187 -0
- data/tracks/rust/exercises/book-store/src/lib.rs +3 -0
- data/tracks/rust/exercises/book-store/tests/book-store.rs +130 -0
- data/tracks/sml/config.json +8 -8
- data/tracks/typescript/config.json +6 -6
- metadata +43 -46
- data/tracks/erlang/exercises/all-your-base/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/allergies/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/anagram/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/atbash-cipher/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/bank-account/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/beer-song/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/bob/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/circular-buffer/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/clock/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/collatz-conjecture/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/complex-numbers/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/custom-set/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/difference-of-squares/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/etl/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/gigasecond/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/grade-school/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/grains/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/hamming/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/hello-world/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/isogram/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/largest-series-product/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/leap/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/luhn/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/meetup/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/nucleotide-count/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/parallel-letter-frequency/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/phone-number/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/rna-transcription/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/robot-simulator/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/roman-numerals/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/rotational-cipher/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/scrabble-score/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/series/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/sieve/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/space-age/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/spiral-matrix/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/strain/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/sum-of-multiples/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/triangle/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/two-fer/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/word-count/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/zipper/include/exercism.hrl +0 -11
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
module Proverb
|
|
2
2
|
|
|
3
|
-
let
|
|
3
|
+
let line (want, lost) = sprintf "For want of a %s the %s was lost." want lost
|
|
4
4
|
|
|
5
|
-
let
|
|
6
|
-
match number with
|
|
7
|
-
| 7 -> "And all for the want of a horseshoe nail."
|
|
8
|
-
| _ -> sprintf "For want of a %s the %s was lost." (List.item (number - 1) subjects) (List.item number subjects)
|
|
5
|
+
let ending input = sprintf "And all for the want of a %s." (List.head input)
|
|
9
6
|
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
let recite input =
|
|
8
|
+
match List.isEmpty input with
|
|
9
|
+
| true ->
|
|
10
|
+
[]
|
|
11
|
+
| false ->
|
|
12
|
+
let lines = input |> List.pairwise |> List.map line
|
|
13
|
+
List.append lines [ending input]
|
|
@@ -1,32 +1,61 @@
|
|
|
1
|
+
// This file was auto-generated based on version 1.0.0 of the canonical data.
|
|
2
|
+
|
|
1
3
|
module ProverbTest
|
|
2
4
|
|
|
3
|
-
open Xunit
|
|
4
5
|
open FsUnit.Xunit
|
|
6
|
+
open Xunit
|
|
5
7
|
|
|
6
8
|
open Proverb
|
|
7
9
|
|
|
8
10
|
[<Fact>]
|
|
9
|
-
let ``
|
|
10
|
-
|
|
11
|
+
let ``Zero pieces`` () =
|
|
12
|
+
let input: string list = []
|
|
13
|
+
let expected: string list = []
|
|
14
|
+
recite input |> should equal expected
|
|
15
|
+
|
|
16
|
+
[<Fact(Skip = "Remove to run test")>]
|
|
17
|
+
let ``One piece`` () =
|
|
18
|
+
let input = ["nail"]
|
|
19
|
+
let expected = ["And all for the want of a nail."]
|
|
20
|
+
recite input |> should equal expected
|
|
11
21
|
|
|
12
22
|
[<Fact(Skip = "Remove to run test")>]
|
|
13
|
-
let ``
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
let ``Two pieces`` () =
|
|
24
|
+
let input = ["nail"; "shoe"]
|
|
25
|
+
let expected =
|
|
26
|
+
[ "For want of a nail the shoe was lost.";
|
|
27
|
+
"And all for the want of a nail." ]
|
|
28
|
+
recite input |> should equal expected
|
|
29
|
+
|
|
16
30
|
[<Fact(Skip = "Remove to run test")>]
|
|
17
|
-
let ``
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
let ``Three pieces`` () =
|
|
32
|
+
let input = ["nail"; "shoe"; "horse"]
|
|
33
|
+
let expected =
|
|
34
|
+
[ "For want of a nail the shoe was lost.";
|
|
35
|
+
"For want of a shoe the horse was lost.";
|
|
36
|
+
"And all for the want of a nail." ]
|
|
37
|
+
recite input |> should equal expected
|
|
38
|
+
|
|
20
39
|
[<Fact(Skip = "Remove to run test")>]
|
|
21
|
-
let ``
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
let ``Full proverb`` () =
|
|
41
|
+
let input = ["nail"; "shoe"; "horse"; "rider"; "message"; "battle"; "kingdom"]
|
|
42
|
+
let expected =
|
|
43
|
+
[ "For want of a nail the shoe was lost.";
|
|
44
|
+
"For want of a shoe the horse was lost.";
|
|
45
|
+
"For want of a horse the rider was lost.";
|
|
46
|
+
"For want of a rider the message was lost.";
|
|
47
|
+
"For want of a message the battle was lost.";
|
|
48
|
+
"For want of a battle the kingdom was lost.";
|
|
49
|
+
"And all for the want of a nail." ]
|
|
50
|
+
recite input |> should equal expected
|
|
51
|
+
|
|
52
|
+
[<Fact(Skip = "Remove to run test")>]
|
|
53
|
+
let ``Four pieces modernized`` () =
|
|
54
|
+
let input = ["pin"; "gun"; "soldier"; "battle"]
|
|
55
|
+
let expected =
|
|
56
|
+
[ "For want of a pin the gun was lost.";
|
|
57
|
+
"For want of a gun the soldier was lost.";
|
|
58
|
+
"For want of a soldier the battle was lost.";
|
|
59
|
+
"And all for the want of a pin." ]
|
|
60
|
+
recite input |> should equal expected
|
|
61
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module TwelveDays
|
|
2
2
|
|
|
3
3
|
let numberToStr =
|
|
4
4
|
function
|
|
@@ -63,6 +63,6 @@ let verseEnd =
|
|
|
63
63
|
|> List.map subjectToStr
|
|
64
64
|
|> List.reduce (fun x y -> x + ", " + y)
|
|
65
65
|
|
|
66
|
-
let verse number = sprintf "%s%s
|
|
67
|
-
|
|
68
|
-
let
|
|
66
|
+
let verse number = sprintf "%s%s." (verseBegin number) (verseEnd number)
|
|
67
|
+
|
|
68
|
+
let recite start stop = List.map verse [start..stop]
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
module
|
|
1
|
+
module TwelveDays
|
|
2
2
|
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
let verses start stop = failwith "You need to implement this function."
|
|
6
|
-
|
|
7
|
-
let song: string = failwith "You need to implement this function."
|
|
3
|
+
let recite start stop = failwith "You need to implement this function."
|
|
@@ -1,78 +1,102 @@
|
|
|
1
|
+
// This file was auto-generated based on version 1.0.0 of the canonical data.
|
|
2
|
+
|
|
1
3
|
module TwelveDaysTest
|
|
2
4
|
|
|
3
|
-
open Xunit
|
|
4
5
|
open FsUnit.Xunit
|
|
6
|
+
open Xunit
|
|
5
7
|
|
|
6
|
-
open
|
|
8
|
+
open TwelveDays
|
|
7
9
|
|
|
8
10
|
[<Fact>]
|
|
9
|
-
let ``
|
|
10
|
-
let expected = "On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
let ``First day a partridge in a pear tree`` () =
|
|
12
|
+
let expected = ["On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree."]
|
|
13
|
+
recite 1 1 |> should equal expected
|
|
14
|
+
|
|
13
15
|
[<Fact(Skip = "Remove to run test")>]
|
|
14
|
-
let ``
|
|
15
|
-
let expected = "On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let ``Second day two turtle doves`` () =
|
|
17
|
+
let expected = ["On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree."]
|
|
18
|
+
recite 2 2 |> should equal expected
|
|
19
|
+
|
|
18
20
|
[<Fact(Skip = "Remove to run test")>]
|
|
19
|
-
let ``
|
|
20
|
-
let expected = "On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
let ``Third day three french hens`` () =
|
|
22
|
+
let expected = ["On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."]
|
|
23
|
+
recite 3 3 |> should equal expected
|
|
24
|
+
|
|
23
25
|
[<Fact(Skip = "Remove to run test")>]
|
|
24
|
-
let ``
|
|
25
|
-
let expected = "On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
let ``Fourth day four calling birds`` () =
|
|
27
|
+
let expected = ["On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."]
|
|
28
|
+
recite 4 4 |> should equal expected
|
|
29
|
+
|
|
28
30
|
[<Fact(Skip = "Remove to run test")>]
|
|
29
|
-
let ``
|
|
30
|
-
let expected = "On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
let ``Fifth day five gold rings`` () =
|
|
32
|
+
let expected = ["On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."]
|
|
33
|
+
recite 5 5 |> should equal expected
|
|
34
|
+
|
|
33
35
|
[<Fact(Skip = "Remove to run test")>]
|
|
34
|
-
let ``
|
|
35
|
-
let expected = "On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
let ``Sixth day six geese-a-laying`` () =
|
|
37
|
+
let expected = ["On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."]
|
|
38
|
+
recite 6 6 |> should equal expected
|
|
39
|
+
|
|
38
40
|
[<Fact(Skip = "Remove to run test")>]
|
|
39
|
-
let ``
|
|
40
|
-
let expected = "On the seventh day of Christmas my true love gave to me, 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
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
let ``Seventh day seven swans-a-swimming`` () =
|
|
42
|
+
let expected = ["On the seventh day of Christmas my true love gave to me, 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."]
|
|
43
|
+
recite 7 7 |> should equal expected
|
|
44
|
+
|
|
45
|
+
[<Fact(Skip = "Remove to run test")>]
|
|
46
|
+
let ``Eighth day eight maids-a-milking`` () =
|
|
47
|
+
let expected = ["On the eighth day of Christmas my true love gave to me, 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."]
|
|
48
|
+
recite 8 8 |> should equal expected
|
|
49
|
+
|
|
43
50
|
[<Fact(Skip = "Remove to run test")>]
|
|
44
|
-
let ``
|
|
45
|
-
let expected = "On the
|
|
46
|
-
|
|
51
|
+
let ``Ninth day nine ladies dancing`` () =
|
|
52
|
+
let expected = ["On the ninth day of Christmas my true love gave to me, 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."]
|
|
53
|
+
recite 9 9 |> should equal expected
|
|
47
54
|
|
|
48
55
|
[<Fact(Skip = "Remove to run test")>]
|
|
49
|
-
let ``
|
|
50
|
-
let expected = "On the
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
let ``Tenth day ten lords-a-leaping`` () =
|
|
57
|
+
let expected = ["On the tenth day of Christmas my true love gave to me, 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."]
|
|
58
|
+
recite 10 10 |> should equal expected
|
|
59
|
+
|
|
53
60
|
[<Fact(Skip = "Remove to run test")>]
|
|
54
|
-
let ``
|
|
55
|
-
let expected = "On the
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
let ``Eleventh day eleven pipers piping`` () =
|
|
62
|
+
let expected = ["On the eleventh day of Christmas my true love gave to me, 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."]
|
|
63
|
+
recite 11 11 |> should equal expected
|
|
64
|
+
|
|
58
65
|
[<Fact(Skip = "Remove to run test")>]
|
|
59
|
-
let ``
|
|
60
|
-
let expected = "On the
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
let ``Twelfth day twelve drummers drumming`` () =
|
|
67
|
+
let expected = ["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."]
|
|
68
|
+
recite 12 12 |> should equal expected
|
|
69
|
+
|
|
63
70
|
[<Fact(Skip = "Remove to run test")>]
|
|
64
|
-
let ``
|
|
65
|
-
let expected =
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
let ``Recites first three verses of the song`` () =
|
|
72
|
+
let expected =
|
|
73
|
+
[ "On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.";
|
|
74
|
+
"On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.";
|
|
75
|
+
"On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree." ]
|
|
76
|
+
recite 1 3 |> should equal expected
|
|
77
|
+
|
|
68
78
|
[<Fact(Skip = "Remove to run test")>]
|
|
69
|
-
let ``
|
|
70
|
-
let expected =
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
let ``Recites three verses from the middle of the song`` () =
|
|
80
|
+
let expected =
|
|
81
|
+
[ "On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.";
|
|
82
|
+
"On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.";
|
|
83
|
+
"On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree." ]
|
|
84
|
+
recite 4 6 |> should equal expected
|
|
73
85
|
|
|
74
|
-
verses 1 3 |> should equal expected
|
|
75
|
-
|
|
76
86
|
[<Fact(Skip = "Remove to run test")>]
|
|
77
|
-
let ``
|
|
78
|
-
|
|
87
|
+
let ``Recites the whole song`` () =
|
|
88
|
+
let expected =
|
|
89
|
+
[ "On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.";
|
|
90
|
+
"On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.";
|
|
91
|
+
"On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.";
|
|
92
|
+
"On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.";
|
|
93
|
+
"On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.";
|
|
94
|
+
"On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.";
|
|
95
|
+
"On the seventh day of Christmas my true love gave to me, 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.";
|
|
96
|
+
"On the eighth day of Christmas my true love gave to me, 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.";
|
|
97
|
+
"On the ninth day of Christmas my true love gave to me, 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.";
|
|
98
|
+
"On the tenth day of Christmas my true love gave to me, 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.";
|
|
99
|
+
"On the eleventh day of Christmas my true love gave to me, 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.";
|
|
100
|
+
"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." ]
|
|
101
|
+
recite 1 12 |> should equal expected
|
|
102
|
+
|
|
@@ -86,8 +86,16 @@ type Anagram() =
|
|
|
86
86
|
type BeerSong() =
|
|
87
87
|
inherit Exercise()
|
|
88
88
|
|
|
89
|
+
override this.PropertiesUsedAsSutParameter canonicalDataCase = ["startBottles"; "takeDown"]
|
|
90
|
+
|
|
89
91
|
override this.PropertiesWithIdentifier canonicalDataCase = ["expected"]
|
|
90
92
|
|
|
93
|
+
override this.RenderExpected (canonicalDataCase, key, value) =
|
|
94
|
+
(value :?> JArray)
|
|
95
|
+
|> normalizeJArray
|
|
96
|
+
|> Seq.map formatValue
|
|
97
|
+
|> formatMultiLineList
|
|
98
|
+
|
|
91
99
|
type BinarySearch() =
|
|
92
100
|
inherit Exercise()
|
|
93
101
|
|
|
@@ -242,17 +250,7 @@ type Etl() =
|
|
|
242
250
|
type FoodChain() =
|
|
243
251
|
inherit Exercise()
|
|
244
252
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
override this.RenderSutProperty canonicalDataCase =
|
|
248
|
-
match hasMultipleVerses canonicalDataCase with
|
|
249
|
-
| true -> "verses"
|
|
250
|
-
| false -> "verse"
|
|
251
|
-
|
|
252
|
-
override this.PropertiesUsedAsSutParameter canonicalDataCase =
|
|
253
|
-
match hasMultipleVerses canonicalDataCase with
|
|
254
|
-
| true -> ["start verse"; "end verse"]
|
|
255
|
-
| false -> ["start verse"]
|
|
253
|
+
override this.PropertiesUsedAsSutParameter canonicalDataCase = ["startVerse"; "endVerse"]
|
|
256
254
|
|
|
257
255
|
override this.PropertiesWithIdentifier canonicalDataCase = ["expected"]
|
|
258
256
|
|
|
@@ -301,10 +299,7 @@ type HelloWorld() =
|
|
|
301
299
|
type House() =
|
|
302
300
|
inherit Exercise()
|
|
303
301
|
|
|
304
|
-
override this.PropertiesUsedAsSutParameter canonicalDataCase =
|
|
305
|
-
match canonicalDataCase.Property with
|
|
306
|
-
| "verses" -> ["start verse"; "end verse"]
|
|
307
|
-
| _ -> base.PropertiesUsedAsSutParameter canonicalDataCase
|
|
302
|
+
override this.PropertiesUsedAsSutParameter canonicalDataCase = ["startVerse"; "endVerse"]
|
|
308
303
|
|
|
309
304
|
override this.PropertiesWithIdentifier canonicalDataCase = ["expected"]
|
|
310
305
|
|
|
@@ -496,6 +491,22 @@ type PrimeFactors() =
|
|
|
496
491
|
|
|
497
492
|
override this.RenderInput (canonicalDataCase, key, value) =
|
|
498
493
|
base.RenderInput (canonicalDataCase, key, value) |> sprintf "%sL"
|
|
494
|
+
|
|
495
|
+
type Proverb() =
|
|
496
|
+
inherit Exercise()
|
|
497
|
+
|
|
498
|
+
override this.PropertiesWithIdentifier canonicalDataCase = ["input"; "expected"]
|
|
499
|
+
|
|
500
|
+
override this.RenderExpected (canonicalDataCase, key, value) =
|
|
501
|
+
(value :?> JArray)
|
|
502
|
+
|> normalizeJArray
|
|
503
|
+
|> Seq.map formatValue
|
|
504
|
+
|> formatMultiLineList
|
|
505
|
+
|
|
506
|
+
override this.IdentifierTypeAnnotation (canonicalDataCase, key, value) =
|
|
507
|
+
match value :?> JArray |> Seq.isEmpty with
|
|
508
|
+
| true -> Some "string list"
|
|
509
|
+
| false -> None
|
|
499
510
|
|
|
500
511
|
type QueenAttack() =
|
|
501
512
|
inherit Exercise()
|
|
@@ -677,6 +688,19 @@ type RomanNumerals() =
|
|
|
677
688
|
type ScrabbleScore() =
|
|
678
689
|
inherit Exercise()
|
|
679
690
|
|
|
691
|
+
type TwelveDays() =
|
|
692
|
+
inherit Exercise()
|
|
693
|
+
|
|
694
|
+
override this.PropertiesUsedAsSutParameter canonicalDataCase = ["startVerse"; "endVerse"]
|
|
695
|
+
|
|
696
|
+
override this.PropertiesWithIdentifier canonicalDataCase = ["expected"]
|
|
697
|
+
|
|
698
|
+
override this.RenderExpected (canonicalDataCase, key, value) =
|
|
699
|
+
(value :?> JArray)
|
|
700
|
+
|> normalizeJArray
|
|
701
|
+
|> Seq.map formatValue
|
|
702
|
+
|> formatMultiLineList
|
|
703
|
+
|
|
680
704
|
type TwoFer() =
|
|
681
705
|
inherit Exercise()
|
|
682
706
|
|
|
@@ -5,7 +5,11 @@ for dir in exercises/*/; do
|
|
|
5
5
|
if [ -f $file ]; then
|
|
6
6
|
cd "$dir/.meta"
|
|
7
7
|
echo "Generating $(basename $dir)"
|
|
8
|
-
go run gen.go
|
|
8
|
+
if ! go run gen.go; then
|
|
9
|
+
echo "[FAIL]: Generator $(basename $dir) gives error"
|
|
10
|
+
exit $?
|
|
11
|
+
fi
|
|
9
12
|
cd -
|
|
10
13
|
fi
|
|
11
14
|
done
|
|
15
|
+
echo "[SUCCESS]: All generators are run"
|
data/tracks/go/config.json
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"strings"
|
|
67
67
|
],
|
|
68
68
|
"unlocked_by": null,
|
|
69
|
-
"uuid": "
|
|
69
|
+
"uuid": "08a6c476-9ffe-4ae3-9996-cd299cc82fca"
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
"core": true,
|
|
@@ -1134,7 +1134,19 @@
|
|
|
1134
1134
|
"arrays"
|
|
1135
1135
|
],
|
|
1136
1136
|
"unlocked_by": "difference-of-squares",
|
|
1137
|
-
"uuid": "
|
|
1137
|
+
"uuid": "3530f2f0-ee5f-46a3-a8ee-e9927a637253"
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
"core": false,
|
|
1141
|
+
"difficulty": 6,
|
|
1142
|
+
"slug": "zebra-puzzle",
|
|
1143
|
+
"topics": [
|
|
1144
|
+
"arrays",
|
|
1145
|
+
"algorithms",
|
|
1146
|
+
"searching"
|
|
1147
|
+
],
|
|
1148
|
+
"unlocked_by": "bank-account",
|
|
1149
|
+
"uuid": "e31199ac-e657-4997-b931-63893a575c08"
|
|
1138
1150
|
},
|
|
1139
1151
|
{
|
|
1140
1152
|
"deprecated": true,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
package accumulate
|
|
2
2
|
|
|
3
|
+
// Accumulate transform given strings by using given function
|
|
3
4
|
func Accumulate(s []string, f func(st string) string) (result []string) {
|
|
4
5
|
for _, v := range s {
|
|
5
|
-
result = append(result,
|
|
6
|
+
result = append(result, f(v))
|
|
6
7
|
}
|
|
7
8
|
return result
|
|
8
9
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
## Implementation
|
|
2
|
+
|
|
3
|
+
Define a single function, SolvePuzzle, which returns a solution
|
|
4
|
+
containing two strings, whose values are the answers to the
|
|
5
|
+
zebra-puzzle questions "Who drinks water?" and "Who owns the Zebra?".
|
|
6
|
+
Each answer will be one of the resident's nationalities:
|
|
7
|
+
Englishman, Spaniard, Ukrainian, Norwegian, or Japanese.
|
|
8
|
+
|
|
9
|
+
For the SolvePuzzle function, use the following signature:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
type Solution struct {
|
|
13
|
+
DrinksWater string
|
|
14
|
+
OwnsZebra string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
func SolvePuzzle() Solution
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Obviously, you could simply write a one-liner function
|
|
21
|
+
if you peek at the test program to see the expected solution.
|
|
22
|
+
But the goal is to develop an algorithm which uses
|
|
23
|
+
the given facts and constraints for the puzzle
|
|
24
|
+
and determines the two correct answers.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Zebra Puzzle
|
|
2
|
+
|
|
3
|
+
Solve the zebra puzzle.
|
|
4
|
+
|
|
5
|
+
1. There are five houses.
|
|
6
|
+
2. The Englishman lives in the red house.
|
|
7
|
+
3. The Spaniard owns the dog.
|
|
8
|
+
4. Coffee is drunk in the green house.
|
|
9
|
+
5. The Ukrainian drinks tea.
|
|
10
|
+
6. The green house is immediately to the right of the ivory house.
|
|
11
|
+
7. The Old Gold smoker owns snails.
|
|
12
|
+
8. Kools are smoked in the yellow house.
|
|
13
|
+
9. Milk is drunk in the middle house.
|
|
14
|
+
10. The Norwegian lives in the first house.
|
|
15
|
+
11. The man who smokes Chesterfields lives in the house next to the man with the fox.
|
|
16
|
+
12. Kools are smoked in the house next to the house where the horse is kept.
|
|
17
|
+
13. The Lucky Strike smoker drinks orange juice.
|
|
18
|
+
14. The Japanese smokes Parliaments.
|
|
19
|
+
15. The Norwegian lives next to the blue house.
|
|
20
|
+
|
|
21
|
+
Each of the five houses is painted a different color, and their
|
|
22
|
+
inhabitants are of different national extractions, own different pets,
|
|
23
|
+
drink different beverages and smoke different brands of cigarettes.
|
|
24
|
+
|
|
25
|
+
Which of the residents drinks water?
|
|
26
|
+
Who owns the zebra?
|
|
27
|
+
|
|
28
|
+
## Implementation
|
|
29
|
+
|
|
30
|
+
Define a single function, SolvePuzzle, which returns a solution
|
|
31
|
+
containing two strings, whose values are the answers to the
|
|
32
|
+
zebra-puzzle questions "Who drinks water?" and "Who owns the Zebra?".
|
|
33
|
+
Each answer will be one of the resident's nationalities:
|
|
34
|
+
Englishman, Spaniard, Ukrainian, Norwegian, or Japanese.
|
|
35
|
+
|
|
36
|
+
For the SolvePuzzle function, use the following signature:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
type Solution struct {
|
|
40
|
+
DrinksWater string
|
|
41
|
+
OwnsZebra string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func SolvePuzzle() Solution
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Obviously, you could simply write a one-liner function
|
|
48
|
+
if you peek at the test program to see the expected solution.
|
|
49
|
+
But the goal is to develop an algorithm which uses
|
|
50
|
+
the given facts and constraints for the puzzle
|
|
51
|
+
and determines the two correct answers.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Running the tests
|
|
55
|
+
|
|
56
|
+
To run the tests run the command `go test` from within the exercise directory.
|
|
57
|
+
|
|
58
|
+
If the test suite contains benchmarks, you can run these with the `-bench`
|
|
59
|
+
flag:
|
|
60
|
+
|
|
61
|
+
go test -bench .
|
|
62
|
+
|
|
63
|
+
Keep in mind that each reviewer will run benchmarks on a different machine, with
|
|
64
|
+
different specs, so the results from these benchmark tests may vary.
|
|
65
|
+
|
|
66
|
+
## Further information
|
|
67
|
+
|
|
68
|
+
For more detailed information about the Go track, including how to get help if
|
|
69
|
+
you're having trouble, please visit the exercism.io [Go language page](http://exercism.io/languages/go/about).
|
|
70
|
+
|
|
71
|
+
## Source
|
|
72
|
+
|
|
73
|
+
Wikipedia [https://en.wikipedia.org/wiki/Zebra_Puzzle](https://en.wikipedia.org/wiki/Zebra_Puzzle)
|
|
74
|
+
|
|
75
|
+
## Submitting Incomplete Solutions
|
|
76
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|