trackler 2.2.1.56 → 2.2.1.57
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/TOPICS.txt +2 -2
- data/problem-specifications/exercises/zipper/description.md +1 -1
- data/tracks/dart/test/exercises_test.dart +9 -9
- data/tracks/delphi/exercises/circular-buffer/uCircularBufferExample.pas +3 -3
- data/tracks/delphi/exercises/circular-buffer/uCircularBufferTests.pas +160 -86
- data/tracks/delphi/exercises/phone-number/README.md +1 -1
- data/tracks/erlang/config.json +10 -0
- data/tracks/erlang/exercises/isogram/README.md +65 -0
- data/tracks/erlang/exercises/isogram/include/exercism.hrl +11 -0
- data/tracks/erlang/exercises/isogram/rebar.config +30 -0
- data/tracks/erlang/exercises/isogram/src/example.erl +16 -0
- data/tracks/erlang/exercises/isogram/src/isogram.app.src +9 -0
- data/tracks/erlang/exercises/isogram/src/isogram.erl +9 -0
- data/tracks/erlang/exercises/isogram/test/isogram_tests.erl +32 -0
- data/tracks/fsharp/exercises/binary-search/BinarySearch.fs +1 -1
- data/tracks/fsharp/exercises/binary-search/BinarySearchTest.fs +58 -30
- data/tracks/fsharp/exercises/binary-search/Example.fs +1 -1
- data/tracks/fsharp/exercises/poker/Example.fs +23 -20
- data/tracks/fsharp/exercises/poker/PokerTest.fs +135 -76
- data/tracks/fsharp/generators/Generators.fs +21 -0
- data/tracks/go/README.md +0 -15
- data/tracks/go/bin/run-generators +11 -0
- data/tracks/go/config.json +389 -277
- data/tracks/go/config/maintainers.json +2 -2
- data/tracks/go/docs/TESTS.md +0 -15
- data/tracks/go/exercises/accumulate/accumulate_test.go +0 -8
- data/tracks/go/exercises/accumulate/example.go +0 -2
- data/tracks/go/exercises/acronym/acronym.go +14 -2
- data/tracks/go/exercises/acronym/acronym_test.go +0 -8
- data/tracks/go/exercises/acronym/cases_test.go +2 -2
- data/tracks/go/exercises/acronym/example.go +0 -2
- data/tracks/go/exercises/all-your-base/all_your_base_test.go +0 -8
- data/tracks/go/exercises/all-your-base/example.go +0 -2
- data/tracks/go/exercises/allergies/allergies_test.go +0 -8
- data/tracks/go/exercises/allergies/example.go +0 -2
- data/tracks/go/exercises/anagram/.meta/gen.go +55 -0
- data/tracks/go/exercises/anagram/anagram_test.go +0 -130
- data/tracks/go/exercises/anagram/cases_test.go +164 -0
- data/tracks/go/exercises/anagram/example.go +0 -2
- data/tracks/go/exercises/atbash-cipher/atbash_cipher_test.go +0 -8
- data/tracks/go/exercises/atbash-cipher/cases_test.go +2 -2
- data/tracks/go/exercises/atbash-cipher/example.go +0 -2
- data/tracks/go/exercises/bank-account/bank_account_test.go +0 -8
- data/tracks/go/exercises/bank-account/example.go +0 -2
- data/tracks/go/exercises/beer-song/beer_test.go +0 -8
- data/tracks/go/exercises/beer-song/example.go +0 -2
- data/tracks/go/exercises/binary-search-tree/binary_search_tree_test.go +0 -8
- data/tracks/go/exercises/binary-search-tree/example.go +0 -2
- data/tracks/go/exercises/binary-search/binary_search_test.go +0 -8
- data/tracks/go/exercises/binary-search/example.go +0 -2
- data/tracks/go/exercises/binary/binary_test.go +0 -11
- data/tracks/go/exercises/binary/example.go +0 -2
- data/tracks/go/exercises/bob/bob.go +14 -0
- data/tracks/go/exercises/bob/bob_test.go +2 -10
- data/tracks/go/exercises/bob/cases_test.go +2 -2
- data/tracks/go/exercises/bob/example.go +12 -13
- data/tracks/go/exercises/book-store/README.md +92 -0
- data/tracks/go/exercises/book-store/book_store_test.go +91 -0
- data/tracks/go/exercises/book-store/example.go +52 -0
- data/tracks/go/exercises/bowling/bowling_test.go +0 -8
- data/tracks/go/exercises/bowling/cases_test.go +2 -2
- data/tracks/go/exercises/bowling/example.go +0 -2
- data/tracks/go/exercises/bracket-push/bracket_push_test.go +0 -8
- data/tracks/go/exercises/bracket-push/cases_test.go +2 -2
- data/tracks/go/exercises/bracket-push/example.go +0 -3
- data/tracks/go/exercises/change/cases_test.go +10 -3
- data/tracks/go/exercises/change/change_test.go +1 -9
- data/tracks/go/exercises/change/example.go +0 -2
- data/tracks/go/exercises/circular-buffer/circular_buffer_test.go +0 -8
- data/tracks/go/exercises/circular-buffer/example.go +0 -2
- data/tracks/go/exercises/clock/cases_test.go +2 -2
- data/tracks/go/exercises/clock/clock_test.go +2 -9
- data/tracks/go/exercises/clock/example.go +0 -2
- data/tracks/go/exercises/collatz-conjecture/README.md +51 -0
- data/tracks/go/exercises/collatz-conjecture/collatz_conjecture_test.go +77 -0
- data/tracks/go/exercises/collatz-conjecture/example.go +24 -0
- data/tracks/go/exercises/connect/cases_test.go +2 -2
- data/tracks/go/exercises/connect/connect_test.go +0 -8
- data/tracks/go/exercises/connect/example.go +0 -2
- data/tracks/go/exercises/crypto-square/crypto_square_test.go +0 -8
- data/tracks/go/exercises/crypto-square/example.go +0 -2
- data/tracks/go/exercises/custom-set/cases_test.go +2 -2
- data/tracks/go/exercises/custom-set/custom_set_test.go +0 -8
- data/tracks/go/exercises/custom-set/example.go +0 -2
- data/tracks/go/exercises/custom-set/example_slice.go +0 -2
- data/tracks/go/exercises/diamond/diamond_test.go +0 -8
- data/tracks/go/exercises/diamond/example.go +0 -2
- data/tracks/go/exercises/difference-of-squares/difference_of_squares_test.go +0 -8
- data/tracks/go/exercises/difference-of-squares/example.go +0 -2
- data/tracks/go/exercises/diffie-hellman/diffie_hellman_test.go +0 -8
- data/tracks/go/exercises/diffie-hellman/example.go +0 -2
- data/tracks/go/exercises/error-handling/error_handling_test.go +0 -7
- data/tracks/go/exercises/error-handling/example.go +0 -2
- data/tracks/go/exercises/etl/etl_test.go +0 -8
- data/tracks/go/exercises/etl/example.go +0 -2
- data/tracks/go/exercises/flatten-array/.meta/gen.go +52 -0
- data/tracks/go/exercises/flatten-array/README.md +35 -0
- data/tracks/go/exercises/flatten-array/cases_test.go +42 -0
- data/tracks/go/exercises/flatten-array/example.go +25 -0
- data/tracks/go/exercises/flatten-array/flatten_test.go +23 -0
- data/tracks/go/exercises/food-chain/example.go +0 -2
- data/tracks/go/exercises/food-chain/food_chain_test.go +0 -8
- data/tracks/go/exercises/forth/cases_test.go +2 -2
- data/tracks/go/exercises/forth/example.go +0 -2
- data/tracks/go/exercises/forth/forth_test.go +0 -8
- data/tracks/go/exercises/gigasecond/cases_test.go +2 -2
- data/tracks/go/exercises/gigasecond/example.go +0 -2
- data/tracks/go/exercises/gigasecond/gigasecond.go +13 -3
- data/tracks/go/exercises/gigasecond/gigasecond_test.go +0 -8
- data/tracks/go/exercises/grade-school/example.go +0 -2
- data/tracks/go/exercises/grade-school/grade_school_test.go +0 -8
- data/tracks/go/exercises/grains/example.go +0 -2
- data/tracks/go/exercises/grains/grains_test.go +0 -8
- data/tracks/go/exercises/hamming/.meta/hints.md +4 -0
- data/tracks/go/exercises/hamming/README.md +6 -0
- data/tracks/go/exercises/hamming/example.go +0 -2
- data/tracks/go/exercises/hamming/hamming.go +0 -2
- data/tracks/go/exercises/hamming/hamming_test.go +0 -8
- data/tracks/go/exercises/hello-world/hello_world.go +9 -1
- data/tracks/go/exercises/hexadecimal/example.go +0 -2
- data/tracks/go/exercises/hexadecimal/hexadecimal_test.go +0 -8
- data/tracks/go/exercises/house/example.go +0 -2
- data/tracks/go/exercises/house/house_test.go +0 -8
- data/tracks/go/exercises/isbn-verifier/README.md +60 -0
- data/tracks/go/exercises/isbn-verifier/example.go +57 -0
- data/tracks/go/exercises/isbn-verifier/isbn_verifier_test.go +35 -0
- data/tracks/go/exercises/isogram/example.go +0 -2
- data/tracks/go/exercises/isogram/isogram_test.go +0 -8
- data/tracks/go/exercises/kindergarten-garden/example.go +0 -2
- data/tracks/go/exercises/kindergarten-garden/kindergarten_garden_test.go +0 -8
- data/tracks/go/exercises/largest-series-product/cases_test.go +2 -2
- data/tracks/go/exercises/largest-series-product/example.go +0 -2
- data/tracks/go/exercises/largest-series-product/largest_series_product_test.go +0 -8
- data/tracks/go/exercises/leap/.meta/hints.md +14 -0
- data/tracks/go/exercises/leap/README.md +16 -0
- data/tracks/go/exercises/leap/cases_test.go +4 -4
- data/tracks/go/exercises/leap/example.go +0 -2
- data/tracks/go/exercises/leap/leap.go +11 -2
- data/tracks/go/exercises/leap/leap_test.go +0 -15
- data/tracks/go/exercises/ledger/example.go +0 -2
- data/tracks/go/exercises/ledger/ledger.go +0 -2
- data/tracks/go/exercises/ledger/ledger_test.go +0 -8
- data/tracks/go/exercises/luhn/cases_test.go +2 -2
- data/tracks/go/exercises/luhn/example.go +0 -2
- data/tracks/go/exercises/luhn/luhn_test.go +0 -8
- data/tracks/go/exercises/matrix/example.go +0 -2
- data/tracks/go/exercises/matrix/matrix_test.go +0 -8
- data/tracks/go/exercises/meetup/cases_test.go +2 -2
- data/tracks/go/exercises/meetup/example.go +0 -2
- data/tracks/go/exercises/meetup/meetup_test.go +0 -8
- data/tracks/go/exercises/minesweeper/example.go +0 -2
- data/tracks/go/exercises/minesweeper/minesweeper_test.go +0 -8
- data/tracks/go/exercises/nth-prime/example.go +0 -2
- data/tracks/go/exercises/nth-prime/nth_prime_test.go +0 -8
- data/tracks/go/exercises/nucleotide-count/example.go +0 -2
- data/tracks/go/exercises/nucleotide-count/nucleotide_count.go +26 -0
- data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +0 -8
- data/tracks/go/exercises/ocr-numbers/example.go +0 -2
- data/tracks/go/exercises/ocr-numbers/ocr_numbers_test.go +0 -8
- data/tracks/go/exercises/octal/example.go +0 -2
- data/tracks/go/exercises/octal/octal_test.go +0 -8
- data/tracks/go/exercises/paasio/example.go +0 -2
- data/tracks/go/exercises/paasio/paasio_test.go +0 -8
- data/tracks/go/exercises/palindrome-products/example.go +0 -2
- data/tracks/go/exercises/palindrome-products/palindrome_products_test.go +0 -8
- data/tracks/go/exercises/pangram/example.go +0 -2
- data/tracks/go/exercises/pangram/pangram_test.go +2 -8
- data/tracks/go/exercises/parallel-letter-frequency/example.go +0 -2
- data/tracks/go/exercises/parallel-letter-frequency/parallel_letter_frequency_test.go +0 -8
- data/tracks/go/exercises/pascals-triangle/example.go +0 -2
- data/tracks/go/exercises/pascals-triangle/pascals_triangle_test.go +0 -8
- data/tracks/go/exercises/perfect-numbers/example.go +0 -2
- data/tracks/go/exercises/perfect-numbers/perfect_numbers_test.go +0 -8
- data/tracks/go/exercises/phone-number/cases_test.go +2 -2
- data/tracks/go/exercises/phone-number/example.go +0 -2
- data/tracks/go/exercises/phone-number/phone_number_test.go +0 -8
- data/tracks/go/exercises/pig-latin/example.go +0 -2
- data/tracks/go/exercises/pig-latin/pig_latin_test.go +0 -8
- data/tracks/go/exercises/poker/.meta/hints.md +7 -0
- data/tracks/go/exercises/poker/README.md +9 -0
- data/tracks/go/exercises/poker/cases_test.go +2 -2
- data/tracks/go/exercises/poker/example.go +0 -2
- data/tracks/go/exercises/poker/poker_test.go +0 -11
- data/tracks/go/exercises/pov/example.go +0 -2
- data/tracks/go/exercises/pov/pov_test.go +1 -9
- data/tracks/go/exercises/prime-factors/example.go +0 -2
- data/tracks/go/exercises/prime-factors/prime_factors_test.go +1 -9
- data/tracks/go/exercises/protein-translation/example.go +0 -2
- data/tracks/go/exercises/protein-translation/protein_translation_test.go +0 -8
- data/tracks/go/exercises/pythagorean-triplet/example.go +0 -2
- data/tracks/go/exercises/pythagorean-triplet/pythagorean_triplet_test.go +0 -8
- data/tracks/go/exercises/queen-attack/example.go +0 -2
- data/tracks/go/exercises/queen-attack/queen_attack_test.go +0 -8
- data/tracks/go/exercises/raindrops/.meta/hints.md +7 -0
- data/tracks/go/exercises/raindrops/cases_test.go +2 -2
- data/tracks/go/exercises/raindrops/example.go +0 -2
- data/tracks/go/exercises/raindrops/raindrops_test.go +0 -8
- data/tracks/go/exercises/react/example.go +0 -2
- data/tracks/go/exercises/react/react_test.go +0 -11
- data/tracks/go/exercises/rna-transcription/cases_test.go +2 -2
- data/tracks/go/exercises/rna-transcription/example.go +0 -2
- data/tracks/go/exercises/rna-transcription/rna_transcription.go +6 -0
- data/tracks/go/exercises/rna-transcription/rna_transcription_test.go +0 -8
- data/tracks/go/exercises/robot-name/example.go +0 -2
- data/tracks/go/exercises/robot-name/robot_name_test.go +0 -8
- data/tracks/go/exercises/robot-simulator/example.go +0 -1
- data/tracks/go/exercises/robot-simulator/robot_simulator_test.go +0 -8
- data/tracks/go/exercises/roman-numerals/cases_test.go +2 -2
- data/tracks/go/exercises/roman-numerals/example.go +0 -2
- data/tracks/go/exercises/roman-numerals/roman_numerals_test.go +0 -8
- data/tracks/go/exercises/rotational-cipher/README.md +56 -0
- data/tracks/go/exercises/rotational-cipher/example.go +20 -0
- data/tracks/go/exercises/rotational-cipher/rotational_cipher_test.go +86 -0
- data/tracks/go/exercises/run-length-encoding/README.md +31 -0
- data/tracks/go/exercises/run-length-encoding/example.go +53 -0
- data/tracks/go/exercises/run-length-encoding/run_length_encoding_test.go +59 -0
- data/tracks/go/exercises/saddle-points/example.go +0 -2
- data/tracks/go/exercises/saddle-points/saddle_points_test.go +0 -8
- data/tracks/go/exercises/say/.meta/gen.go +70 -0
- data/tracks/go/exercises/say/cases_test.go +88 -0
- data/tracks/go/exercises/say/example.go +12 -6
- data/tracks/go/exercises/say/say_test.go +17 -43
- data/tracks/go/exercises/scrabble-score/cases_test.go +2 -2
- data/tracks/go/exercises/scrabble-score/example.go +0 -3
- data/tracks/go/exercises/scrabble-score/scrabble_score_test.go +0 -8
- data/tracks/go/exercises/secret-handshake/cases_test.go +2 -2
- data/tracks/go/exercises/secret-handshake/example.go +0 -2
- data/tracks/go/exercises/secret-handshake/secret_handshake_test.go +0 -8
- data/tracks/go/exercises/series/example.go +0 -2
- data/tracks/go/exercises/series/series_test.go +0 -8
- data/tracks/go/exercises/sieve/example.go +0 -2
- data/tracks/go/exercises/sieve/sieve_test.go +0 -8
- data/tracks/go/exercises/simple-cipher/example.go +0 -2
- data/tracks/go/exercises/simple-cipher/simple_cipher_test.go +0 -8
- data/tracks/go/exercises/space-age/.meta/gen.go +56 -0
- data/tracks/go/exercises/space-age/README.md +42 -0
- data/tracks/go/exercises/space-age/cases_test.go +61 -0
- data/tracks/go/exercises/space-age/example.go +36 -0
- data/tracks/go/exercises/space-age/space_age_test.go +22 -0
- data/tracks/go/exercises/spiral-matrix/README.md +48 -0
- data/tracks/go/exercises/spiral-matrix/example.go +93 -0
- data/tracks/go/exercises/spiral-matrix/spiral_matrix_test.go +71 -0
- data/tracks/go/exercises/strain/example.go +0 -2
- data/tracks/go/exercises/strain/strain_test.go +0 -8
- data/tracks/go/exercises/sublist/.meta/gen.go +56 -0
- data/tracks/go/exercises/sublist/README.md +39 -0
- data/tracks/go/exercises/sublist/cases_test.go +115 -0
- data/tracks/go/exercises/sublist/example.go +49 -0
- data/tracks/go/exercises/sublist/sublist_test.go +22 -0
- data/tracks/go/exercises/sum-of-multiples/cases_test.go +4 -3
- data/tracks/go/exercises/sum-of-multiples/example.go +0 -2
- data/tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go +0 -8
- data/tracks/go/exercises/tournament/example.go +0 -2
- data/tracks/go/exercises/tournament/tournament_test.go +0 -11
- data/tracks/go/exercises/transpose/cases_test.go +2 -2
- data/tracks/go/exercises/transpose/example.go +0 -2
- data/tracks/go/exercises/transpose/transpose_test.go +0 -8
- data/tracks/go/exercises/tree-building/example.go +0 -2
- data/tracks/go/exercises/tree-building/tree_building.go +0 -2
- data/tracks/go/exercises/tree-building/tree_test.go +0 -11
- data/tracks/go/exercises/triangle/.meta/hints.md +10 -0
- data/tracks/go/exercises/triangle/example.go +0 -2
- data/tracks/go/exercises/triangle/triangle.go +21 -9
- data/tracks/go/exercises/triangle/triangle_test.go +0 -8
- data/tracks/go/exercises/trinary/example.go +0 -2
- data/tracks/go/exercises/trinary/trinary_test.go +0 -8
- data/tracks/go/exercises/twelve-days/example.go +0 -2
- data/tracks/go/exercises/twelve-days/twelve_days_test.go +0 -8
- data/tracks/go/exercises/two-fer/two_fer.go +2 -2
- data/tracks/go/exercises/variable-length-quantity/cases_test.go +2 -2
- data/tracks/go/exercises/variable-length-quantity/example.go +0 -2
- data/tracks/go/exercises/variable-length-quantity/variable_length_quantity_test.go +0 -8
- data/tracks/go/exercises/word-count/cases_test.go +2 -2
- data/tracks/go/exercises/word-count/example.go +0 -2
- data/tracks/go/exercises/word-count/word_count_test.go +4 -7
- data/tracks/go/exercises/word-search/.meta/gen.go +96 -0
- data/tracks/go/exercises/word-search/cases_test.go +154 -0
- data/tracks/go/exercises/word-search/example.go +0 -2
- data/tracks/go/exercises/word-search/word_search_test.go +16 -52
- data/tracks/go/exercises/wordy/example.go +0 -2
- data/tracks/go/exercises/wordy/wordy_test.go +0 -8
- data/tracks/go/gen/gen.go +4 -1
- data/tracks/java/exercises/phone-number/README.md +1 -1
- data/tracks/kotlin/exercises/phone-number/README.md +1 -1
- data/tracks/perl6/config.json +50 -0
- data/tracks/perl6/exercises/etl/ETL.pm6 +6 -0
- data/tracks/perl6/exercises/etl/Example.pm6 +7 -0
- data/tracks/perl6/exercises/etl/README.md +72 -0
- data/tracks/perl6/exercises/etl/etl.t +139 -0
- data/tracks/perl6/exercises/etl/example.yaml +35 -0
- data/tracks/perl6/exercises/hamming/Example.pm6 +6 -0
- data/tracks/perl6/exercises/hamming/Hamming.pm6 +4 -0
- data/tracks/perl6/exercises/hamming/README.md +61 -0
- data/tracks/perl6/exercises/hamming/example.yaml +22 -0
- data/tracks/perl6/exercises/hamming/hamming.t +175 -0
- data/tracks/perl6/exercises/meetup/Example.pm6 +37 -0
- data/tracks/perl6/exercises/meetup/Meetup.pm6 +4 -0
- data/tracks/perl6/exercises/meetup/README.md +48 -0
- data/tracks/perl6/exercises/meetup/example.yaml +48 -0
- data/tracks/perl6/exercises/meetup/meetup.t +907 -0
- data/tracks/perl6/exercises/pangram/Example.pm6 +5 -0
- data/tracks/perl6/exercises/pangram/Pangram.pm6 +4 -0
- data/tracks/perl6/exercises/pangram/README.md +34 -0
- data/tracks/perl6/exercises/pangram/example.yaml +17 -0
- data/tracks/perl6/exercises/pangram/pangram.t +125 -0
- data/tracks/perl6/exercises/phone-number/README.md +1 -1
- data/tracks/perl6/exercises/two-fer/Example.pm6 +14 -0
- data/tracks/perl6/exercises/two-fer/README.md +38 -0
- data/tracks/perl6/exercises/two-fer/TwoFer.pm6 +15 -0
- data/tracks/perl6/exercises/two-fer/example.yaml +43 -0
- data/tracks/perl6/exercises/two-fer/two-fer.t +82 -0
- data/tracks/php/config.json +13 -0
- data/tracks/php/exercises/rail-fence-cipher/README.md +80 -0
- data/tracks/php/exercises/rail-fence-cipher/example.php +61 -0
- data/tracks/php/exercises/rail-fence-cipher/rail-fence-cipher_test.php +76 -0
- data/tracks/purescript/.travis.yml +1 -1
- data/tracks/python/config.json +13 -0
- data/tracks/python/exercises/alphametics/example.py +42 -29
- data/tracks/python/exercises/crypto-square/crypto_square_test.py +20 -13
- data/tracks/python/exercises/crypto-square/example.py +1 -1
- data/tracks/python/exercises/kindergarten-garden/kindergarten_garden_test.py +15 -2
- data/tracks/python/exercises/phone-number/README.md +2 -1
- data/tracks/python/exercises/pov/README.md +53 -0
- data/tracks/python/exercises/pov/example.py +70 -0
- data/tracks/python/exercises/pov/pov.py +25 -0
- data/tracks/python/exercises/pov/pov_test.py +200 -0
- data/tracks/python/test/check-exercises.py +11 -1
- data/tracks/ruby/exercises/meetup/.meta/.version +1 -0
- data/tracks/ruby/exercises/meetup/.meta/generator/meetup_case.rb +11 -0
- data/tracks/ruby/exercises/meetup/.meta/solutions/meetup.rb +5 -0
- data/tracks/ruby/exercises/meetup/meetup_test.rb +48 -4
- metadata +90 -8
- data/tracks/go/exercises/accumulate/accumulate.go +0 -5
- data/tracks/go/exercises/clock/clock.go +0 -19
- data/tracks/go/exercises/pangram/pangram.go +0 -5
- data/tracks/go/exercises/raindrops/raindrops.go +0 -8
- data/tracks/go/exercises/twelve-days/HINTS.md +0 -2
- data/tracks/go/exercises/word-count/word_count.go +0 -9
@@ -0,0 +1,52 @@
|
|
1
|
+
package bookstore
|
2
|
+
|
3
|
+
import (
|
4
|
+
"math"
|
5
|
+
)
|
6
|
+
|
7
|
+
const bookPrice = 8
|
8
|
+
|
9
|
+
var discountTiers = [...]float64{0, 0.05, 0.1, 0.2, 0.25}
|
10
|
+
|
11
|
+
// Cost implements the book store exercise.
|
12
|
+
func Cost(books []int) float64 {
|
13
|
+
return cost(books, 0)
|
14
|
+
}
|
15
|
+
|
16
|
+
func cost(books []int, priceSoFar float64) float64 {
|
17
|
+
if len(books) == 0 {
|
18
|
+
return priceSoFar
|
19
|
+
}
|
20
|
+
|
21
|
+
distinctBooks, remainingBooks := getDistinctBooks(books)
|
22
|
+
minPrice := math.MaxFloat32
|
23
|
+
|
24
|
+
for i := 1; i <= len(distinctBooks); i++ {
|
25
|
+
newRemainingBooks := make([]int, len(remainingBooks))
|
26
|
+
copy(newRemainingBooks, remainingBooks)
|
27
|
+
newRemainingBooks = append(newRemainingBooks, distinctBooks[i:]...)
|
28
|
+
|
29
|
+
price := cost(newRemainingBooks, priceSoFar+groupCost(i))
|
30
|
+
minPrice = math.Min(minPrice, price)
|
31
|
+
}
|
32
|
+
|
33
|
+
return minPrice
|
34
|
+
}
|
35
|
+
|
36
|
+
func getDistinctBooks(books []int) (distinct []int, remaining []int) {
|
37
|
+
exists := make(map[int]bool)
|
38
|
+
for _, book := range books {
|
39
|
+
if exists[book] {
|
40
|
+
remaining = append(remaining, book)
|
41
|
+
} else {
|
42
|
+
distinct = append(distinct, book)
|
43
|
+
exists[book] = true
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
return
|
48
|
+
}
|
49
|
+
|
50
|
+
func groupCost(groupSize int) float64 {
|
51
|
+
return float64(bookPrice*groupSize) * (1.00 - discountTiers[groupSize-1])
|
52
|
+
}
|
@@ -2,20 +2,12 @@ package bowling
|
|
2
2
|
|
3
3
|
import "testing"
|
4
4
|
|
5
|
-
const targetTestVersion = 1
|
6
|
-
|
7
5
|
const previousRollErrorMessage = `FAIL: %s
|
8
6
|
Unexpected error occurred: %q
|
9
7
|
while applying the previous rolls for the
|
10
8
|
test case: %v
|
11
9
|
The error was returned from Roll(%d) for previousRolls[%d].`
|
12
10
|
|
13
|
-
func TestTestVersion(t *testing.T) {
|
14
|
-
if testVersion != targetTestVersion {
|
15
|
-
t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
11
|
func applyPreviousRolls(g *Game, rolls []int) (int, int, error) {
|
20
12
|
for index, pins := range rolls {
|
21
13
|
var err error
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package bowling
|
2
2
|
|
3
|
-
// Source: exercism/
|
3
|
+
// Source: exercism/problem-specifications
|
4
4
|
// Commit: 26e345e [Bowling] Fix case descriptions (#832)
|
5
|
-
//
|
5
|
+
// Problem Specifications Version: 1.0.1
|
6
6
|
|
7
7
|
var scoreTestCases = []struct {
|
8
8
|
description string
|
@@ -4,14 +4,6 @@ import (
|
|
4
4
|
"testing"
|
5
5
|
)
|
6
6
|
|
7
|
-
const targetTestVersion = 5
|
8
|
-
|
9
|
-
func TestTestVersion(t *testing.T) {
|
10
|
-
if testVersion != targetTestVersion {
|
11
|
-
t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
|
12
|
-
}
|
13
|
-
}
|
14
|
-
|
15
7
|
func TestBracket(t *testing.T) {
|
16
8
|
for _, tt := range testCases {
|
17
9
|
actual, err := Bracket(tt.input)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package brackets
|
2
2
|
|
3
|
-
// Source: exercism/
|
3
|
+
// Source: exercism/problem-specifications
|
4
4
|
// Commit: 855c591 bracket-push: add test case (#747)
|
5
|
-
//
|
5
|
+
// Problem Specifications Version: 1.1.0
|
6
6
|
|
7
7
|
type bracketTest struct {
|
8
8
|
input string
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package change
|
2
2
|
|
3
|
-
// Source: exercism/
|
4
|
-
// Commit:
|
5
|
-
//
|
3
|
+
// Source: exercism/problem-specifications
|
4
|
+
// Commit: 52cf1cf Add test for incorrect greedy algorithm
|
5
|
+
// Problem Specifications Version: 1.1.0
|
6
6
|
|
7
7
|
var testCases = []struct {
|
8
8
|
description string
|
@@ -53,6 +53,13 @@ var testCases = []struct {
|
|
53
53
|
true,
|
54
54
|
[]int{2, 2, 2, 5, 10},
|
55
55
|
},
|
56
|
+
{
|
57
|
+
"another possible change without unit coins available",
|
58
|
+
[]int{4, 5},
|
59
|
+
27,
|
60
|
+
true,
|
61
|
+
[]int{4, 4, 4, 5, 5, 5},
|
62
|
+
},
|
56
63
|
{
|
57
64
|
"no coins make 0 change",
|
58
65
|
[]int{1, 5, 10, 21, 25},
|
@@ -5,14 +5,6 @@ import (
|
|
5
5
|
"testing"
|
6
6
|
)
|
7
7
|
|
8
|
-
const targetTestVersion = 1
|
9
|
-
|
10
|
-
func TestTestVersion(t *testing.T) {
|
11
|
-
if testVersion != targetTestVersion {
|
12
|
-
t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
8
|
func TestChange(t *testing.T) {
|
17
9
|
for _, tc := range testCases {
|
18
10
|
actual, err := Change(tc.coins, tc.target)
|
@@ -22,7 +14,7 @@ func TestChange(t *testing.T) {
|
|
22
14
|
tc.description, tc.coins, tc.target, tc.expectedChange, err.Error())
|
23
15
|
} else {
|
24
16
|
if !reflect.DeepEqual(actual, tc.expectedChange) {
|
25
|
-
t.Fatalf("%s : Change(%v, %d): expected
|
17
|
+
t.Fatalf("%s : Change(%v, %d): expected %#v, actual %#v",
|
26
18
|
tc.description, tc.coins, tc.target, tc.expectedChange, actual)
|
27
19
|
} else {
|
28
20
|
t.Logf("PASS: %s", tc.description)
|
@@ -19,8 +19,6 @@ import (
|
|
19
19
|
"testing"
|
20
20
|
)
|
21
21
|
|
22
|
-
const targetTestVersion = 4
|
23
|
-
|
24
22
|
// Here is one way you can have a test case verify that the expected
|
25
23
|
// interfaces are implemented.
|
26
24
|
|
@@ -88,12 +86,6 @@ func (tb testBuffer) overwrite(c byte) {
|
|
88
86
|
|
89
87
|
// tests. separate functions so log will have descriptive test name.
|
90
88
|
|
91
|
-
func TestTestVersion(t *testing.T) {
|
92
|
-
if testVersion != targetTestVersion {
|
93
|
-
t.Fatalf("Found testVersion = %v, want %v.", testVersion, targetTestVersion)
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
89
|
func TestReadEmptyBuffer(t *testing.T) {
|
98
90
|
tb := nb(1, t)
|
99
91
|
tb.readFail()
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package clock
|
2
2
|
|
3
|
-
// Source: exercism/
|
3
|
+
// Source: exercism/problem-specifications
|
4
4
|
// Commit: 54c3b74 Cleanup canonical-data for clock
|
5
|
-
//
|
5
|
+
// Problem Specifications Version: 1.0.1
|
6
6
|
|
7
7
|
// Create a new clock with an initial time
|
8
8
|
var timeTests = []struct {
|
@@ -5,8 +5,9 @@ import (
|
|
5
5
|
"testing"
|
6
6
|
)
|
7
7
|
|
8
|
-
// Clock
|
8
|
+
// Clock API:
|
9
9
|
//
|
10
|
+
// type Clock // define the clock type
|
10
11
|
// New(hour, minute int) Clock // a "constructor"
|
11
12
|
// (Clock) String() string // a "stringer"
|
12
13
|
// (Clock) Add(minutes int) Clock
|
@@ -27,14 +28,6 @@ import (
|
|
27
28
|
// For some useful guidelines on when to use a value receiver or a pointer
|
28
29
|
// receiver see: https://github.com/golang/go/wiki/CodeReviewComments#receiver-type
|
29
30
|
|
30
|
-
const targetTestVersion = 4
|
31
|
-
|
32
|
-
func TestTestVersion(t *testing.T) {
|
33
|
-
if testVersion != targetTestVersion {
|
34
|
-
t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
31
|
func TestCreateClock(t *testing.T) {
|
39
32
|
for _, n := range timeTests {
|
40
33
|
if got := New(n.h, n.m); got.String() != n.want {
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Collatz Conjecture
|
2
|
+
|
3
|
+
The Collatz Conjecture or 3x+1 problem can be summarized as follows:
|
4
|
+
|
5
|
+
Take any positive integer n. If n is even, divide n by 2 to get n / 2. If n is
|
6
|
+
odd, multiply n by 3 and add 1 to get 3n + 1. Repeat the process indefinitely.
|
7
|
+
The conjecture states that no matter which number you start with, you will
|
8
|
+
always reach 1 eventually.
|
9
|
+
|
10
|
+
Given a number n, return the number of steps required to reach 1.
|
11
|
+
|
12
|
+
## Examples
|
13
|
+
|
14
|
+
Starting with n = 12, the steps would be as follows:
|
15
|
+
|
16
|
+
0. 12
|
17
|
+
1. 6
|
18
|
+
2. 3
|
19
|
+
3. 10
|
20
|
+
4. 5
|
21
|
+
5. 16
|
22
|
+
6. 8
|
23
|
+
7. 4
|
24
|
+
8. 2
|
25
|
+
9. 1
|
26
|
+
|
27
|
+
Resulting in 9 steps. So for input n = 12, the return value would be 9.
|
28
|
+
|
29
|
+
## Running the tests
|
30
|
+
|
31
|
+
To run the tests run the command `go test` from within the exercise directory.
|
32
|
+
|
33
|
+
If the test suite contains benchmarks, you can run these with the `-bench`
|
34
|
+
flag:
|
35
|
+
|
36
|
+
go test -bench .
|
37
|
+
|
38
|
+
Keep in mind that each reviewer will run benchmarks on a different machine, with
|
39
|
+
different specs, so the results from these benchmark tests may vary.
|
40
|
+
|
41
|
+
## Further information
|
42
|
+
|
43
|
+
For more detailed information about the Go track, including how to get help if
|
44
|
+
you're having trouble, please visit the exercism.io [Go language page](http://exercism.io/languages/go/about).
|
45
|
+
|
46
|
+
## Source
|
47
|
+
|
48
|
+
Wikipedia [https://en.wikipedia.org/wiki/Collatz_conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture)
|
49
|
+
|
50
|
+
## Submitting Incomplete Solutions
|
51
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,77 @@
|
|
1
|
+
package collatzconjecture
|
2
|
+
|
3
|
+
import (
|
4
|
+
"testing"
|
5
|
+
)
|
6
|
+
|
7
|
+
var testCases = []struct {
|
8
|
+
description string
|
9
|
+
input int
|
10
|
+
expectError bool
|
11
|
+
expected int
|
12
|
+
}{
|
13
|
+
{
|
14
|
+
description: "zero steps for one",
|
15
|
+
input: 1,
|
16
|
+
expectError: false,
|
17
|
+
expected: 0,
|
18
|
+
},
|
19
|
+
{
|
20
|
+
description: "divide if even",
|
21
|
+
input: 16,
|
22
|
+
expectError: false,
|
23
|
+
expected: 4,
|
24
|
+
},
|
25
|
+
{
|
26
|
+
description: "even and old steps",
|
27
|
+
input: 12,
|
28
|
+
expectError: false,
|
29
|
+
expected: 9,
|
30
|
+
},
|
31
|
+
{
|
32
|
+
description: "large number of even and odd steps",
|
33
|
+
input: 1000000,
|
34
|
+
expectError: false,
|
35
|
+
expected: 152,
|
36
|
+
},
|
37
|
+
{
|
38
|
+
description: "zero is an error",
|
39
|
+
input: 0,
|
40
|
+
expectError: true,
|
41
|
+
},
|
42
|
+
{
|
43
|
+
description: "negative value is an error",
|
44
|
+
input: -15,
|
45
|
+
expectError: true,
|
46
|
+
},
|
47
|
+
}
|
48
|
+
|
49
|
+
func TestCollatzConjecture(t *testing.T) {
|
50
|
+
for _, testCase := range testCases {
|
51
|
+
steps, err := CollatzConjecture(testCase.input)
|
52
|
+
if testCase.expectError {
|
53
|
+
if err == nil {
|
54
|
+
t.Fatalf("FAIL: %s\n\tCollatzConjecture(%v) expected an error, got %v",
|
55
|
+
testCase.description, testCase.input, steps)
|
56
|
+
}
|
57
|
+
} else {
|
58
|
+
if err != nil {
|
59
|
+
t.Fatalf("FAIL: %s\n\tCollatzConjecture(%v) returns unexpected error %s",
|
60
|
+
testCase.description, testCase.input, err.Error())
|
61
|
+
}
|
62
|
+
if steps != testCase.expected {
|
63
|
+
t.Fatalf("FAIL: %s\n\tCollatzConjecture(%v) expected %v, got %v",
|
64
|
+
testCase.description, testCase.input, testCase.expected, steps)
|
65
|
+
}
|
66
|
+
}
|
67
|
+
t.Logf("PASS: %s", testCase.description)
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
func BenchmarkCollatzConjecture(b *testing.B) {
|
72
|
+
for i := 0; i < b.N; i++ {
|
73
|
+
for _, testCase := range testCases {
|
74
|
+
CollatzConjecture(testCase.input)
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
package collatzconjecture
|
2
|
+
|
3
|
+
import (
|
4
|
+
"errors"
|
5
|
+
)
|
6
|
+
|
7
|
+
// CollatzConjecture is an example implementation of the collatz conjecture exercise.
|
8
|
+
func CollatzConjecture(n int) (int, error) {
|
9
|
+
if n <= 0 {
|
10
|
+
return -1, errors.New("Only positive numbers are allowed")
|
11
|
+
}
|
12
|
+
|
13
|
+
steps := 0
|
14
|
+
for n != 1 {
|
15
|
+
if n%2 == 0 {
|
16
|
+
n = n / 2
|
17
|
+
} else {
|
18
|
+
n = 3*n + 1
|
19
|
+
}
|
20
|
+
steps++
|
21
|
+
}
|
22
|
+
|
23
|
+
return steps, nil
|
24
|
+
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package connect
|
2
2
|
|
3
|
-
// Source: exercism/
|
3
|
+
// Source: exercism/problem-specifications
|
4
4
|
// Commit: 327db7f connect: Fix canonical-data.json formatting
|
5
|
-
//
|
5
|
+
// Problem Specifications Version: 1.0.0
|
6
6
|
|
7
7
|
var testCases = []struct {
|
8
8
|
description string
|