├── .appends └── .github │ └── labels.yml ├── .github ├── CODEOWNERS ├── dependabot.yml ├── labels.yml └── workflows │ ├── configlet.yml │ ├── no-important-files-changed.yml │ ├── pause-community-contributions.yml │ ├── ping-cross-track-maintainers-team.yml │ ├── sync-labels.yml │ └── test.yml ├── .gitignore ├── .scalafmt.conf ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── bin ├── fetch-configlet └── test ├── build.sbt ├── config.json ├── docs ├── ABOUT.md ├── INSTALLATION.md ├── LEARNING.md ├── RESOURCES.md ├── SNIPPET.txt ├── TESTS.md └── config.json ├── exercises ├── concept │ └── basics │ │ ├── .docs │ │ ├── after.md │ │ ├── hints.md │ │ ├── instructions.md │ │ └── introduction.md │ │ ├── .meta │ │ ├── Exemplar.scala │ │ ├── config.json │ │ └── design.md │ │ ├── build.sbt │ │ ├── project │ │ └── build.properties │ │ └── src │ │ ├── main │ │ └── scala │ │ │ └── Lasagna.scala │ │ └── test │ │ └── scala │ │ └── LasagnaTest.scala ├── practice │ ├── accumulate │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Accumulate.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── AccumulateTest.scala │ ├── acronym │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── findallin │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ └── split │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Acronym.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── AcronymTest.scala │ ├── all-your-base │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── AllYourBase.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── AllYourBaseTest.scala │ ├── allergies │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Allergies.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── AllergiesTest.scala │ ├── alphametics │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Alphametics.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── AlphameticsTest.scala │ ├── anagram │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Anagram.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── AnagramTest.scala │ ├── armstrong-numbers │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ ├── iterate-takewhile-last │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── tostring-map-sum │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── ArmstrongNumbers.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── ArmstrongNumbersTest.scala │ ├── atbash-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── AtbashCipher.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── AtbashCipherTest.scala │ ├── bank-account │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ └── config.json │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── BankAccount.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── BankAccountTest.scala │ ├── beer-song │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── BeerSong.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── BeerSongTest.scala │ ├── binary-search-tree │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Bst.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── BstTest.scala │ ├── binary-search │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── BinarySearch.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── BinarySearchTest.scala │ ├── binary │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Binary.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── BinaryTest.scala │ ├── bob │ │ ├── .approaches │ │ │ ├── answers-vector │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ ├── if-expressions │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ └── match-expression │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Bob.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── BobTest.scala │ ├── book-store │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── BookStore.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── BookStoreTest.scala │ ├── bottle-song │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── BottleSong.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── BottleSongTest.scala │ ├── bowling │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Bowling.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── BowlingTest.scala │ ├── change │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Change.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── ChangeTest.scala │ ├── circular-buffer │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── CircularBuffer.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── CircularBufferTest.scala │ ├── clock │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Clock.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── ClockTest.scala │ ├── collatz-conjecture │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── filter-map-stream-takewhile │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ └── match-recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── CollatzConjecture.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── CollatzConjectureTest.scala │ ├── complex-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── ComplexNumber.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── ComplexNumberTest.scala │ ├── connect │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Connect.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── ConnectTest.scala │ ├── crypto-square │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── CryptoSquare.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── CryptoSquareTest.scala │ ├── custom-set │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── CustomSet.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── CustomSetTest.scala │ ├── darts │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Darts.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── DartsTest.scala │ ├── diamond │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Diamond.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── DiamondTest.scala │ ├── difference-of-squares │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── DifferenceOfSquares.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── DifferenceOfSquaresTest.scala │ ├── dominoes │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Dominoes.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── DominoesTest.scala │ ├── etl │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Etl.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── EtlTest.scala │ ├── flatten-array │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── FlattenArray.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── FlattenArrayTest.scala │ ├── food-chain │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ └── move-complexity-to-data │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── FoodChain.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── FoodChainTest.scala │ ├── forth │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ ├── Forth.scala │ │ │ │ └── ForthEvaluator.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── ForthTest.scala │ ├── gigasecond │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Gigasecond.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── GigasecondTest.scala │ ├── grade-school │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── GradeSchool.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── GradeSchoolTest.scala │ ├── grains │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Grains.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── GrainsTest.scala │ ├── hamming │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── if-zip-count │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ ├── match-recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── match-zip-count │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Hamming.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── HammingTest.scala │ ├── hello-world │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── HelloWorld.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── HelloWorldTest.scala │ ├── hexadecimal │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ └── config.json │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Hexadecimal.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── HexadecimalTest.scala │ ├── high-scores │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── HighScores.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── HighScoresTest.scala │ ├── house │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── House.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── HouseTest.scala │ ├── isogram │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Isogram.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── IsogramTest.scala │ ├── killer-sudoku-helper │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── KillerSudokuHelper.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── KillerSudokuHelperTest.scala │ ├── kindergarten-garden │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Garden.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── GardenTest.scala │ ├── largest-series-product │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── LargestSeriesProduct.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── LargestSeriesProductTest.scala │ ├── leap │ │ ├── .approaches │ │ │ ├── boolean-chain │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── built-in-method │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ ├── localdate-plusdays │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── match-on-a-tuple │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── ternary-expression │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Leap.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── LeapTest.scala │ ├── lens-person │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ └── config.json │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── LensPerson.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── LensPersonTest.scala │ ├── linked-list │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Deque.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── DequeTest.scala │ ├── luhn │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── foldright │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ ├── recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── validate-scrub-foldright │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── validate-scrub-recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Luhn.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── LuhnTest.scala │ ├── matching-brackets │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── foldleft │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ └── recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── MatchingBrackets.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── MatchingBracketsTest.scala │ ├── matrix │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Matrix.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── MatrixTest.scala │ ├── meetup │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Meetup.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── MeetupTest.scala │ ├── minesweeper │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Minesweeper.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── MinesweeperTest.scala │ ├── nth-prime │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── NthPrime.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── NthPrimeTest.scala │ ├── nucleotide-count │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── foldleft-match │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ ├── recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── validate-map-count │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── NucleotideCount.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── NucleotideCountTest.scala │ ├── ocr-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── OcrNumbers.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── OcrNumbersTest.scala │ ├── octal │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ └── config.json │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Octal.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── OctalTest.scala │ ├── palindrome-products │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── PalindromeProducts.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── PalindromeProductsTest.scala │ ├── pangram │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Pangrams.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── PangramTest.scala │ ├── parallel-letter-frequency │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ └── config.json │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Frequency.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── FrequencyTest.scala │ ├── pascals-triangle │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── PascalsTriangle.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── PascalsTriangleTest.scala │ ├── perfect-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── PerfectNumbers.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── PerfectNumbersTest.scala │ ├── phone-number │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── foldleft │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ ├── recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── regex-with-filter │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── PhoneNumber.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── PhoneNumberTest.scala │ ├── pig-latin │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ └── map-recursion-mkstring │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── PigLatin.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── PigLatinTest.scala │ ├── prime-factors │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── PrimeFactors.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── PrimeFactorsTest.scala │ ├── protein-translation │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── grouped-map-takewhile │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── if-else-match-recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── introduction.md │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── ProteinTranslation.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── ProteinTranslationTest.scala │ ├── pythagorean-triplet │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── PythagoreanTriplet.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── PythagoreanTripletTest.scala │ ├── queen-attack │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── QueenAttack.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── QueenAttackTest.scala │ ├── rail-fence-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── RailFenceCipher.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── RailFenceCipherTest.scala │ ├── raindrops │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ ├── list-foldright-match │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── sortedmap-filterkeys-match │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Raindrops.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── RaindropsTest.scala │ ├── reverse-string │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── ReverseString.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── ReverseStringTest.scala │ ├── rna-transcription │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── RnaTranscription.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── RnaTranscriptionTest.scala │ ├── robot-name │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ ├── random-add-to-used-names │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── sequential-take-from-shuffled-names │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ └── config.json │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── RobotName.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── RobotNameTest.scala │ ├── robot-simulator │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── foldleft │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ └── recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ ├── Robot.scala │ │ │ │ └── RobotSimulator.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── RobotSimulatorTest.scala │ ├── roman-numerals │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ ├── iterate-takewhile-last │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── map-recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── vectors-recursion │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── RomanNumerals.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── RomanNumeralsTest.scala │ ├── rotational-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── RotationalCipher.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── RotationalCipherTest.scala │ ├── run-length-encoding │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── RunLengthEncoding.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── RunLengthEncodingTest.scala │ ├── saddle-points │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── SaddlePoints.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SaddlePointsTest.scala │ ├── say │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Say.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SayTest.scala │ ├── scrabble-score │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ ├── map-with-map │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── match-with-map │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── ScrabbleScore.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── ScrabbleScoreTest.scala │ ├── secret-handshake │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── foldleft-and-reverse │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── foldleft-with-appended-or-prepended │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── introduction.md │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── SecretHandshake.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SecretHandshakeTest.scala │ ├── series │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Series.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SeriesTest.scala │ ├── sgf-parsing │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Sgf.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SgfTest.scala │ ├── sieve │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Sieve.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SieveTest.scala │ ├── simple-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Cipher.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── CipherTest.scala │ ├── simple-linked-list │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ └── config.json │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── SimpleLinkedList.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SimpleLinkedListTest.scala │ ├── space-age │ │ ├── .approaches │ │ │ ├── applydynamic │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ ├── currying │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ └── partial-application │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── SpaceAge.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SpaceAgeTest.scala │ ├── spiral-matrix │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── SpiralMatrix.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SpiralMatrixTest.scala │ ├── strain │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ └── config.json │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Strain.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── StrainTest.scala │ ├── sublist │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Sublist.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SublistTest.scala │ ├── sum-of-multiples │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── SumOfMultiples.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── SumOfMultiplesTest.scala │ ├── triangle │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Triangle.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── TriangleTest.scala │ ├── trinary │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Trinary.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── TrinaryTest.scala │ ├── two-fer │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Twofer.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── TwoferTest.scala │ ├── variable-length-quantity │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── VariableLengthQuantity.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── VariableLengthQuantityTest.scala │ ├── word-count │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── WordCount.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── WordCountTest.scala │ ├── wordy │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Wordy.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── WordyTest.scala │ ├── yacht │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── Yacht.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── YachtTest.scala │ ├── zebra-puzzle │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── Example.scala │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ │ └── build.properties │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── ZebraPuzzle.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── ZebraPuzzleTest.scala │ └── zipper │ │ ├── .docs │ │ └── instructions.md │ │ ├── .meta │ │ ├── Example.scala │ │ ├── config.json │ │ └── tests.toml │ │ ├── build.sbt │ │ ├── project │ │ └── build.properties │ │ └── src │ │ ├── main │ │ └── scala │ │ │ └── Zipper.scala │ │ └── test │ │ └── scala │ │ └── ZipperTest.scala └── shared │ └── .docs │ ├── help.md │ └── tests.md ├── project ├── build.properties └── plugins.sbt ├── reference ├── exercise-concepts │ ├── accumulate.md │ ├── flatten-array.md │ ├── hamming.md │ ├── hello-world.md │ ├── leap.md │ ├── raindrops.md │ ├── scrabble-score.md │ └── space-age.md └── implementing-a-concept-exercise.md └── testgen └── src └── main ├── resources └── version-check-ignore.txt ├── scala └── testgen │ ├── CanonicalDataParser.scala │ ├── TestGenError.scala │ ├── TestGenerator.scala │ ├── TestGeneratorRunner.scala │ └── generator │ └── WordCountTestGenerator.scala └── twirl └── funSuiteTemplate.scala.txt /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners 2 | .github/CODEOWNERS @exercism/maintainers-admin 3 | 4 | # Changes to `fetch-configlet` should be made in the `exercism/configlet` repo 5 | bin/fetch-configlet @exercism/maintainers-admin 6 | 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | 5 | # Keep dependencies for GitHub Actions up-to-date 6 | - package-ecosystem: 'github-actions' 7 | directory: '/' 8 | schedule: 9 | interval: 'monthly' 10 | -------------------------------------------------------------------------------- /.github/workflows/configlet.yml: -------------------------------------------------------------------------------- 1 | name: Configlet 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | workflow_dispatch: 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | configlet: 15 | uses: exercism/github-actions/.github/workflows/configlet.yml@main 16 | -------------------------------------------------------------------------------- /.github/workflows/ping-cross-track-maintainers-team.yml: -------------------------------------------------------------------------------- 1 | name: Ping cross-track maintainers team 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | 8 | permissions: 9 | pull-requests: write 10 | 11 | jobs: 12 | ping: 13 | if: github.repository_owner == 'exercism' # Stops this job from running on forks 14 | uses: exercism/github-actions/.github/workflows/ping-cross-track-maintainers-team.yml@main 15 | secrets: 16 | github_membership_token: ${{ secrets.COMMUNITY_CONTRIBUTIONS_WORKFLOW_TOKEN }} 17 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yml: -------------------------------------------------------------------------------- 1 | name: Tools 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - .github/labels.yml 9 | - .github/workflows/sync-labels.yml 10 | workflow_dispatch: 11 | schedule: 12 | - cron: 0 0 1 * * # First day of each month 13 | 14 | permissions: 15 | issues: write 16 | 17 | jobs: 18 | sync-labels: 19 | uses: exercism/github-actions/.github/workflows/labels.yml@main 20 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Scala / Test 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | workflow_dispatch: 8 | 9 | jobs: 10 | ci: 11 | runs-on: ubuntu-22.04 12 | 13 | steps: 14 | - name: Checkout repository 15 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 16 | 17 | - name: Run tests for all exercises 18 | run: bin/test 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | *.swp 3 | .DS_Store 4 | .idea 5 | .vscode 6 | tmp 7 | target/ 8 | bin/configlet 9 | bin/configlet.exe 10 | 11 | .bsp/ 12 | 13 | # metals workflow junk, shouldn't be commited 14 | .bloop/ 15 | .metals/ 16 | 17 | project/* 18 | !project/build.properties 19 | !project/plugins.sbt 20 | project/target 21 | src/test/scala/project/ 22 | target 23 | 24 | generated 25 | -------------------------------------------------------------------------------- /.scalafmt.conf: -------------------------------------------------------------------------------- 1 | version = "3.8.2" 2 | align.preset = most 3 | maxColumn = 160 4 | trailingCommas = always 5 | continuationIndent.callSite = 2 6 | continuationIndent.defnSite = 2 7 | runner.dialect = scala3 8 | rewrite.scala3.convertToNewSyntax = yes 9 | rewrite.scala3.removeOptionalBraces = yes 10 | -------------------------------------------------------------------------------- /docs/SNIPPET.txt: -------------------------------------------------------------------------------- 1 | object HelloWorld { 2 | def hello() = "Hello, World!" 3 | } 4 | 5 | -------------------------------------------------------------------------------- /exercises/concept/basics/.meta/Exemplar.scala: -------------------------------------------------------------------------------- 1 | class Lasagna { 2 | 3 | def remainingMinutesInOven(actualMinutesInOven: Int): Int = 4 | expectedMinutesInOven() - actualMinutesInOven 5 | 6 | def expectedMinutesInOven(): Int = 40 7 | 8 | def elapsedTimeInMinutes(numberOfLayers: Int, actualMinutesInOven: Int): Int = 9 | preparationTimeInMinutes(numberOfLayers) + actualMinutesInOven 10 | 11 | def preparationTimeInMinutes(numberOfLayers: Int): Int = numberOfLayers * 2 12 | 13 | } 14 | -------------------------------------------------------------------------------- /exercises/concept/basics/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "stillleben" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/main/scala/Lasagna.scala" 8 | ], 9 | "test": [ 10 | "src/test/scala/LasagnaTest.scala" 11 | ], 12 | "exemplar": [ 13 | ".meta/Exemplar.scala" 14 | ], 15 | "invalidator": [ 16 | "build.sbt" 17 | ] 18 | }, 19 | "forked_from": [ 20 | "csharp/lucians-luscious-lasagna" 21 | ], 22 | "blurb": "TODO: add blurb for basics exercise" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/concept/basics/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/concept/basics/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/concept/basics/src/main/scala/Lasagna.scala: -------------------------------------------------------------------------------- 1 | class Lasagna { 2 | // TODO: define the 'expectedMinutesInOven()' method 3 | 4 | // TODO: define the 'remainingMinutesInOven()' method 5 | 6 | // TODO: define the 'preparationTimeInMinutes()' method 7 | 8 | // TODO: define the 'elapsedTimeInMinutes()' method 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | class Accumulate { 2 | def accumulate[A, B](f: (A) => B, list : List[A]): List[B] = 3 | list match { 4 | case Nil => Nil 5 | case x::xs => f(x) :: accumulate(f, xs) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/src/main/scala/Accumulate.scala: -------------------------------------------------------------------------------- 1 | class Accumulate { 2 | def accumulate[A, B](f: (A) => B, list : List[A]): List[B] = ??? 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": [ 4 | "bobahop" 5 | ] 6 | }, 7 | "approaches": [ 8 | { 9 | "uuid": "83f3d79b-fc07-4160-87e5-e11e21d31ac2", 10 | "slug": "split", 11 | "title": "split", 12 | "blurb": "Use split to get the words.", 13 | "authors": [ 14 | "bobahop" 15 | ] 16 | }, 17 | { 18 | "uuid": "986e4b72-1a7a-4684-9dd1-280537d285c8", 19 | "slug": "findallin", 20 | "title": "findAllIn", 21 | "blurb": "Use findAllIn to get the words.", 22 | "authors": [ 23 | "bobahop" 24 | ] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.approaches/findallin/snippet.txt: -------------------------------------------------------------------------------- 1 | object Acronym { 2 | def abbreviate(phrase: String): String = { 3 | raw"[\p{L}']+".r 4 | .findAllIn(phrase) 5 | .map(_.head.toUpper) 6 | .mkString 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.approaches/split/snippet.txt: -------------------------------------------------------------------------------- 1 | object Acronym { 2 | def abbreviate(phrase: String): String = raw"[\s-]+".r 3 | .split(phrase) 4 | .map(_.head.toUpper) 5 | .mkString 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Convert a phrase to its acronym. 4 | 5 | Techies love their TLA (Three Letter Acronyms)! 6 | 7 | Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG). 8 | 9 | Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input. 10 | 11 | For example: 12 | 13 | | Input | Output | 14 | | ------------------------- | ------ | 15 | | As Soon As Possible | ASAP | 16 | | Liquid-crystal display | LCD | 17 | | Thank George It's Friday! | TGIF | 18 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Acronym { 2 | def abbreviate(phrase: String): String = { 3 | "('\\w+)|(\\w+'\\w+)|(\\w+')|(\\w+)".r 4 | .findAllIn(phrase) 5 | .map(_.head.toUpper) 6 | .mkString 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "abo64", 7 | "ErikSchierboom", 8 | "ppartarr", 9 | "rajeshpg" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/Acronym.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/AcronymTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Convert a long phrase to its acronym.", 26 | "source": "Julien Vanier", 27 | "source_url": "https://github.com/monkbroc" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/acronym/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/acronym/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/acronym/src/main/scala/Acronym.scala: -------------------------------------------------------------------------------- 1 | object Acronym { 2 | def abbreviate(phrase: String): String = ??? 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You've just been hired as professor of mathematics. 4 | Your first week went well, but something is off in your second week. 5 | The problem is that every answer given by your students is wrong! 6 | Luckily, your math skills have allowed you to identify the problem: the student answers _are_ correct, but they're all in base 2 (binary)! 7 | Amazingly, it turns out that each week, the students use a different base. 8 | To help you quickly verify the student answers, you'll be building a tool to translate between bases. 9 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "abo64", 7 | "ErikSchierboom", 8 | "ppartarr", 9 | "rajeshpg" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/AllYourBase.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/AllYourBaseTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Convert a number, represented as a sequence of digits in one base, to any other base." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/src/main/scala/AllYourBase.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/all-your-base/src/main/scala/AllYourBase.scala -------------------------------------------------------------------------------- /exercises/practice/allergies/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/allergies/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/allergies/src/main/scala/Allergies.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/allergies/src/main/scala/Allergies.scala -------------------------------------------------------------------------------- /exercises/practice/alphametics/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "abo64" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg", 9 | "ricemery" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/Alphametics.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/AlphameticsTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Given an alphametics puzzle, find the correct solution." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/src/main/scala/Alphametics.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/alphametics/src/main/scala/Alphametics.scala -------------------------------------------------------------------------------- /exercises/practice/anagram/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions Append 2 | 3 | You must return the anagrams in the same order as they are listed in the candidate words. 4 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Anagram { 2 | def findAnagrams(word: String, anagrams: Seq[String]) = 3 | anagrams.filter(w => doesMatch(word, w)).filterNot(w => isIdentical(word, w)) 4 | 5 | private def doesMatch(word1: String, word2: String) = 6 | word2.toLowerCase.sorted == word1.toLowerCase.sorted 7 | 8 | private def isIdentical(word1: String, word2: String) = 9 | word2.toLowerCase == word1.toLowerCase 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/anagram/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/anagram/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/anagram/src/main/scala/Anagram.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/anagram/src/main/scala/Anagram.scala -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.approaches/iterate-takewhile-last/snippet.txt: -------------------------------------------------------------------------------- 1 | Iterator 2 | .iterate((num, 0.0, false))(tup => 3 | (tup._1 / 10, tup._2 + pow(tup._1 % 10, len), tup._1 == 0) 4 | ) 5 | .takeWhile(tup => !tup._3) 6 | .to(Seq) 7 | .last 8 | ._2 == num 9 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.approaches/recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | @tailrec 2 | def recurMe(nbr: Int, total: Double): Boolean = 3 | nbr match { 4 | case 0 => total == num 5 | case n => recurMe(n / 10, total + pow(n % 10, len)) 6 | } 7 | 8 | recurMe(num, 0.0) 9 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.approaches/tostring-map-sum/snippet.txt: -------------------------------------------------------------------------------- 1 | object ArmstrongNumbers { 2 | def isArmstrongNumber(num: Int): Boolean = { 3 | val text = num.toString() 4 | val len: Double = text.length() 5 | text.map(chr => Math.pow(chr.asDigit, len)).sum == num 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | An [Armstrong number][armstrong-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 = 1` 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 | [armstrong-number]: https://en.wikipedia.org/wiki/Narcissistic_number 15 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object ArmstrongNumbers { 2 | def isArmstrongNumber(i: Int): Boolean = { 3 | val s = i.toString 4 | val power = s.length 5 | i == s.toStream.foldLeft(0.0)((acc, c) => acc + math.pow(c.asDigit, power)) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/ArmstrongNumbers.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/ArmstrongNumbersTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Determine if a number is an Armstrong number.", 25 | "source": "Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/Narcissistic_number" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/src/main/scala/ArmstrongNumbers.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/armstrong-numbers/src/main/scala/ArmstrongNumbers.scala -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object AtbashCipher { 2 | private def substitute(c: Char) = 3 | if (c.isDigit) c.toString 4 | else if (c.isLetter) ('a' + ('z' - c.toLower)).toChar.toString 5 | else "" 6 | 7 | def encode(s: String): String = 8 | s.foldLeft("")((acc, c) => acc + substitute(c)).grouped(5).mkString(" ") 9 | 10 | def decode(s: String): String = 11 | s.foldLeft("")((acc, c) => acc + substitute(c)) 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/AtbashCipher.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/AtbashCipherTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.", 25 | "source": "Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/Atbash" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/src/main/scala/AtbashCipher.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/atbash-cipher/src/main/scala/AtbashCipher.scala -------------------------------------------------------------------------------- /exercises/practice/bank-account/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "Freshwood", 8 | "kytrinyx", 9 | "nlochschmidt", 10 | "ppartarr", 11 | "rajeshpg" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "src/main/scala/BankAccount.scala" 16 | ], 17 | "test": [ 18 | "src/test/scala/BankAccountTest.scala" 19 | ], 20 | "example": [ 21 | ".meta/Example.scala" 22 | ], 23 | "invalidator": [ 24 | "build.sbt" 25 | ] 26 | }, 27 | "blurb": "Simulate a bank account supporting opening/closing, withdraws, and deposits of money. Watch out for concurrent transactions!" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/src/main/scala/BankAccount.scala: -------------------------------------------------------------------------------- 1 | trait BankAccount { 2 | 3 | def closeAccount(): Unit 4 | 5 | def getBalance: Option[Int] 6 | 7 | def incrementBalance(increment: Int): Option[Int] 8 | } 9 | 10 | object Bank { 11 | def openAccount(): BankAccount = ??? 12 | } 13 | 14 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/src/main/scala/BeerSong.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/beer-song/src/main/scala/BeerSong.scala -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Bst.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/BstTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Insert and search for numbers in a binary tree.", 25 | "source": "Josh Cheek" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/src/main/scala/Bst.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/binary-search-tree/src/main/scala/Bst.scala -------------------------------------------------------------------------------- /exercises/practice/binary-search/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/BinarySearch.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/BinarySearchTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Implement a binary search algorithm.", 25 | "source": "Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/Binary_search_algorithm" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/src/main/scala/BinarySearch.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/binary-search/src/main/scala/BinarySearch.scala -------------------------------------------------------------------------------- /exercises/practice/binary/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | case class Binary(s: String) { 2 | val toDecimal: Int = s.foldLeft[Option[Int]](Some(0)){ 3 | case (Some(acc), '0') => Some(acc * 2) 4 | case (Some(acc), '1') => Some(acc * 2 + 1) 5 | case _ => None 6 | }.getOrElse(0) 7 | } 8 | 9 | -------------------------------------------------------------------------------- /exercises/practice/binary/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/binary/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/binary/src/main/scala/Binary.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/binary/src/main/scala/Binary.scala -------------------------------------------------------------------------------- /exercises/practice/bob/.approaches/answers-vector/snippet.txt: -------------------------------------------------------------------------------- 1 | val ANSWERS = Vector("Whatever.","Sure.","Whoa, chill out!","Calm down, I know what I'm doing!") 2 | def response(statement: String): String = { 3 | val input = statement.trim() 4 | if (input.isEmpty) return "Fine. Be that way!" 5 | val isShout = 6 | if (input.exists(_.isLetter) && input.toUpperCase() == input) 2 else 0 7 | val isQuestion = if (input.endsWith("?")) 1 else 0 8 | ANSWERS.apply(isQuestion + isShout) 9 | -------------------------------------------------------------------------------- /exercises/practice/bob/.approaches/if-expressions/snippet.txt: -------------------------------------------------------------------------------- 1 | val isShout = 2 | input.exists(_.isLetter) && input.toUpperCase() == input 3 | val isQuestion = input.endsWith("?") 4 | if (isShout) 5 | if (isQuestion) "Calm down, I know what I'm doing!" 6 | else "Whoa, chill out!" 7 | else if (isQuestion) "Sure." 8 | else "Whatever." 9 | -------------------------------------------------------------------------------- /exercises/practice/bob/.approaches/match-expression/snippet.txt: -------------------------------------------------------------------------------- 1 | val isShout = input.exists(_.isLetter) && input.toUpperCase() == input 2 | val isQuestion = input.endsWith("?") 3 | (isQuestion, isShout) match { 4 | case (true, true) => "Calm down, I know what I'm doing!" 5 | case (_, true) => "Whoa, chill out!" 6 | case (true, _) => "Sure." 7 | case _ => "Whatever." 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/bob/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Bob is a [lackadaisical][] teenager. 4 | He likes to think that he's very cool. 5 | And he definitely doesn't get excited about things. 6 | That wouldn't be cool. 7 | 8 | When people talk to him, his responses are pretty limited. 9 | 10 | [lackadaisical]: https://www.collinsdictionary.com/dictionary/english/lackadaisical 11 | -------------------------------------------------------------------------------- /exercises/practice/bob/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/bob/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/bob/src/main/scala/Bob.scala: -------------------------------------------------------------------------------- 1 | object Bob { 2 | def response(statement: String): String = ??? 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/book-store/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/book-store/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/book-store/src/main/scala/BookStore.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/book-store/src/main/scala/BookStore.scala -------------------------------------------------------------------------------- /exercises/practice/bottle-song/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "rabestro" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/main/scala/BottleSong.scala" 8 | ], 9 | "test": [ 10 | "src/test/scala/BottleSongTest.scala" 11 | ], 12 | "example": [ 13 | ".meta/Example.scala" 14 | ] 15 | }, 16 | "blurb": "Produce the lyrics to the popular children's repetitive song: Ten Green Bottles.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Ten_Green_Bottles" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/bottle-song/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test -------------------------------------------------------------------------------- /exercises/practice/bottle-song/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/bottle-song/src/main/scala/BottleSong.scala: -------------------------------------------------------------------------------- 1 | object BottleSong: 2 | 3 | def recite(startBottles: Int, takeDown: Int): String = ??? 4 | -------------------------------------------------------------------------------- /exercises/practice/bowling/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ppartarr", 7 | "rajeshpg" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "src/main/scala/Bowling.scala" 12 | ], 13 | "test": [ 14 | "src/test/scala/BowlingTest.scala" 15 | ], 16 | "example": [ 17 | ".meta/Example.scala" 18 | ], 19 | "invalidator": [ 20 | "build.sbt" 21 | ] 22 | }, 23 | "blurb": "Score a bowling game.", 24 | "source": "The Bowling Game Kata from UncleBob", 25 | "source_url": "https://web.archive.org/web/20221001111000/http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/bowling/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/bowling/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/bowling/src/main/scala/Bowling.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/bowling/src/main/scala/Bowling.scala -------------------------------------------------------------------------------- /exercises/practice/change/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Correctly determine the fewest number of coins to be given to a customer such that the sum of the coins' value would equal the correct amount of change. 4 | 5 | ## For example 6 | 7 | - An input of 15 with [1, 5, 10, 25, 100] should return one nickel (5) and one dime (10) or [5, 10] 8 | - An input of 40 with [1, 5, 10, 25, 100] should return one nickel (5) and one dime (10) and one quarter (25) or [5, 10, 25] 9 | 10 | ## Edge cases 11 | 12 | - Does your algorithm work for any given set of coins? 13 | - Can you ask for negative change? 14 | - Can you ask for a change value smaller than the smallest coin value? 15 | -------------------------------------------------------------------------------- /exercises/practice/change/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/change/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/change/src/main/scala/Change.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/change/src/main/scala/Change.scala -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/main/scala/CircularBuffer.scala" 8 | ], 9 | "test": [ 10 | "src/test/scala/CircularBufferTest.scala" 11 | ], 12 | "example": [ 13 | ".meta/Example.scala" 14 | ], 15 | "invalidator": [ 16 | "build.sbt" 17 | ] 18 | }, 19 | "blurb": "A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Circular_buffer" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/src/main/scala/CircularBuffer.scala: -------------------------------------------------------------------------------- 1 | class EmptyBufferException() extends Exception {} 2 | 3 | class FullBufferException() extends Exception {} 4 | 5 | class CircularBuffer(var capacity: Int) { 6 | 7 | def write(value: Int) = ??? 8 | 9 | def read(): Int = ??? 10 | 11 | def overwrite(value: Int) = ??? 12 | 13 | def clear() = ??? 14 | } -------------------------------------------------------------------------------- /exercises/practice/clock/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Implement a clock that handles times without dates. 4 | 5 | You should be able to add and subtract minutes to it. 6 | 7 | Two clocks that represent the same time should be equal to each other. 8 | -------------------------------------------------------------------------------- /exercises/practice/clock/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Clock.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/ClockTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Implement a clock that handles times without dates.", 25 | "source": "Pairing session with Erin Drummond" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/clock/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/clock/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/clock/src/main/scala/Clock.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/clock/src/main/scala/Clock.scala -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.approaches/filter-map-stream-takewhile/snippet.txt: -------------------------------------------------------------------------------- 1 | def steps(start: Int): Option[Int] = { 2 | Option(start) 3 | .filter(_ > 0) 4 | .map(collatzStream(_).takeWhile(_ != 1).length) 5 | } 6 | 7 | private def collatzStream(n: Int): Stream[Int] = 8 | Stream.iterate(n)(n => if (n % 2 == 0) n / 2 else (n * 3) + 1) 9 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.approaches/match-recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | private def collatzMeRecur(steps: Int, num: Int): Option[Int] = { 2 | getStatus(num) match { 3 | case ILLEGAL => None 4 | case ONE => Some(steps) 5 | case EVEN => collatzMeRecur(steps + 1, num / 2) 6 | case ODD => collatzMeRecur(steps + 1, (num * 3) + 1) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | import scala.annotation.tailrec 2 | 3 | object CollatzConjecture { 4 | 5 | def isEven(v: Int): Boolean = v % 2 == 0 6 | 7 | @tailrec 8 | def collatz_h(n: Int, acc: Int): Option[Int] = { 9 | if (n <= 0) 10 | None 11 | else if (n == 1) 12 | Some(acc) 13 | else if (isEven(n)) 14 | collatz_h(n / 2, acc + 1) 15 | else 16 | collatz_h(n * 3 + 1, acc + 1) 17 | } 18 | 19 | def steps(n: Int): Option[Int] = collatz_h(n, 0) 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/src/main/scala/CollatzConjecture.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/collatz-conjecture/src/main/scala/CollatzConjecture.scala -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/ComplexNumber.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/ComplexNumberTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Implement complex numbers.", 25 | "source": "Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/Complex_number" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/src/main/scala/ComplexNumber.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/complex-numbers/src/main/scala/ComplexNumber.scala -------------------------------------------------------------------------------- /exercises/practice/connect/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | You may notice that some test cases seem unfair. However, they may be legitimately so. For example, it is common to give young or beginner players an extra n pieces at fixed positions on the board, so mismatched piece counts can occur in an otherwise fully legal game. 3 | 4 | In any case, this exercise cares only about determining a winner for a game that can have a variety of parameters, like board length and extra pieces. It is not interested in any other state of the game, such as who moved where, when, or whose turn it is. 5 | 6 | So don't be puzzled by those seemingly unfair games. 7 | -------------------------------------------------------------------------------- /exercises/practice/connect/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "abo64", 7 | "ErikSchierboom", 8 | "kytrinyx", 9 | "petertseng", 10 | "ppartarr", 11 | "rajeshpg" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "src/main/scala/Connect.scala" 16 | ], 17 | "test": [ 18 | "src/test/scala/ConnectTest.scala" 19 | ], 20 | "example": [ 21 | ".meta/Example.scala" 22 | ], 23 | "invalidator": [ 24 | "build.sbt" 25 | ] 26 | }, 27 | "blurb": "Compute the result for a game of Hex / Polygon." 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/connect/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/connect/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/connect/src/main/scala/Connect.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/connect/src/main/scala/Connect.scala -------------------------------------------------------------------------------- /exercises/practice/crypto-square/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/src/main/scala/CryptoSquare.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/crypto-square/src/main/scala/CryptoSquare.scala -------------------------------------------------------------------------------- /exercises/practice/custom-set/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Create a custom set type. 4 | 5 | Sometimes it is necessary to define a custom data structure of some type, like a set. 6 | In this exercise you will define your own set. 7 | How it works internally doesn't matter, as long as it behaves like a set of unique elements. 8 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/CustomSet.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/CustomSetTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Create a custom set type." 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/src/main/scala/CustomSet.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/custom-set/src/main/scala/CustomSet.scala -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Darts { 2 | def score(x: Double, y: Double): Int = { 3 | val distance = math.sqrt(x * x + y * y) 4 | distance match { 5 | case _ if distance <= 1.0 => 10 6 | case _ if distance <= 5.0 => 5 7 | case _ if distance <= 10.0 => 1 8 | case _ => 0 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Darts.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/DartsTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Calculate the points scored in a single toss of a Darts game.", 25 | "source": "Inspired by an exercise created by a professor Della Paolera in Argentina" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/darts/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/darts/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/darts/src/main/scala/Darts.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/darts/src/main/scala/Darts.scala -------------------------------------------------------------------------------- /exercises/practice/diamond/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/diamond/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/diamond/src/main/scala/Diamond.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/diamond/src/main/scala/Diamond.scala -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | import scala.math.pow 2 | 3 | object DifferenceOfSquares { 4 | 5 | def sumOfSquares(n: Int): Int = n * (n + 1) * (2 * n + 1) / 6 6 | 7 | def squareOfSum(n: Int): Int = pow((n * (n + 1) / 2), 2).toInt 8 | 9 | def differenceOfSquares(n: Int): Int = squareOfSum(n) - sumOfSquares(n) 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/src/main/scala/DifferenceOfSquares.scala: -------------------------------------------------------------------------------- 1 | object DifferenceOfSquares { 2 | 3 | def sumOfSquares(n: Int): Int = ??? 4 | 5 | def squareOfSum(n: Int): Int = ??? 6 | 7 | def differenceOfSquares(n: Int): Int = ??? 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "abo64" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg", 9 | "ricemery" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/Dominoes.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/DominoesTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Make a chain of dominoes." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/src/main/scala/Dominoes.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/dominoes/src/main/scala/Dominoes.scala -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Etl { 2 | def transform(m: Map[Int, Seq[String]]): Map[String, Int] = m.flatMap { case (key, strings) => 3 | Map(strings.map(_.toLowerCase -> key): _*) 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/etl/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/etl/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/etl/src/main/scala/Etl.scala: -------------------------------------------------------------------------------- 1 | object Etl { 2 | def transform(scoreMap: Map[Int, Seq[String]]): Map[String, Int] = ??? 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Take a nested list and return a single flattened list with all values except nil/null. 4 | 5 | The challenge is to take an arbitrarily-deep nested list-like structure and produce a flattened structure without any nil/null values. 6 | 7 | For example: 8 | 9 | input: [1,[2,3,null,4],[null],5] 10 | 11 | output: [1,2,3,4,5] 12 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object FlattenArray { 2 | def flatten(l: List[Any]): List[Any] = (l match { 3 | case Nil => Nil 4 | case (h:List[_])::tail => flatten(h):::flatten(tail) 5 | case h::tail => h::flatten(tail) 6 | }).filter(_ != null) 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/src/main/scala/FlattenArray.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/flatten-array/src/main/scala/FlattenArray.scala -------------------------------------------------------------------------------- /exercises/practice/food-chain/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": [ 4 | "bobahop" 5 | ] 6 | }, 7 | "approaches": [ 8 | { 9 | "uuid": "9ff84c5b-080e-41b7-92e4-f2f1743bc925", 10 | "slug": "move-complexity-to-data", 11 | "title": "Move complexity to data", 12 | "blurb": "Move complexity to data to keep code simple.", 13 | "authors": [ 14 | "bobahop" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/.approaches/move-complexity-to-data/snippet.txt: -------------------------------------------------------------------------------- 1 | private val cow = s"""I know an old lady who swallowed a cow. 2 | I don't know how she swallowed a cow! 3 | She swallowed the cow to catch the goat. 4 | ${backwash(goat, 2, 8)} 5 | """ 6 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/FoodChain.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/FoodChainTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'.", 25 | "source": "Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/There_Was_an_Old_Lady_Who_Swallowed_a_Fly" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/src/main/scala/FoodChain.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/food-chain/src/main/scala/FoodChain.scala -------------------------------------------------------------------------------- /exercises/practice/forth/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Forth.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/ForthTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Implement an evaluator for a very simple subset of Forth." 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/forth/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/forth/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/forth/src/main/scala/Forth.scala: -------------------------------------------------------------------------------- 1 | import ForthError.ForthError 2 | 3 | 4 | class Forth extends ForthEvaluator { 5 | def eval(text: String): Either[ForthError, ForthEvaluatorState] = ??? 6 | } -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | Note that `addGigaseconds` accepts two different types of input. 3 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine the date and time one gigasecond after a certain date. 4 | 5 | A gigasecond is one thousand million seconds. 6 | That is a one with nine zeros after it. 7 | 8 | If you were born on _January 24th, 2015 at 22:00 (10:00:00pm)_, then you would be a gigasecond old on _October 2nd, 2046 at 23:46:40 (11:46:40pm)_. 9 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | import java.time.LocalDate 2 | import java.time.LocalDateTime 3 | import java.time.LocalTime 4 | 5 | object Gigasecond { 6 | private type Seconds = Long 7 | 8 | def add(startDate: LocalDate): LocalDateTime = { 9 | val startDateTime = LocalDateTime.of(startDate, LocalTime.of(0, 0)) 10 | add(startDateTime) 11 | } 12 | 13 | def add(startDateTime: LocalDateTime): LocalDateTime = 14 | startDateTime.plusSeconds(OneGigasecond) 15 | 16 | private val OneGigasecond: Seconds = math.pow(10, 9).toLong 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/src/main/scala/Gigasecond.scala: -------------------------------------------------------------------------------- 1 | import java.time.LocalDate 2 | import java.time.LocalDateTime 3 | 4 | object Gigasecond { 5 | def add(startDate: LocalDate): LocalDateTime = ??? 6 | 7 | def add(startDateTime: LocalDateTime): LocalDateTime = ??? 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | import scala.collection.immutable.SortedMap 2 | 3 | class School { 4 | type DB = Map[Int, Seq[String]] 5 | 6 | private var _db: DB = Map.empty 7 | 8 | def db: DB = _db 9 | 10 | def add(name: String, g: Int) = { 11 | _db = db.updated(g, grade(g) :+ name) 12 | } 13 | 14 | def grade(g: Int): Seq[String] = { 15 | db.getOrElse(g, Vector.empty) 16 | } 17 | 18 | def sorted: DB = SortedMap(db.toSeq: _*).mapValues(_.sorted).toMap 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/src/main/scala/GradeSchool.scala: -------------------------------------------------------------------------------- 1 | class School { 2 | type DB = Map[Int, Seq[String]] 3 | 4 | def add(name: String, g: Int) = ??? 5 | 6 | def db: DB = ??? 7 | 8 | def grade(g: Int): Seq[String] = ??? 9 | 10 | def sorted: DB = ??? 11 | } 12 | 13 | -------------------------------------------------------------------------------- /exercises/practice/grains/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/grains/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/grains/src/main/scala/Grains.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/grains/src/main/scala/Grains.scala -------------------------------------------------------------------------------- /exercises/practice/hamming/.approaches/if-zip-count/snippet.txt: -------------------------------------------------------------------------------- 1 | def distance(strand1: String, strand2: String): Option[Int] = { 2 | if (strand1.length != strand2.length) 3 | return None 4 | Some(strand1 zip strand2 count (strand => strand._1 != strand._2)) 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.approaches/match-recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | @tailrec def distanceCount(acc: Int, s1: String, s2: String): Int = { 2 | s1.length match { 3 | case 0 => acc 4 | case _ => 5 | distanceCount( 6 | (if (s1.head != s2.head) acc + 1 else acc), 7 | s1.tail, 8 | s2.tail)}} 9 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.approaches/match-zip-count/snippet.txt: -------------------------------------------------------------------------------- 1 | def distance(strand1: String, strand2: String): Option[Int] = { 2 | strand1.length == strand2.length match { 3 | case true => 4 | Some(strand1 zip strand2 count (strand => strand._1 != strand._2)) 5 | case false => None 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | class Hamming(strand1: String, strand2: String) { 2 | 3 | def distance = 4 | if (strand1.length == strand2.length) { 5 | val dist = commonPairs.count { case (a, b) => a != b } 6 | Some(dist) 7 | } else None 8 | 9 | private def commonPairs = strand1.zip(strand2) 10 | } 11 | 12 | object Hamming { 13 | def distance(strand1: String, strand2: String) = 14 | new Hamming(strand1, strand2).distance 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/hamming/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/hamming/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/hamming/src/main/scala/Hamming.scala: -------------------------------------------------------------------------------- 1 | object Hamming { 2 | def distance(dnaStrandOne: String, dnaStrandTwo: String): Option[Int] = ??? 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | 3 | ## Common pitfalls that you should avoid 4 | - Usually there is no need in Scala to use `return`. For a discussion see [here](http://stackoverflow.com/questions/24856106/return-in-a-scala-function-literal). Or as a quote from that discussion: *Don't use return, it makes Scala cry.* 5 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | The classical introductory exercise. 4 | Just say "Hello, World!". 5 | 6 | ["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. 7 | 8 | The objectives are simple: 9 | 10 | - Modify the provided code so that it produces the string "Hello, World!". 11 | - Run the test suite and make sure that it succeeds. 12 | - Submit your solution and check it at the website. 13 | 14 | If everything goes well, you will be ready to fetch your first real exercise. 15 | 16 | [hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program 17 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object HelloWorld { 2 | def hello() = "Hello, World!" 3 | } 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [af9ffe10-dc13-42d8-a742-e7bdafac449d] 13 | description = "Say Hi!" 14 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/src/main/scala/HelloWorld.scala: -------------------------------------------------------------------------------- 1 | object HelloWorld { 2 | def hello() = "Goodbye, Mars!" 3 | } 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/src/test/scala/HelloWorldTest.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.funsuite.AnyFunSuite 2 | import org.scalatest.matchers.should.Matchers 3 | 4 | 5 | /** @version 1.1.0 */ 6 | class HelloWorldTest extends AnyFunSuite with Matchers { 7 | 8 | test("Say Hi!") { 9 | HelloWorld.hello() should be ("Hello, World!") 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Convert a hexadecimal number, represented as a string (e.g. "10af8c"), to its decimal equivalent using first principles (i.e. no, you may not use built-in or external libraries to accomplish the conversion). 4 | 5 | On the web we use hexadecimal to represent colors, e.g. green: 008000, 6 | teal: 008080, navy: 000080). 7 | 8 | The program should handle invalid hexadecimal strings. 9 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Hexadecimal { 2 | private val hexChars = 'a' to 'f' 3 | 4 | def hexToInt(s: String): Int = 5 | s.foldLeft(Some(0): Option[Int]){case (acc, c) => accumulate(acc, c)}.getOrElse(0) 6 | 7 | private def accumulate(acc: Option[Int], c: Char) = 8 | if (c.isDigit || (hexChars contains c.toLower)) 9 | acc.map(x => c.asDigit + (x * 16)) 10 | else 11 | None 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/src/main/scala/Hexadecimal.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/hexadecimal/src/main/scala/Hexadecimal.scala -------------------------------------------------------------------------------- /exercises/practice/high-scores/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Manage a game player's High Score list. 4 | 5 | Your task is to build a high-score component of the classic Frogger game, one of the highest selling and most addictive games of all time, and a classic of the arcade era. 6 | Your task is to write methods that return the highest score from the list, the last added score and the three highest scores. 7 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object HighScores { 2 | def latest(scores: List[Int]): Int = scores.last 3 | 4 | def personalBest(scores: List[Int]): Int = scores.max 5 | 6 | def personalTop(scores: List[Int]): List[Int] = 7 | scores.sorted(Ordering[Int].reverse).take(3) 8 | 9 | def report(scores: List[Int]): String = { 10 | val highScore = personalBest(scores) 11 | val latestScore = latest(scores) 12 | if (highScore == latestScore) 13 | s"Your latest score was $latestScore. That's your personal best!" 14 | else 15 | s"Your latest score was $latestScore. That's ${highScore - latestScore} short of your personal best!" 16 | } 17 | } -------------------------------------------------------------------------------- /exercises/practice/high-scores/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg", 9 | "tqa236" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/HighScores.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/HighScoresTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Manage a player's High Score list.", 26 | "source": "Tribute to the eighties' arcade game Frogger" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/src/main/scala/HighScores.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/high-scores/src/main/scala/HighScores.scala -------------------------------------------------------------------------------- /exercises/practice/house/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/House.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/HouseTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Output the nursery rhyme 'This is the House that Jack Built'.", 25 | "source": "British nursery rhyme", 26 | "source_url": "https://en.wikipedia.org/wiki/This_Is_The_House_That_Jack_Built" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/house/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/house/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/house/src/main/scala/House.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/house/src/main/scala/House.scala -------------------------------------------------------------------------------- /exercises/practice/isogram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Determine if a word or phrase is an isogram. 4 | 5 | An isogram (also known as a "non-pattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. 6 | 7 | Examples of isograms: 8 | 9 | - lumberjacks 10 | - background 11 | - downstream 12 | - six-year-old 13 | 14 | The word _isograms_, however, is not an isogram, because the s repeats. 15 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Isogram { 2 | def isIsogram(s: String): Boolean = 3 | !s.filter(_.isLetter) 4 | .map(_.toLower) 5 | .groupBy(identity) 6 | .values 7 | .exists(_.length > 1) 8 | } -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Isogram.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/IsogramTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Determine if a word or phrase is an isogram.", 25 | "source": "Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/Isogram" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/isogram/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/isogram/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/isogram/src/main/scala/Isogram.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/isogram/src/main/scala/Isogram.scala -------------------------------------------------------------------------------- /exercises/practice/killer-sudoku-helper/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "rabestro" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/main/scala/KillerSudokuHelper.scala" 8 | ], 9 | "test": [ 10 | "src/test/scala/KillerSudokuHelperTest.scala" 11 | ], 12 | "example": [ 13 | ".meta/Example.scala" 14 | ], 15 | "invalidator": [ 16 | "build.sbt" 17 | ] 18 | }, 19 | "blurb": "Write a tool that makes it easier to solve Killer Sudokus", 20 | "source": "Created by Sascha Mann, Jeremy Walker, and BethanyG for the Julia track on Exercism.", 21 | "source_url": "https://github.com/exercism/julia/pull/413" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/killer-sudoku-helper/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/killer-sudoku-helper/src/main/scala/KillerSudokuHelper.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/killer-sudoku-helper/src/main/scala/KillerSudokuHelper.scala -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The kindergarten class is learning about growing plants. 4 | The teacher thought it would be a good idea to give the class seeds to plant and grow in the dirt. 5 | To this end, the children have put little cups along the window sills and planted one type of plant in each cup. 6 | The children got to pick their favorites from four available types of seeds: grass, clover, radishes, and violets. 7 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/src/main/scala/Garden.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/kindergarten-garden/src/main/scala/Garden.scala -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a government agency that has intercepted a series of encrypted communication signals from a group of bank robbers. 4 | The signals contain a long sequence of digits. 5 | Your team needs to use various digital signal processing techniques to analyze the signals and identify any patterns that may indicate the planning of a heist. 6 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Series { 2 | private def digits(s: String): List[Int] = s.filter(_.isDigit).map(_.asDigit).toList 3 | 4 | private def slices(n: Int, digits: List[Int]): List[List[Int]] = 5 | digits.tails.filter(xs => xs.length >= n).map(_.take(n)).toList 6 | 7 | def largestProduct(n: Int, s: String): Option[Int] = 8 | if (n < 0) 9 | None 10 | else { 11 | val ds = digits(s) 12 | if (ds.length < s.length) 13 | None 14 | else { 15 | slices(n, ds) match { 16 | case Nil => None 17 | case xs => Some(xs.map(_.product).max) 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/src/main/scala/LargestSeriesProduct.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/largest-series-product/src/main/scala/LargestSeriesProduct.scala -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/boolean-chain/snippet.txt: -------------------------------------------------------------------------------- 1 | def leapYear(year: Int): Boolean = 2 | year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) 3 | -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/built-in-method/content.md: -------------------------------------------------------------------------------- 1 | # Built-in method 2 | 3 | ```scala 4 | import java.time.{Year} 5 | 6 | object Leap { 7 | def leapYear(year: Int): Boolean = 8 | Year.of(year).isLeap() 9 | } 10 | ``` 11 | 12 | This may be considered a "wicked cheat" for this exercise, by simply passing the year into the [isLeap()][is-leap] method of the [Year][year] class. 13 | Although it is not in the spirit of this exercise, `isLeap()` would be the idiomatic way to determine if a year is a leap year in the "real world". 14 | 15 | [is-leap]: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#isLeap-- 16 | [year]: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html 17 | 18 | 19 | -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/built-in-method/snippet.txt: -------------------------------------------------------------------------------- 1 | import java.time.{Year} 2 | 3 | object Leap { 4 | def leapYear(year: Int): Boolean = 5 | Year.of(year).isLeap() 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/localdate-plusdays/snippet.txt: -------------------------------------------------------------------------------- 1 | import java.time.{LocalDate, Month} 2 | 3 | object Leap { 4 | def leapYear(year: Int): Boolean = 5 | LocalDate.of(year, Month.FEBRUARY, 28).plusDays(1).getDayOfMonth() == 29 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/match-on-a-tuple/snippet.txt: -------------------------------------------------------------------------------- 1 | def leapYear(year: Int): Boolean = 2 | (year % 4, year % 100, year % 400) match { 3 | case (_, _, 0) => true 4 | case (_, 0, _) => false 5 | case (0, _, _) => true 6 | case (_, _, _) => false 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/ternary-expression/snippet.txt: -------------------------------------------------------------------------------- 1 | def leapYear(year: Int): Boolean = 2 | if (year % 100 == 0) year % 400 == 0 3 | else year % 4 == 0 4 | -------------------------------------------------------------------------------- /exercises/practice/leap/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | Try to avoid code repetition, use private helper functions if you can. 3 | 4 | And you might consider using a single `Boolean` expression instead of `if-else` for better readability. See [here](http://cs.wellesley.edu/~cs111/spring00/lectures/boolean-simplification.html) on how this could be done (the link is for Java, but of course the logic is valid for Scala, too). 5 | -------------------------------------------------------------------------------- /exercises/practice/leap/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine whether a given year is a leap year. 4 | -------------------------------------------------------------------------------- /exercises/practice/leap/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | A leap year (in the Gregorian calendar) occurs: 4 | 5 | - In every year that is evenly divisible by 4. 6 | - Unless the year is evenly divisible by 100, in which case it's only a leap year if the year is also evenly divisible by 400. 7 | 8 | Some examples: 9 | 10 | - 1997 was not a leap year as it's not divisible by 4. 11 | - 1900 was not a leap year as it's not divisible by 400. 12 | - 2000 was a leap year! 13 | 14 | ~~~~exercism/note 15 | For a delightful, four-minute explanation of the whole phenomenon of leap years, check out [this YouTube video](https://www.youtube.com/watch?v=xX96xng7sAE). 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Leap { 2 | def leapYear(year: Int): Boolean = { 3 | def divisibleBy(i: Int) = year % i == 0 4 | divisibleBy(4) && (divisibleBy(400) || !divisibleBy(100)) 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "sgrif" 4 | ], 5 | "contributors": [ 6 | "abo64", 7 | "ErikSchierboom", 8 | "kytrinyx", 9 | "ppartarr", 10 | "rajeshpg", 11 | "ricemery" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "src/main/scala/Leap.scala" 16 | ], 17 | "test": [ 18 | "src/test/scala/LeapTest.scala" 19 | ], 20 | "example": [ 21 | ".meta/Example.scala" 22 | ], 23 | "invalidator": [ 24 | "build.sbt" 25 | ] 26 | }, 27 | "blurb": "Determine whether a given year is a leap year.", 28 | "source": "CodeRanch Cattle Drive, Assignment 3", 29 | "source_url": "https://coderanch.com/t/718816/Leap" 30 | } 31 | -------------------------------------------------------------------------------- /exercises/practice/leap/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/leap/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/leap/src/main/scala/Leap.scala: -------------------------------------------------------------------------------- 1 | object Leap { 2 | def leapYear(year: Int): Boolean = ??? 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/lens-person/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | In Scala, a popular alternative for using Lens that is supported 2 | by Exercism is [Monocle](https://www.optics.dev/Monocle/) -------------------------------------------------------------------------------- /exercises/practice/lens-person/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "abo64" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg", 9 | "ricemery" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/LensPerson.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/LensPersonTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Use lenses to update nested records (specific to languages with immutable data)." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/lens-person/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | val monocleVersion = "3.2.0" 6 | 7 | libraryDependencies ++= Seq( 8 | "dev.optics" %% "monocle-core" % monocleVersion, 9 | "dev.optics" %% "monocle-macro" % monocleVersion 10 | ) 11 | 12 | // used for solution example only, not provided in the test runner 13 | libraryDependencies += "org.scalaz" %% "scalaz-core" % "7.3.8" 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/lens-person/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You are working on a project to develop a train scheduling system for a busy railway network. 4 | 5 | You've been asked to develop a prototype for the train routes in the scheduling system. 6 | Each route consists of a sequence of train stations that a given train stops at. 7 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Deque.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/DequeTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Implement a doubly linked list.", 25 | "source": "Classic computer science topic" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/src/main/scala/Deque.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/linked-list/src/main/scala/Deque.scala -------------------------------------------------------------------------------- /exercises/practice/luhn/.approaches/foldright/snippet.txt: -------------------------------------------------------------------------------- 1 | input 2 | .foldRight((1, 0)) { (chr, tup) => 3 | chr match { 4 | case chr if chr.isDigit => { 5 | val num = chr.asDigit 6 | tup match { 7 | case (pos, sum) if pos % 2 == 0 => 8 | (pos + 1, sum + (if (num > 4) (num * 2) - 9 else num * 2)) 9 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.approaches/recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | pos match { 2 | case pos if pos % 2 == 0 => 3 | validRecur( 4 | pos + 1, 5 | sum + (if (num > 4) (num * 2) - 9 else num * 2), 6 | input.init 7 | ) 8 | case _ => validRecur(pos + 1, sum + num, input.init)}} 9 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.approaches/validate-scrub-foldright/snippet.txt: -------------------------------------------------------------------------------- 1 | cleanedInput 2 | .foldRight((1, 0)) { (chr, tup) => 3 | val num = chr.asDigit 4 | tup match { 5 | case (pos, sum) if pos % 2 == 0 => 6 | (pos + 1, sum + (if (num > 4) (num * 2) - 9 else num * 2)) 7 | case (pos, sum) => (pos + 1, sum + num) 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.approaches/validate-scrub-recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | pos match { 2 | case pos if pos % 2 == 0 => 3 | validRecur( 4 | pos + 1, 5 | sum + (if (num > 4) (num * 2) - 9 else num * 2), 6 | input.init 7 | ) 8 | case _ => validRecur(pos + 1, sum + num, input.init) 9 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "abo64", 7 | "ErikSchierboom", 8 | "ppartarr", 9 | "rajeshpg" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/Luhn.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/LuhnTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Given a number determine whether or not it is valid per the Luhn formula.", 26 | "source": "The Luhn Algorithm on Wikipedia", 27 | "source_url": "https://en.wikipedia.org/wiki/Luhn_algorithm" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/luhn/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/luhn/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/luhn/src/main/scala/Luhn.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/luhn/src/main/scala/Luhn.scala -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": [ 4 | "bobahop" 5 | ] 6 | }, 7 | "approaches": [ 8 | { 9 | "uuid": "50bbae1f-d05e-447a-967f-586734d256e1", 10 | "slug": "foldleft", 11 | "title": "foldLeft", 12 | "blurb": "foldLeft to iterate for the result.", 13 | "authors": [ 14 | "bobahop" 15 | ] 16 | }, 17 | { 18 | "uuid": "cb041f76-3569-4723-8627-fdf5004ae341", 19 | "slug": "recursion", 20 | "title": "Recursion", 21 | "blurb": "Recurse to iterate for the result.", 22 | "authors": [ 23 | "bobahop" 24 | ] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.approaches/foldleft/snippet.txt: -------------------------------------------------------------------------------- 1 | input 2 | .foldLeft((List[Char](), true))((tup, chr) => 3 | tup match { 4 | case (stack, valid) if ends.contains(chr) => 5 | (safeTail(stack), valid && isValid(stack, chr)) 6 | case (stack, valid) if (brackets.contains(chr)) => 7 | (brackets(chr) :: stack, valid) 8 | case _ => tup} 9 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.approaches/recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | (input.head, stack) match { 2 | case (chr, stack) if ends.contains(chr) => 3 | if (isValid(stack, chr)) 4 | isPairedRecur(input.tail, safeTail(stack)) 5 | else false 6 | case (chr, stack) if (brackets.contains(chr)) => 7 | isPairedRecur(input.tail, brackets(chr) :: stack) 8 | case _ => isPairedRecur(input.tail, stack)} 9 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a string containing brackets `[]`, braces `{}`, parentheses `()`, or any combination thereof, verify that any and all pairs are matched and nested correctly. 4 | Any other characters should be ignored. 5 | For example, `"{what is (42)}?"` is balanced and `"[text}"` is not. 6 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You're given the opportunity to write software for the Bracketeer™, an ancient but powerful mainframe. 4 | The software that runs on it is written in a proprietary language. 5 | Much of its syntax is familiar, but you notice _lots_ of brackets, braces and parentheses. 6 | Despite the Bracketeer™ being powerful, it lacks flexibility. 7 | If the source code has any unbalanced brackets, braces or parentheses, the Bracketeer™ crashes and must be rebooted. 8 | To avoid such a scenario, you start writing code that can verify that brackets, braces, and parentheses are balanced before attempting to run it on the Bracketeer™. 9 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | import scala.util.parsing.combinator.RegexParsers 2 | 3 | object MatchingBrackets extends RegexParsers { 4 | lazy val t = "[^\\[\\]\\(\\)\\{\\}]+".r 5 | 6 | private def paren: Parser[String] = 7 | ("(" ~ rep1(t | paren) ~ ")" | 8 | "[" ~ rep1(t | paren) ~ "]" | 9 | "{" ~ rep1(t | paren) ~ "}" | 10 | "(" ~ ")" | 11 | "[" ~ "]" | 12 | "{" ~ "}" | 13 | t) ^^ { 14 | case _ => "" 15 | } 16 | 17 | private def all = rep(paren) 18 | 19 | def isPaired(s: String) = this.parseAll(all, s) match { 20 | case NoSuccess(_, _) => false 21 | case Success(_, _) => true 22 | } 23 | } -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/MatchingBrackets.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/MatchingBracketsTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Make sure the brackets and braces all match.", 25 | "source": "Ginna Baker" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/src/main/scala/MatchingBrackets.scala: -------------------------------------------------------------------------------- 1 | object MatchingBrackets { 2 | def isPaired(brackets: String): Boolean = ??? 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/matrix/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | case class Matrix(matrix: String) { 2 | lazy val rows: Vector[Vector[Int]] = Predef.augmentString(matrix).lines.map(_.split(' ').map(_.toInt).toVector).toVector 3 | 4 | lazy val columns: Vector[Vector[Int]] = rows.transpose 5 | 6 | def row(i: Int) = rows(i) 7 | 8 | def column(i: Int) = columns(i) 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/matrix/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/matrix/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/matrix/src/main/scala/Matrix.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/matrix/src/main/scala/Matrix.scala -------------------------------------------------------------------------------- /exercises/practice/meetup/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "sgrif" 4 | ], 5 | "contributors": [ 6 | "abo64", 7 | "ErikSchierboom", 8 | "jmtuley", 9 | "kytrinyx", 10 | "ppartarr", 11 | "rajeshpg", 12 | "ricemery" 13 | ], 14 | "files": { 15 | "solution": [ 16 | "src/main/scala/Meetup.scala" 17 | ], 18 | "test": [ 19 | "src/test/scala/MeetupTest.scala" 20 | ], 21 | "example": [ 22 | ".meta/Example.scala" 23 | ], 24 | "invalidator": [ 25 | "build.sbt" 26 | ] 27 | }, 28 | "blurb": "Calculate the date of meetups.", 29 | "source": "Jeremy Hinegardner mentioned a Boulder meetup that happens on the Wednesteenth of every month" 30 | } 31 | -------------------------------------------------------------------------------- /exercises/practice/meetup/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/meetup/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/meetup/src/main/scala/Meetup.scala: -------------------------------------------------------------------------------- 1 | import java.time.{DayOfWeek, LocalDate} 2 | 3 | import Schedule.Schedule 4 | 5 | case class Meetup(month: Int, year: Int) { 6 | 7 | def day(dayOfWeek: Int, schedule: Schedule): LocalDate = ??? 8 | } 9 | 10 | object Schedule extends Enumeration { 11 | type Schedule = Value 12 | val Teenth, First, Second, Third, Fourth, Last = Value 13 | } 14 | 15 | object Meetup { 16 | val Mon = DayOfWeek.MONDAY.getValue 17 | val Tue = DayOfWeek.TUESDAY.getValue 18 | val Wed = DayOfWeek.WEDNESDAY.getValue 19 | val Thu = DayOfWeek.THURSDAY.getValue 20 | val Fri = DayOfWeek.FRIDAY.getValue 21 | val Sat = DayOfWeek.SATURDAY.getValue 22 | val Sun = DayOfWeek.SUNDAY.getValue 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | [Minesweeper][wikipedia] is a popular game where the user has to find the mines using numeric hints that indicate how many mines are directly adjacent (horizontally, vertically, diagonally) to a square. 4 | 5 | [wikipedia]: https://en.wikipedia.org/wiki/Minesweeper_(video_game) 6 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Minesweeper.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/MinesweeperTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Add the numbers to a minesweeper board." 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/src/main/scala/Minesweeper.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/minesweeper/src/main/scala/Minesweeper.scala -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a number n, determine what the nth prime is. 4 | 5 | By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. 6 | 7 | If your language provides methods in the standard library to deal with prime numbers, pretend they don't exist and implement them yourself. 8 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object NthPrime { 2 | // The stream will cache calculated primes. This is nice for performance, 3 | // but not so nice for memory utilization. 4 | private lazy val primes: Stream[BigInt] = 5 | Stream.cons(BigInt(2), primes.map(b => new BigInt(b.bigInteger.nextProbablePrime))) 6 | 7 | def prime(n: Int): Option[Int] = 8 | if (n < 1) None 9 | else Some(primes.drop(n - 1).head.toInt) 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/NthPrime.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/NthPrimeTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Given a number n, determine what the nth prime is.", 25 | "source": "A variation on Problem 7 at Project Euler", 26 | "source_url": "https://projecteuler.net/problem=7" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/src/main/scala/NthPrime.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/nth-prime/src/main/scala/NthPrime.scala -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.approaches/foldleft-match/snippet.txt: -------------------------------------------------------------------------------- 1 | strand.foldLeft(("", output)) { (tup, chr) => 2 | tup match { 3 | case (errStr, output) if output.contains(chr) => 4 | (errStr, output + (chr -> (output(chr) + 1))) 5 | case (errStr, output) => (s"invalid nucleotide '$chr'", output) 6 | }} match { 7 | case (errStr, output) if errStr.isEmpty() => Right(output) 8 | case (errStr, _) => Left(errStr)} 9 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.approaches/recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | private def countRecur(strand: String, output: Map[Char, Int]): Either[String, Map[Char, Int]] = { 2 | if (strand.isEmpty) return Right(output) 3 | strand.head match { 4 | case chr if output.contains(chr) => 5 | countRecur(strand.tail, output + (chr -> (output(chr) + 1))) 6 | case chr => Left(s"invalid nucleotide '$chr'") 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.approaches/validate-map-count/snippet.txt: -------------------------------------------------------------------------------- 1 | private def findInvalid(strand: String): Option[Either[String, Nothing]] = 2 | strand 3 | .find(!"ACTG".contains(_)) 4 | .map(chr => Left(f"invalid nucleotide '$chr'")) 5 | 6 | def nucleotideCounts: Either[String, Map[Char, Int]] = 7 | findInvalid(strand) 8 | .getOrElse(Right("ACTG".map(chr => (chr, strand.count(_ == chr))).toMap)) 9 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/src/main/scala/NucleotideCount.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/nucleotide-count/src/main/scala/NucleotideCount.scala -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/src/main/scala/OcrNumbers.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/ocr-numbers/src/main/scala/OcrNumbers.scala -------------------------------------------------------------------------------- /exercises/practice/octal/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/octal/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/octal/src/main/scala/Octal.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/octal/src/main/scala/Octal.scala -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | 2 | case class PalindromeProducts(minFactor: Int, maxFactor: Int) { 3 | 4 | lazy val (smallest: Option[(Int, Set[(Int, Int)])], 5 | largest: Option[(Int, Set[(Int, Int)])]) = { 6 | val palindromes = for (a <- Range(minFactor, maxFactor + 1); 7 | b <- Range(a, maxFactor + 1) if isPalindrome(a * b)) yield (a * b, (a, b)) 8 | val mapped = palindromes.groupBy(_._1).map{case(k, v) => (k, v.map(_._2).toSet)} 9 | if (mapped.isEmpty) 10 | (None, None) 11 | else 12 | (Some(mapped.minBy(_._1)), Some(mapped.maxBy(_._1))) 13 | } 14 | 15 | private def isPalindrome(i: Int) = i.toString == i.toString.reverse 16 | } 17 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/PalindromeProducts.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/PalindromeProductsTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Detect palindrome products in a given range.", 25 | "source": "Problem 4 at Project Euler", 26 | "source_url": "https://projecteuler.net/problem=4" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/src/main/scala/PalindromeProducts.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/palindrome-products/src/main/scala/PalindromeProducts.scala -------------------------------------------------------------------------------- /exercises/practice/pangram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to figure out if a sentence is a pangram. 4 | 5 | A pangram is a sentence using every letter of the alphabet at least once. 6 | It is case insensitive, so it doesn't matter if a letter is lower-case (e.g. `k`) or upper-case (e.g. `K`). 7 | 8 | For this exercise, a sentence is a pangram if it contains each of the 26 letters in the English alphabet. 9 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a company that sells fonts through their website. 4 | They'd like to show a different sentence each time someone views a font on their website. 5 | To give a comprehensive sense of the font, the random sentences should use **all** the letters in the English alphabet. 6 | 7 | They're running a competition to get suggestions for sentences that they can use. 8 | You're in charge of checking the submissions to see if they are valid. 9 | 10 | ~~~~exercism/note 11 | Pangram comes from Greek, παν γράμμα, pan gramma, which means "every letter". 12 | 13 | The best known English pangram is: 14 | 15 | > The quick brown fox jumps over the lazy dog. 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Pangrams { 2 | private val alphaLength = 26 3 | 4 | def isPangram(input: String): Boolean = { 5 | val numUniqueChars = input.toStream 6 | .map(_.toLower) 7 | .filter(c => c >= 'a' && c <='z') 8 | .toSet 9 | .size 10 | numUniqueChars == alphaLength 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg", 9 | "Trevoke" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/Pangrams.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/PangramTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Determine if a sentence is a pangram.", 26 | "source": "Wikipedia", 27 | "source_url": "https://en.wikipedia.org/wiki/Pangram" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/pangram/build.sbt: -------------------------------------------------------------------------------- 1 | 2 | scalaVersion := "3.4.2" 3 | 4 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 5 | 6 | -------------------------------------------------------------------------------- /exercises/practice/pangram/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/pangram/src/main/scala/Pangrams.scala: -------------------------------------------------------------------------------- 1 | object Pangrams { 2 | def isPangram(input: String): Boolean = ??? 3 | } 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Count the frequency of letters in texts using parallel computation. 4 | 5 | Parallelism is about doing things in parallel that can also be done sequentially. 6 | A common example is counting the frequency of letters. 7 | Employ parallelism to calculate the total frequency of each letter in a list of texts. 8 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "abo64", 7 | "ErikSchierboom", 8 | "ppartarr", 9 | "rajeshpg" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/Frequency.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/FrequencyTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Count the frequency of letters in texts using parallel computation." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/src/main/scala/Frequency.scala: -------------------------------------------------------------------------------- 1 | object Frequency { 2 | def frequency(numWorkers: Int, texts: Seq[String]): Map[Char, Int] = ??? 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object PascalsTriangle { 2 | def rows(n: Int): List[List[Int]] = 3 | (for (row <- 1 to n) yield triRow(row)).toList 4 | 5 | private def triRow(row: Int): List[Int] = { 6 | var m = 1 7 | List(1) ::: (for (j <- 1 until row) yield { 8 | m = m * (row - j) / j 9 | m 10 | }).toList 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/PascalsTriangle.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/PascalsTriangleTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Compute Pascal's triangle up to a given number of rows.", 25 | "source": "Pascal's Triangle at Wolfram Math World", 26 | "source_url": "https://www.wolframalpha.com/input/?i=Pascal%27s+triangle" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/src/main/scala/PascalsTriangle.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/pascals-triangle/src/main/scala/PascalsTriangle.scala -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/src/main/scala/PerfectNumbers.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/perfect-numbers/src/main/scala/PerfectNumbers.scala -------------------------------------------------------------------------------- /exercises/practice/phone-number/.approaches/foldleft/snippet.txt: -------------------------------------------------------------------------------- 1 | case index => { 2 | head.isDigit match { 3 | case true => (head :: tup._1, index + 1) 4 | case false 5 | if (index == 6 && List(' ', '-', '.').contains(head)) => 6 | tup 7 | case false if (head == ' ') => tup 8 | case _ => (Nil, -100)}} 9 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.approaches/recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | case (head :: tail, index) => { 2 | head.isDigit match { 3 | case true => cleanRecur(tail, head :: cleaned) 4 | case false if (index == 6 && List(' ', '-', '.').contains(head)) => 5 | cleanRecur(tail, cleaned) 6 | case false if (head == ' ') => cleanRecur(tail, cleaned) 7 | case _ => None 8 | }} 9 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.approaches/regex-with-filter/snippet.txt: -------------------------------------------------------------------------------- 1 | object PhoneNumber { 2 | private val VALID_PHONE_NUMBER = raw"^1?([2-9]\d{2}[2-9]\d{6})$$".r 3 | 4 | def clean(input: String): Option[String] = { 5 | val cleaned = input.filter(_.isDigit) 6 | Option(cleaned) collect { case VALID_PHONE_NUMBER(cleaned) => cleaned } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | For simplicity and readability: Consider using the Scala collection functions instead of Java's `String` methods. Remember that in Scala a `String` is implicitly also a `Seq[Char]`, so you can call them as easily as the `String` methods. 3 | 4 | Some examples: 5 | - `filter` instead of `replaceAll` 6 | - `take`, `takeRight`, `drop`, `head`, `tail` instead of `substring` 7 | 8 | Another idea worth exploring might be to change the `String` into a `List[Char]` 9 | and then use [pattern matching](http://alvinalexander.com/scala/how-to-use-lists-nil-cons-scala-match-case-expressions) with the `::` operator. 10 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/src/main/scala/PhoneNumber.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/phone-number/src/main/scala/PhoneNumber.scala -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": [ 4 | "bobahop" 5 | ] 6 | }, 7 | "approaches": [ 8 | { 9 | "uuid": "933e626a-b060-4fa1-acd3-d4a84abf78ed", 10 | "slug": "map-recursion-mkstring", 11 | "title": "map with recursion and mkString", 12 | "blurb": "Use map with recursion and mkString to return the answer.", 13 | "authors": [ 14 | "bobahop" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.approaches/map-recursion-mkstring/snippet.txt: -------------------------------------------------------------------------------- 1 | phrase 2 | .split(" ") 3 | .map(word => 4 | if (vowels.contains(word.head) || specials.contains(word.slice(0, 2))) 5 | word + "ay" 6 | else findVowel(word, 1) 7 | ) 8 | .mkString(" " 9 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your parents have challenged you and your sibling to a game of two-on-two basketball. 4 | Confident they'll win, they let you score the first couple of points, but then start taking over the game. 5 | Needing a little boost, you start speaking in [Pig Latin][pig-latin], which is a made-up children's language that's difficult for non-children to understand. 6 | This will give you the edge to prevail over your parents! 7 | 8 | [pig-latin]: https://en.wikipedia.org/wiki/Pig_latin 9 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object PigLatin { 2 | private val vowelRegex = "(^|\\s+)(a|e|i|o|u|yt|xr)(\\w+)".r 3 | private val consonantRegex = "(^|\\s+)(?ch|qu|thr|th|sch|yt|rh|\\wqu|\\w)(?\\w+)".r 4 | private val vowelReplacement = "$1$2$3ay" 5 | private val consonantReplacement = "$1$3$2ay" 6 | 7 | def translate(phrase: String): String = 8 | vowelRegex.findFirstIn(phrase) match { 9 | case Some(x) => vowelRegex.replaceAllIn(phrase, vowelReplacement) 10 | case None => consonantRegex.replaceAllIn(phrase, consonantReplacement) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/src/main/scala/PigLatin.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/pig-latin/src/main/scala/PigLatin.scala -------------------------------------------------------------------------------- /exercises/practice/prime-factors/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/src/main/scala/PrimeFactors.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/prime-factors/src/main/scala/PrimeFactors.scala -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.approaches/grouped-map-takewhile/snippet.txt: -------------------------------------------------------------------------------- 1 | def proteins(input: String): Seq[String] = { 2 | input.grouped(3).map(codonsToProteins).takeWhile(_ != "STOP").toSeq 3 | } 4 | private def codonsToProteins(codon: String): String = { 5 | 6 | codon match { 7 | case "AUG" => "Methionine" 8 | case "UUU" | "UUC" => "Phenylalanine" 9 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.approaches/if-else-match-recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | private def codonsToProteins(input: String, proteins: Seq[String]): Seq[String] = { 2 | if (input.length < 3) 3 | proteins 4 | else 5 | codonToProtein(input.take(3)) match { 6 | case "STOP" => proteins 7 | case protein => 8 | codonsToProteins(input.drop(3), proteins :+ protein)}} 9 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/ProteinTranslation.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/ProteinTranslationTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Translate RNA sequences into proteins.", 25 | "source": "Tyler Long" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/src/main/scala/ProteinTranslation.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/protein-translation/src/main/scala/ProteinTranslation.scala -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | A Pythagorean triplet is a set of three natural numbers, {a, b, c}, for which, 4 | 5 | ```text 6 | a² + b² = c² 7 | ``` 8 | 9 | and such that, 10 | 11 | ```text 12 | a < b < c 13 | ``` 14 | 15 | For example, 16 | 17 | ```text 18 | 3² + 4² = 5². 19 | ``` 20 | 21 | Given an input integer N, find all Pythagorean triplets for which `a + b + c = N`. 22 | 23 | For example, with N = 1000, there is exactly one Pythagorean triplet for which `a + b + c = 1000`: `{200, 375, 425}`. 24 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/src/main/scala/PythagoreanTriplet.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/pythagorean-triplet/src/main/scala/PythagoreanTriplet.scala -------------------------------------------------------------------------------- /exercises/practice/queen-attack/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/src/main/scala/QueenAttack.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/queen-attack/src/main/scala/QueenAttack.scala -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/RailFenceCipher.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/RailFenceCipherTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Implement encoding and decoding for the rail fence cipher.", 25 | "source": "Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/Transposition_cipher#Rail_Fence_cipher" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/src/main/scala/RailFenceCipher.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/rail-fence-cipher/src/main/scala/RailFenceCipher.scala -------------------------------------------------------------------------------- /exercises/practice/raindrops/.approaches/list-foldright-match/snippet.txt: -------------------------------------------------------------------------------- 1 | private val drops = List((3, "Pling"), (5, "Plang"), (7, "Plong")) 2 | 3 | def convert(n: Int): String = 4 | drops.foldRight(List[String]())((factor_drop, acc) => 5 | if (n % factor_drop._1 == 0) factor_drop._2 :: acc else acc 6 | ) match { 7 | case drops if !drops.isEmpty => drops.mkString 8 | case _ => n.toString()}} 9 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.approaches/sortedmap-filterkeys-match/snippet.txt: -------------------------------------------------------------------------------- 1 | private val sound = SortedMap( 2 | 3 -> "Pling", 5 -> "Plang", 7 -> "Plong") 3 | def convert(n: Int): String = 4 | sound.filterKeys(n % _ == 0).values match { 5 | case drops if (!drops.isEmpty) => drops.mkString 6 | case _ => n.toString} 7 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Raindrops is a slightly more complex version of the FizzBuzz challenge, a classic interview question. 4 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Raindrops { 2 | private val sounds = List((3, "Pling"), (5, "Plang"), (7, "Plong")) 3 | 4 | def convert(n: Int): String = 5 | sounds.filter{case (m, _) => n % m == 0}.map{case (_, s) => s}.mkString match { 6 | case "" => n.toString 7 | case s => s 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/src/main/scala/Raindrops.scala: -------------------------------------------------------------------------------- 1 | object Raindrops { 2 | def convert(n: Int): String = ??? 3 | } 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to reverse a given string. 4 | 5 | Some examples: 6 | 7 | - Turn `"stressed"` into `"desserts"`. 8 | - Turn `"strops"` into `"sports"`. 9 | - Turn `"racecar"` into `"racecar"`. 10 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Reversing strings (reading them from right to left, rather than from left to right) is a surprisingly common task in programming. 4 | 5 | For example, in bioinformatics, reversing the sequence of DNA or RNA strings is often important for various analyses, such as finding complementary strands or identifying palindromic sequences that have biological significance. 6 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object ReverseString { 2 | def reverse(str: String): String = str.foldRight("") ( (a, b) => b + a) 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/main/scala/ReverseString.scala" 8 | ], 9 | "test": [ 10 | "src/test/scala/ReverseStringTest.scala" 11 | ], 12 | "example": [ 13 | ".meta/Example.scala" 14 | ], 15 | "invalidator": [ 16 | "build.sbt" 17 | ] 18 | }, 19 | "blurb": "Reverse a given string.", 20 | "source": "Introductory challenge to reverse an input string", 21 | "source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/src/main/scala/ReverseString.scala: -------------------------------------------------------------------------------- 1 | object ReverseString { 2 | def reverse(str: String): String = ??? 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object RnaTranscription { 2 | private type Strand = String 3 | private type Nucleotide = Char 4 | 5 | def toRna(dna: Strand): Option[Strand] = 6 | dna.foldRight (Option("")) { case (char, rna) => 7 | for { 8 | rnaNucleotide <- toRnaNucleotide(char) 9 | rnaStrand <- rna 10 | } yield rnaNucleotide +: rnaStrand 11 | } 12 | 13 | private val DnaToRna = 14 | Map('G' -> 'C', 'C' -> 'G', 'T' -> 'A', 'A' -> 'U') 15 | 16 | private def toRnaNucleotide(char: Char): Option[Nucleotide] = 17 | DnaToRna get char 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/src/main/scala/RnaTranscription.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/rna-transcription/src/main/scala/RnaTranscription.scala -------------------------------------------------------------------------------- /exercises/practice/robot-name/.approaches/random-add-to-used-names/snippet.txt: -------------------------------------------------------------------------------- 1 | private def addName: String = { 2 | val temp = nameMeBaby(List[Char]()) 3 | temp match { 4 | case name if savedNames contains name => addName 5 | case name => 6 | savedNames += name 7 | name 8 | }} 9 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.approaches/sequential-take-from-shuffled-names/snippet.txt: -------------------------------------------------------------------------------- 1 | for { 2 | ltr1 <- ('A' to 'Z') 3 | ltr2 <- ('A' to 'Z') 4 | num <- (0 to 999) 5 | } yield { 6 | f"$ltr1%c$ltr2%c$num%03d" 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | Make sure your solution is general enough to be easily scalable for longer names containing more letters and digits. This usually makes for better code quality, too. 3 | 4 | Suggestion (this is not explicitly tested): 5 | To make sure you always have a unique name you could implement your own cache or use a `Stream` with its built-in cache. 6 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Manage robot factory settings. 4 | 5 | When a robot comes off the factory floor, it has no name. 6 | 7 | The first time you turn on a robot, a random name is generated in the format of two uppercase letters followed by three digits, such as RX837 or BC811. 8 | 9 | Every once in a while we need to reset a robot to its factory settings, which means that its name gets wiped. 10 | The next time you ask, that robot will respond with a new random name. 11 | 12 | The names must be random: they should not follow a predictable sequence. 13 | Using random names means a risk of collisions. 14 | Your solution must ensure that every existing robot has a unique name. 15 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | import scala.util.Random 2 | 3 | object UniqueNames { 4 | val names = 5 | Random.shuffle(1 to 26 * 26 * 1000).iterator.map(n => { 6 | val lettersPart = n / 1000 7 | val firstLetter = 'A' + (lettersPart / 26) 8 | val secondLetter = 'A' + (lettersPart % 26) 9 | f"$firstLetter%c$secondLetter%c${n % 1000}%03d" 10 | }) 11 | } 12 | 13 | class Robot { 14 | private var storedName = UniqueNames.names.next() 15 | 16 | def name: String = storedName 17 | def reset(): Unit = storedName = UniqueNames.names.next() 18 | } -------------------------------------------------------------------------------- /exercises/practice/robot-name/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/src/main/scala/RobotName.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/robot-name/src/main/scala/RobotName.scala -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": [ 4 | "bobahop" 5 | ] 6 | }, 7 | "approaches": [ 8 | { 9 | "uuid": "01459161-87e9-47db-bd43-d3bc046b699d", 10 | "slug": "foldleft", 11 | "title": "foldLeft", 12 | "blurb": "Use foldLeft for simulate.", 13 | "authors": [ 14 | "bobahop" 15 | ] 16 | }, 17 | { 18 | "uuid": "c7c6a192-7897-489e-b662-6a9bf38f22ee", 19 | "slug": "recursion", 20 | "title": "Recursion", 21 | "blurb": "Use recursion for simulate.", 22 | "authors": [ 23 | "bobahop" 24 | ] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.approaches/foldleft/snippet.txt: -------------------------------------------------------------------------------- 1 | def simulate(orders: String): Robot = 2 | orders.foldLeft(this)((robbie, cmd) => 3 | cmd match { 4 | case 'L' => robbie.turnLeft 5 | case 'R' => robbie.turnRight 6 | case 'A' => robbie.advance 7 | } 8 | ) 9 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.approaches/recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | final def simulate(orders: String): Robot = 2 | if (orders.isEmpty) this 3 | else 4 | (orders.head match { 5 | case 'L' => turnLeft 6 | case 'R' => turnRight 7 | case 'A' => advance 8 | }).simulate(orders.tail) 9 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "mlopes", 8 | "ppartarr", 9 | "rajeshpg" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/RobotSimulator.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/RobotSimulatorTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Write a robot simulator.", 26 | "source": "Inspired by an interview question at a famous company." 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/src/main/scala/Robot.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/robot-simulator/src/main/scala/Robot.scala -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/src/main/scala/RobotSimulator.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/robot-simulator/src/main/scala/RobotSimulator.scala -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.approaches/iterate-takewhile-last/snippet.txt: -------------------------------------------------------------------------------- 1 | Iterator 2 | .iterate((num, 0, List[String]()))(tup => 3 | tup match { 4 | case (num, idx, digits) if num >= ArabicNum(idx) => 5 | (num - ArabicNum(idx), idx, RomanNum(idx) :: digits) 6 | case (num, idx, digits) => 7 | (num, idx + 1, digits)}) 8 | .takeWhile(tup => tup._2 < 13) 9 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.approaches/map-recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | def romanRecur(num: Int, digits: List[String]): String = 2 | (num, digits) match { 3 | case (0, digits) => digits.reverse.mkString 4 | case (num, digits) => { 5 | val digit = ArabicToRoman.keys.filter(_ <= num).max 6 | romanRecur(num - digit, ArabicToRoman(digit) :: digits) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.approaches/vectors-recursion/snippet.txt: -------------------------------------------------------------------------------- 1 | private def romanRecur(num: Int, idx: Int, digits: List[String]): String = { 2 | (num, idx, digits) match { 3 | case (_, 13, digits) => digits.reverse.mkString 4 | case (num, idx, digits) if num >= ArabicNum(idx) => 5 | romanRecur(num - ArabicNum(idx), idx, RomanNum(idx) :: digits) 6 | case (num, idx, digits) => 7 | romanRecur(num, idx + 1, digits)}} 8 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your task is to convert a number from Arabic numerals to Roman numerals. 4 | 5 | For this exercise, we are only concerned about traditional Roman numerals, in which the largest number is MMMCMXCIX (or 3,999). 6 | 7 | ~~~~exercism/note 8 | There are lots of different ways to convert between Arabic and Roman numerals. 9 | We recommend taking a naive approach first to familiarise yourself with the concept of Roman numerals and then search for more efficient methods. 10 | 11 | Make sure to check out our Deep Dive video at the end to explore the different approaches you can take! 12 | ~~~~ 13 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/src/main/scala/RomanNumerals.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/roman-numerals/src/main/scala/RomanNumerals.scala -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object RotationalCipher { 2 | private def rotate(c: Char, key: Int): Char = { 3 | if (!c.isLetter) 4 | return c 5 | 6 | val base = if (c.isUpper) 'A'.toInt else 'a'.toInt 7 | ((c.toInt - base + key) % 26 + base).toChar 8 | } 9 | 10 | def rotate(text: String, key: Int): String = 11 | text.map(rotate(_, key)).concat("") 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/RotationalCipher.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/RotationalCipherTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Create an implementation of the rotational cipher, also sometimes called the Caesar cipher.", 25 | "source": "Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/Caesar_cipher" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/src/main/scala/RotationalCipher.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/rotational-cipher/src/main/scala/RotationalCipher.scala -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "abo64" 4 | ], 5 | "contributors": [ 6 | "ppartarr", 7 | "rajeshpg", 8 | "ricemery" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/RunLengthEncoding.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/RunLengthEncodingTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Implement run-length encoding and decoding.", 25 | "source": "Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/Run-length_encoding" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/src/main/scala/RunLengthEncoding.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/run-length-encoding/src/main/scala/RunLengthEncoding.scala -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You plan to build a tree house in the woods near your house so that you can watch the sun rise and set. 4 | 5 | You've obtained data from a local survey company that show the height of every tree in each rectangular section of the map. 6 | You need to analyze each grid on the map to find good trees for your tree house. 7 | 8 | A good tree is both: 9 | 10 | - taller than every tree to the east and west, so that you have the best possible view of the sunrises and sunsets. 11 | - shorter than every tree to the north and south, to minimize the amount of tree climbing. 12 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | case class Matrix(values: List[List[Int]]) { 2 | lazy val saddlePoints: Set[(Int, Int)] = { 3 | val columns = values.transpose 4 | if (values.isEmpty || columns.isEmpty) { 5 | Set() 6 | } else { 7 | val rowMaxes = values.map(_.max).toVector 8 | val colMins = columns.map(_.min).toVector 9 | (for { 10 | i <- values.indices 11 | j <- columns.indices 12 | if rowMaxes(i) == colMins(j) 13 | } yield (i, j)).toSet 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/SaddlePoints.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/SaddlePointsTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Detect saddle points in a matrix.", 25 | "source": "J Dalbey's Programming Practice problems", 26 | "source_url": "https://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/src/main/scala/SaddlePoints.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/saddle-points/src/main/scala/SaddlePoints.scala -------------------------------------------------------------------------------- /exercises/practice/say/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "nlochschmidt", 8 | "ppartarr", 9 | "rajeshpg" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/Say.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/SayTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Given a number from 0 to 999,999,999,999, spell out that number in English.", 26 | "source": "A variation on the JavaRanch CattleDrive, Assignment 4", 27 | "source_url": "https://coderanch.com/wiki/718804" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/say/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/say/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/say/src/main/scala/Say.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/say/src/main/scala/Say.scala -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": [ 4 | "bobahop" 5 | ] 6 | }, 7 | "approaches": [ 8 | { 9 | "uuid": "5f2eaa9e-8112-422d-a385-b63fc216dbc4", 10 | "slug": "match-with-map", 11 | "title": "match with map", 12 | "blurb": "Use a match with map to return the answer.", 13 | "authors": [ 14 | "bobahop" 15 | ] 16 | }, 17 | { 18 | "uuid": "ba7fe14d-acf6-4998-aab7-1f64a9d2c522", 19 | "slug": "map-with-map", 20 | "title": "Map with map", 21 | "blurb": "Use a Map with map to return the answer.", 22 | "authors": [ 23 | "bobahop" 24 | ] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.approaches/map-with-map/snippet.txt: -------------------------------------------------------------------------------- 1 | private val lookup: Map[Char, Int] = Map( 2 | 1 -> "AEIOULNRST", 3 | 2 -> "DG", 4 | 3 -> "BCMP", 5 | 4 -> "FHVWY", 6 | 5 -> "K", 7 | 8 -> "JX", 8 | 10 -> "QZ").flatMap(tuple => tuple._2.map((_, tuple._1))) 9 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.approaches/match-with-map/snippet.txt: -------------------------------------------------------------------------------- 1 | private def letterValue(c: Char): Int = c match { 2 | case 'A' | 'E' | 'I' | 'O' | 'U' | 'L' | 'N' | 'R' | 'S' | 'T' => 1 3 | case 'D' | 'G' => 2 4 | case 'B' | 'C' | 'M' | 'P' => 3 5 | case 'F' | 'H' | 'V' | 'W' | 'Y' => 4 6 | case 'K' => 5 7 | case 'J' | 'X' => 8 8 | case 'Q' | 'Z' => 10} 9 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | [Scrabble][wikipedia] is a word game where players place letter tiles on a board to form words. 4 | Each letter has a value. 5 | A word's score is the sum of its letters' values. 6 | 7 | [wikipedia]: https://en.wikipedia.org/wiki/Scrabble 8 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object ScrabbleScore { 2 | 3 | def score(word: String): Int = word.foldLeft(0)((score, c) => score + scoreLetter(c)) 4 | 5 | def scoreLetter(c: Char): Int = letterScores.getOrElse(c.toUpper, 0) 6 | 7 | private val scores = List(("AEIOULNRST", 1), ("DG", 2), ("BCMP", 3), ("FHVWY", 4), 8 | ("K", 5), ("JX", 8), ("QZ", 10)) 9 | 10 | private val letterScores: Map[Char, Int] = 11 | scores.flatMap({case (letters, score) => for {c <- letters} yield (c, score)}).toMap 12 | } 13 | 14 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "kytrinyx", 8 | "ppartarr", 9 | "rajeshpg" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/ScrabbleScore.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/ScrabbleScoreTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Given a word, compute the Scrabble score for that word.", 26 | "source": "Inspired by the Extreme Startup game", 27 | "source_url": "https://github.com/rchatley/extreme_startup" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/src/main/scala/ScrabbleScore.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/scrabble-score/src/main/scala/ScrabbleScore.scala -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.approaches/foldleft-and-reverse/snippet.txt: -------------------------------------------------------------------------------- 1 | val signs = 2 | (0 until SIGNS.length) 3 | .foldLeft(Seq(): Seq[String])((output, index) => 4 | if ((1 << index & orders) != 0) output :+ SIGNS(index) 5 | else output 6 | ) 7 | 8 | if ((orders & REVERSE_SIGNS) == 0) signs else signs.reverse 9 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.approaches/foldleft-with-appended-or-prepended/snippet.txt: -------------------------------------------------------------------------------- 1 | val stitch = if ((orders & REVERSE_SIGNS) == 0) 2 | (coll: Seq[String], that: String) => coll.:+(that) 3 | else (coll: Seq[String], that: String) => coll.+:(that) 4 | 5 | (0 until SIGNS.length) 6 | .foldLeft(Seq(): Seq[String])((output, index) => 7 | if ((1 << index & orders) != 0) stitch(output, SIGNS(index)) 8 | else output) 9 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You are starting a secret coding club with some friends and friends-of-friends. 4 | Not everyone knows each other, so you and your friends have decided to create a secret handshake that you can use to recognize that someone is a member. 5 | You don't want anyone who isn't in the know to be able to crack the code. 6 | 7 | You've designed the code so that one person says a number between 1 and 31, and the other person turns it into a series of actions. 8 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/src/main/scala/SecretHandshake.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/secret-handshake/src/main/scala/SecretHandshake.scala -------------------------------------------------------------------------------- /exercises/practice/series/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a string of digits, output all the contiguous substrings of length `n` in that string in the order that they appear. 4 | 5 | For example, the string "49142" has the following 3-digit series: 6 | 7 | - "491" 8 | - "914" 9 | - "142" 10 | 11 | And the following 4-digit series: 12 | 13 | - "4914" 14 | - "9142" 15 | 16 | And if you ask for a 6-digit series from a 5-digit string, you deserve whatever you get. 17 | 18 | Note that these series are only required to occupy _adjacent positions_ in the input; 19 | the digits need not be _numerically consecutive_. 20 | -------------------------------------------------------------------------------- /exercises/practice/series/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Series { 2 | def slices(n: Int, s: String): Seq[Seq[Int]] = 3 | s.sliding(n).map(seq => seq.map(c => c.asDigit)).toSeq 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/series/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Series.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/SeriesTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Given a string of digits, output all the contiguous substrings of length `n` in that string.", 25 | "source": "A subset of the Problem 8 at Project Euler", 26 | "source_url": "https://projecteuler.net/problem=8" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/series/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/series/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/series/src/main/scala/Series.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/series/src/main/scala/Series.scala -------------------------------------------------------------------------------- /exercises/practice/sgf-parsing/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "abo64" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg", 9 | "ricemery" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/Sgf.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/SgfTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Parsing a Smart Game Format string." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/sgf-parsing/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | 5 | libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.0" 6 | -------------------------------------------------------------------------------- /exercises/practice/sgf-parsing/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/sgf-parsing/src/main/scala/Sgf.scala: -------------------------------------------------------------------------------- 1 | import scala.util.parsing.combinator.RegexParsers 2 | 3 | object Sgf extends RegexParsers { 4 | 5 | type Tree[A] = Node[A] // to separate the type from the constructor, cf. Haskell's Data.Tree 6 | type Forest[A] = List[Tree[A]] 7 | case class Node[A](rootLabel: A, subForest: Forest[A] = List()) 8 | 9 | // A tree of nodes. 10 | type SgfTree = Tree[SgfNode] 11 | 12 | // A node is a property list, each key can only occur once. 13 | // Keys may have multiple values associated with them. 14 | type SgfNode = Map[String, List[String]] 15 | 16 | def parseSgf(text: String): Option[SgfTree] = ??? 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You bought a big box of random computer parts at a garage sale. 4 | You've started putting the parts together to build custom computers. 5 | 6 | You want to test the performance of different combinations of parts, and decide to create your own benchmarking program to see how your computers compare. 7 | You choose the famous "Sieve of Eratosthenes" algorithm, an ancient algorithm, but one that should push your computers to the limits. 8 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Sieve.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/SieveTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.", 25 | "source": "Sieve of Eratosthenes at Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/sieve/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/sieve/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/sieve/src/main/scala/Sieve.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/sieve/src/main/scala/Sieve.scala -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Cipher.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/CipherTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Implement a simple shift cipher like Caesar and a more secure substitution cipher.", 25 | "source": "Substitution Cipher at Wikipedia", 26 | "source_url": "https://en.wikipedia.org/wiki/Substitution_cipher" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/src/main/scala/Cipher.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/simple-cipher/src/main/scala/Cipher.scala -------------------------------------------------------------------------------- /exercises/practice/simple-linked-list/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a music streaming company. 4 | 5 | You've been tasked with creating a playlist feature for your music player application. 6 | -------------------------------------------------------------------------------- /exercises/practice/simple-linked-list/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | libraryDependencies += "org.scalatestplus" %% "scalacheck-1-18" % "3.2.19.0" % Test 5 | 6 | -------------------------------------------------------------------------------- /exercises/practice/simple-linked-list/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/simple-linked-list/src/main/scala/SimpleLinkedList.scala: -------------------------------------------------------------------------------- 1 | trait SimpleLinkedList[T] { 2 | def isEmpty: Boolean 3 | def value: T 4 | def add(item: T): SimpleLinkedList[T] 5 | def next: SimpleLinkedList[T] 6 | def reverse: SimpleLinkedList[T] 7 | def toSeq: Seq[T] 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.approaches/applydynamic/snippet.txt: -------------------------------------------------------------------------------- 1 | private def calculate(planet: String, seconds: Double): Double = 2 | seconds / EarthSeconds / PlanetRatio.getOrElse(planet, 1.0) 3 | 4 | def applyDynamic(methodCall: String)(seconds: Double): Double = 5 | calculate(methodCall.substring(2), seconds) 6 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.approaches/currying/snippet.txt: -------------------------------------------------------------------------------- 1 | private val EARTH_SECONDS = 31_557_600.0 2 | private def calculate(orbitPeriod: Double) = 3 | (seconds: Double) => seconds / EARTH_SECONDS / orbitPeriod 4 | 5 | val onEarth = calculate(1.0) 6 | val onMercury = calculate(0.2408467) 7 | val onVenus = calculate(0.61519726) 8 | val onMars = calculate(1.8808158) 9 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.approaches/partial-application/snippet.txt: -------------------------------------------------------------------------------- 1 | private val EARTH_SECONDS = 31_557_600.0 2 | private def calculate(orbitPeriod: Double, seconds: Double): Double = 3 | seconds / EARTH_SECONDS / orbitPeriod 4 | 5 | val onEarth = calculate(1, _) 6 | val onMercury = calculate(0.2408467, _) 7 | val onVenus = calculate(0.61519726, _) 8 | val onMars = calculate(1.8808158, _) 9 | -------------------------------------------------------------------------------- /exercises/practice/space-age/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/space-age/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/space-age/src/main/scala/SpaceAge.scala: -------------------------------------------------------------------------------- 1 | object SpaceAge { 2 | def onEarth(age: Double): Double = ??? 3 | 4 | def onVenus(age: Double): Double = ??? 5 | 6 | def onMercury(age: Double): Double = ??? 7 | 8 | def onMars(age: Double): Double = ??? 9 | 10 | def onJupiter(age: Double): Double = ??? 11 | 12 | def onSaturn(age: Double): Double = ??? 13 | 14 | def onUranus(age: Double): Double = ??? 15 | 16 | def onNeptune(age: Double): Double = ??? 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to return a square matrix of a given size. 4 | 5 | The matrix should be filled with natural numbers, starting from 1 in the top-left corner, increasing in an inward, clockwise spiral order, like these examples: 6 | 7 | ## Examples 8 | 9 | ### Spiral matrix of size 3 10 | 11 | ```text 12 | 1 2 3 13 | 8 9 4 14 | 7 6 5 15 | ``` 16 | 17 | ### Spiral matrix of size 4 18 | 19 | ```text 20 | 1 2 3 4 21 | 12 13 14 5 22 | 11 16 15 6 23 | 10 9 8 7 24 | ``` 25 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/src/main/scala/SpiralMatrix.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/spiral-matrix/src/main/scala/SpiralMatrix.scala -------------------------------------------------------------------------------- /exercises/practice/strain/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | import scala.annotation.tailrec 2 | 3 | object Strain { 4 | def keep[A](seq: Seq[A], func: A => Boolean): Seq[A] = 5 | recurse(seq, func, List()).reverse 6 | 7 | def discard[A](seq: Seq[A], func: A => Boolean): Seq[A] = { 8 | val notFunc: A => Boolean = a => !func(a) 9 | recurse(seq, notFunc, List()).reverse 10 | } 11 | 12 | @tailrec 13 | private def recurse[A](seq: Seq[A], func: A => Boolean, acc: Seq[A]): Seq[A] = 14 | seq match { 15 | case Nil => acc 16 | case x::xs => 17 | if (func(x)) 18 | recurse(xs, func, x +: acc) 19 | else 20 | recurse(xs, func, acc) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/strain/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Strain.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/StrainTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Implement the `keep` and `discard` operation on collections.", 25 | "source": "Conversation with James Edward Gray II", 26 | "source_url": "http://graysoftinc.com/" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/strain/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/strain/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/strain/src/main/scala/Strain.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/strain/src/main/scala/Strain.scala -------------------------------------------------------------------------------- /exercises/practice/sublist/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Sublist extends Enumeration { 2 | def sublist[T](l1: List[T], l2: List[T]): Value = { 3 | if (equal(l1, l2)) Equal 4 | else if (isSublist(l1, l2)) Sublist 5 | else if (isSuperlist(l1, l2)) Superlist 6 | else Unequal 7 | } 8 | 9 | private def equal[T](l1: List[T], l2: List[T]) = l1.equals(l2) 10 | 11 | private def isSublist[T](l1: List[T], l2: List[T]) = l2.containsSlice(l1) 12 | 13 | private def isSuperlist[T](l1: List[T], l2: List[T]) = l1.containsSlice(l2) 14 | 15 | type SublistType = Value 16 | val Equal, Sublist, Superlist, Unequal = Value 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/sublist/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "petertseng", 8 | "ppartarr", 9 | "rajeshpg" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/Sublist.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/SublistTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Write a function to determine if a list is a sublist of another list." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/sublist/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/sublist/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/sublist/src/main/scala/Sublist.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/sublist/src/main/scala/Sublist.scala -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a company that makes an online, fantasy-survival game. 4 | 5 | When a player finishes a level, they are awarded energy points. 6 | The amount of energy awarded depends on which magical items the player found while exploring that level. 7 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object SumOfMultiples { 2 | def sum(factors: Set[Int], limit: Int): Int = { 3 | def isDivisibleBy(x: Int)(y: Int): Boolean = x % y == 0 4 | def isMultiple(x: Int): Boolean = factors exists isDivisibleBy(x) 5 | 6 | val multiples = (1 until limit) filter isMultiple 7 | multiples.sum 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/src/main/scala/SumOfMultiples.scala: -------------------------------------------------------------------------------- 1 | object SumOfMultiples { 2 | def sum(factors: Set[Int], limit: Int): Int = ??? 3 | } 4 | 5 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | case class Triangle(a: Double, b: Double, c: Double) { 2 | private def checkInequality = a + b >= c && a + c >= b && b + c >= a 3 | 4 | val illogical: Boolean = List(a, b, c).count(_ <= 0) > 0 || !checkInequality 5 | val isosceles: Boolean = !illogical && (a == b || a == c || b == c) 6 | val equilateral: Boolean = !illogical && ( a == b && b == c) 7 | val scalene: Boolean = !illogical && !isosceles && !equilateral 8 | } -------------------------------------------------------------------------------- /exercises/practice/triangle/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/triangle/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/triangle/src/main/scala/Triangle.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/triangle/src/main/scala/Triangle.scala -------------------------------------------------------------------------------- /exercises/practice/trinary/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/trinary/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/trinary/src/main/scala/Trinary.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/trinary/src/main/scala/Trinary.scala -------------------------------------------------------------------------------- /exercises/practice/two-fer/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine what you will say as you give away the extra cookie. 4 | 5 | If you know the person's name (e.g. if they're named Do-yun), then you will say: 6 | 7 | ```text 8 | One for Do-yun, one for me. 9 | ``` 10 | 11 | If you don't know the person's name, you will say _you_ instead. 12 | 13 | ```text 14 | One for you, one for me. 15 | ``` 16 | 17 | Here are some examples: 18 | 19 | | Name | Dialogue | 20 | | :----- | :-------------------------- | 21 | | Alice | One for Alice, one for me. | 22 | | Bohdan | One for Bohdan, one for me. | 23 | | | One for you, one for me. | 24 | | Zaphod | One for Zaphod, one for me. | 25 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | In some English accents, when you say "two for" quickly, it sounds like "two fer". 4 | Two-for-one is a way of saying that if you buy one, you also get one for free. 5 | So the phrase "two-fer" often implies a two-for-one offer. 6 | 7 | Imagine a bakery that has a holiday offer where you can buy two cookies for the price of one ("two-fer one!"). 8 | You take the offer and (very generously) decide to give the extra cookie to someone else in the queue. 9 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | object Twofer { 2 | def twofer(name: String = "you"): String = 3 | s"One for $name, one for me." 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ricemery" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/main/scala/Twofer.scala" 13 | ], 14 | "test": [ 15 | "src/test/scala/TwoferTest.scala" 16 | ], 17 | "example": [ 18 | ".meta/Example.scala" 19 | ], 20 | "invalidator": [ 21 | "build.sbt" 22 | ] 23 | }, 24 | "blurb": "Create a sentence of the form \"One for X, one for me.\".", 25 | "source_url": "https://github.com/exercism/problem-specifications/issues/757" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/src/main/scala/Twofer.scala: -------------------------------------------------------------------------------- 1 | object Twofer { 2 | def twofer(name: String): String = ??? 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/src/test/scala/TwoferTest.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.funsuite.AnyFunSuite 2 | import org.scalatest.matchers.should.Matchers 3 | 4 | 5 | /** @version 1.2.0 */ 6 | class TwoferTest extends AnyFunSuite with Matchers { 7 | 8 | test("no name given") { 9 | Twofer.twofer() should be ("One for you, one for me.") 10 | } 11 | 12 | test("a name given") { 13 | pending 14 | Twofer.twofer("Alice") should be ("One for Alice, one for me.") 15 | } 16 | 17 | test("another name given") { 18 | pending 19 | Twofer.twofer("Bob") should be ("One for Bob, one for me.") 20 | } 21 | } -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | Remember that in Scala there are two forms of the right shift operator. The `>>` operator preserves the sign, while `>>>` zeroes the leftmost bits. 3 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/src/main/scala/VariableLengthQuantity.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/variable-length-quantity/src/main/scala/VariableLengthQuantity.scala -------------------------------------------------------------------------------- /exercises/practice/word-count/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You teach English as a foreign language to high school students. 4 | 5 | You've decided to base your entire curriculum on TV shows. 6 | You need to analyze which words are used, and how often they're repeated. 7 | 8 | This will let you choose the simplest shows to start with, and to gradually increase the difficulty as time passes. 9 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.meta/Example.scala: -------------------------------------------------------------------------------- 1 | case class WordCount(phrase: String) { 2 | def countWords = "\\w+('\\w+)*".r 3 | .findAllIn(phrase) 4 | .toSeq 5 | .map(_.toLowerCase) 6 | .groupBy(w => w) 7 | .mapValues(_.length) 8 | .toMap 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/word-count/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/word-count/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/word-count/src/main/scala/WordCount.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/word-count/src/main/scala/WordCount.scala -------------------------------------------------------------------------------- /exercises/practice/wordy/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/wordy/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/wordy/src/main/scala/Wordy.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/scala/bbce1ca1122f713f5d6d002b3d6a7d14a60efb21/exercises/practice/wordy/src/main/scala/Wordy.scala -------------------------------------------------------------------------------- /exercises/practice/yacht/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Each year, something new is "all the rage" in your high school. 4 | This year it is a dice game: [Yacht][yacht]. 5 | 6 | The game of Yacht is from the same family as Poker Dice, Generala and particularly Yahtzee, of which it is a precursor. 7 | The game consists of twelve rounds. 8 | In each, five dice are rolled and the player chooses one of twelve categories. 9 | The chosen category is then used to score the throw of the dice. 10 | 11 | [yacht]: https://en.wikipedia.org/wiki/Yacht_(dice_game) 12 | -------------------------------------------------------------------------------- /exercises/practice/yacht/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wangxiaoxuan273" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "src/main/scala/Yacht.scala" 8 | ], 9 | "test": [ 10 | "src/test/scala/YachtTest.scala" 11 | ], 12 | "example": [ 13 | ".meta/Example.scala" 14 | ], 15 | "invalidator": [ 16 | "build.sbt" 17 | ] 18 | }, 19 | "blurb": "Score a single throw of dice in the game Yacht.", 20 | "source": "James Kilfiger, using Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/yacht/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/yacht/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/yacht/src/main/scala/Yacht.scala: -------------------------------------------------------------------------------- 1 | object Yacht { 2 | 3 | def score(dices: List[Int], category: String): Int = ??? 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "abo64" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg", 9 | "ricemery" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/ZebraPuzzle.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/ZebraPuzzleTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Solve the zebra puzzle.", 26 | "source": "Wikipedia", 27 | "source_url": "https://en.wikipedia.org/wiki/Zebra_Puzzle" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/src/main/scala/ZebraPuzzle.scala: -------------------------------------------------------------------------------- 1 | object ZebraPuzzle { 2 | 3 | sealed trait Resident 4 | case object Englishman extends Resident 5 | case object Spaniard extends Resident 6 | case object Ukrainian extends Resident 7 | case object Norwegian extends Resident 8 | case object Japanese extends Resident 9 | 10 | case class Solution(waterDrinker: Resident, zebraOwner: Resident) 11 | 12 | lazy val solve: Solution = ??? 13 | } 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/src/test/scala/ZebraPuzzleTest.scala: -------------------------------------------------------------------------------- 1 | import org.scalatest.funsuite.AnyFunSuite 2 | import org.scalatest.matchers.should.Matchers 3 | 4 | import ZebraPuzzle._ 5 | 6 | /** @version created manually **/ 7 | class ZebraPuzzleTest extends AnyFunSuite with Matchers { 8 | test("solve the Zebra Puzzle") { 9 | ZebraPuzzle.solve should be ( 10 | Solution(waterDrinker = Norwegian, 11 | zebraOwner = Japanese)) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/zipper/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "abo64" 4 | ], 5 | "contributors": [ 6 | "ErikSchierboom", 7 | "ppartarr", 8 | "rajeshpg", 9 | "ricemery" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "src/main/scala/Zipper.scala" 14 | ], 15 | "test": [ 16 | "src/test/scala/ZipperTest.scala" 17 | ], 18 | "example": [ 19 | ".meta/Example.scala" 20 | ], 21 | "invalidator": [ 22 | "build.sbt" 23 | ] 24 | }, 25 | "blurb": "Creating a zipper for a binary tree." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/zipper/build.sbt: -------------------------------------------------------------------------------- 1 | scalaVersion := "3.4.2" 2 | 3 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test 4 | -------------------------------------------------------------------------------- /exercises/practice/zipper/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /exercises/shared/.docs/help.md: -------------------------------------------------------------------------------- 1 | # Help 2 | 3 | Please see the [learning](https://exercism.org/docs/tracks/scala/learning) and [installation](https://exercism.org/docs/tracks/scala/installation) pages if you need any help. 4 | -------------------------------------------------------------------------------- /exercises/shared/.docs/tests.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | To run the tests, run the command `sbt test` in the exercise's directory. 4 | See the [tests page](https://exercism.org/docs/tracks/scala/tests) for more information. 5 | 6 | ## Skipped tests 7 | 8 | Initially, only the first test will be enabled. 9 | This is to encourage you to solve the exercise one step at a time. 10 | Once you get the first test passing, remove the `pending` keyword from the beginning of the next test and work on getting that test passing. 11 | -------------------------------------------------------------------------------- /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("org.playframework.twirl" % "sbt-twirl" % "2.0.7") 2 | 3 | -------------------------------------------------------------------------------- /reference/exercise-concepts/hello-world.md: -------------------------------------------------------------------------------- 1 | # Hello World 2 | 3 | [Example implementation](https://github.com/exercism/scala/blob/master/exercises/hello-world/example.scala) 4 | 5 | # General 6 | 7 | - object or case class: used as class wrapper for exercise 8 | - functions: used as main entry point for the exercise 9 | - function arguments: input strands passed as arguments 10 | - return values: return a value from a function 11 | - string: make String using `"` 12 | - functions: make function using `def [NAME]([ARGUMENTS]): [RETURN_TYPE] = [CONTENT]` 13 | -------------------------------------------------------------------------------- /reference/implementing-a-concept-exercise.md: -------------------------------------------------------------------------------- 1 | # How to implement an Scala concept exercise 2 | 3 | TODO: describe how to implement a concept exercise for the Scala track. For inspiration, check out the [C# version of this file][csharp-implementing]. 4 | 5 | [csharp-implementing]: https://github.com/exercism/v3/blob/main/csharp/reference/implementing-a-concept-exercise.md 6 | -------------------------------------------------------------------------------- /testgen/src/main/resources/version-check-ignore.txt: -------------------------------------------------------------------------------- 1 | binary 2 | hexadecimal 3 | octal 4 | trinary -------------------------------------------------------------------------------- /testgen/src/main/scala/testgen/TestGenError.scala: -------------------------------------------------------------------------------- 1 | package testgen 2 | 3 | import scala.util.control.NoStackTrace 4 | 5 | enum TestGenError extends NoStackTrace: 6 | case ParserError(value: String) 7 | 8 | override def getMessage(): String = productPrefix 9 | 10 | type Result[A] = Either[TestGenError, A] 11 | -------------------------------------------------------------------------------- /testgen/src/main/twirl/funSuiteTemplate.scala.txt: -------------------------------------------------------------------------------- 1 | @(data: testgen.TestSuiteData)@for(imp <- data.imports) {import @imp} 2 | import org.scalatest.funsuite.AnyFunSuite 3 | import org.scalatest.matchers.should.Matchers 4 | 5 | class @data.name extends AnyFunSuite, Matchers: 6 | @for(statement <- data.statements) { @statement } 7 | @for(testCase <- data.testCases) { 8 | test("@testCase.description"): 9 | @if(testCase.pending) {pending} 10 | @testCase.suiteCall should be (@testCase.expected) 11 | } 12 | --------------------------------------------------------------------------------