trackler 2.2.1.44 → 2.2.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/isbn-verifier/canonical-data.json +88 -0
- data/problem-specifications/exercises/isbn-verifier/description.md +35 -0
- data/problem-specifications/exercises/isbn-verifier/metadata.yml +4 -0
- data/problem-specifications/exercises/robot-simulator/canonical-data.json +125 -32
- data/problem-specifications/exercises/sum-of-multiples/description.md +0 -3
- data/problem-specifications/exercises/two-bucket/canonical-data.json +3 -3
- data/tracks/c/config.json +235 -237
- data/tracks/c/exercises/acronym/README.md +0 -1
- data/tracks/c/exercises/all-your-base/README.md +1 -1
- data/tracks/c/exercises/allergies/README.md +0 -1
- data/tracks/c/exercises/atbash-cipher/README.md +2 -1
- data/tracks/c/exercises/beer-song/README.md +1 -1
- data/tracks/c/exercises/binary/README.md +2 -0
- data/tracks/c/exercises/grains/README.md +0 -1
- data/tracks/c/exercises/isogram/README.md +2 -1
- data/tracks/c/exercises/leap/README.md +1 -1
- data/tracks/c/exercises/meetup/README.md +1 -2
- data/tracks/c/exercises/nucleotide-count/README.md +8 -22
- data/tracks/c/exercises/palindrome-products/README.md +12 -6
- data/tracks/c/exercises/pangram/README.md +1 -1
- data/tracks/c/exercises/pascals-triangle/README.md +1 -1
- data/tracks/c/exercises/perfect-numbers/README.md +2 -2
- data/tracks/c/exercises/phone-number/README.md +3 -2
- data/tracks/c/exercises/roman-numerals/README.md +1 -1
- data/tracks/c/exercises/scrabble-score/README.md +3 -1
- data/tracks/c/exercises/space-age/README.md +2 -1
- data/tracks/c/exercises/triangle/README.md +9 -6
- data/tracks/c/exercises/word-count/README.md +1 -2
- data/tracks/csharp/exercises/accumulate/Accumulate.csproj +2 -2
- data/tracks/csharp/exercises/acronym/Acronym.csproj +2 -2
- data/tracks/csharp/exercises/all-your-base/AllYourBase.csproj +2 -2
- data/tracks/csharp/exercises/allergies/Allergies.csproj +2 -2
- data/tracks/csharp/exercises/alphametics/Alphametics.csproj +2 -2
- data/tracks/csharp/exercises/anagram/Anagram.csproj +2 -2
- data/tracks/csharp/exercises/atbash-cipher/AtbashCipher.csproj +2 -2
- data/tracks/csharp/exercises/bank-account/BankAccount.csproj +2 -2
- data/tracks/csharp/exercises/beer-song/BeerSong.csproj +2 -2
- data/tracks/csharp/exercises/binary-search/BinarySearch.csproj +2 -2
- data/tracks/csharp/exercises/binary-search-tree/BinarySearchTree.csproj +2 -2
- data/tracks/csharp/exercises/bob/Bob.csproj +2 -2
- data/tracks/csharp/exercises/book-store/BookStore.csproj +2 -2
- data/tracks/csharp/exercises/bowling/Bowling.csproj +2 -2
- data/tracks/csharp/exercises/bracket-push/BracketPush.csproj +2 -2
- data/tracks/csharp/exercises/change/Change.csproj +2 -2
- data/tracks/csharp/exercises/circular-buffer/CircularBuffer.csproj +2 -2
- data/tracks/csharp/exercises/clock/Clock.csproj +2 -2
- data/tracks/csharp/exercises/collatz-conjecture/CollatzConjecture.csproj +2 -2
- data/tracks/csharp/exercises/complex-numbers/ComplexNumbers.csproj +2 -2
- data/tracks/csharp/exercises/connect/Connect.cs +1 -1
- data/tracks/csharp/exercises/connect/Connect.csproj +2 -2
- data/tracks/csharp/exercises/connect/ConnectTest.cs +120 -85
- data/tracks/csharp/exercises/connect/Example.cs +11 -7
- data/tracks/csharp/exercises/crypto-square/CryptoSquare.csproj +2 -2
- data/tracks/csharp/exercises/custom-set/CustomSet.csproj +2 -2
- data/tracks/csharp/exercises/diamond/Diamond.csproj +2 -2
- data/tracks/csharp/exercises/difference-of-squares/DifferenceOfSquares.csproj +2 -2
- data/tracks/csharp/exercises/diffie-hellman/DiffieHellman.csproj +2 -2
- data/tracks/csharp/exercises/dominoes/Dominoes.csproj +2 -2
- data/tracks/csharp/exercises/dot-dsl/DotDsl.csproj +2 -2
- data/tracks/csharp/exercises/error-handling/ErrorHandling.csproj +2 -2
- data/tracks/csharp/exercises/etl/Etl.csproj +2 -2
- data/tracks/csharp/exercises/flatten-array/FlattenArray.csproj +2 -2
- data/tracks/csharp/exercises/food-chain/FoodChain.csproj +2 -2
- data/tracks/csharp/exercises/forth/Forth.csproj +2 -2
- data/tracks/csharp/exercises/gigasecond/Gigasecond.csproj +2 -2
- data/tracks/csharp/exercises/go-counting/GoCounting.csproj +2 -2
- data/tracks/csharp/exercises/grade-school/GradeSchool.csproj +2 -2
- data/tracks/csharp/exercises/grains/Grains.csproj +2 -2
- data/tracks/csharp/exercises/grep/Grep.csproj +2 -2
- data/tracks/csharp/exercises/hamming/Hamming.csproj +2 -2
- data/tracks/csharp/exercises/hangman/Hangman.csproj +2 -2
- data/tracks/csharp/exercises/hello-world/HelloWorld.csproj +2 -2
- data/tracks/csharp/exercises/house/House.csproj +2 -2
- data/tracks/csharp/exercises/isogram/Isogram.csproj +2 -2
- data/tracks/csharp/exercises/kindergarten-garden/KindergartenGarden.csproj +2 -2
- data/tracks/csharp/exercises/largest-series-product/LargestSeriesProduct.csproj +2 -2
- data/tracks/csharp/exercises/leap/Leap.csproj +2 -2
- data/tracks/csharp/exercises/ledger/Ledger.csproj +2 -2
- data/tracks/csharp/exercises/linked-list/LinkedList.csproj +2 -2
- data/tracks/csharp/exercises/list-ops/ListOps.csproj +2 -2
- data/tracks/csharp/exercises/luhn/Luhn.csproj +2 -2
- data/tracks/csharp/exercises/markdown/Markdown.csproj +2 -2
- data/tracks/csharp/exercises/matrix/Matrix.csproj +2 -2
- data/tracks/csharp/exercises/meetup/Meetup.csproj +2 -2
- data/tracks/csharp/exercises/minesweeper/Minesweeper.csproj +2 -2
- data/tracks/csharp/exercises/nth-prime/NthPrime.csproj +2 -2
- data/tracks/csharp/exercises/nucleotide-count/NucleotideCount.csproj +2 -2
- data/tracks/csharp/exercises/ocr-numbers/OcrNumbers.csproj +2 -2
- data/tracks/csharp/exercises/palindrome-products/PalindromeProducts.csproj +2 -2
- data/tracks/csharp/exercises/pangram/Pangram.csproj +2 -2
- data/tracks/csharp/exercises/parallel-letter-frequency/ParallelLetterFrequency.csproj +2 -2
- data/tracks/csharp/exercises/pascals-triangle/PascalsTriangle.csproj +2 -2
- data/tracks/csharp/exercises/perfect-numbers/PerfectNumbers.csproj +2 -2
- data/tracks/csharp/exercises/phone-number/PhoneNumber.csproj +2 -2
- data/tracks/csharp/exercises/pig-latin/PigLatin.csproj +2 -2
- data/tracks/csharp/exercises/poker/Poker.csproj +2 -2
- data/tracks/csharp/exercises/pov/Pov.csproj +2 -2
- data/tracks/csharp/exercises/prime-factors/PrimeFactors.csproj +2 -2
- data/tracks/csharp/exercises/protein-translation/ProteinTranslation.csproj +2 -2
- data/tracks/csharp/exercises/proverb/Proverb.csproj +2 -2
- data/tracks/csharp/exercises/pythagorean-triplet/PythagoreanTriplet.csproj +2 -2
- data/tracks/csharp/exercises/queen-attack/QueenAttack.csproj +2 -2
- data/tracks/csharp/exercises/rail-fence-cipher/RailFenceCipher.csproj +2 -2
- data/tracks/csharp/exercises/raindrops/Raindrops.csproj +2 -2
- data/tracks/csharp/exercises/react/React.csproj +2 -2
- data/tracks/csharp/exercises/rectangles/Rectangles.csproj +2 -2
- data/tracks/csharp/exercises/rna-transcription/RnaTranscription.csproj +2 -2
- data/tracks/csharp/exercises/robot-name/RobotName.csproj +2 -2
- data/tracks/csharp/exercises/robot-simulator/RobotSimulator.csproj +2 -2
- data/tracks/csharp/exercises/roman-numerals/RomanNumerals.csproj +2 -2
- data/tracks/csharp/exercises/rotational-cipher/RotationalCipher.csproj +2 -2
- data/tracks/csharp/exercises/run-length-encoding/RunLengthEncoding.csproj +2 -2
- data/tracks/csharp/exercises/saddle-points/SaddlePoints.csproj +2 -2
- data/tracks/csharp/exercises/say/Say.csproj +2 -2
- data/tracks/csharp/exercises/scale-generator/ScaleGenerator.csproj +2 -2
- data/tracks/csharp/exercises/scrabble-score/ScrabbleScore.csproj +2 -2
- data/tracks/csharp/exercises/secret-handshake/SecretHandshake.csproj +2 -2
- data/tracks/csharp/exercises/series/Series.csproj +2 -2
- data/tracks/csharp/exercises/series/SeriesTest.cs +17 -17
- data/tracks/csharp/exercises/sgf-parsing/SgfParsing.csproj +2 -2
- data/tracks/csharp/exercises/sieve/Sieve.csproj +2 -2
- data/tracks/csharp/exercises/simple-cipher/SimpleCipher.csproj +2 -2
- data/tracks/csharp/exercises/simple-linked-list/SimpleLinkedList.csproj +2 -2
- data/tracks/csharp/exercises/space-age/SpaceAge.csproj +2 -2
- data/tracks/csharp/exercises/spiral-matrix/SpiralMatrix.csproj +2 -2
- data/tracks/csharp/exercises/strain/Strain.csproj +2 -2
- data/tracks/csharp/exercises/sublist/Sublist.csproj +2 -2
- data/tracks/csharp/exercises/sum-of-multiples/SumOfMultiples.csproj +2 -2
- data/tracks/csharp/exercises/tournament/Tournament.csproj +2 -2
- data/tracks/csharp/exercises/transpose/Transpose.csproj +2 -2
- data/tracks/csharp/exercises/tree-building/TreeBuilding.csproj +2 -2
- data/tracks/csharp/exercises/triangle/Triangle.cs +0 -11
- data/tracks/csharp/exercises/triangle/Triangle.csproj +2 -2
- data/tracks/csharp/exercises/triangle/TriangleTest.cs +17 -17
- data/tracks/csharp/exercises/twelve-days/TwelveDays.csproj +2 -2
- data/tracks/csharp/exercises/two-bucket/TwoBucket.csproj +2 -2
- data/tracks/csharp/exercises/two-fer/TwoFer.csproj +2 -2
- data/tracks/csharp/exercises/variable-length-quantity/VariableLengthQuantity.csproj +2 -2
- data/tracks/csharp/exercises/word-count/WordCount.csproj +2 -2
- data/tracks/csharp/exercises/word-search/WordSearch.csproj +2 -2
- data/tracks/csharp/exercises/wordy/Wordy.csproj +2 -2
- data/tracks/csharp/exercises/zebra-puzzle/ZebraPuzzle.csproj +2 -2
- data/tracks/csharp/exercises/zipper/Zipper.csproj +2 -2
- data/tracks/csharp/generators/Exercises/Connect.cs +47 -0
- data/tracks/csharp/generators/Exercises/Triangle.cs +1 -1
- data/tracks/dart/config/maintainers.json +27 -1
- data/tracks/dart/pubspec.yaml +3 -0
- data/tracks/dart/tool/create-exercise +144 -5
- data/tracks/elm/.gitattributes +1 -0
- data/tracks/elm/bin/install-elm-format +9 -3
- data/tracks/elm/config.json +30 -0
- data/tracks/elm/exercises/all-your-base/AllYourBase.elm +1 -0
- data/tracks/elm/exercises/all-your-base/AllYourBase.example.elm +68 -0
- data/tracks/elm/exercises/all-your-base/README.md +65 -0
- data/tracks/elm/exercises/all-your-base/elm-package.json +15 -0
- data/tracks/elm/exercises/all-your-base/tests/Tests.elm +53 -0
- data/tracks/elm/exercises/all-your-base/tests/elm-package.json +16 -0
- data/tracks/elm/exercises/collatz-conjecture/CollatzConjecture.elm +2 -0
- data/tracks/elm/exercises/collatz-conjecture/CollatzConjecture.example.elm +19 -0
- data/tracks/elm/exercises/collatz-conjecture/elm-package.json +15 -0
- data/tracks/elm/exercises/collatz-conjecture/package.json +14 -0
- data/tracks/elm/exercises/collatz-conjecture/tests/Tests.elm +38 -0
- data/tracks/elm/exercises/collatz-conjecture/tests/elm-package.json +16 -0
- data/tracks/elm/exercises/isogram/Isogram.elm +1 -0
- data/tracks/elm/exercises/isogram/Isogram.example.elm +76 -0
- data/tracks/elm/exercises/isogram/README.md +50 -0
- data/tracks/elm/exercises/isogram/elm-package.json +14 -0
- data/tracks/elm/exercises/isogram/package.json +14 -0
- data/tracks/elm/exercises/isogram/tests/Tests.elm +46 -0
- data/tracks/elm/exercises/isogram/tests/elm-package.json +16 -0
- data/tracks/fsharp/.gitignore +2 -1
- data/tracks/fsharp/exercises/accumulate/Accumulate.fsproj +3 -2
- data/tracks/fsharp/exercises/acronym/Acronym.fs +1 -1
- data/tracks/fsharp/exercises/acronym/Acronym.fsproj +3 -2
- data/tracks/fsharp/exercises/acronym/AcronymTest.fs +13 -38
- data/tracks/fsharp/exercises/acronym/Example.fs +1 -1
- data/tracks/fsharp/exercises/all-your-base/AllYourBase.fsproj +3 -2
- data/tracks/fsharp/exercises/all-your-base/AllYourBaseTest.fs +64 -61
- data/tracks/fsharp/exercises/all-your-base/Example.fs +4 -1
- data/tracks/fsharp/exercises/allergies/Allergies.fs +2 -2
- data/tracks/fsharp/exercises/allergies/Allergies.fsproj +3 -2
- data/tracks/fsharp/exercises/allergies/AllergiesTest.fs +28 -37
- data/tracks/fsharp/exercises/allergies/Example.fs +3 -3
- data/tracks/fsharp/exercises/alphametics/Alphametics.fsproj +3 -2
- data/tracks/fsharp/exercises/anagram/Anagram.fsproj +3 -2
- data/tracks/fsharp/exercises/atbash-cipher/AtbashCipher.fs +4 -2
- data/tracks/fsharp/exercises/atbash-cipher/AtbashCipher.fsproj +3 -2
- data/tracks/fsharp/exercises/atbash-cipher/AtbashCipherTest.fs +38 -42
- data/tracks/fsharp/exercises/atbash-cipher/Example.fs +5 -3
- data/tracks/fsharp/exercises/bank-account/BankAccount.fsproj +3 -2
- data/tracks/fsharp/exercises/beer-song/BeerSong.fsproj +3 -2
- data/tracks/fsharp/exercises/beer-song/BeerSongTest.fs +36 -32
- data/tracks/fsharp/exercises/beer-song/Example.fs +2 -2
- data/tracks/fsharp/exercises/binary-search/BinarySearch.fsproj +3 -2
- data/tracks/fsharp/exercises/binary-search-tree/BinarySearchTree.fsproj +3 -2
- data/tracks/fsharp/exercises/bob/Bob.fs +1 -1
- data/tracks/fsharp/exercises/bob/Bob.fsproj +3 -2
- data/tracks/fsharp/exercises/bob/BobTest.fs +64 -20
- data/tracks/fsharp/exercises/bob/Example.fs +3 -4
- data/tracks/fsharp/exercises/book-store/BookStore.fs +1 -1
- data/tracks/fsharp/exercises/book-store/BookStore.fsproj +3 -2
- data/tracks/fsharp/exercises/book-store/BookStoreTest.fs +32 -25
- data/tracks/fsharp/exercises/book-store/Example.fs +1 -1
- data/tracks/fsharp/exercises/bowling/Bowling.fsproj +3 -2
- data/tracks/fsharp/exercises/bracket-push/BracketPush.fs +1 -1
- data/tracks/fsharp/exercises/bracket-push/BracketPush.fsproj +3 -2
- data/tracks/fsharp/exercises/bracket-push/BracketPushTest.fs +24 -25
- data/tracks/fsharp/exercises/bracket-push/Example.fs +1 -1
- data/tracks/fsharp/exercises/change/Change.fs +1 -1
- data/tracks/fsharp/exercises/change/Change.fsproj +3 -2
- data/tracks/fsharp/exercises/change/ChangeTest.fs +42 -18
- data/tracks/fsharp/exercises/change/Example.fs +7 -4
- data/tracks/fsharp/exercises/circular-buffer/CircularBuffer.fsproj +3 -2
- data/tracks/fsharp/exercises/clock/Clock.fsproj +3 -2
- data/tracks/fsharp/exercises/connect/Connect.fsproj +3 -2
- data/tracks/fsharp/exercises/crypto-square/CryptoSquare.fs +1 -40
- data/tracks/fsharp/exercises/crypto-square/CryptoSquare.fsproj +3 -2
- data/tracks/fsharp/exercises/crypto-square/CryptoSquareTest.fs +16 -40
- data/tracks/fsharp/exercises/crypto-square/Example.fs +13 -16
- data/tracks/fsharp/exercises/custom-set/CustomSet.fs +12 -12
- data/tracks/fsharp/exercises/custom-set/CustomSet.fsproj +3 -2
- data/tracks/fsharp/exercises/diamond/Diamond.fsproj +3 -2
- data/tracks/fsharp/exercises/difference-of-squares/DifferenceOfSquares.fs +2 -2
- data/tracks/fsharp/exercises/difference-of-squares/DifferenceOfSquares.fsproj +3 -2
- data/tracks/fsharp/exercises/difference-of-squares/DifferenceOfSquaresTest.fs +24 -20
- data/tracks/fsharp/exercises/difference-of-squares/Example.fs +3 -3
- data/tracks/fsharp/exercises/diffie-hellman/DiffieHellman.fsproj +3 -2
- data/tracks/fsharp/exercises/dominoes/Dominoes.fsproj +3 -2
- data/tracks/fsharp/exercises/dot-dsl/DotDsl.fsproj +3 -2
- data/tracks/fsharp/exercises/error-handling/ErrorHandling.fsproj +3 -2
- data/tracks/fsharp/exercises/etl/Etl.fsproj +3 -2
- data/tracks/fsharp/exercises/food-chain/FoodChain.fsproj +3 -2
- data/tracks/fsharp/exercises/forth/Forth.fsproj +3 -2
- data/tracks/fsharp/exercises/gigasecond/Example.fs +1 -3
- data/tracks/fsharp/exercises/gigasecond/Gigasecond.fs +1 -1
- data/tracks/fsharp/exercises/gigasecond/Gigasecond.fsproj +3 -2
- data/tracks/fsharp/exercises/gigasecond/GigasecondTest.fs +21 -12
- data/tracks/fsharp/exercises/go-counting/GoCounting.fsproj +3 -2
- data/tracks/fsharp/exercises/grade-school/GradeSchool.fsproj +3 -2
- data/tracks/fsharp/exercises/grains/Grains.fsproj +3 -2
- data/tracks/fsharp/exercises/grep/Grep.fsproj +3 -2
- data/tracks/fsharp/exercises/hamming/Hamming.fsproj +3 -2
- data/tracks/fsharp/exercises/hangman/Hangman.fsproj +3 -2
- data/tracks/fsharp/exercises/hello-world/HelloWorld.fsproj +3 -2
- data/tracks/fsharp/exercises/hello-world/HelloWorldTest.fs +6 -3
- data/tracks/fsharp/exercises/house/House.fsproj +3 -2
- data/tracks/fsharp/exercises/isogram/Example.fs +1 -1
- data/tracks/fsharp/exercises/isogram/Isogram.fs +1 -1
- data/tracks/fsharp/exercises/isogram/Isogram.fsproj +3 -2
- data/tracks/fsharp/exercises/isogram/IsogramTest.fs +16 -40
- data/tracks/fsharp/exercises/kindergarten-garden/Example.fs +6 -4
- data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGarden.fs +3 -5
- data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGarden.fsproj +3 -2
- data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGardenTest.fs +100 -47
- data/tracks/fsharp/exercises/largest-series-product/LargestSeriesProduct.fsproj +3 -2
- data/tracks/fsharp/exercises/leap/Example.fs +2 -2
- data/tracks/fsharp/exercises/leap/Leap.fs +2 -2
- data/tracks/fsharp/exercises/leap/Leap.fsproj +3 -2
- data/tracks/fsharp/exercises/leap/LeapTest.fs +19 -15
- data/tracks/fsharp/exercises/ledger/Ledger.fsproj +3 -2
- data/tracks/fsharp/exercises/lens-person/LensPerson.fsproj +3 -2
- data/tracks/fsharp/exercises/linked-list/LinkedList.fsproj +3 -2
- data/tracks/fsharp/exercises/list-ops/ListOps.fsproj +3 -2
- data/tracks/fsharp/exercises/luhn/Luhn.fsproj +3 -2
- data/tracks/fsharp/exercises/luhn/LuhnTest.fs +30 -65
- data/tracks/fsharp/exercises/markdown/Markdown.fsproj +3 -2
- data/tracks/fsharp/exercises/matrix/Matrix.fsproj +3 -2
- data/tracks/fsharp/exercises/meetup/Meetup.fsproj +3 -2
- data/tracks/fsharp/exercises/minesweeper/Example.fs +9 -11
- data/tracks/fsharp/exercises/minesweeper/Minesweeper.fsproj +3 -2
- data/tracks/fsharp/exercises/minesweeper/MinesweeperTest.fs +117 -80
- data/tracks/fsharp/exercises/nth-prime/NthPrime.fsproj +3 -2
- data/tracks/fsharp/exercises/nucleotide-count/NucleotideCount.fsproj +3 -2
- data/tracks/fsharp/exercises/ocr-numbers/OcrNumbers.fsproj +3 -2
- data/tracks/fsharp/exercises/palindrome-products/PalindromeProducts.fsproj +3 -2
- data/tracks/fsharp/exercises/pangram/Pangram.fsproj +3 -2
- data/tracks/fsharp/exercises/pangram/PangramTest.fs +15 -27
- data/tracks/fsharp/exercises/parallel-letter-frequency/ParallelLetterFrequency.fsproj +3 -2
- data/tracks/fsharp/exercises/pascals-triangle/PascalsTriangle.fsproj +3 -2
- data/tracks/fsharp/exercises/perfect-numbers/PerfectNumbers.fsproj +3 -2
- data/tracks/fsharp/exercises/phone-number/PhoneNumber.fsproj +3 -2
- data/tracks/fsharp/exercises/pig-latin/Example.fs +1 -1
- data/tracks/fsharp/exercises/pig-latin/PigLatin.fsproj +3 -2
- data/tracks/fsharp/exercises/pig-latin/PigLatinTest.fs +64 -26
- data/tracks/fsharp/exercises/poker/Poker.fsproj +3 -2
- data/tracks/fsharp/exercises/pov/Pov.fsproj +3 -2
- data/tracks/fsharp/exercises/prime-factors/PrimeFactors.fsproj +3 -2
- data/tracks/fsharp/exercises/protein-translation/ProteinTranslation.fsproj +3 -2
- data/tracks/fsharp/exercises/proverb/Proverb.fsproj +3 -2
- data/tracks/fsharp/exercises/pythagorean-triplet/PythagoreanTriplet.fsproj +3 -2
- data/tracks/fsharp/exercises/queen-attack/Example.fs +3 -1
- data/tracks/fsharp/exercises/queen-attack/QueenAttack.fs +2 -0
- data/tracks/fsharp/exercises/queen-attack/QueenAttack.fsproj +3 -2
- data/tracks/fsharp/exercises/queen-attack/QueenAttackTest.fs +50 -20
- data/tracks/fsharp/exercises/rail-fence-cipher/RailFenceCipher.fsproj +3 -2
- data/tracks/fsharp/exercises/raindrops/Raindrops.fsproj +3 -2
- data/tracks/fsharp/exercises/raindrops/RaindropsTest.fs +77 -37
- data/tracks/fsharp/exercises/react/React.fsproj +3 -2
- data/tracks/fsharp/exercises/rectangles/Rectangles.fsproj +3 -2
- data/tracks/fsharp/exercises/rna-transcription/Example.fs +15 -7
- data/tracks/fsharp/exercises/rna-transcription/RnaTranscription.fs +2 -2
- data/tracks/fsharp/exercises/rna-transcription/RnaTranscription.fsproj +3 -2
- data/tracks/fsharp/exercises/rna-transcription/RnaTranscriptionTest.fs +29 -14
- data/tracks/fsharp/exercises/robot-name/RobotName.fsproj +3 -2
- data/tracks/fsharp/exercises/robot-simulator/RobotSimulator.fsproj +3 -2
- data/tracks/fsharp/exercises/roman-numerals/Example.fs +2 -2
- data/tracks/fsharp/exercises/roman-numerals/RomanNumerals.fs +2 -2
- data/tracks/fsharp/exercises/roman-numerals/RomanNumerals.fsproj +3 -2
- data/tracks/fsharp/exercises/roman-numerals/RomanNumeralsTest.fs +79 -26
- data/tracks/fsharp/exercises/run-length-encoding/RunLengthEncoding.fsproj +3 -2
- data/tracks/fsharp/exercises/saddle-points/SaddlePoints.fsproj +3 -2
- data/tracks/fsharp/exercises/say/Say.fsproj +3 -2
- data/tracks/fsharp/exercises/scale-generator/ScaleGenerator.fsproj +3 -2
- data/tracks/fsharp/exercises/scrabble-score/ScrabbleScore.fsproj +3 -2
- data/tracks/fsharp/exercises/scrabble-score/ScrabbleScoreTest.fs +33 -17
- data/tracks/fsharp/exercises/secret-handshake/SecretHandshake.fsproj +3 -2
- data/tracks/fsharp/exercises/series/Series.fsproj +3 -2
- data/tracks/fsharp/exercises/sgf-parsing/SgfParsing.fsproj +3 -2
- data/tracks/fsharp/exercises/sieve/Sieve.fsproj +3 -2
- data/tracks/fsharp/exercises/simple-cipher/SimpleCipher.fsproj +3 -2
- data/tracks/fsharp/exercises/simple-linked-list/SimpleLinkedList.fsproj +3 -2
- data/tracks/fsharp/exercises/space-age/SpaceAge.fsproj +3 -2
- data/tracks/fsharp/exercises/strain/Strain.fsproj +3 -2
- data/tracks/fsharp/exercises/sublist/Sublist.fsproj +3 -2
- data/tracks/fsharp/exercises/sum-of-multiples/SumOfMultiples.fsproj +3 -2
- data/tracks/fsharp/exercises/tournament/Tournament.fsproj +3 -2
- data/tracks/fsharp/exercises/transpose/Transpose.fsproj +3 -2
- data/tracks/fsharp/exercises/tree-building/TreeBuilding.fsproj +3 -2
- data/tracks/fsharp/exercises/triangle/Triangle.fsproj +3 -2
- data/tracks/fsharp/exercises/twelve-days/TwelveDays.fsproj +3 -2
- data/tracks/fsharp/exercises/two-bucket/TwoBucket.fsproj +3 -2
- data/tracks/fsharp/exercises/two-fer/TwoFer.fsproj +3 -2
- data/tracks/fsharp/exercises/variable-length-quantity/VariableLengthQuantity.fsproj +3 -2
- data/tracks/fsharp/exercises/word-count/WordCount.fsproj +3 -2
- data/tracks/fsharp/exercises/word-search/WordSearch.fsproj +3 -2
- data/tracks/fsharp/exercises/wordy/Wordy.fsproj +3 -2
- data/tracks/fsharp/exercises/zebra-puzzle/ZebraPuzzle.fsproj +3 -2
- data/tracks/fsharp/exercises/zipper/Zipper.fsproj +3 -2
- data/tracks/fsharp/generators/Common.fs +96 -0
- data/tracks/fsharp/generators/Exercise.fs +250 -0
- data/tracks/fsharp/generators/Generators.fs +210 -0
- data/tracks/fsharp/generators/Generators.fsproj +32 -0
- data/tracks/fsharp/generators/Generators.sln +24 -0
- data/tracks/fsharp/generators/Input.fs +99 -0
- data/tracks/fsharp/generators/Options.fs +31 -0
- data/tracks/fsharp/generators/Output.fs +224 -0
- data/tracks/fsharp/generators/Program.fs +35 -0
- data/tracks/fsharp/generators/Properties/launchSettings.json +8 -0
- data/tracks/fsharp/generators/Templates/_AssertEmpty.liquid +1 -0
- data/tracks/fsharp/generators/Templates/_AssertEqual.liquid +1 -0
- data/tracks/fsharp/generators/Templates/_TestClass.liquid +13 -0
- data/tracks/fsharp/generators/Templates/_TestMethod.liquid +3 -0
- data/tracks/fsharp/generators/Templates/_TestMethodBody.liquid +4 -0
- data/tracks/go/.travis.yml +3 -3
- data/tracks/groovy/CONTRIBUTING.md +2 -2
- data/tracks/groovy/config.json +12 -0
- data/tracks/groovy/exercises/scrabble-score/Example.groovy +18 -0
- data/tracks/groovy/exercises/scrabble-score/README.md +63 -0
- data/tracks/groovy/exercises/scrabble-score/ScrabbleScore.groovy +7 -0
- data/tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy +45 -0
- data/tracks/groovy/exercises/two-fer/TwoFer.groovy +2 -2
- data/tracks/haskell/exercises/change/README.md +1 -1
- data/tracks/haskell/exercises/lens-person/README.md +1 -1
- data/tracks/haskell/exercises/palindrome-products/README.md +5 -12
- data/tracks/haskell/exercises/sum-of-multiples/README.md +0 -3
- data/tracks/idris/config.json +12 -0
- data/tracks/idris/exercises/accumulate/Accumulate.ipkg +5 -0
- data/tracks/idris/exercises/accumulate/Makefile +23 -0
- data/tracks/idris/exercises/accumulate/README.md +32 -0
- data/tracks/idris/exercises/accumulate/src/Example.idr +6 -0
- data/tracks/idris/exercises/accumulate/src/Test/Accumulate.idr +35 -0
- data/tracks/java/config/maintainers.json +4 -7
- data/tracks/java/config.json +99 -22
- data/tracks/java/exercises/binary-search-tree/.meta/src/reference/java/{BST.java → BinarySearchTree.java} +1 -1
- data/tracks/java/exercises/binary-search-tree/src/test/java/{BSTTest.java → BinarySearchTreeTest.java} +34 -36
- data/tracks/java/exercises/robot-simulator/src/main/java/GridPosition.java +19 -15
- data/tracks/java/exercises/saddle-points/.meta/src/reference/java/MatrixCoordinate.java +7 -1
- data/tracks/java/exercises/saddle-points/src/main/java/MatrixCoordinate.java +7 -1
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/java/exercises/tournament/.meta/src/reference/java/Result.java +5 -0
- data/tracks/java/exercises/tournament/.meta/src/reference/java/TeamResult.java +41 -0
- data/tracks/java/exercises/tournament/.meta/src/reference/java/Tournament.java +62 -0
- data/tracks/java/exercises/tournament/README.md +78 -0
- data/tracks/java/exercises/tournament/build.gradle +18 -0
- data/tracks/java/{.Rhistory → exercises/tournament/src/main/java/.keep} +0 -0
- data/tracks/java/exercises/tournament/src/test/java/TournamentTest.java +160 -0
- data/tracks/php/config.json +14 -0
- data/tracks/php/exercises/collatz-conjecture/collatz-conjecture_test.php +44 -0
- data/tracks/php/exercises/collatz-conjecture/example.php +18 -0
- data/tracks/python/exercises/circular-buffer/circular_buffer.py +1 -1
- data/tracks/python/exercises/clock/clock.py +1 -1
- data/tracks/python/exercises/etl/etl.py +1 -1
- data/tracks/python/exercises/grade-school/grade_school.py +1 -1
- data/tracks/python/exercises/grains/grains.py +2 -2
- data/tracks/python/exercises/kindergarten-garden/kindergarten_garden.py +1 -1
- data/tracks/python/exercises/linked-list/linked_list.py +1 -1
- data/tracks/python/exercises/rectangles/rectangles.py +1 -1
- data/tracks/python/exercises/sum-of-multiples/sum_of_multiples.py +1 -1
- data/tracks/rust/exercises/bob/tests/bob.rs +1 -0
- data/tracks/rust/exercises/crypto-square/tests/crypto-square.rs +7 -0
- data/tracks/rust/exercises/gigasecond/tests/gigasecond.rs +1 -1
- data/tracks/rust/exercises/phone-number/Cargo.lock +1 -1
- data/tracks/rust/exercises/phone-number/Cargo.toml +1 -1
- data/tracks/rust/exercises/phone-number/example.rs +17 -23
- data/tracks/rust/exercises/phone-number/tests/phone-number.rs +31 -40
- data/tracks/rust/exercises/say/tests/say.rs +2 -0
- data/tracks/rust/exercises/sum-of-multiples/README.md +0 -3
- data/tracks/scala/config.json +11 -0
- data/tracks/scala/exercises/collatz-conjecture/README.md +43 -0
- data/tracks/scala/exercises/collatz-conjecture/build.sbt +3 -0
- data/tracks/scala/exercises/collatz-conjecture/example.scala +17 -0
- data/tracks/scala/exercises/collatz-conjecture/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/collatz-conjecture/src/test/scala/CollatzConjectureTest.scala +34 -0
- data/tracks/scala/testgen/src/main/scala/CollatzConjectureTestGenerator.scala +35 -0
- data/tracks/scheme/config.json +8 -0
- data/tracks/scheme/exercises/word-count/README.md +19 -0
- data/tracks/scheme/exercises/word-count/example.scm +27 -0
- data/tracks/scheme/exercises/word-count/word-count-test.scm +90 -0
- data/tracks/scheme/exercises/word-count/word-count.scm +5 -0
- data/tracks/sml/README.md +20 -1
- data/tracks/sml/bin/generate +74 -20
- data/tracks/sml/exercises/binary/README.md +23 -5
- data/tracks/sml/exercises/binary/binary.sml +2 -0
- data/tracks/sml/exercises/binary/example.sml +10 -21
- data/tracks/sml/exercises/binary/test.sml +55 -30
- data/tracks/sml/exercises/binary/testlib.sml +159 -0
- data/tracks/sml/exercises/flatten-array/HINTS.md +8 -0
- data/tracks/sml/exercises/flatten-array/README.md +31 -6
- data/tracks/sml/exercises/flatten-array/example.sml +3 -4
- data/tracks/sml/exercises/flatten-array/flatten-array.sml +4 -5
- data/tracks/sml/exercises/flatten-array/test.sml +76 -52
- data/tracks/sml/exercises/flatten-array/testlib.sml +159 -0
- data/tracks/sml/exercises/nth-prime/HINTS.md +9 -0
- data/tracks/sml/exercises/nth-prime/README.md +32 -5
- data/tracks/sml/exercises/nth-prime/example.sml +28 -46
- data/tracks/sml/exercises/nth-prime/nth-prime.sml +1 -1
- data/tracks/sml/exercises/nth-prime/test.sml +19 -63
- data/tracks/sml/exercises/nth-prime/testlib.sml +159 -0
- data/tracks/sml/exercises/raindrops/README.md +21 -5
- data/tracks/typescript/config.json +14 -0
- data/tracks/typescript/exercises/triangle/README.md +55 -0
- data/tracks/typescript/exercises/triangle/package.json +36 -0
- data/tracks/typescript/exercises/triangle/triangle.example.ts +56 -0
- data/tracks/typescript/exercises/triangle/triangle.test.ts +79 -0
- data/tracks/typescript/exercises/triangle/triangle.ts +12 -0
- data/tracks/typescript/exercises/triangle/tsconfig.json +22 -0
- data/tracks/typescript/exercises/triangle/tslint.json +127 -0
- data/tracks/typescript/exercises/triangle/yarn.lock +2305 -0
- metadata +85 -6
- data/tracks/d/exercises/crypto-square/.dub/dub.json +0 -6
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
structure Expect =
|
|
2
|
+
struct
|
|
3
|
+
datatype expectation = Pass | Fail of string * string
|
|
4
|
+
|
|
5
|
+
local
|
|
6
|
+
fun failEq b a =
|
|
7
|
+
Fail ("Expected: " ^ b, "Got: " ^ a)
|
|
8
|
+
|
|
9
|
+
fun failExn b a =
|
|
10
|
+
Fail ("Expected: " ^ b, "Raised: " ^ a)
|
|
11
|
+
|
|
12
|
+
fun exnName (e: exn): string = General.exnName e
|
|
13
|
+
in
|
|
14
|
+
fun truthy a =
|
|
15
|
+
if a
|
|
16
|
+
then Pass
|
|
17
|
+
else failEq "true" "false"
|
|
18
|
+
|
|
19
|
+
fun falsy a =
|
|
20
|
+
if a
|
|
21
|
+
then failEq "false" "true"
|
|
22
|
+
else Pass
|
|
23
|
+
|
|
24
|
+
fun equalTo b a =
|
|
25
|
+
if a = b
|
|
26
|
+
then Pass
|
|
27
|
+
else failEq (PolyML.makestring b) (PolyML.makestring a)
|
|
28
|
+
|
|
29
|
+
fun nearTo b a =
|
|
30
|
+
if Real.== (a, b)
|
|
31
|
+
then Pass
|
|
32
|
+
else failEq (Real.toString b) (Real.toString a)
|
|
33
|
+
|
|
34
|
+
fun anyError f =
|
|
35
|
+
(
|
|
36
|
+
f ();
|
|
37
|
+
failExn "an exception" "Nothing"
|
|
38
|
+
) handle _ => Pass
|
|
39
|
+
|
|
40
|
+
fun error e f =
|
|
41
|
+
(
|
|
42
|
+
f ();
|
|
43
|
+
failExn (exnName e) "Nothing"
|
|
44
|
+
) handle e' => if exnMessage e' = exnMessage e
|
|
45
|
+
then Pass
|
|
46
|
+
else failExn (exnMessage e) (exnMessage e')
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
structure TermColor =
|
|
51
|
+
struct
|
|
52
|
+
datatype color = Red | Green | Yellow | Normal
|
|
53
|
+
|
|
54
|
+
fun f Red = "\027[31m"
|
|
55
|
+
| f Green = "\027[32m"
|
|
56
|
+
| f Yellow = "\027[33m"
|
|
57
|
+
| f Normal = "\027[0m"
|
|
58
|
+
|
|
59
|
+
fun colorize color s = (f color) ^ s ^ (f Normal)
|
|
60
|
+
|
|
61
|
+
val redit = colorize Red
|
|
62
|
+
|
|
63
|
+
val greenit = colorize Green
|
|
64
|
+
|
|
65
|
+
val yellowit = colorize Yellow
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
structure Test =
|
|
69
|
+
struct
|
|
70
|
+
datatype testnode = TestGroup of string * testnode list
|
|
71
|
+
| Test of string * (unit -> Expect.expectation)
|
|
72
|
+
|
|
73
|
+
local
|
|
74
|
+
datatype evaluation = Success of string
|
|
75
|
+
| Failure of string * string * string
|
|
76
|
+
| Error of string * string
|
|
77
|
+
|
|
78
|
+
fun indent n s = (implode (List.tabulate (n, fn _ => #" "))) ^ s
|
|
79
|
+
|
|
80
|
+
fun fmt indentlvl ev =
|
|
81
|
+
let
|
|
82
|
+
val check = TermColor.greenit "\226\156\148 " (* ✔ *)
|
|
83
|
+
val cross = TermColor.redit "\226\156\150 " (* ✖ *)
|
|
84
|
+
val indentlvl = indentlvl * 2
|
|
85
|
+
in
|
|
86
|
+
case ev of
|
|
87
|
+
Success descr => indent indentlvl (check ^ descr)
|
|
88
|
+
| Failure (descr, exp, got) =>
|
|
89
|
+
String.concatWith "\n" [indent indentlvl (cross ^ descr),
|
|
90
|
+
indent (indentlvl + 2) exp,
|
|
91
|
+
indent (indentlvl + 2) got]
|
|
92
|
+
| Error (descr, reason) =>
|
|
93
|
+
String.concatWith "\n" [indent indentlvl (cross ^ descr),
|
|
94
|
+
indent (indentlvl + 2) (TermColor.redit reason)]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
fun eval (TestGroup _) = raise Fail "Only a 'Test' can be evaluated"
|
|
98
|
+
| eval (Test (descr, thunk)) =
|
|
99
|
+
(
|
|
100
|
+
case thunk () of
|
|
101
|
+
Expect.Pass => ((1, 0, 0), Success descr)
|
|
102
|
+
| Expect.Fail (s, s') => ((0, 1, 0), Failure (descr, s, s'))
|
|
103
|
+
)
|
|
104
|
+
handle e => ((0, 0, 1), Error (descr, "Unexpected error: " ^ exnMessage e))
|
|
105
|
+
|
|
106
|
+
fun flatten depth testnode =
|
|
107
|
+
let
|
|
108
|
+
fun sum (x, y, z) (a, b, c) = (x + a, y + b, z + c)
|
|
109
|
+
|
|
110
|
+
fun aux (t, (counter, acc)) =
|
|
111
|
+
let
|
|
112
|
+
val (counter', texts) = flatten (depth + 1) t
|
|
113
|
+
in
|
|
114
|
+
(sum counter' counter, texts :: acc)
|
|
115
|
+
end
|
|
116
|
+
in
|
|
117
|
+
case testnode of
|
|
118
|
+
TestGroup (descr, ts) =>
|
|
119
|
+
let
|
|
120
|
+
val (counter, texts) = foldr aux ((0, 0, 0), []) ts
|
|
121
|
+
in
|
|
122
|
+
(counter, (indent (depth * 2) descr) :: List.concat texts)
|
|
123
|
+
end
|
|
124
|
+
| Test _ =>
|
|
125
|
+
let
|
|
126
|
+
val (counter, evaluation) = eval testnode
|
|
127
|
+
in
|
|
128
|
+
(counter, [fmt depth evaluation])
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
fun println s = print (s ^ "\n")
|
|
133
|
+
in
|
|
134
|
+
fun run suite =
|
|
135
|
+
let
|
|
136
|
+
val ((succeeded, failed, errored), texts) = flatten 0 suite
|
|
137
|
+
|
|
138
|
+
val summary = String.concatWith ", " [
|
|
139
|
+
TermColor.greenit ((Int.toString succeeded) ^ " passed"),
|
|
140
|
+
TermColor.redit ((Int.toString failed) ^ " failed"),
|
|
141
|
+
TermColor.redit ((Int.toString errored) ^ " errored"),
|
|
142
|
+
(Int.toString (succeeded + failed + errored)) ^ " total"
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
val status = if failed = 0 andalso errored = 0
|
|
146
|
+
then OS.Process.success
|
|
147
|
+
else OS.Process.failure
|
|
148
|
+
|
|
149
|
+
in
|
|
150
|
+
List.app println texts;
|
|
151
|
+
println "";
|
|
152
|
+
println ("Tests: " ^ summary);
|
|
153
|
+
OS.Process.exit status
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
fun describe description tests = Test.TestGroup (description, tests)
|
|
159
|
+
fun test description thunk = Test.Test (description, thunk)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## Hints
|
|
2
|
+
|
|
3
|
+
If the argument is not less than `1` raise the exception [`Domain`](http://sml-family.org/Basis/general.html#SIG:GENERAL.Domain:EXN).
|
|
4
|
+
|
|
5
|
+
Some of these concepts may be helpful:
|
|
6
|
+
|
|
7
|
+
- [Lazy evaluation](https://en.wikipedia.org/wiki/Lazy_evaluation)
|
|
8
|
+
- Sieving (for instance [Sieve of Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes)
|
|
9
|
+
- Primality by [trial division](https://en.wikipedia.org/wiki/Trial_divisio://en.wikipedia.org/wiki/Trial_division)
|
|
@@ -8,19 +8,46 @@ the 6th prime is 13.
|
|
|
8
8
|
If your language provides methods in the standard library to deal with prime
|
|
9
9
|
numbers, pretend they don't exist and implement them yourself.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Hints
|
|
12
|
+
|
|
13
|
+
If the argument is not less than `1` raise the exception [`Domain`](http://sml-family.org/Basis/general.html#SIG:GENERAL.Domain:EXN).
|
|
14
|
+
|
|
15
|
+
Some of these concepts may be helpful:
|
|
16
|
+
|
|
17
|
+
- [Lazy evaluation](https://en.wikipedia.org/wiki/Lazy_evaluation)
|
|
18
|
+
- Sieving (for instance [Sieve of Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes)
|
|
19
|
+
- Primality by [trial division](https://en.wikipedia.org/wiki/Trial_divisio://en.wikipedia.org/wiki/Trial_division)
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
|
|
22
|
+
## Loading your exercise implementation in PolyML
|
|
14
23
|
|
|
15
24
|
```
|
|
16
|
-
$ poly
|
|
25
|
+
$ poly --use {exercise}.sml
|
|
17
26
|
```
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
Or:
|
|
29
|
+
|
|
20
30
|
```
|
|
21
|
-
$ poly
|
|
31
|
+
$ poly
|
|
32
|
+
> use "{exercise}.sml";
|
|
22
33
|
```
|
|
23
34
|
|
|
35
|
+
**Note:** You have to replace {exercise}.
|
|
36
|
+
|
|
37
|
+
## Running the tests
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
$ poly -q --use test.sml
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Feedback, Issues, Pull Requests
|
|
44
|
+
|
|
45
|
+
The [exercism/sml](https://github.com/exercism/sml) repository on
|
|
46
|
+
GitHub is the home for all of the Standard ML exercises.
|
|
47
|
+
|
|
48
|
+
If you have feedback about an exercise, or want to help implementing a new
|
|
49
|
+
one, head over there and create an issue. We'll do our best to help you!
|
|
50
|
+
|
|
24
51
|
## Source
|
|
25
52
|
|
|
26
53
|
A variation on Problem 7 at Project Euler [http://projecteuler.net/problem=7](http://projecteuler.net/problem=7)
|
|
@@ -1,47 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
fun
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
fun nthPrime n =
|
|
2
|
+
let
|
|
3
|
+
fun isPrime n =
|
|
4
|
+
if n = 2
|
|
5
|
+
then true
|
|
6
|
+
else if n < 2 orelse n mod 2 = 0
|
|
7
|
+
then false
|
|
8
|
+
else
|
|
9
|
+
let
|
|
10
|
+
fun loop i =
|
|
11
|
+
if i * i > n
|
|
12
|
+
then true
|
|
13
|
+
else if n mod i = 0
|
|
14
|
+
then false
|
|
15
|
+
else loop (i + 2)
|
|
16
|
+
in
|
|
17
|
+
loop 3
|
|
18
|
+
end
|
|
9
19
|
|
|
10
|
-
fun
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
fun factors' 0 acc = acc
|
|
21
|
-
| factors' c acc = if (n mod c) = 0
|
|
22
|
-
then factors' (c-1) (c :: acc)
|
|
23
|
-
else factors' (c-1) acc
|
|
24
|
-
in
|
|
25
|
-
factors' (n div 2) []
|
|
26
|
-
end
|
|
27
|
-
in
|
|
28
|
-
(List.length (factors n)) = 1
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
fun nextPrime n = let
|
|
32
|
-
val nextN = if (n mod 2) = 0 then n + 1 else n + 2
|
|
33
|
-
in
|
|
34
|
-
if isPrime nextN then nextN else nextPrime nextN
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
in
|
|
38
|
-
Cons(n, fn () => (allPrimes (nextPrime n)))
|
|
39
|
-
end ;
|
|
40
|
-
|
|
41
|
-
fun nthPrime n = let
|
|
42
|
-
fun nthPrime' 0 s = hd s
|
|
43
|
-
| nthPrime' n s = nthPrime' (n-1) (next s)
|
|
44
|
-
in
|
|
45
|
-
if n <= 0 then raise Domain
|
|
46
|
-
else nthPrime' (n-1) (allPrimes 2)
|
|
47
|
-
end ;
|
|
20
|
+
fun loop i m =
|
|
21
|
+
case (i = n, isPrime m) of
|
|
22
|
+
(true , true) => m
|
|
23
|
+
| (false, true) => loop (i + 1) (m + 1)
|
|
24
|
+
| (_ , _ ) => loop i (m + 1)
|
|
25
|
+
in
|
|
26
|
+
if n < 1
|
|
27
|
+
then raise Domain
|
|
28
|
+
else loop 1 2
|
|
29
|
+
end
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
fun nthPrime (n: int): int =
|
|
2
|
-
raise Fail "'
|
|
2
|
+
raise Fail "'prime' is not implemented"
|
|
@@ -1,71 +1,27 @@
|
|
|
1
|
+
(* version 1.0.0 *)
|
|
2
|
+
|
|
3
|
+
use "testlib.sml";
|
|
1
4
|
use "nth-prime.sml";
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
description = "The first prime is 2",
|
|
6
|
-
input = 1,
|
|
7
|
-
expected = 2
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
description = "The second prime is 3",
|
|
11
|
-
input = 2,
|
|
12
|
-
expected = 3
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
description = "The ninth prime is 23",
|
|
16
|
-
input = 9,
|
|
17
|
-
expected = 23
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
description = "The one-hundredth prime is 541",
|
|
21
|
-
input = 100,
|
|
22
|
-
expected = 541
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
description = "The three-thousand and first prime is 27457",
|
|
26
|
-
input = 3001,
|
|
27
|
-
expected = 27457
|
|
28
|
-
}
|
|
29
|
-
];
|
|
6
|
+
infixr |>
|
|
7
|
+
fun x |> f = f x
|
|
30
8
|
|
|
31
|
-
val
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
expected = Domain
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
description = "The -1st prime is not defined",
|
|
39
|
-
input = ~1,
|
|
40
|
-
expected = Domain
|
|
41
|
-
}
|
|
42
|
-
];
|
|
9
|
+
val testsuite =
|
|
10
|
+
describe "nth-prime" [
|
|
11
|
+
test "first prime"
|
|
12
|
+
(fn _ => nthPrime 1 |> Expect.equalTo 2),
|
|
43
13
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
fun aux { description, is_correct } =
|
|
48
|
-
let
|
|
49
|
-
val expl = description ^ ": " ^
|
|
50
|
-
(if is_correct then "PASSED" else "FAILED") ^ "\n"
|
|
51
|
-
in
|
|
52
|
-
(print (expl); is_correct)
|
|
53
|
-
end
|
|
54
|
-
in
|
|
55
|
-
(aux x) :: run_tests f xs
|
|
56
|
-
end
|
|
14
|
+
test "second prime"
|
|
15
|
+
(fn _ => nthPrime 2 |> Expect.equalTo 3),
|
|
57
16
|
|
|
58
|
-
|
|
59
|
-
|
|
17
|
+
test "sixth prime"
|
|
18
|
+
(fn _ => nthPrime 6 |> Expect.equalTo 13),
|
|
60
19
|
|
|
61
|
-
|
|
62
|
-
|
|
20
|
+
test "big prime"
|
|
21
|
+
(fn _ => nthPrime 10001 |> Expect.equalTo 104743),
|
|
63
22
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
val failedTests = List.filter (fn x => not x) testResults;
|
|
23
|
+
test "there is no zeroth prime"
|
|
24
|
+
(fn _ => (fn _ => nthPrime 0) |> Expect.error Domain)
|
|
25
|
+
]
|
|
68
26
|
|
|
69
|
-
|
|
70
|
-
then (print "ALL TESTS PASSED")
|
|
71
|
-
else (print (Int.toString (List.length failedTests) ^ " TEST(S) FAILED"));
|
|
27
|
+
val _ = Test.run testsuite
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
structure Expect =
|
|
2
|
+
struct
|
|
3
|
+
datatype expectation = Pass | Fail of string * string
|
|
4
|
+
|
|
5
|
+
local
|
|
6
|
+
fun failEq b a =
|
|
7
|
+
Fail ("Expected: " ^ b, "Got: " ^ a)
|
|
8
|
+
|
|
9
|
+
fun failExn b a =
|
|
10
|
+
Fail ("Expected: " ^ b, "Raised: " ^ a)
|
|
11
|
+
|
|
12
|
+
fun exnName (e: exn): string = General.exnName e
|
|
13
|
+
in
|
|
14
|
+
fun truthy a =
|
|
15
|
+
if a
|
|
16
|
+
then Pass
|
|
17
|
+
else failEq "true" "false"
|
|
18
|
+
|
|
19
|
+
fun falsy a =
|
|
20
|
+
if a
|
|
21
|
+
then failEq "false" "true"
|
|
22
|
+
else Pass
|
|
23
|
+
|
|
24
|
+
fun equalTo b a =
|
|
25
|
+
if a = b
|
|
26
|
+
then Pass
|
|
27
|
+
else failEq (PolyML.makestring b) (PolyML.makestring a)
|
|
28
|
+
|
|
29
|
+
fun nearTo b a =
|
|
30
|
+
if Real.== (a, b)
|
|
31
|
+
then Pass
|
|
32
|
+
else failEq (Real.toString b) (Real.toString a)
|
|
33
|
+
|
|
34
|
+
fun anyError f =
|
|
35
|
+
(
|
|
36
|
+
f ();
|
|
37
|
+
failExn "an exception" "Nothing"
|
|
38
|
+
) handle _ => Pass
|
|
39
|
+
|
|
40
|
+
fun error e f =
|
|
41
|
+
(
|
|
42
|
+
f ();
|
|
43
|
+
failExn (exnName e) "Nothing"
|
|
44
|
+
) handle e' => if exnMessage e' = exnMessage e
|
|
45
|
+
then Pass
|
|
46
|
+
else failExn (exnMessage e) (exnMessage e')
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
structure TermColor =
|
|
51
|
+
struct
|
|
52
|
+
datatype color = Red | Green | Yellow | Normal
|
|
53
|
+
|
|
54
|
+
fun f Red = "\027[31m"
|
|
55
|
+
| f Green = "\027[32m"
|
|
56
|
+
| f Yellow = "\027[33m"
|
|
57
|
+
| f Normal = "\027[0m"
|
|
58
|
+
|
|
59
|
+
fun colorize color s = (f color) ^ s ^ (f Normal)
|
|
60
|
+
|
|
61
|
+
val redit = colorize Red
|
|
62
|
+
|
|
63
|
+
val greenit = colorize Green
|
|
64
|
+
|
|
65
|
+
val yellowit = colorize Yellow
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
structure Test =
|
|
69
|
+
struct
|
|
70
|
+
datatype testnode = TestGroup of string * testnode list
|
|
71
|
+
| Test of string * (unit -> Expect.expectation)
|
|
72
|
+
|
|
73
|
+
local
|
|
74
|
+
datatype evaluation = Success of string
|
|
75
|
+
| Failure of string * string * string
|
|
76
|
+
| Error of string * string
|
|
77
|
+
|
|
78
|
+
fun indent n s = (implode (List.tabulate (n, fn _ => #" "))) ^ s
|
|
79
|
+
|
|
80
|
+
fun fmt indentlvl ev =
|
|
81
|
+
let
|
|
82
|
+
val check = TermColor.greenit "\226\156\148 " (* ✔ *)
|
|
83
|
+
val cross = TermColor.redit "\226\156\150 " (* ✖ *)
|
|
84
|
+
val indentlvl = indentlvl * 2
|
|
85
|
+
in
|
|
86
|
+
case ev of
|
|
87
|
+
Success descr => indent indentlvl (check ^ descr)
|
|
88
|
+
| Failure (descr, exp, got) =>
|
|
89
|
+
String.concatWith "\n" [indent indentlvl (cross ^ descr),
|
|
90
|
+
indent (indentlvl + 2) exp,
|
|
91
|
+
indent (indentlvl + 2) got]
|
|
92
|
+
| Error (descr, reason) =>
|
|
93
|
+
String.concatWith "\n" [indent indentlvl (cross ^ descr),
|
|
94
|
+
indent (indentlvl + 2) (TermColor.redit reason)]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
fun eval (TestGroup _) = raise Fail "Only a 'Test' can be evaluated"
|
|
98
|
+
| eval (Test (descr, thunk)) =
|
|
99
|
+
(
|
|
100
|
+
case thunk () of
|
|
101
|
+
Expect.Pass => ((1, 0, 0), Success descr)
|
|
102
|
+
| Expect.Fail (s, s') => ((0, 1, 0), Failure (descr, s, s'))
|
|
103
|
+
)
|
|
104
|
+
handle e => ((0, 0, 1), Error (descr, "Unexpected error: " ^ exnMessage e))
|
|
105
|
+
|
|
106
|
+
fun flatten depth testnode =
|
|
107
|
+
let
|
|
108
|
+
fun sum (x, y, z) (a, b, c) = (x + a, y + b, z + c)
|
|
109
|
+
|
|
110
|
+
fun aux (t, (counter, acc)) =
|
|
111
|
+
let
|
|
112
|
+
val (counter', texts) = flatten (depth + 1) t
|
|
113
|
+
in
|
|
114
|
+
(sum counter' counter, texts :: acc)
|
|
115
|
+
end
|
|
116
|
+
in
|
|
117
|
+
case testnode of
|
|
118
|
+
TestGroup (descr, ts) =>
|
|
119
|
+
let
|
|
120
|
+
val (counter, texts) = foldr aux ((0, 0, 0), []) ts
|
|
121
|
+
in
|
|
122
|
+
(counter, (indent (depth * 2) descr) :: List.concat texts)
|
|
123
|
+
end
|
|
124
|
+
| Test _ =>
|
|
125
|
+
let
|
|
126
|
+
val (counter, evaluation) = eval testnode
|
|
127
|
+
in
|
|
128
|
+
(counter, [fmt depth evaluation])
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
fun println s = print (s ^ "\n")
|
|
133
|
+
in
|
|
134
|
+
fun run suite =
|
|
135
|
+
let
|
|
136
|
+
val ((succeeded, failed, errored), texts) = flatten 0 suite
|
|
137
|
+
|
|
138
|
+
val summary = String.concatWith ", " [
|
|
139
|
+
TermColor.greenit ((Int.toString succeeded) ^ " passed"),
|
|
140
|
+
TermColor.redit ((Int.toString failed) ^ " failed"),
|
|
141
|
+
TermColor.redit ((Int.toString errored) ^ " errored"),
|
|
142
|
+
(Int.toString (succeeded + failed + errored)) ^ " total"
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
val status = if failed = 0 andalso errored = 0
|
|
146
|
+
then OS.Process.success
|
|
147
|
+
else OS.Process.failure
|
|
148
|
+
|
|
149
|
+
in
|
|
150
|
+
List.app println texts;
|
|
151
|
+
println "";
|
|
152
|
+
println ("Tests: " ^ summary);
|
|
153
|
+
OS.Process.exit status
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
fun describe description tests = Test.TestGroup (description, tests)
|
|
159
|
+
fun test description thunk = Test.Test (description, thunk)
|
|
@@ -17,19 +17,35 @@ Convert a number to a string, the contents of which depend on the number's facto
|
|
|
17
17
|
- 34 has four factors: 1, 2, 17, and 34.
|
|
18
18
|
- In raindrop-speak, this would be "34".
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Loading your exercise implementation in PolyML
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
```
|
|
23
|
+
$ poly --use {exercise}.sml
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or:
|
|
23
27
|
|
|
24
28
|
```
|
|
25
|
-
$ poly
|
|
29
|
+
$ poly
|
|
30
|
+
> use "{exercise}.sml";
|
|
26
31
|
```
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
**Note:** You have to replace {exercise}.
|
|
34
|
+
|
|
35
|
+
## Running the tests
|
|
36
|
+
|
|
29
37
|
```
|
|
30
|
-
$ poly --use
|
|
38
|
+
$ poly -q --use test.sml
|
|
31
39
|
```
|
|
32
40
|
|
|
41
|
+
## Feedback, Issues, Pull Requests
|
|
42
|
+
|
|
43
|
+
The [exercism/sml](https://github.com/exercism/sml) repository on
|
|
44
|
+
GitHub is the home for all of the Standard ML exercises.
|
|
45
|
+
|
|
46
|
+
If you have feedback about an exercise, or want to help implementing a new
|
|
47
|
+
one, head over there and create an issue. We'll do our best to help you!
|
|
48
|
+
|
|
33
49
|
## Source
|
|
34
50
|
|
|
35
51
|
A variation on a famous interview question intended to weed out potential candidates. [http://jumpstartlab.com](http://jumpstartlab.com)
|
|
@@ -373,6 +373,20 @@
|
|
|
373
373
|
"Integers",
|
|
374
374
|
"Logic"
|
|
375
375
|
]
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"uuid": "cf2d545c-036e-0980-3ac2-64ad54c3867e37f4cfa",
|
|
379
|
+
"slug": "triangle",
|
|
380
|
+
"core": false,
|
|
381
|
+
"unlocked_by": "leap",
|
|
382
|
+
"difficulty": 3,
|
|
383
|
+
"topics": [
|
|
384
|
+
"Control-flow (loops)",
|
|
385
|
+
"Control-flow (conditionals)",
|
|
386
|
+
"Exception handling",
|
|
387
|
+
"Integers",
|
|
388
|
+
"Mathematics"
|
|
389
|
+
]
|
|
376
390
|
}
|
|
377
391
|
],
|
|
378
392
|
"foregone": []
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Triangle
|
|
2
|
+
|
|
3
|
+
Determine if a triangle is equilateral, isosceles, or scalene.
|
|
4
|
+
|
|
5
|
+
An _equilateral_ triangle has all three sides the same length.
|
|
6
|
+
|
|
7
|
+
An _isosceles_ triangle has at least two sides the same length. (It is sometimes
|
|
8
|
+
specified as having exactly two sides the same length, but for the purposes of
|
|
9
|
+
this exercise we'll say at least two.)
|
|
10
|
+
|
|
11
|
+
A _scalene_ triangle has all sides of different lengths.
|
|
12
|
+
|
|
13
|
+
## Note
|
|
14
|
+
|
|
15
|
+
For a shape to be a triangle at all, all sides have to be of length > 0, and
|
|
16
|
+
the sum of the lengths of any two sides must be greater than or equal to the
|
|
17
|
+
length of the third side. See [Triangle Inequality](https://en.wikipedia.org/wiki/Triangle_inequality).
|
|
18
|
+
|
|
19
|
+
## Dig Deeper
|
|
20
|
+
|
|
21
|
+
The case where the sum of the lengths of two sides _equals_ that of the
|
|
22
|
+
third is known as a _degenerate_ triangle - it has zero area and looks like
|
|
23
|
+
a single line. Feel free to add your own code/tests to check for degenerate triangles.
|
|
24
|
+
|
|
25
|
+
## Setup
|
|
26
|
+
|
|
27
|
+
Go through the setup instructions for TypeScript to
|
|
28
|
+
install the necessary dependencies:
|
|
29
|
+
|
|
30
|
+
http://exercism.io/languages/typescript
|
|
31
|
+
|
|
32
|
+
## Requirements
|
|
33
|
+
|
|
34
|
+
Install assignment dependencies:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
$ yarn install
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Making the test suite pass
|
|
41
|
+
|
|
42
|
+
Execute the tests with:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
$ yarn test
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## Source
|
|
51
|
+
|
|
52
|
+
The Ruby Koans triangle project, parts 1 & 2 [http://rubykoans.com](http://rubykoans.com)
|
|
53
|
+
|
|
54
|
+
## Submitting Incomplete Solutions
|
|
55
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|