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,61 @@
|
|
1
|
+
<?php
|
2
|
+
function encode($plainMessage, $rails)
|
3
|
+
{
|
4
|
+
$cipherMessage = [];
|
5
|
+
$position = ($rails * 2) - 2;
|
6
|
+
for ($index = 0; $index < strlen($plainMessage); $index++) {
|
7
|
+
for ($step = 0; $step < $rails; $step++) {
|
8
|
+
if (!isset($cipherMessage[$step])) {
|
9
|
+
$cipherMessage[$step] = '';
|
10
|
+
}
|
11
|
+
if ($index % $position == $step || $index % $position == $position-$step) {
|
12
|
+
$cipherMessage[$step] .= $plainMessage[$index];
|
13
|
+
} else {
|
14
|
+
$cipherMessage[$step] .= ".";
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
return implode('', str_replace('.', '', $cipherMessage));
|
19
|
+
}
|
20
|
+
|
21
|
+
function decode($cipherMessage, $rails)
|
22
|
+
{
|
23
|
+
$position = ($rails * 2) - 2;
|
24
|
+
$textLength = strlen($cipherMessage);
|
25
|
+
|
26
|
+
$minLength = floor($textLength / $position);
|
27
|
+
$balance = $textLength % $position;
|
28
|
+
$lengths = [];
|
29
|
+
$strings = [];
|
30
|
+
$totalLengths = 0;
|
31
|
+
//find no of characters in each row
|
32
|
+
for ($rowIndex = 0; $rowIndex < $rails; $rowIndex++) {
|
33
|
+
$lengths[$rowIndex] = $minLength;
|
34
|
+
if ($rowIndex != 0 && $rowIndex != ($rails - 1)) {
|
35
|
+
$lengths[$rowIndex] += $minLength;
|
36
|
+
}
|
37
|
+
if ($balance > $rowIndex) {
|
38
|
+
$lengths[$rowIndex]++;
|
39
|
+
}
|
40
|
+
if ($balance > ($rails + ($rails - $rowIndex) - 2)) {
|
41
|
+
$lengths[$rowIndex]++;
|
42
|
+
}
|
43
|
+
$strings[] = substr($cipherMessage, $totalLengths, $lengths[$rowIndex]);
|
44
|
+
$totalLengths += $lengths[$rowIndex];
|
45
|
+
}
|
46
|
+
|
47
|
+
//convert row of characters to plain message
|
48
|
+
$plainText = '';
|
49
|
+
while (strlen($plainText) < $textLength) {
|
50
|
+
for ($charIndex = 0; $charIndex < $position; $charIndex++) {
|
51
|
+
if (isset($strings[$charIndex])) {
|
52
|
+
$index = $charIndex;
|
53
|
+
} else {
|
54
|
+
$index = $position - $charIndex;
|
55
|
+
}
|
56
|
+
$plainText .= substr($strings[$index], 0, 1);
|
57
|
+
$strings[$index] = substr($strings[$index], 1);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
return $plainText;
|
61
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
<?php
|
2
|
+
require_once "rail-fence-cipher.php";
|
3
|
+
|
4
|
+
class RailFenceCipherTest extends PHPUnit\Framework\TestCase
|
5
|
+
{
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Test encode with two rails.
|
9
|
+
*/
|
10
|
+
public function testEncodeWithTwoRails()
|
11
|
+
{
|
12
|
+
|
13
|
+
$plainText = "XOXOXOXOXOXOXOXOXO";
|
14
|
+
$rails = 2;
|
15
|
+
$expected = "XXXXXXXXXOOOOOOOOO";
|
16
|
+
$this->assertEquals(encode($plainText, $rails), $expected);
|
17
|
+
}
|
18
|
+
/**
|
19
|
+
* Test encode with three rails.
|
20
|
+
*/
|
21
|
+
public function testEncodeWithThreeRails()
|
22
|
+
{
|
23
|
+
$this->markTestSkipped();
|
24
|
+
$plainText = "WEAREDISCOVEREDFLEEATONCE";
|
25
|
+
$rails = 3;
|
26
|
+
$expected = "WECRLTEERDSOEEFEAOCAIVDEN";
|
27
|
+
$this->assertEquals(encode($plainText, $rails), $expected);
|
28
|
+
}
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Test encode with ending in the middle.
|
32
|
+
*/
|
33
|
+
public function testEncodeWithEndingInTheMiddle()
|
34
|
+
{
|
35
|
+
$this->markTestSkipped();
|
36
|
+
$plainText = "EXERCISES";
|
37
|
+
$rails = 4;
|
38
|
+
$expected = "ESXIEECSR";
|
39
|
+
$this->assertEquals(encode($plainText, $rails), $expected);
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Test decode with three rails.
|
44
|
+
*/
|
45
|
+
public function testDecodeWithThreeRails()
|
46
|
+
{
|
47
|
+
$this->markTestSkipped();
|
48
|
+
$encryptedText = "TEITELHDVLSNHDTISEIIEA";
|
49
|
+
$rails = 3;
|
50
|
+
$expected = "THEDEVILISINTHEDETAILS";
|
51
|
+
$this->assertEquals(decode($encryptedText, $rails), $expected);
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* Test decode with five rails.
|
55
|
+
*/
|
56
|
+
public function testDecodeWithFiveRails()
|
57
|
+
{
|
58
|
+
$this->markTestSkipped();
|
59
|
+
$encryptedText = "EIEXMSMESAORIWSCE";
|
60
|
+
$rails = 5;
|
61
|
+
$expected = "EXERCISMISAWESOME";
|
62
|
+
$this->assertEquals(decode($encryptedText, $rails), $expected);
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Test decode with six rails.
|
67
|
+
*/
|
68
|
+
public function testDecodeWithSixRails()
|
69
|
+
{
|
70
|
+
$this->markTestSkipped();
|
71
|
+
$encryptedText = "133714114238148966225439541018335470986172518171757571896261";
|
72
|
+
$rails = 6;
|
73
|
+
$expected = "112358132134558914423337761098715972584418167651094617711286";
|
74
|
+
$this->assertEquals(decode($encryptedText, $rails), $expected);
|
75
|
+
}
|
76
|
+
}
|
data/tracks/python/config.json
CHANGED
@@ -1115,6 +1115,19 @@
|
|
1115
1115
|
"exception_handling"
|
1116
1116
|
]
|
1117
1117
|
},
|
1118
|
+
{
|
1119
|
+
"uuid": "55c818d6-04a8-2480-de83-9f85fd0d2eafa71935f",
|
1120
|
+
"slug": "pov",
|
1121
|
+
"core": false,
|
1122
|
+
"unlocked_by": null,
|
1123
|
+
"difficulty": 9,
|
1124
|
+
"topics": [
|
1125
|
+
"graphs",
|
1126
|
+
"recursion",
|
1127
|
+
"searching",
|
1128
|
+
"trees"
|
1129
|
+
]
|
1130
|
+
},
|
1118
1131
|
{
|
1119
1132
|
"uuid": "e7351e8e-d3ff-4621-b818-cd55cf05bffd",
|
1120
1133
|
"slug": "accumulate",
|
@@ -1,29 +1,42 @@
|
|
1
|
-
from itertools import
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
if
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
1
|
+
from itertools import permutations
|
2
|
+
from string import ascii_uppercase as acu, digits
|
3
|
+
acuset = set(acu)
|
4
|
+
dset = set(digits)
|
5
|
+
|
6
|
+
|
7
|
+
def solve(an):
|
8
|
+
fullexp = [tuple(map(str.strip, s.split("+")))
|
9
|
+
for s in an.upper().split("==")]
|
10
|
+
digexp = [[w[-1] for w in s] for s in fullexp]
|
11
|
+
|
12
|
+
alphas = set("".join([w for s in fullexp for w in s]))
|
13
|
+
if not alphas <= acuset:
|
14
|
+
raise ValueError
|
15
|
+
leadchars = set([w[0] for s in fullexp for w in s])
|
16
|
+
digchars = set([x for s in digexp for x in s])
|
17
|
+
leadigchars = leadchars & digchars
|
18
|
+
leadigcharslen = len(leadigchars)
|
19
|
+
leadother = leadchars - leadigchars
|
20
|
+
leadotherlen = len(leadother)
|
21
|
+
|
22
|
+
digtuple = tuple(leadigchars) + tuple(set(digchars) - leadigchars)
|
23
|
+
othertuple = tuple(leadother) + tuple(alphas - digchars - leadother)
|
24
|
+
combostg = "".join(digtuple + othertuple)
|
25
|
+
olen = len(othertuple)
|
26
|
+
for digtest in permutations(digits, len(digtuple)):
|
27
|
+
if any(map(lambda x: x == "0", digtest[:leadigcharslen])):
|
28
|
+
continue
|
29
|
+
td = dict(zip(digtuple, digtest))
|
30
|
+
digeval = [[int(td[w]) for w in s] for s in digexp]
|
31
|
+
if (sum(digeval[0]) % 10) == (sum(digeval[1]) % 10):
|
32
|
+
for otest in permutations(dset - set(digtest), olen):
|
33
|
+
if any(map(lambda x: x == "0", otest[:leadotherlen])):
|
34
|
+
continue
|
35
|
+
b = an
|
36
|
+
for c, v in zip(combostg, "".join(digtest + otest)):
|
37
|
+
b = b.replace(c, v)
|
38
|
+
fulleval = [[int(w.strip())
|
39
|
+
for w in s.split("+")] for s in b.split("==")]
|
40
|
+
if sum(fulleval[0]) == sum(fulleval[1]):
|
41
|
+
return dict(zip(combostg, map(int, digtest + otest)))
|
42
|
+
return {}
|
@@ -3,26 +3,33 @@ import unittest
|
|
3
3
|
from crypto_square import encode
|
4
4
|
|
5
5
|
|
6
|
+
# Tests adapted from `problem-specifications//canonical-data.json` @ v3.1.0
|
7
|
+
|
6
8
|
class CryptoSquareTest(unittest.TestCase):
|
7
9
|
def test_empty_string(self):
|
8
10
|
self.assertEqual(encode(''), '')
|
9
11
|
|
10
|
-
def
|
11
|
-
self.assertEqual(encode('
|
12
|
+
def test_lowercase(self):
|
13
|
+
self.assertEqual(encode('A'), 'a')
|
14
|
+
|
15
|
+
def test_remove_spaces(self):
|
16
|
+
self.assertEqual(encode(' b '), 'b')
|
17
|
+
|
18
|
+
def test_remove_punctuation(self):
|
19
|
+
self.assertEqual(encode('@1,%!'), '1')
|
12
20
|
|
13
|
-
def
|
14
|
-
self.assertEqual(encode('This is
|
21
|
+
def test_9chars_results_3chunks(self):
|
22
|
+
self.assertEqual(encode('This is fun!'), 'tsf hiu isn')
|
15
23
|
|
16
|
-
def
|
17
|
-
|
18
|
-
ciph = '1gga 2ook 3fde gos ors'
|
19
|
-
self.assertEqual(encode(msg), ciph)
|
24
|
+
def test_8chars_results_3chunks_ending_space(self):
|
25
|
+
self.assertEqual(encode('Chill out.'), 'clu hlt io ')
|
20
26
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
27
|
+
def test_54chars_results_7chunks_2ending_space(self):
|
28
|
+
self.assertEqual(
|
29
|
+
encode('If man was meant to stay on the ground, '
|
30
|
+
'god would have given us roots.'),
|
31
|
+
'imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau '
|
32
|
+
)
|
26
33
|
|
27
34
|
|
28
35
|
if __name__ == '__main__':
|
@@ -12,7 +12,7 @@ def encode(msg):
|
|
12
12
|
square_size = int(ceil(sqrt(len(msg))))
|
13
13
|
square = _chunks_of(msg, square_size)
|
14
14
|
return ' '.join([''.join(col)
|
15
|
-
for col in zip_longest(*square, fillvalue='')])
|
15
|
+
for col in zip_longest(*square, fillvalue=' ')])
|
16
16
|
|
17
17
|
|
18
18
|
def _cleanse(s):
|
@@ -2,14 +2,26 @@ import unittest
|
|
2
2
|
|
3
3
|
from kindergarten_garden import Garden
|
4
4
|
|
5
|
+
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0
|
6
|
+
|
5
7
|
|
6
8
|
class KindergartenGardenTests(unittest.TestCase):
|
7
|
-
def
|
9
|
+
def test_garden_with_single_student(self):
|
8
10
|
self.assertEqual(
|
9
11
|
Garden("RC\nGG").plants("Alice"),
|
10
12
|
"Radishes Clover Grass Grass".split())
|
11
13
|
|
12
|
-
def
|
14
|
+
def test_different_garden_with_single_student(self):
|
15
|
+
self.assertEqual(
|
16
|
+
Garden("VC\nRC").plants("Alice"),
|
17
|
+
"Violets Clover Radishes Clover".split())
|
18
|
+
|
19
|
+
def test_garden_with_two_students(self):
|
20
|
+
garden = Garden("VVCG\nVVRC")
|
21
|
+
self.assertEqual(
|
22
|
+
garden.plants("Bob"), "Clover Grass Radishes Clover".split())
|
23
|
+
|
24
|
+
def test_multiple_students_for_the_same_garden_with_three_students(self):
|
13
25
|
garden = Garden("VVCCGG\nVVCCGG")
|
14
26
|
self.assertEqual(garden.plants("Bob"), ["Clover"] * 4)
|
15
27
|
self.assertEqual(garden.plants("Charlie"), ["Grass"] * 4)
|
@@ -26,6 +38,7 @@ class KindergartenGardenTests(unittest.TestCase):
|
|
26
38
|
self.assertEqual(
|
27
39
|
garden.plants("Larry"), "Grass Violets Clover Violets".split())
|
28
40
|
|
41
|
+
# Additional tests for this track
|
29
42
|
def test_disordered_test(self):
|
30
43
|
garden = Garden(
|
31
44
|
"VCRRGVRG\nRVGCCGCV",
|
@@ -14,7 +14,8 @@ 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
|
18
|
+
country code (1) if present.
|
18
19
|
|
19
20
|
For example, the inputs
|
20
21
|
- `+1 (613)-995-0253`
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# POV
|
2
|
+
|
3
|
+
Reparent a graph on a selected node.
|
4
|
+
|
5
|
+
### Tree Reparenting
|
6
|
+
|
7
|
+
This exercise is all about re-orientating a graph to see things from a different
|
8
|
+
point of view. For example family trees are usually presented from the
|
9
|
+
ancestor's perspective:
|
10
|
+
|
11
|
+
```text
|
12
|
+
+------0------+
|
13
|
+
| | |
|
14
|
+
+-1-+ +-2-+ +-3-+
|
15
|
+
| | | | | |
|
16
|
+
4 5 6 7 8 9
|
17
|
+
```
|
18
|
+
|
19
|
+
But the same information can be presented from the perspective of any other node
|
20
|
+
in the graph, by pulling it up to the root and dragging its relationships along
|
21
|
+
with it. So the same graph from 6's perspective would look like:
|
22
|
+
|
23
|
+
```text
|
24
|
+
6
|
25
|
+
|
|
26
|
+
+-----2-----+
|
27
|
+
| |
|
28
|
+
7 +-----0-----+
|
29
|
+
| |
|
30
|
+
+-1-+ +-3-+
|
31
|
+
| | | |
|
32
|
+
4 5 8 9
|
33
|
+
```
|
34
|
+
|
35
|
+
This lets us more simply describe the paths between two nodes. So for example
|
36
|
+
the path from 6-9 (which in the first graph goes up to the root and then down to
|
37
|
+
a different leaf node) can be seen to follow the path 6-2-0-3-9
|
38
|
+
|
39
|
+
This exercise involves taking an input graph and re-orientating it from the point
|
40
|
+
of view of one of the nodes.
|
41
|
+
|
42
|
+
## Submitting Exercises
|
43
|
+
|
44
|
+
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
|
45
|
+
|
46
|
+
For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.
|
47
|
+
|
48
|
+
|
49
|
+
For more detailed information about running tests, code style and linting,
|
50
|
+
please see the [help page](http://exercism.io/languages/python).
|
51
|
+
|
52
|
+
## Submitting Incomplete Solutions
|
53
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,70 @@
|
|
1
|
+
from json import dumps
|
2
|
+
|
3
|
+
|
4
|
+
class Tree(object):
|
5
|
+
def __init__(self, label, children=[]):
|
6
|
+
self.label = label
|
7
|
+
self.children = children
|
8
|
+
|
9
|
+
def __dict__(self):
|
10
|
+
return {self.label: [c.__dict__() for c in sorted(self.children)]}
|
11
|
+
|
12
|
+
def __str__(self, indent=None):
|
13
|
+
return dumps(self.__dict__(), indent=indent)
|
14
|
+
|
15
|
+
def __lt__(self, other):
|
16
|
+
return self.label < other.label
|
17
|
+
|
18
|
+
def __eq__(self, other):
|
19
|
+
return self.__dict__() == other.__dict__()
|
20
|
+
|
21
|
+
def __iter__(self):
|
22
|
+
yield self.label
|
23
|
+
for child in self.children:
|
24
|
+
for gchild in child:
|
25
|
+
yield gchild
|
26
|
+
|
27
|
+
def dup(self):
|
28
|
+
return Tree(self.label, [c.dup() for c in self.children])
|
29
|
+
|
30
|
+
def add(self, other):
|
31
|
+
tree = self.dup()
|
32
|
+
tree.children.append(other)
|
33
|
+
return tree
|
34
|
+
|
35
|
+
def remove(self, node):
|
36
|
+
tree = self.dup()
|
37
|
+
for child in list(tree.children):
|
38
|
+
tree.children.remove(child)
|
39
|
+
if child.label == node:
|
40
|
+
break
|
41
|
+
tree.children.append(child.remove(node))
|
42
|
+
return tree
|
43
|
+
|
44
|
+
def fromPov(self, from_node):
|
45
|
+
stack = [self]
|
46
|
+
visited = set()
|
47
|
+
while stack:
|
48
|
+
tree = stack.pop(0)
|
49
|
+
if tree.label in visited:
|
50
|
+
continue
|
51
|
+
visited.add(tree.label)
|
52
|
+
if from_node == tree.label:
|
53
|
+
return tree
|
54
|
+
for child in tree.children:
|
55
|
+
stack.append(child.add(tree.remove(child.label)))
|
56
|
+
raise ValueError()
|
57
|
+
|
58
|
+
def pathTo(self, from_node, to_node):
|
59
|
+
reordered = self.fromPov(from_node)
|
60
|
+
stack = reordered.children
|
61
|
+
path = [from_node]
|
62
|
+
while path[-1] != to_node:
|
63
|
+
try:
|
64
|
+
tree = stack.pop()
|
65
|
+
except IndexError:
|
66
|
+
raise ValueError()
|
67
|
+
if to_node in tree:
|
68
|
+
path.append(tree.label)
|
69
|
+
stack = tree.children
|
70
|
+
return path
|