trackler 2.2.1.128 → 2.2.1.129
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/bracket-push/canonical-data.json +9 -1
- data/tracks/bash/config.json +3 -3
- data/tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon +3 -1
- data/tracks/crystal/exercises/difference-of-squares/spec/difference_of_squares_spec.cr +9 -9
- data/tracks/csharp/config.json +12 -0
- data/tracks/csharp/exercises/Exercises.sln +7 -1
- data/tracks/csharp/exercises/yacht/Example.cs +71 -0
- data/tracks/csharp/exercises/yacht/README.md +34 -0
- data/tracks/csharp/exercises/yacht/Yacht.cs +26 -0
- data/tracks/csharp/exercises/yacht/Yacht.csproj +18 -0
- data/tracks/csharp/exercises/yacht/YachtTest.cs +162 -0
- data/tracks/csharp/generators/Exercises/Yacht.cs +20 -0
- data/tracks/dart/exercises/leap/lib/example.dart +4 -8
- data/tracks/dart/exercises/leap/lib/leap.dart +1 -1
- data/tracks/dart/exercises/leap/test/leap_test.dart +14 -16
- data/tracks/delphi/config.json +11 -0
- data/tracks/delphi/exercises/bracket-push/BracketPush.dpr +60 -0
- data/tracks/delphi/exercises/bracket-push/README.md +31 -0
- data/tracks/delphi/exercises/bracket-push/uBracketPushExample.pas +40 -0
- data/tracks/delphi/exercises/bracket-push/uBracketPushTest.pas +158 -0
- data/tracks/fsharp/config.json +18 -6
- data/tracks/fsharp/exercises/Exercises.sln +7 -1
- data/tracks/fsharp/exercises/accumulate/Accumulate.fsproj +2 -2
- data/tracks/fsharp/exercises/acronym/Acronym.fsproj +2 -2
- data/tracks/fsharp/exercises/all-your-base/AllYourBase.fsproj +2 -2
- data/tracks/fsharp/exercises/allergies/Allergies.fsproj +2 -2
- data/tracks/fsharp/exercises/alphametics/Alphametics.fsproj +2 -2
- data/tracks/fsharp/exercises/anagram/Anagram.fsproj +2 -2
- data/tracks/fsharp/exercises/armstrong-numbers/ArmstrongNumbers.fsproj +2 -2
- data/tracks/fsharp/exercises/atbash-cipher/AtbashCipher.fsproj +2 -2
- data/tracks/fsharp/exercises/bank-account/BankAccount.fsproj +2 -2
- data/tracks/fsharp/exercises/beer-song/BeerSong.fsproj +2 -2
- data/tracks/fsharp/exercises/binary/Binary.fsproj +2 -2
- data/tracks/fsharp/exercises/binary-search/BinarySearch.fsproj +2 -2
- data/tracks/fsharp/exercises/binary-search-tree/BinarySearchTree.fsproj +2 -2
- data/tracks/fsharp/exercises/bob/Bob.fsproj +2 -2
- data/tracks/fsharp/exercises/book-store/BookStore.fsproj +2 -2
- data/tracks/fsharp/exercises/bowling/Bowling.fsproj +2 -2
- data/tracks/fsharp/exercises/bowling/BowlingTest.fs +15 -1
- data/tracks/fsharp/exercises/bracket-push/BracketPush.fsproj +2 -2
- data/tracks/fsharp/exercises/change/Change.fsproj +2 -2
- data/tracks/fsharp/exercises/circular-buffer/CircularBuffer.fsproj +2 -2
- data/tracks/fsharp/exercises/circular-buffer/CircularBufferTest.fs +1 -1
- data/tracks/fsharp/exercises/clock/Clock.fsproj +2 -2
- data/tracks/fsharp/exercises/collatz-conjecture/CollatzConjecture.fsproj +2 -2
- data/tracks/fsharp/exercises/complex-numbers/ComplexNumbers.fsproj +2 -2
- data/tracks/fsharp/exercises/connect/Connect.fsproj +2 -2
- data/tracks/fsharp/exercises/crypto-square/CryptoSquare.fsproj +2 -2
- data/tracks/fsharp/exercises/custom-set/CustomSet.fsproj +2 -2
- data/tracks/fsharp/exercises/diamond/Diamond.fsproj +2 -2
- data/tracks/fsharp/exercises/difference-of-squares/DifferenceOfSquares.fsproj +2 -2
- data/tracks/fsharp/exercises/diffie-hellman/DiffieHellman.fsproj +2 -2
- data/tracks/fsharp/exercises/dominoes/Dominoes.fsproj +2 -2
- data/tracks/fsharp/exercises/dot-dsl/DotDsl.fsproj +2 -2
- data/tracks/fsharp/exercises/error-handling/ErrorHandling.fsproj +2 -2
- data/tracks/fsharp/exercises/etl/Etl.fsproj +2 -2
- data/tracks/fsharp/exercises/food-chain/FoodChain.fsproj +2 -2
- data/tracks/fsharp/exercises/forth/Forth.fsproj +2 -2
- data/tracks/fsharp/exercises/forth/ForthTest.fs +1 -1
- data/tracks/fsharp/exercises/gigasecond/Gigasecond.fsproj +2 -2
- data/tracks/fsharp/exercises/go-counting/GoCounting.fsproj +2 -2
- data/tracks/fsharp/exercises/grade-school/GradeSchool.fsproj +2 -2
- data/tracks/fsharp/exercises/grains/Grains.fsproj +2 -2
- data/tracks/fsharp/exercises/grains/GrainsTest.fs +1 -1
- data/tracks/fsharp/exercises/grep/Grep.fsproj +2 -2
- data/tracks/fsharp/exercises/grep/GrepTest.fs +1 -1
- data/tracks/fsharp/exercises/hamming/Hamming.fsproj +2 -2
- data/tracks/fsharp/exercises/hangman/Hangman.fsproj +2 -2
- data/tracks/fsharp/exercises/hello-world/HelloWorld.fsproj +2 -2
- data/tracks/fsharp/exercises/hexadecimal/Hexadecimal.fsproj +2 -2
- data/tracks/fsharp/exercises/house/Example.fs +2 -2
- data/tracks/fsharp/exercises/house/House.fsproj +2 -2
- data/tracks/fsharp/exercises/house/HouseTest.fs +28 -211
- data/tracks/fsharp/exercises/isbn-verifier/IsbnVerifier.fsproj +2 -2
- data/tracks/fsharp/exercises/isbn-verifier/IsbnVerifierTest.fs +2 -2
- data/tracks/fsharp/exercises/isogram/Isogram.fsproj +2 -2
- data/tracks/fsharp/exercises/isogram/IsogramTest.fs +1 -1
- data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGarden.fsproj +2 -2
- data/tracks/fsharp/exercises/largest-series-product/LargestSeriesProduct.fsproj +2 -2
- data/tracks/fsharp/exercises/leap/Leap.fsproj +2 -2
- data/tracks/fsharp/exercises/ledger/Ledger.fsproj +2 -2
- data/tracks/fsharp/exercises/lens-person/LensPerson.fsproj +2 -2
- data/tracks/fsharp/exercises/linked-list/LinkedList.fsproj +2 -2
- data/tracks/fsharp/exercises/list-ops/ListOps.fsproj +2 -2
- data/tracks/fsharp/exercises/list-ops/ListOpsTest.fs +1 -1
- data/tracks/fsharp/exercises/luhn/Luhn.fsproj +2 -2
- data/tracks/fsharp/exercises/markdown/Markdown.fsproj +2 -2
- data/tracks/fsharp/exercises/matrix/Matrix.fsproj +2 -2
- data/tracks/fsharp/exercises/meetup/Meetup.fsproj +2 -2
- data/tracks/fsharp/exercises/minesweeper/Minesweeper.fsproj +2 -2
- data/tracks/fsharp/exercises/nth-prime/NthPrime.fsproj +2 -2
- data/tracks/fsharp/exercises/nucleotide-count/NucleotideCount.fsproj +2 -2
- data/tracks/fsharp/exercises/ocr-numbers/OcrNumbers.fsproj +2 -2
- data/tracks/fsharp/exercises/octal/Octal.fsproj +2 -2
- data/tracks/fsharp/exercises/palindrome-products/PalindromeProducts.fsproj +2 -2
- data/tracks/fsharp/exercises/pangram/Pangram.fsproj +2 -2
- data/tracks/fsharp/exercises/parallel-letter-frequency/ParallelLetterFrequency.fsproj +2 -2
- data/tracks/fsharp/exercises/pascals-triangle/PascalsTriangle.fsproj +2 -2
- data/tracks/fsharp/exercises/perfect-numbers/PerfectNumbers.fsproj +2 -2
- data/tracks/fsharp/exercises/phone-number/PhoneNumber.fsproj +2 -2
- data/tracks/fsharp/exercises/pig-latin/PigLatin.fsproj +2 -2
- data/tracks/fsharp/exercises/poker/Poker.fsproj +2 -2
- data/tracks/fsharp/exercises/pov/Pov.fsproj +2 -2
- data/tracks/fsharp/exercises/pov/PovTest.fs +2 -2
- data/tracks/fsharp/exercises/prime-factors/PrimeFactors.fsproj +2 -2
- data/tracks/fsharp/exercises/protein-translation/ProteinTranslation.fsproj +2 -2
- data/tracks/fsharp/exercises/proverb/Proverb.fsproj +2 -2
- data/tracks/fsharp/exercises/pythagorean-triplet/PythagoreanTriplet.fsproj +2 -2
- data/tracks/fsharp/exercises/queen-attack/QueenAttack.fsproj +2 -2
- data/tracks/fsharp/exercises/rail-fence-cipher/RailFenceCipher.fsproj +2 -2
- data/tracks/fsharp/exercises/raindrops/Raindrops.fsproj +2 -2
- data/tracks/fsharp/exercises/rational-numbers/RationalNumbers.fsproj +2 -2
- data/tracks/fsharp/exercises/react/Example.fs +1 -1
- data/tracks/fsharp/exercises/react/React.fsproj +2 -2
- data/tracks/fsharp/exercises/react/ReactTest.fs +14 -1
- data/tracks/fsharp/exercises/rectangles/Rectangles.fsproj +2 -2
- data/tracks/fsharp/exercises/reverse-string/ReverseString.fsproj +2 -2
- data/tracks/fsharp/exercises/rna-transcription/RnaTranscription.fsproj +2 -2
- data/tracks/fsharp/exercises/robot-name/RobotName.fsproj +2 -2
- data/tracks/fsharp/exercises/robot-simulator/RobotSimulator.fsproj +2 -2
- data/tracks/fsharp/exercises/roman-numerals/RomanNumerals.fsproj +2 -2
- data/tracks/fsharp/exercises/rotational-cipher/RotationalCipher.fsproj +2 -2
- data/tracks/fsharp/exercises/run-length-encoding/RunLengthEncoding.fsproj +2 -2
- data/tracks/fsharp/exercises/saddle-points/SaddlePoints.fsproj +2 -2
- data/tracks/fsharp/exercises/say/Say.fsproj +2 -2
- data/tracks/fsharp/exercises/scale-generator/ScaleGenerator.fsproj +2 -2
- data/tracks/fsharp/exercises/scrabble-score/ScrabbleScore.fsproj +2 -2
- data/tracks/fsharp/exercises/secret-handshake/SecretHandshake.fsproj +2 -2
- data/tracks/fsharp/exercises/series/Series.fsproj +2 -2
- data/tracks/fsharp/exercises/sgf-parsing/SgfParsing.fsproj +2 -2
- data/tracks/fsharp/exercises/sieve/Sieve.fsproj +2 -2
- data/tracks/fsharp/exercises/simple-cipher/SimpleCipher.fsproj +2 -2
- data/tracks/fsharp/exercises/simple-linked-list/SimpleLinkedList.fsproj +2 -2
- data/tracks/fsharp/exercises/space-age/SpaceAge.fsproj +2 -2
- data/tracks/fsharp/exercises/spiral-matrix/SpiralMatrix.fsproj +2 -2
- data/tracks/fsharp/exercises/strain/Strain.fsproj +2 -2
- data/tracks/fsharp/exercises/sublist/Sublist.fsproj +2 -2
- data/tracks/fsharp/exercises/sum-of-multiples/SumOfMultiples.fsproj +2 -2
- data/tracks/fsharp/exercises/tournament/Tournament.fsproj +2 -2
- data/tracks/fsharp/exercises/transpose/Transpose.fsproj +2 -2
- data/tracks/fsharp/exercises/tree-building/TreeBuilding.fsproj +2 -2
- data/tracks/fsharp/exercises/triangle/Triangle.fsproj +2 -2
- data/tracks/fsharp/exercises/trinary/Trinary.fsproj +2 -2
- data/tracks/fsharp/exercises/twelve-days/TwelveDays.fsproj +2 -2
- data/tracks/fsharp/exercises/two-bucket/TwoBucket.fsproj +2 -2
- data/tracks/fsharp/exercises/two-fer/TwoFer.fsproj +2 -2
- data/tracks/fsharp/exercises/variable-length-quantity/VariableLengthQuantity.fsproj +2 -2
- data/tracks/fsharp/exercises/word-count/WordCount.fsproj +2 -2
- data/tracks/fsharp/exercises/word-search/WordSearch.fsproj +2 -2
- data/tracks/fsharp/exercises/word-search/WordSearchTest.fs +1 -1
- data/tracks/fsharp/exercises/wordy/Wordy.fsproj +2 -2
- data/tracks/fsharp/exercises/yacht/Example.fs +65 -0
- data/tracks/fsharp/exercises/yacht/Program.fs +1 -0
- data/tracks/fsharp/exercises/yacht/README.md +34 -0
- data/tracks/fsharp/exercises/yacht/Yacht.fs +17 -0
- data/tracks/fsharp/exercises/yacht/Yacht.fsproj +23 -0
- data/tracks/fsharp/exercises/yacht/YachtTest.fs +113 -0
- data/tracks/fsharp/exercises/zebra-puzzle/ZebraPuzzle.fsproj +2 -2
- data/tracks/fsharp/exercises/zipper/Zipper.fsproj +2 -2
- data/tracks/fsharp/generators/CanonicalData.fs +2 -20
- data/tracks/fsharp/generators/Common.fs +1 -1
- data/tracks/fsharp/generators/Generators.fs +24 -11
- data/tracks/fsharp/generators/Generators.fsproj +4 -4
- data/tracks/fsharp/generators/Options.fs +1 -1
- data/tracks/haskell/exercises/bracket-push/package.yaml +1 -1
- data/tracks/haskell/exercises/bracket-push/test/Tests.hs +4 -0
- data/tracks/java/config.json +13 -0
- data/tracks/java/exercises/dominoes/.meta/src/reference/java/ChainNotFoundException.java +5 -0
- data/tracks/java/exercises/dominoes/.meta/src/reference/java/Domino.java +30 -0
- data/tracks/java/exercises/dominoes/.meta/src/reference/java/Dominoes.java +67 -0
- data/tracks/java/exercises/dominoes/.meta/version +2 -0
- data/tracks/java/exercises/dominoes/README.md +29 -0
- data/tracks/java/exercises/dominoes/build.gradle +18 -0
- data/tracks/java/exercises/dominoes/src/main/java/ChainNotFoundException.java +5 -0
- data/tracks/java/exercises/dominoes/src/main/java/Domino.java +30 -0
- data/tracks/java/exercises/dominoes/src/test/java/DominoesTest.java +230 -0
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/javascript/.eslintignore +0 -1
- data/tracks/javascript/exercises/simple-cipher/example.js +4 -6
- data/tracks/javascript/exercises/simple-cipher/simple-cipher.spec.js +7 -3
- data/tracks/php/config.json +7 -7
- data/tracks/python/config.json +195 -188
- data/tracks/python/exercises/alphametics/alphametics_test.py +1 -0
- data/tracks/python/exercises/bank-account/README.md +20 -1
- data/tracks/python/exercises/go-counting/README.md +2 -0
- data/tracks/python/test/check-exercises.py +1 -1
- data/tracks/rust/_test/ensure-stubs-compile.sh +5 -0
- data/tracks/rust/config/exercise_readme.go.tmpl +1 -1
- data/tracks/rust/config.json +10 -0
- data/tracks/rust/exercises/accumulate/README.md +1 -1
- data/tracks/rust/exercises/acronym/README.md +1 -1
- data/tracks/rust/exercises/all-your-base/README.md +1 -1
- data/tracks/rust/exercises/all-your-base/example.rs +15 -5
- data/tracks/rust/exercises/all-your-base/src/lib.rs +8 -1
- data/tracks/rust/exercises/all-your-base/tests/all-your-base.rs +10 -5
- data/tracks/rust/exercises/allergies/README.md +1 -1
- data/tracks/rust/exercises/alphametics/README.md +1 -1
- data/tracks/rust/exercises/anagram/README.md +1 -1
- data/tracks/rust/exercises/armstrong-numbers/.gitignore +3 -0
- data/tracks/rust/exercises/armstrong-numbers/Cargo.toml +3 -0
- data/tracks/rust/exercises/armstrong-numbers/README.md +51 -0
- data/tracks/rust/exercises/armstrong-numbers/example.rs +7 -0
- data/tracks/rust/exercises/armstrong-numbers/src/lib.rs +3 -0
- data/tracks/rust/exercises/armstrong-numbers/tests/armstrong-numbers.rs +49 -0
- data/tracks/rust/exercises/atbash-cipher/README.md +1 -1
- data/tracks/rust/exercises/beer-song/README.md +1 -1
- data/tracks/rust/exercises/binary-search/README.md +1 -1
- data/tracks/rust/exercises/bob/README.md +1 -1
- data/tracks/rust/exercises/book-store/README.md +1 -1
- data/tracks/rust/exercises/bowling/README.md +1 -1
- data/tracks/rust/exercises/bowling/example.rs +13 -8
- data/tracks/rust/exercises/bowling/src/lib.rs +22 -0
- data/tracks/rust/exercises/bowling/tests/bowling.rs +31 -31
- data/tracks/rust/exercises/bracket-push/README.md +1 -1
- data/tracks/rust/exercises/circular-buffer/README.md +1 -1
- data/tracks/rust/exercises/clock/README.md +1 -1
- data/tracks/rust/exercises/collatz-conjecture/README.md +1 -1
- data/tracks/rust/exercises/crypto-square/README.md +1 -1
- data/tracks/rust/exercises/crypto-square/example.rs +11 -3
- data/tracks/rust/exercises/crypto-square/tests/crypto-square.rs +8 -16
- data/tracks/rust/exercises/custom-set/README.md +1 -1
- data/tracks/rust/exercises/custom-set/example.rs +17 -17
- data/tracks/rust/exercises/custom-set/tests/custom-set.rs +84 -84
- data/tracks/rust/exercises/decimal/README.md +1 -1
- data/tracks/rust/exercises/difference-of-squares/README.md +1 -1
- data/tracks/rust/exercises/diffie-hellman/README.md +1 -1
- data/tracks/rust/exercises/dominoes/README.md +1 -1
- data/tracks/rust/exercises/etl/README.md +1 -1
- data/tracks/rust/exercises/forth/README.md +1 -1
- data/tracks/rust/exercises/gigasecond/README.md +1 -1
- data/tracks/rust/exercises/grade-school/README.md +1 -1
- data/tracks/rust/exercises/grains/README.md +1 -1
- data/tracks/rust/exercises/hamming/README.md +1 -1
- data/tracks/rust/exercises/hello-world/README.md +1 -1
- data/tracks/rust/exercises/hexadecimal/README.md +1 -1
- data/tracks/rust/exercises/isbn-verifier/README.md +1 -1
- data/tracks/rust/exercises/isogram/README.md +1 -1
- data/tracks/rust/exercises/largest-series-product/README.md +1 -1
- data/tracks/rust/exercises/largest-series-product/example.rs +10 -4
- data/tracks/rust/exercises/largest-series-product/src/lib.rs +9 -0
- data/tracks/rust/exercises/largest-series-product/tests/largest-series-product.rs +3 -3
- data/tracks/rust/exercises/leap/README.md +1 -1
- data/tracks/rust/exercises/luhn/README.md +1 -1
- data/tracks/rust/exercises/luhn-from/README.md +1 -1
- data/tracks/rust/exercises/luhn-trait/README.md +1 -1
- data/tracks/rust/exercises/macros/.meta/ALLOWED_TO_NOT_COMPILE +2 -0
- data/tracks/rust/exercises/macros/README.md +1 -1
- data/tracks/rust/exercises/minesweeper/README.md +1 -1
- data/tracks/rust/exercises/nth-prime/README.md +1 -1
- data/tracks/rust/exercises/nucleotide-codons/README.md +1 -1
- data/tracks/rust/exercises/nucleotide-count/README.md +1 -1
- data/tracks/rust/exercises/ocr-numbers/README.md +1 -1
- data/tracks/rust/exercises/ocr-numbers/example.rs +14 -6
- data/tracks/rust/exercises/ocr-numbers/src/lib.rs +7 -1
- data/tracks/rust/exercises/ocr-numbers/tests/ocr-numbers.rs +2 -2
- data/tracks/rust/exercises/pangram/README.md +1 -1
- data/tracks/rust/exercises/parallel-letter-frequency/README.md +1 -1
- data/tracks/rust/exercises/pascals-triangle/README.md +1 -1
- data/tracks/rust/exercises/perfect-numbers/README.md +1 -1
- data/tracks/rust/exercises/phone-number/README.md +1 -1
- data/tracks/rust/exercises/pig-latin/README.md +1 -1
- data/tracks/rust/exercises/poker/README.md +1 -1
- data/tracks/rust/exercises/prime-factors/README.md +1 -1
- data/tracks/rust/exercises/protein-translation/README.md +1 -1
- data/tracks/rust/exercises/proverb/README.md +1 -1
- data/tracks/rust/exercises/pythagorean-triplet/README.md +1 -1
- data/tracks/rust/exercises/queen-attack/README.md +1 -1
- data/tracks/rust/exercises/raindrops/README.md +1 -1
- data/tracks/rust/exercises/react/README.md +1 -1
- data/tracks/rust/exercises/react/example.rs +27 -18
- data/tracks/rust/exercises/react/src/lib.rs +25 -10
- data/tracks/rust/exercises/react/tests/react.rs +113 -83
- data/tracks/rust/exercises/rectangles/README.md +1 -1
- data/tracks/rust/exercises/reverse-string/README.md +1 -1
- data/tracks/rust/exercises/rna-transcription/README.md +1 -1
- data/tracks/rust/exercises/robot-name/README.md +1 -1
- data/tracks/rust/exercises/robot-simulator/README.md +1 -1
- data/tracks/rust/exercises/roman-numerals/README.md +1 -1
- data/tracks/rust/exercises/rotational-cipher/README.md +1 -1
- data/tracks/rust/exercises/run-length-encoding/README.md +1 -1
- data/tracks/rust/exercises/saddle-points/README.md +1 -1
- data/tracks/rust/exercises/say/README.md +1 -1
- data/tracks/rust/exercises/scrabble-score/README.md +1 -1
- data/tracks/rust/exercises/series/README.md +1 -1
- data/tracks/rust/exercises/sieve/README.md +1 -1
- data/tracks/rust/exercises/simple-linked-list/README.md +1 -1
- data/tracks/rust/exercises/space-age/README.md +1 -1
- data/tracks/rust/exercises/sublist/README.md +1 -1
- data/tracks/rust/exercises/sum-of-multiples/README.md +1 -1
- data/tracks/rust/exercises/tournament/README.md +1 -1
- data/tracks/rust/exercises/triangle/README.md +1 -1
- data/tracks/rust/exercises/two-bucket/README.md +1 -1
- data/tracks/rust/exercises/variable-length-quantity/README.md +1 -1
- data/tracks/rust/exercises/word-count/README.md +1 -1
- data/tracks/rust/exercises/wordy/README.md +1 -1
- data/tracks/typescript/config.json +11 -0
- data/tracks/typescript/exercises/list-ops/README.md +35 -0
- data/tracks/typescript/exercises/list-ops/list-ops.example.ts +80 -0
- data/tracks/typescript/exercises/list-ops/list-ops.test.ts +117 -0
- data/tracks/typescript/exercises/list-ops/list-ops.ts +0 -0
- data/tracks/typescript/exercises/list-ops/package.json +36 -0
- data/tracks/typescript/exercises/list-ops/tsconfig.json +22 -0
- data/tracks/typescript/exercises/list-ops/tslint.json +127 -0
- data/tracks/typescript/exercises/list-ops/yarn.lock +2624 -0
- metadata +42 -3
- data/tracks/dart/exercises/leap/pubspec.lock +0 -293
@@ -34,12 +34,30 @@ every exercise will require you to raise an exception, but for those that do, th
|
|
34
34
|
a message.
|
35
35
|
|
36
36
|
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
37
|
-
`raise Exception`, you
|
37
|
+
`raise Exception`, you should write:
|
38
38
|
|
39
39
|
```python
|
40
40
|
raise Exception("Meaningful message indicating the source of the error")
|
41
41
|
```
|
42
42
|
|
43
|
+
## Running the tests
|
44
|
+
|
45
|
+
To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)):
|
46
|
+
|
47
|
+
- Python 2.7: `py.test bank_account_test.py`
|
48
|
+
- Python 3.3+: `pytest bank_account_test.py`
|
49
|
+
|
50
|
+
Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version):
|
51
|
+
`python -m pytest bank_account_test.py`
|
52
|
+
|
53
|
+
### Common `pytest` options
|
54
|
+
|
55
|
+
- `-v` : enable verbose output
|
56
|
+
- `-x` : stop running tests on first failure
|
57
|
+
- `--ff` : run failures from previous test before running other test cases
|
58
|
+
|
59
|
+
For other options, see `python -m pytest -h`
|
60
|
+
|
43
61
|
## Submitting Exercises
|
44
62
|
|
45
63
|
Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/bank-account` directory.
|
@@ -50,4 +68,5 @@ For more detailed information about running tests, code style and linting,
|
|
50
68
|
please see the [help page](http://exercism.io/languages/python).
|
51
69
|
|
52
70
|
## Submitting Incomplete Solutions
|
71
|
+
|
53
72
|
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -11,6 +11,8 @@ Write a function that determines the territory of each player. You may
|
|
11
11
|
assume that any stones that have been stranded in enemy territory have
|
12
12
|
already been taken off the board.
|
13
13
|
|
14
|
+
Write a function that determines the territory which includes a specified coordinate.
|
15
|
+
|
14
16
|
Multiple empty intersections may be encircled at once and for encircling
|
15
17
|
only horizontal and vertical neighbours count. In the following diagram
|
16
18
|
the stones which matter are marked "O" and the stones that don't are
|
@@ -11,6 +11,11 @@ for dir in $repo/exercises/*/; do
|
|
11
11
|
# it probably contains function signatures, and these should compile.
|
12
12
|
if grep -v '^//' $dir/src/lib.rs | grep '\S' > /dev/null; then
|
13
13
|
allowed_file=$dir/.meta/ALLOWED_TO_NOT_COMPILE
|
14
|
+
|
15
|
+
# In Travis CI, we may have already compiled using the example solution.
|
16
|
+
# Touch the src/lib.rs file so that we surely recompile using the stub.
|
17
|
+
touch $dir/src/lib.rs
|
18
|
+
|
14
19
|
if [ -f $allowed_file ]; then
|
15
20
|
echo "$exercise's stub is allowed to not compile"
|
16
21
|
elif ! (cd $dir && cargo test --quiet --no-run); then
|
@@ -28,7 +28,7 @@ haven't already, it will help you with organizing your files.
|
|
28
28
|
|
29
29
|
## Feedback, Issues, Pull Requests
|
30
30
|
|
31
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
31
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
32
32
|
|
33
33
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
34
34
|
|
data/tracks/rust/config.json
CHANGED
@@ -165,6 +165,16 @@
|
|
165
165
|
"strings"
|
166
166
|
]
|
167
167
|
},
|
168
|
+
{
|
169
|
+
"uuid": "e652139e-ff3f-4e03-9810-d21f8b0c9e60",
|
170
|
+
"slug": "armstrong-numbers",
|
171
|
+
"core": false,
|
172
|
+
"unlocked_by": null,
|
173
|
+
"difficulty": 1,
|
174
|
+
"topics": [
|
175
|
+
"mathematics"
|
176
|
+
]
|
177
|
+
},
|
168
178
|
{
|
169
179
|
"uuid": "f9afd650-8103-4373-a284-fa4ecfee7207",
|
170
180
|
"slug": "collatz-conjecture",
|
@@ -61,7 +61,7 @@ haven't already, it will help you with organizing your files.
|
|
61
61
|
|
62
62
|
## Feedback, Issues, Pull Requests
|
63
63
|
|
64
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
64
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
65
65
|
|
66
66
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
67
67
|
|
@@ -31,7 +31,7 @@ haven't already, it will help you with organizing your files.
|
|
31
31
|
|
32
32
|
## Feedback, Issues, Pull Requests
|
33
33
|
|
34
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
34
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
35
35
|
|
36
36
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
37
37
|
|
@@ -55,7 +55,7 @@ haven't already, it will help you with organizing your files.
|
|
55
55
|
|
56
56
|
## Feedback, Issues, Pull Requests
|
57
57
|
|
58
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
58
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
59
59
|
|
60
60
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
61
61
|
|
@@ -1,5 +1,12 @@
|
|
1
1
|
pub type Digit = u32;
|
2
2
|
|
3
|
+
#[derive(Debug, PartialEq)]
|
4
|
+
pub enum Error {
|
5
|
+
InvalidInputBase,
|
6
|
+
InvalidOutputBase,
|
7
|
+
InvalidDigit(Digit),
|
8
|
+
}
|
9
|
+
|
3
10
|
///
|
4
11
|
/// Convert a number between two bases.
|
5
12
|
///
|
@@ -31,15 +38,18 @@ pub type Digit = u32;
|
|
31
38
|
/// * Never output leading 0 digits. However, your function must be able to
|
32
39
|
/// process input with leading 0 digits.
|
33
40
|
///
|
34
|
-
pub fn convert<P: AsRef<[Digit]>>(digits: P, from_base: Digit, to_base: Digit) -> Result<Vec<Digit>,
|
41
|
+
pub fn convert<P: AsRef<[Digit]>>(digits: P, from_base: Digit, to_base: Digit) -> Result<Vec<Digit>, Error> {
|
35
42
|
// check that both bases are in the correct range
|
36
|
-
if from_base < 2
|
37
|
-
return Err(
|
43
|
+
if from_base < 2 {
|
44
|
+
return Err(Error::InvalidInputBase);
|
45
|
+
}
|
46
|
+
if to_base < 2 {
|
47
|
+
return Err(Error::InvalidOutputBase);
|
38
48
|
}
|
39
49
|
|
40
50
|
// check that all digits are in the correct range specified by the base
|
41
|
-
if digits.as_ref().iter().
|
42
|
-
return Err(
|
51
|
+
if let Some(&invalid) = digits.as_ref().iter().find(|&num| *num >= from_base) {
|
52
|
+
return Err(Error::InvalidDigit(invalid));
|
43
53
|
}
|
44
54
|
|
45
55
|
// convert all digits into a single large number
|
@@ -1,3 +1,10 @@
|
|
1
|
+
#[derive(Debug, PartialEq)]
|
2
|
+
pub enum Error {
|
3
|
+
InvalidInputBase,
|
4
|
+
InvalidOutputBase,
|
5
|
+
InvalidDigit(u32),
|
6
|
+
}
|
7
|
+
|
1
8
|
///
|
2
9
|
/// Convert a number between two bases.
|
3
10
|
///
|
@@ -30,6 +37,6 @@
|
|
30
37
|
/// process input with leading 0 digits.
|
31
38
|
///
|
32
39
|
#[allow(unused_variables)]
|
33
|
-
pub fn convert(number: &[u32], from_base: u32, to_base: u32) -> Result<Vec<u32>,
|
40
|
+
pub fn convert(number: &[u32], from_base: u32, to_base: u32) -> Result<Vec<u32>, Error> {
|
34
41
|
unimplemented!()
|
35
42
|
}
|
@@ -137,7 +137,8 @@ fn invalid_positive_digit() {
|
|
137
137
|
let input_base = 2;
|
138
138
|
let input_digits = &[1, 2, 1, 0, 1, 0];
|
139
139
|
let output_base = 10;
|
140
|
-
|
140
|
+
assert_eq!(ayb::convert(input_digits, input_base, output_base),
|
141
|
+
Err(ayb::Error::InvalidDigit(2)));
|
141
142
|
}
|
142
143
|
|
143
144
|
#[test]
|
@@ -146,7 +147,8 @@ fn input_base_is_one() {
|
|
146
147
|
let input_base = 1;
|
147
148
|
let input_digits = &[];
|
148
149
|
let output_base = 10;
|
149
|
-
|
150
|
+
assert_eq!(ayb::convert(input_digits, input_base, output_base),
|
151
|
+
Err(ayb::Error::InvalidInputBase));
|
150
152
|
}
|
151
153
|
|
152
154
|
#[test]
|
@@ -155,7 +157,8 @@ fn output_base_is_one() {
|
|
155
157
|
let input_base = 2;
|
156
158
|
let input_digits = &[1, 0, 1, 0, 1, 0];
|
157
159
|
let output_base = 1;
|
158
|
-
|
160
|
+
assert_eq!(ayb::convert(input_digits, input_base, output_base),
|
161
|
+
Err(ayb::Error::InvalidOutputBase));
|
159
162
|
}
|
160
163
|
|
161
164
|
#[test]
|
@@ -164,7 +167,8 @@ fn input_base_is_zero() {
|
|
164
167
|
let input_base = 0;
|
165
168
|
let input_digits = &[];
|
166
169
|
let output_base = 10;
|
167
|
-
|
170
|
+
assert_eq!(ayb::convert(input_digits, input_base, output_base),
|
171
|
+
Err(ayb::Error::InvalidInputBase));
|
168
172
|
}
|
169
173
|
|
170
174
|
#[test]
|
@@ -173,5 +177,6 @@ fn output_base_is_zero() {
|
|
173
177
|
let input_base = 10;
|
174
178
|
let input_digits = &[7];
|
175
179
|
let output_base = 0;
|
176
|
-
|
180
|
+
assert_eq!(ayb::convert(input_digits, input_base, output_base),
|
181
|
+
Err(ayb::Error::InvalidOutputBase));
|
177
182
|
}
|
@@ -53,7 +53,7 @@ haven't already, it will help you with organizing your files.
|
|
53
53
|
|
54
54
|
## Feedback, Issues, Pull Requests
|
55
55
|
|
56
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
56
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
57
57
|
|
58
58
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
59
59
|
|
@@ -55,7 +55,7 @@ haven't already, it will help you with organizing your files.
|
|
55
55
|
|
56
56
|
## Feedback, Issues, Pull Requests
|
57
57
|
|
58
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
58
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
59
59
|
|
60
60
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
61
61
|
|
@@ -30,7 +30,7 @@ haven't already, it will help you with organizing your files.
|
|
30
30
|
|
31
31
|
## Feedback, Issues, Pull Requests
|
32
32
|
|
33
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
33
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
34
34
|
|
35
35
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
36
36
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Armstrong Numbers
|
2
|
+
|
3
|
+
An [Armstrong number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that is the sum of its own digits each raised to the power of the number of digits.
|
4
|
+
|
5
|
+
For example:
|
6
|
+
|
7
|
+
- 9 is an Armstrong number, because `9 = 9^1 = 9`
|
8
|
+
- 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 2`
|
9
|
+
- 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153`
|
10
|
+
- 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190`
|
11
|
+
|
12
|
+
Write some code to determine whether a number is an Armstrong number.
|
13
|
+
|
14
|
+
## Rust Installation
|
15
|
+
|
16
|
+
Refer to the [exercism help page][help-page] for Rust installation and learning
|
17
|
+
resources.
|
18
|
+
|
19
|
+
## Writing the Code
|
20
|
+
|
21
|
+
Execute the tests with:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
$ cargo test
|
25
|
+
```
|
26
|
+
|
27
|
+
All but the first test have been ignored. After you get the first test to
|
28
|
+
pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
|
29
|
+
to pass again. The test file is located in the `tests` directory. You can
|
30
|
+
also remove the ignore flag from all the tests to get them to run all at once
|
31
|
+
if you wish.
|
32
|
+
|
33
|
+
Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
|
34
|
+
haven't already, it will help you with organizing your files.
|
35
|
+
|
36
|
+
## Feedback, Issues, Pull Requests
|
37
|
+
|
38
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
39
|
+
|
40
|
+
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
41
|
+
|
42
|
+
[help-page]: http://exercism.io/languages/rust
|
43
|
+
[modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
|
44
|
+
[cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
|
45
|
+
|
46
|
+
## Source
|
47
|
+
|
48
|
+
Wikipedia [https://en.wikipedia.org/wiki/Narcissistic_number](https://en.wikipedia.org/wiki/Narcissistic_number)
|
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,49 @@
|
|
1
|
+
extern crate armstrong_numbers;
|
2
|
+
use armstrong_numbers::*;
|
3
|
+
|
4
|
+
#[test]
|
5
|
+
fn test_single_digit_numbers_are_armstrong_numbers() {
|
6
|
+
assert!(is_armstrong_number(5))
|
7
|
+
}
|
8
|
+
|
9
|
+
#[test]
|
10
|
+
#[ignore]
|
11
|
+
fn test_there_are_no_2_digit_armstring_numbers() {
|
12
|
+
assert!(!is_armstrong_number(10))
|
13
|
+
}
|
14
|
+
|
15
|
+
#[test]
|
16
|
+
#[ignore]
|
17
|
+
fn test_three_digit_armstrong_number() {
|
18
|
+
assert!(is_armstrong_number(153))
|
19
|
+
}
|
20
|
+
|
21
|
+
#[test]
|
22
|
+
#[ignore]
|
23
|
+
fn test_three_digit_non_armstrong_number() {
|
24
|
+
assert!(!is_armstrong_number(100))
|
25
|
+
}
|
26
|
+
|
27
|
+
#[test]
|
28
|
+
#[ignore]
|
29
|
+
fn test_four_digit_armstrong_number() {
|
30
|
+
assert!(is_armstrong_number(9474))
|
31
|
+
}
|
32
|
+
|
33
|
+
#[test]
|
34
|
+
#[ignore]
|
35
|
+
fn test_four_digit_non_armstrong_number() {
|
36
|
+
assert!(!is_armstrong_number(9475))
|
37
|
+
}
|
38
|
+
|
39
|
+
#[test]
|
40
|
+
#[ignore]
|
41
|
+
fn test_seven_digit_armstrong_number() {
|
42
|
+
assert!(is_armstrong_number(9926315))
|
43
|
+
}
|
44
|
+
|
45
|
+
#[test]
|
46
|
+
#[ignore]
|
47
|
+
fn test_seven_digit_non_armstrong_number() {
|
48
|
+
assert!(!is_armstrong_number(9926316))
|
49
|
+
}
|
@@ -52,7 +52,7 @@ haven't already, it will help you with organizing your files.
|
|
52
52
|
|
53
53
|
## Feedback, Issues, Pull Requests
|
54
54
|
|
55
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
55
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
56
56
|
|
57
57
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
58
58
|
|
@@ -344,7 +344,7 @@ haven't already, it will help you with organizing your files.
|
|
344
344
|
|
345
345
|
## Feedback, Issues, Pull Requests
|
346
346
|
|
347
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
347
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
348
348
|
|
349
349
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
350
350
|
|
@@ -98,7 +98,7 @@ haven't already, it will help you with organizing your files.
|
|
98
98
|
|
99
99
|
## Feedback, Issues, Pull Requests
|
100
100
|
|
101
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
101
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
102
102
|
|
103
103
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
104
104
|
|
@@ -37,7 +37,7 @@ haven't already, it will help you with organizing your files.
|
|
37
37
|
|
38
38
|
## Feedback, Issues, Pull Requests
|
39
39
|
|
40
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
40
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
41
41
|
|
42
42
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
43
43
|
|
@@ -91,7 +91,7 @@ haven't already, it will help you with organizing your files.
|
|
91
91
|
|
92
92
|
## Feedback, Issues, Pull Requests
|
93
93
|
|
94
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
94
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
95
95
|
|
96
96
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
97
97
|
|
@@ -84,7 +84,7 @@ haven't already, it will help you with organizing your files.
|
|
84
84
|
|
85
85
|
## Feedback, Issues, Pull Requests
|
86
86
|
|
87
|
-
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the
|
87
|
+
The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
|
88
88
|
|
89
89
|
If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
|
90
90
|
|
@@ -1,3 +1,8 @@
|
|
1
|
+
#[derive(Debug, PartialEq)]
|
2
|
+
pub enum Error {
|
3
|
+
NotEnoughPinsLeft,
|
4
|
+
GameComplete,
|
5
|
+
}
|
1
6
|
|
2
7
|
pub struct BowlingGame {
|
3
8
|
frames: Vec<Frame>,
|
@@ -96,12 +101,12 @@ impl BowlingGame {
|
|
96
101
|
BowlingGame { frames: vec![Frame::new()] }
|
97
102
|
}
|
98
103
|
|
99
|
-
pub fn roll(&mut self, pins: u16) -> Result<(),
|
104
|
+
pub fn roll(&mut self, pins: u16) -> Result<(), Error> {
|
100
105
|
if pins > 10 {
|
101
|
-
Err(
|
106
|
+
Err(Error::NotEnoughPinsLeft)
|
102
107
|
} else {
|
103
|
-
if self.score().
|
104
|
-
return Err(
|
108
|
+
if self.score().is_some() {
|
109
|
+
return Err(Error::GameComplete);
|
105
110
|
}
|
106
111
|
|
107
112
|
for frame in self.frames.iter_mut() {
|
@@ -109,7 +114,7 @@ impl BowlingGame {
|
|
109
114
|
}
|
110
115
|
|
111
116
|
if self.frames.iter().any(|f| !f.is_valid()) {
|
112
|
-
return Err(
|
117
|
+
return Err(Error::NotEnoughPinsLeft);
|
113
118
|
}
|
114
119
|
|
115
120
|
if self.frames.iter().last().unwrap().rolls_done() && self.frames.len() < 10 {
|
@@ -120,11 +125,11 @@ impl BowlingGame {
|
|
120
125
|
}
|
121
126
|
}
|
122
127
|
|
123
|
-
pub fn score(&self) ->
|
128
|
+
pub fn score(&self) -> Option<u16> {
|
124
129
|
if !self.is_done() {
|
125
|
-
|
130
|
+
None
|
126
131
|
} else {
|
127
|
-
|
132
|
+
Some(self.frames.iter().fold(0, |acc, r| acc + r.score()))
|
128
133
|
}
|
129
134
|
}
|
130
135
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#[derive(Debug, PartialEq)]
|
2
|
+
pub enum Error {
|
3
|
+
NotEnoughPinsLeft,
|
4
|
+
GameComplete,
|
5
|
+
}
|
6
|
+
|
7
|
+
pub struct BowlingGame {
|
8
|
+
}
|
9
|
+
|
10
|
+
impl BowlingGame {
|
11
|
+
pub fn new() -> Self {
|
12
|
+
unimplemented!();
|
13
|
+
}
|
14
|
+
|
15
|
+
pub fn roll(&mut self, pins: u16) -> Result<(), Error> {
|
16
|
+
unimplemented!("Record that {} pins have been scored", pins);
|
17
|
+
}
|
18
|
+
|
19
|
+
pub fn score(&self) -> Option<u16> {
|
20
|
+
unimplemented!("Return the score if the game is complete, or None if not.");
|
21
|
+
}
|
22
|
+
}
|