├── .appends └── .github │ └── labels.yml ├── .github ├── CODEOWNERS ├── configlet-sync-issue.md ├── dependabot.yml ├── labels.yml ├── stale.yml └── workflows │ ├── ci.yml │ ├── configlet-sync.yml │ ├── configlet.yml │ ├── no-important-files-changed.yml │ ├── ping-cross-track-maintainers-team.yml │ └── sync-labels.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SETUP.md ├── bin ├── fetch-configlet ├── generate_practice_exercise ├── stub-check └── test-examples ├── config.json ├── docs ├── ABOUT.md ├── INSTALLATION.md ├── LEARNING.md ├── RESOURCES.md ├── SNIPPET.txt ├── TESTS.md ├── config.json └── img │ └── dual-pane.png ├── exercises ├── .dir-locals.el ├── practice │ ├── accumulate │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── accumulate-test.el │ │ └── accumulate.el │ ├── acronym │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── acronym-test.el │ │ └── acronym.el │ ├── affine-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── affine-cipher-test.el │ │ └── affine-cipher.el │ ├── all-your-base │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── all-your-base-test.el │ │ └── all-your-base.el │ ├── allergies │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── allergies-test.el │ │ └── allergies.el │ ├── anagram │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── anagram-test.el │ │ └── anagram.el │ ├── armstrong-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── armstrong-numbers-test.el │ │ └── armstrong-numbers.el │ ├── atbash-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── atbash-cipher-test.el │ │ └── atbash-cipher.el │ ├── bank-account │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── bank-account-test.el │ │ └── bank-account.el │ ├── binary-search │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── binary-search-test.el │ │ └── binary-search.el │ ├── binary │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── binary-test.el │ │ └── binary.el │ ├── bob │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── bob-test.el │ │ └── bob.el │ ├── circular-buffer │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── circular-buffer-test.el │ │ └── circular-buffer.el │ ├── collatz-conjecture │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── collatz-conjecture-test.el │ │ └── collatz-conjecture.el │ ├── crypto-square │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── crypto-square-test.el │ │ └── crypto-square.el │ ├── darts │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── darts-test.el │ │ └── darts.el │ ├── diamond │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── diamond-test.el │ │ └── diamond.el │ ├── difference-of-squares │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── difference-of-squares-test.el │ │ └── difference-of-squares.el │ ├── dnd-character │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── dnd-character-test.el │ │ └── dnd-character.el │ ├── eliuds-eggs │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── eliuds-eggs-test.el │ │ └── eliuds-eggs.el │ ├── etl │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── etl-test.el │ │ └── etl.el │ ├── flatten-array │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── flatten-array-test.el │ │ └── flatten-array.el │ ├── food-chain │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── food-chain-test.el │ │ └── food-chain.el │ ├── game-of-life │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── game-of-life-test.el │ │ └── game-of-life.el │ ├── gigasecond │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── gigasecond-test.el │ │ └── gigasecond.el │ ├── grade-school │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── grade-school-test.el │ │ └── grade-school.el │ ├── grains │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── grains-test.el │ │ └── grains.el │ ├── hamming │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── hamming-test.el │ │ └── hamming.el │ ├── hello-world │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── hello-world-test.el │ │ └── hello-world.el │ ├── isbn-verifier │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── isbn-verifier-test.el │ │ └── isbn-verifier.el │ ├── isogram │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── isogram-test.el │ │ └── isogram.el │ ├── kindergarten-garden │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── kindergarten-garden-test.el │ │ └── kindergarten-garden.el │ ├── knapsack │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── knapsack-test.el │ │ └── knapsack.el │ ├── largest-series-product │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── largest-series-product-test.el │ │ └── largest-series-product.el │ ├── leap │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── leap-test.el │ │ └── leap.el │ ├── linked-list │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── linked-list-test.el │ │ └── linked-list.el │ ├── list-ops │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── list-ops-test.el │ │ └── list-ops.el │ ├── luhn │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── luhn-test.el │ │ └── luhn.el │ ├── matching-brackets │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── matching-brackets-test.el │ │ └── matching-brackets.el │ ├── meetup │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── meetup-test.el │ │ └── meetup.el │ ├── minesweeper │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── minesweeper-test.el │ │ └── minesweeper.el │ ├── nth-prime │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── nth-prime-test.el │ │ └── nth-prime.el │ ├── nucleotide-count │ │ ├── .docs │ │ │ ├── hints.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── nucleotide-count-test.el │ │ └── nucleotide-count.el │ ├── pangram │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── pangram-test.el │ │ └── pangram.el │ ├── parallel-letter-frequency │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── parallel-letter-frequency-test.el │ │ └── parallel-letter-frequency.el │ ├── pascals-triangle │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── pascals-triangle-test.el │ │ └── pascals-triangle.el │ ├── perfect-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── perfect-numbers-test.el │ │ └── perfect-numbers.el │ ├── phone-number │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── phone-number-test.el │ │ └── phone-number.el │ ├── pig-latin │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── pig-latin-test.el │ │ └── pig-latin.el │ ├── prime-factors │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── prime-factors-test.el │ │ └── prime-factors.el │ ├── protein-translation │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── protein-translation-test.el │ │ └── protein-translation.el │ ├── proverb │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── proverb-test.el │ │ └── proverb.el │ ├── pythagorean-triplet │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── pythagorean-triplet-test.el │ │ └── pythagorean-triplet.el │ ├── queen-attack │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── queen-attack-test.el │ │ └── queen-attack.el │ ├── rail-fence-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── rail-fence-cipher-test.el │ │ └── rail-fence-cipher.el │ ├── raindrops │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── raindrops-test.el │ │ └── raindrops.el │ ├── resistor-color-duo │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── resistor-color-duo-test.el │ │ └── resistor-color-duo.el │ ├── resistor-color-trio │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── resistor-color-trio-test.el │ │ └── resistor-color-trio.el │ ├── resistor-color │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── resistor-color-test.el │ │ └── resistor-color.el │ ├── reverse-string │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── reverse-string-test.el │ │ └── reverse-string.el │ ├── rna-transcription │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── rna-transcription-test.el │ │ └── rna-transcription.el │ ├── robot-name │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.el │ │ ├── robot-name-test.el │ │ └── robot-name.el │ ├── robot-simulator │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── robot-simulator-test.el │ │ └── robot-simulator.el │ ├── roman-numerals │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── roman-numerals-test.el │ │ └── roman-numerals.el │ ├── rotational-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── rotational-cipher-test.el │ │ └── rotational-cipher.el │ ├── run-length-encoding │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── run-length-encoding-test.el │ │ └── run-length-encoding.el │ ├── satellite │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── satellite-test.el │ │ └── satellite.el │ ├── say │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── say-test.el │ │ └── say.el │ ├── scrabble-score │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── scrabble-score-test.el │ │ └── scrabble-score.el │ ├── secret-handshake │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── secret-handshake-test.el │ │ └── secret-handshake.el │ ├── series │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── series-test.el │ │ └── series.el │ ├── sieve │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── sieve-test.el │ │ └── sieve.el │ ├── simple-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── simple-cipher-test.el │ │ └── simple-cipher.el │ ├── space-age │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── space-age-test.el │ │ └── space-age.el │ ├── spiral-matrix │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── spiral-matrix-test.el │ │ └── spiral-matrix.el │ ├── square-root │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── square-root-test.el │ │ └── square-root.el │ ├── strain │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── strain-test.el │ │ └── strain.el │ ├── sublist │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── sublist-test.el │ │ └── sublist.el │ ├── sum-of-multiples │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── sum-of-multiples-test.el │ │ └── sum-of-multiples.el │ ├── triangle │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── triangle-test.el │ │ └── triangle.el │ ├── trinary │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── trinary-test.el │ │ └── trinary.el │ ├── two-bucket │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── two-bucket-test.el │ │ └── two-bucket.el │ ├── two-fer │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── two-fer-test.el │ │ └── two-fer.el │ ├── variable-length-quantity │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── variable-length-quantity-test.el │ │ └── variable-length-quantity.el │ ├── word-count │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── word-count-test.el │ │ └── word-count.el │ ├── yacht │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.el │ │ │ └── tests.toml │ │ ├── yacht-test.el │ │ └── yacht.el │ └── zebra-puzzle │ │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ │ ├── .meta │ │ ├── config.json │ │ ├── example.el │ │ └── tests.toml │ │ ├── zebra-puzzle-test.el │ │ └── zebra-puzzle.el └── shared │ └── .docs │ ├── debug.md │ ├── help.md │ └── tests.md ├── reference ├── exercise-concepts │ └── rna-transcription.md ├── implementing-a-concept-exercise.md └── progression.md └── tools ├── README.md ├── install-packages.el ├── practice-exercise-generator.el └── templates ├── exercises └── practice │ ├── solution.mustache │ └── test.mustache └── partials ├── footer.mustache └── header.mustache /.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/configlet-sync-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Out of sync practice exercises 3 | --- 4 | 5 | Out of sync practice exercises have been detected: 6 | 7 | Command: `configlet sync --tests --docs --metadata --filepaths` 8 | 9 | Output: 10 | ``` 11 | {{ env.SYNC_OUTPUT }} 12 | ``` 13 | -------------------------------------------------------------------------------- /.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/stale.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/emacs-lisp/4c972d0d8443d41981105fe24368340d2f9ad92c/.github/stale.yml -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: emacs-lisp / main 2 | 3 | on: 4 | push: 5 | branches: [master, main] 6 | pull_request: 7 | workflow_dispatch: 8 | 9 | jobs: 10 | ci: 11 | runs-on: ubuntu-24.04 12 | 13 | steps: 14 | - uses: purcell/setup-emacs@7a92187aa5b5a3b854cbdfa47499fbd3d1207163 15 | with: 16 | version: 30.1 17 | 18 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.0.0 19 | 20 | - name: Run exercism/emacs-lisp ci (runs tests) for all exercises 21 | run: | 22 | bash bin/stub-check 23 | bash bin/test-examples 24 | -------------------------------------------------------------------------------- /.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/no-important-files-changed.yml: -------------------------------------------------------------------------------- 1 | name: No important files changed 2 | 3 | on: 4 | pull_request_target: 5 | types: [opened] 6 | branches: [main] 7 | paths: 8 | - "exercises/concept/**" 9 | - "exercises/practice/**" 10 | - "!exercises/*/*/.approaches/**" 11 | - "!exercises/*/*/.articles/**" 12 | - "!exercises/*/*/.docs/**" 13 | - "!exercises/*/*/.meta/**" 14 | 15 | permissions: 16 | pull-requests: write 17 | 18 | jobs: 19 | check: 20 | uses: exercism/github-actions/.github/workflows/check-no-important-files-changed.yml@main 21 | with: 22 | repository: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }} 23 | ref: ${{ github.head_ref }} 24 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | .DS_Store 3 | bin/configlet 4 | bin/configlet.exe 5 | CHECKLIST 6 | -------------------------------------------------------------------------------- /SETUP.md: -------------------------------------------------------------------------------- 1 | # Setup 2 | 3 | Check out [Exercism Help](http://exercism.io/languages/elisp) for instructions getting started with Emacs and 4 | Emacs Lisp. 5 | -------------------------------------------------------------------------------- /bin/test-examples: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | # make sure we are in the right place 4 | if [[ ! -d exercises ]]; then 5 | # can't run this script from wherever we are 6 | die "can't run 'test-example' from ${PWD}." 7 | fi 8 | 9 | err_cnt=0 10 | 11 | pushd exercises/practice > /dev/null 12 | for exercise in *; do 13 | pushd $exercise 14 | mv "${exercise}.el" "${exercise}.el.bak" 15 | cp .meta/example.el "${exercise}.el" 16 | emacs -batch -l ert -l "${exercise}-test.el" -f ert-run-tests-batch-and-exit 17 | let "err_cnt += $?" 18 | mv "${exercise}.el.bak" "${exercise}.el" 19 | popd 20 | done 21 | popd > /dev/null 22 | 23 | [ $err_cnt -eq 0 ] || exit 1 24 | -------------------------------------------------------------------------------- /docs/SNIPPET.txt: -------------------------------------------------------------------------------- 1 | (defun hello (&optional name) 2 | "Say hello, optionally to NAME." 3 | (let ((greetee (or name "World"))) 4 | (concat "Hello, " greetee "!"))) 5 | -------------------------------------------------------------------------------- /docs/img/dual-pane.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/emacs-lisp/4c972d0d8443d41981105fe24368340d2f9ad92c/docs/img/dual-pane.png -------------------------------------------------------------------------------- /exercises/.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;;; Directory Local Variables 2 | ;;; For more information see (info "(emacs) Directory Variables") 3 | 4 | ((emacs-lisp-mode 5 | (indent-tabs-mode))) 6 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Implement the `accumulate` operation, which, given a collection and an operation to perform on each element of the collection, returns a new collection containing the result of applying that operation to each element of the input collection. 4 | 5 | Given the collection of numbers: 6 | 7 | - 1, 2, 3, 4, 5 8 | 9 | And the operation: 10 | 11 | - square a number (`x => x * x`) 12 | 13 | Your code should be able to produce the collection of squares: 14 | 15 | - 1, 4, 9, 16, 25 16 | 17 | Check out the test suite to see the expected function signature. 18 | 19 | ## Restrictions 20 | 21 | Keep your hands off that collect/map/fmap/whatchamacallit functionality provided by your standard library! 22 | Solve this one yourself using other basic tools instead. 23 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "accumulate.el" 8 | ], 9 | "test": [ 10 | "accumulate-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Implement the `accumulate` operation, which, given a collection and an operation to perform on each element of the collection, returns a new collection containing the result of applying that operation to each element of the input collection.", 17 | "source": "Conversation with James Edward Gray II", 18 | "source_url": "http://graysoftinc.com/" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; accumulate.el --- Accumulate (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun accumulate (lst op) 9 | (cond 10 | ((null lst) lst) 11 | (t (cons (funcall op (car lst)) (accumulate (cdr lst) op))))) 12 | 13 | 14 | (provide 'accumulate) 15 | ;;; accumulate.el ends here 16 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/accumulate.el: -------------------------------------------------------------------------------- 1 | ;;; accumulate.el --- Accumulate (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun accumulate (lst op) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'accumulate) 13 | ;;; accumulate.el ends here 14 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wasamasa" 4 | ], 5 | "contributors": [ 6 | "vermiculus", 7 | "yurrriq" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "acronym.el" 12 | ], 13 | "test": [ 14 | "acronym-test.el" 15 | ], 16 | "example": [ 17 | ".meta/example.el" 18 | ] 19 | }, 20 | "blurb": "Convert a long phrase to its acronym.", 21 | "source": "Julien Vanier", 22 | "source_url": "https://github.com/monkbroc" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; acronym.el --- Acronym (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun acronym (input) 10 | (let ((words (split-string (string-replace "'" "" input) "\\W+"))) 11 | (mapconcat (lambda (word) (upcase (substring word 0 1))) words ""))) 12 | 13 | (provide 'acronym) 14 | ;;; acronym.el ends here 15 | -------------------------------------------------------------------------------- /exercises/practice/acronym/acronym.el: -------------------------------------------------------------------------------- 1 | ;;; acronym.el --- Acronym (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun acronym (phrase) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | (provide 'acronym) 12 | ;;; acronym.el ends here 13 | -------------------------------------------------------------------------------- /exercises/practice/affine-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "affine-cipher.el" 8 | ], 9 | "test": [ 10 | "affine-cipher-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Create an implementation of the Affine cipher, an ancient encryption algorithm from the Middle East.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Affine_cipher" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/affine-cipher/affine-cipher.el: -------------------------------------------------------------------------------- 1 | ;;; affine-cipher.el --- Affine Cipher (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun encode (phrase key) 9 | (error 10 | "Delete this S-Expression and write your own implementation")) 11 | 12 | (defun decode (phrase key) 13 | (error 14 | "Delete this S-Expression and write your own implementation")) 15 | 16 | 17 | (provide 'affine-cipher) 18 | ;;; affine-cipher.el ends here 19 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Convert a sequence of digits in one base, representing a number, into a sequence of digits in another base, representing the same number. 4 | 5 | ~~~~exercism/note 6 | Try to implement the conversion yourself. 7 | Do not use something else to perform the conversion for you. 8 | ~~~~ 9 | 10 | ## About [Positional Notation][positional-notation] 11 | 12 | In positional notation, a number in base **b** can be understood as a linear combination of powers of **b**. 13 | 14 | The number 42, _in base 10_, means: 15 | 16 | `(4 × 10¹) + (2 × 10⁰)` 17 | 18 | The number 101010, _in base 2_, means: 19 | 20 | `(1 × 2⁵) + (0 × 2⁴) + (1 × 2³) + (0 × 2²) + (1 × 2¹) + (0 × 2⁰)` 21 | 22 | The number 1120, _in base 3_, means: 23 | 24 | `(1 × 3³) + (1 × 3²) + (2 × 3¹) + (0 × 3⁰)` 25 | 26 | _Yes. Those three numbers above are exactly the same. Congratulations!_ 27 | 28 | [positional-notation]: https://en.wikipedia.org/wiki/Positional_notation 29 | -------------------------------------------------------------------------------- /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 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "all-your-base.el" 8 | ], 9 | "test": [ 10 | "all-your-base-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Convert a number, represented as a sequence of digits in one base, to any other base." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/all-your-base.el: -------------------------------------------------------------------------------- 1 | ;;; all-your-base.el --- All Your Base (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defun rebase (list-of-digits in-base out-base) 8 | (error "Delete this S-Expression and write your own implementation")) 9 | 10 | (provide 'all-your-base) 11 | ;;; all-your-base.el ends here 12 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "vermiculus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "allergies.el" 11 | ], 12 | "test": [ 13 | "allergies-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 17 | ] 18 | }, 19 | "blurb": "Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.", 20 | "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 21 | "source_url": "https://turing.edu" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/allergies/allergies.el: -------------------------------------------------------------------------------- 1 | ;;; allergies.el --- Allergies Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun allergen-list (score) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (defun allergic-to-p (score allergen) 13 | (error "Delete this S-Expression and write your own implementation")) 14 | 15 | 16 | (provide 'allergies) 17 | ;;; allergies.el ends here 18 | -------------------------------------------------------------------------------- /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/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a target word and one or more candidate words, your task is to find the candidates that are anagrams of the target. 4 | 5 | An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`. 6 | A word is _not_ its own anagram: for example, `"stop"` is not an anagram of `"stop"`. 7 | 8 | The target word and candidate words are made up of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`). 9 | Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `"StoP"` is not an anagram of `"sTOp"`. 10 | The words you need to find should be taken from the candidate words, using the same letter case. 11 | 12 | Given the target `"stone"` and the candidate words `"stone"`, `"tones"`, `"banana"`, `"tons"`, `"notes"`, and `"Seton"`, the anagram words you need to find are `"tones"`, `"notes"`, and `"Seton"`. 13 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | At a garage sale, you find a lovely vintage typewriter at a bargain price! 4 | Excitedly, you rush home, insert a sheet of paper, and start typing away. 5 | However, your excitement wanes when you examine the output: all words are garbled! 6 | For example, it prints "stop" instead of "post" and "least" instead of "stale." 7 | Carefully, you try again, but now it prints "spot" and "slate." 8 | After some experimentation, you find there is a random delay before each letter is printed, which messes up the order. 9 | You now understand why they sold it for so little money! 10 | 11 | You realize this quirk allows you to generate anagrams, which are words formed by rearranging the letters of another word. 12 | Pleased with your finding, you spend the rest of the day generating hundreds of anagrams. 13 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "vermiculus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "anagram.el" 11 | ], 12 | "test": [ 13 | "anagram-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 17 | ] 18 | }, 19 | "blurb": "Given a word and a list of possible anagrams, select the correct sublist.", 20 | "source": "Inspired by the Extreme Startup game", 21 | "source_url": "https://github.com/rchatley/extreme_startup" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; anagram.el --- Anagram (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun anagram-equal (a b) 10 | "Check that words A and B are anagrams of each other, but not identical." 11 | (and (equal (cl-sort (split-string-and-unquote (downcase a) "") #'string<) 12 | (cl-sort (split-string-and-unquote (downcase b) "") #'string<)) 13 | (not (string= (downcase a) (downcase b))))) 14 | 15 | (defun anagrams-for (subject candidates) 16 | "Find anagrams for SUBJECT from list of CANDIDATES." 17 | (cl-remove-if-not (lambda (w) (anagram-equal w subject)) 18 | candidates)) 19 | 20 | 21 | (provide 'anagram) 22 | ;;; anagram.el ends here 23 | -------------------------------------------------------------------------------- /exercises/practice/anagram/anagram.el: -------------------------------------------------------------------------------- 1 | ;;; anagram.el --- Anagram (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun anagrams-for (subject candidates) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'anagram) 13 | ;;; anagram.el ends here 14 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cpaulbond" 4 | ], 5 | "contributors": [ 6 | "benreyn", 7 | "vermiculus" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "armstrong-numbers.el" 12 | ], 13 | "test": [ 14 | "armstrong-numbers-test.el" 15 | ], 16 | "example": [ 17 | ".meta/example.el" 18 | ] 19 | }, 20 | "blurb": "Determine if a number is an Armstrong number.", 21 | "source": "Wikipedia", 22 | "source_url": "https://en.wikipedia.org/wiki/Narcissistic_number" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; armstrong-numbers.el --- armstrong-numbers Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defun armstrong-p (n) 8 | (let* ((digits (mapcar (lambda (d) (- d ?0)) (string-to-list (int-to-string n)))) 9 | (p (length digits))) 10 | (= n (apply #'+ (mapcar (lambda (d) (expt d p)) digits))))) 11 | 12 | (provide 'armstrong-numbers) 13 | ;;; armstrong-numbers.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/armstrong-numbers.el: -------------------------------------------------------------------------------- 1 | ;;; armstrong-numbers.el --- armstrong-numbers Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun armstrong-p (n) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'armstrong-numbers) 13 | ;;; armstrong-numbers.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "vermiculus", 7 | "kmarker1101" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "atbash-cipher.el" 12 | ], 13 | "test": [ 14 | "atbash-cipher-test.el" 15 | ], 16 | "example": [ 17 | ".meta/example.el" 18 | ] 19 | }, 20 | "blurb": "Create an implementation of the Atbash cipher, an ancient encryption system created in the Middle East.", 21 | "source": "Wikipedia", 22 | "source_url": "https://en.wikipedia.org/wiki/Atbash" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/atbash-cipher.el: -------------------------------------------------------------------------------- 1 | ;;; atbash-cipher.el --- Atbash-Cipher (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun encode (plaintext) 6 | "Encode PLAINTEXT to atbash-cipher encoding." 7 | ;;; Code: 8 | ) 9 | 10 | (defun decode (plaintext) 11 | "Decode atbash-cipher encoding to PLAINTEXT." 12 | ;;; Code: 13 | ) 14 | 15 | 16 | (provide 'atbash-cipher) 17 | ;;; atbash-cipher.el ends here 18 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to implement bank accounts supporting opening/closing, withdrawals, and deposits of money. 4 | 5 | As bank accounts can be accessed in many different ways (internet, mobile phones, automatic charges), your bank software must allow accounts to be safely accessed from multiple threads/processes (terminology depends on your programming language) in parallel. 6 | For example, there may be many deposits and withdrawals occurring in parallel; you need to ensure there are no [race conditions][wikipedia] between when you read the account balance and set the new balance. 7 | 8 | It should be possible to close an account; operations against a closed account must fail. 9 | 10 | [wikipedia]: https://en.wikipedia.org/wiki/Race_condition#In_software 11 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "bank-account.el" 8 | ], 9 | "test": [ 10 | "bank-account-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Simulate a bank account supporting opening/closing, withdraws, and deposits of money. Watch out for concurrent transactions!" 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/bank-account.el: -------------------------------------------------------------------------------- 1 | ;;; bank-account.el --- Bank Account (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (define-error 'account-closed 9 | (error "Delete this S-Expression and write your own implementation")) 10 | (define-error 'account-open 11 | (error "Delete this S-Expression and write your own implementation")) 12 | (define-error 'account-overdraw 13 | (error "Delete this S-Expression and write your own implementation")) 14 | (define-error 'account-negative-transaction 15 | (error "Delete this S-Expression and write your own implementation")) 16 | 17 | (defclass bank-account (operations) 18 | (error "Delete this S-Expression and write your own implementation")) 19 | 20 | 21 | (provide 'bank-account) 22 | ;;; bank-account.el ends here 23 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You have stumbled upon a group of mathematicians who are also singer-songwriters. 4 | They have written a song for each of their favorite numbers, and, as you can imagine, they have a lot of favorite numbers (like [0][zero] or [73][seventy-three] or [6174][kaprekars-constant]). 5 | 6 | You are curious to hear the song for your favorite number, but with so many songs to wade through, finding the right song could take a while. 7 | Fortunately, they have organized their songs in a playlist sorted by the title — which is simply the number that the song is about. 8 | 9 | You realize that you can use a binary search algorithm to quickly find a song given the title. 10 | 11 | [zero]: https://en.wikipedia.org/wiki/0 12 | [seventy-three]: https://en.wikipedia.org/wiki/73_(number) 13 | [kaprekars-constant]: https://en.wikipedia.org/wiki/6174_(number) 14 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "binary-search.el" 8 | ], 9 | "test": [ 10 | "binary-search-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Implement a binary search algorithm.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Binary_search_algorithm" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; binary-search.el --- Binary Search (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun find-binary (array value) 9 | (let ((left 0) 10 | (right (1- (length array))) 11 | middle 12 | index-of-value) 13 | (while (and (not index-of-value) (<= left right)) 14 | (setq middle (+ left (/ (- right left) 2))) 15 | (cond 16 | ((equal (aref array middle) value) 17 | (setq index-of-value middle)) 18 | ((< (aref array middle) value) 19 | (setq left (1+ middle))) 20 | ((> (aref array middle) value) 21 | (setq right (1- middle))))) 22 | index-of-value)) 23 | 24 | 25 | (provide 'binary-search) 26 | ;;; binary-search.el ends here 27 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/binary-search.el: -------------------------------------------------------------------------------- 1 | ;;; binary-search.el --- Binary Search (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun find-binary (array value) 9 | (error 10 | "Delete this S-Expression and write your own implementation")) 11 | 12 | 13 | (provide 'binary-search) 14 | ;;; binary-search.el ends here 15 | -------------------------------------------------------------------------------- /exercises/practice/binary/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "binary.el" 8 | ], 9 | "test": [ 10 | "binary-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles.", 17 | "source": "All of Computer Science", 18 | "source_url": "https://www.wolframalpha.com/examples/mathematics/numbers/base-conversions" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/binary/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; binary.el --- Binary exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defun to-decimal (binary-string) 8 | "Convert BINARY-STRING to a decimal integer." 9 | (string-to-number binary-string 2)) 10 | 11 | 12 | (provide 'binary) 13 | ;;; binary.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/binary/binary.el: -------------------------------------------------------------------------------- 1 | ;;; binary.el --- Binary exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun to-decimal (binary-string) 6 | ;;; Code: 7 | ) 8 | 9 | (provide 'binary) 10 | ;;; binary.el ends here 11 | -------------------------------------------------------------------------------- /exercises/practice/bob/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine what Bob will reply to someone when they say something to him or ask him a question. 4 | 5 | Bob only ever answers one of five things: 6 | 7 | - **"Sure."** 8 | This is his response if you ask him a question, such as "How are you?" 9 | The convention used for questions is that it ends with a question mark. 10 | - **"Whoa, chill out!"** 11 | This is his answer if you YELL AT HIM. 12 | The convention used for yelling is ALL CAPITAL LETTERS. 13 | - **"Calm down, I know what I'm doing!"** 14 | This is what he says if you yell a question at him. 15 | - **"Fine. Be that way!"** 16 | This is how he responds to silence. 17 | The convention used for silence is nothing, or various combinations of whitespace characters. 18 | - **"Whatever."** 19 | This is what he answers to anything else. 20 | -------------------------------------------------------------------------------- /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/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "benreyn", 7 | "kytrinyx", 8 | "stefanv", 9 | "vermiculus", 10 | "yurrriq" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "bob.el" 15 | ], 16 | "test": [ 17 | "bob-test.el" 18 | ], 19 | "example": [ 20 | ".meta/example.el" 21 | ] 22 | }, 23 | "blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.", 24 | "source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.", 25 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=06" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/bob/bob.el: -------------------------------------------------------------------------------- 1 | ;;; bob.el --- Bob (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun response-for (phrase) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'bob) 13 | ;;; bob.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "circular-buffer.el" 8 | ], 9 | "test": [ 10 | "circular-buffer-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Circular_buffer" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/circular-buffer.el: -------------------------------------------------------------------------------- 1 | ;;; circular-buffer.el --- Circular Buffer (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (define-error 'empty-buffer-error 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | (define-error 'full-buffer-error 12 | (error "Delete this S-Expression and write your own implementation")) 13 | 14 | (defclass circular-buffer () 15 | (error "Delete this S-Expression and write your own implementation")) 16 | 17 | (provide 'circular-buffer) 18 | ;;; circular-buffer.el ends here 19 | 20 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a positive integer, return the number of steps it takes to reach 1 according to the rules of the Collatz Conjecture. 4 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "collatz-conjecture.el" 8 | ], 9 | "test": [ 10 | "collatz-conjecture-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Calculate the number of steps to reach 1 using the Collatz conjecture.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Collatz_conjecture" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; collatz-conjecture.el --- Collatz Conjecture (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun steps (number) 10 | "Count the steps to reach 1 using the Collatz conjecture." 11 | (unless (< 0 number) (error "Only positive integers are allowed")) 12 | (cl-labels 13 | ((recur (n count) 14 | (cond 15 | ((= 0 (mod n 2)) (funcall #'recur (/ n 2) (+ 1 count))) 16 | ((< 1 n) (funcall #'recur (+ 1 (* 3 n)) (+ 1 count))) 17 | (t count)))) 18 | (funcall #'recur number 0))) 19 | 20 | (provide 'collatz-conjecture) 21 | ;;; collatz-conjecture.el ends here 22 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/collatz-conjecture-test.el: -------------------------------------------------------------------------------- 1 | ;;; collatz-conjecture-test.el --- Tests for Collatz Conjecture (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (load-file "collatz-conjecture.el") 8 | (declare-function steps "collatz-conjecture.el" (number)) 9 | 10 | 11 | (ert-deftest zero-steps-for-one () 12 | (should (equal 0 (steps 1)))) 13 | 14 | 15 | (ert-deftest divide-if-even () 16 | (should (equal 4 (steps 16)))) 17 | 18 | 19 | (ert-deftest even-and-odd-steps () 20 | (should (equal 9 (steps 12)))) 21 | 22 | 23 | (ert-deftest large-number-of-even-and-odd-steps () 24 | (should (equal 152 (steps 1000000)))) 25 | 26 | 27 | (ert-deftest zero-is-an-error () 28 | (should-error (steps 0))) 29 | 30 | 31 | (ert-deftest negative-value-is-an-error () 32 | (should-error (steps -15))) 33 | 34 | (provide 'collatz-conjecture-test) 35 | ;;; collatz-conjecture-test.el ends here 36 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/collatz-conjecture.el: -------------------------------------------------------------------------------- 1 | ;;; collatz-conjecture.el --- Collatz Conjecture (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defun steps (number) 8 | "Count the steps to reach 1 using the Collatz conjecture." 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | (provide 'collatz-conjecture) 12 | ;;; collatz-conjecture.el ends here 13 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wasamasa" 4 | ], 5 | "contributors": [ 6 | "vermiculus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "crypto-square.el" 11 | ], 12 | "test": [ 13 | "crypto-square-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 17 | ] 18 | }, 19 | "blurb": "Implement the classic method for composing secret messages called a square code.", 20 | "source": "J Dalbey's Programming Practice problems", 21 | "source_url": "https://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/crypto-square.el: -------------------------------------------------------------------------------- 1 | ;;; crypto-square.el --- Crypto Square (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun encipher (plaintext) 6 | ;;; Code: 7 | ) 8 | 9 | (provide 'crypto-square) 10 | ;;; crypto-square.el ends here 11 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "darts.el" 8 | ], 9 | "test": [ 10 | "darts-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Calculate the points scored in a single toss of a Darts game.", 17 | "source": "Inspired by an exercise created by a professor Della Paolera in Argentina" 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; darts.el --- Darts (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun score (x y) 9 | (let ((distance-to-center (sqrt (+ (expt x 2) (expt y 2))))) 10 | (cond 11 | ((<= distance-to-center 1) 12 | 10) 13 | ((<= distance-to-center 5) 14 | 5) 15 | ((<= distance-to-center 10) 16 | 1) 17 | (t 18 | 0)))) 19 | 20 | 21 | (provide 'darts) 22 | ;;; darts.el ends here 23 | -------------------------------------------------------------------------------- /exercises/practice/darts/darts.el: -------------------------------------------------------------------------------- 1 | ;;; darts.el --- Darts (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun score (x y) 9 | (error 10 | "Delete this S-Expression and write your own implementation")) 11 | 12 | 13 | (provide 'darts) 14 | ;;; darts.el ends here 15 | -------------------------------------------------------------------------------- /exercises/practice/diamond/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "diamond.el" 8 | ], 9 | "test": [ 10 | "diamond-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a letter, print a diamond starting with 'A' with the supplied letter at the widest point.", 17 | "source": "Seb Rose", 18 | "source_url": "https://web.archive.org/web/20220807163751/http://claysnow.co.uk/recycling-tests-in-tdd/" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/diamond/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; diamond.el --- Diamond (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun rows (letter) 10 | (let* ((n (- letter ?A)) 11 | (length (1+ (* 2 n))) 12 | (result (make-vector length nil))) 13 | (cl-labels 14 | ((row (index) 15 | (let ((str (make-string length 32))) 16 | (aset str (- n index) (+ ?A index)) 17 | (aset str (+ n index) (+ ?A index)) 18 | str))) 19 | (cl-loop for index to n 20 | do (aset result index (funcall #'row index))) 21 | (cl-loop for index below n 22 | do (aset result (- length 1 index) (funcall #'row index))) 23 | result))) 24 | 25 | (provide 'diamond) 26 | ;;; diamond.el ends here 27 | 28 | -------------------------------------------------------------------------------- /exercises/practice/diamond/diamond.el: -------------------------------------------------------------------------------- 1 | ;;; diamond.el --- Diamond (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun rows (letter) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'diamond) 13 | ;;; diamond.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Find the difference between the square of the sum and the sum of the squares of the first N natural numbers. 4 | 5 | The square of the sum of the first ten natural numbers is 6 | (1 + 2 + ... + 10)² = 55² = 3025. 7 | 8 | The sum of the squares of the first ten natural numbers is 9 | 1² + 2² + ... + 10² = 385. 10 | 11 | Hence the difference between the square of the sum of the first ten natural numbers and the sum of the squares of the first ten natural numbers is 3025 - 385 = 2640. 12 | 13 | You are not expected to discover an efficient solution to this yourself from first principles; research is allowed, indeed, encouraged. 14 | Finding the best algorithm for the problem is a key skill in software engineering. 15 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "Scientifica96", 7 | "vermiculus", 8 | "yurrriq" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "difference-of-squares.el" 13 | ], 14 | "test": [ 15 | "difference-of-squares-test.el" 16 | ], 17 | "example": [ 18 | ".meta/example.el" 19 | ] 20 | }, 21 | "blurb": "Find the difference between the square of the sum and the sum of the squares of the first N natural numbers.", 22 | "source": "Problem 6 at Project Euler", 23 | "source_url": "https://projecteuler.net/problem=6" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; difference-of-squares.el --- Difference of Squares (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | (require 'cl-lib) 7 | 8 | (defun sum-of-squares (n) 9 | "Square of sum of N." 10 | (cl-reduce #'+ (mapcar (lambda (i) (expt i 2)) (number-sequence 1 n)))) 11 | 12 | (defun square-of-sum (n) 13 | "Sum of squares of N." 14 | (expt (cl-reduce #'+ (number-sequence 1 n)) 2)) 15 | 16 | (defun difference (n) 17 | "Difference of squares pertaining to N." 18 | (- (square-of-sum n) 19 | (sum-of-squares n))) 20 | 21 | (provide 'difference-of-squares) 22 | ;;; difference-of-squares.el ends here 23 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/difference-of-squares.el: -------------------------------------------------------------------------------- 1 | ;;; difference-of-squares.el --- Difference of Squares (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun sum-of-squares (n) 6 | ;;; Code: 7 | ) 8 | 9 | (defun square-of-sum (n) 10 | ;;; Code: 11 | ) 12 | 13 | (defun difference (n) 14 | ;;; Code: 15 | ) 16 | 17 | (provide 'difference-of-squares) 18 | ;;; difference-of-squares.el ends here 19 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | After weeks of anticipation, you and your friends get together for your very first game of [Dungeons & Dragons][dnd] (D&D). 4 | Since this is the first session of the game, each player has to generate a character to play with. 5 | The character's abilities are determined by rolling 6-sided dice, but where _are_ the dice? 6 | With a shock, you realize that your friends are waiting for _you_ to produce the dice; after all it was your idea to play D&D! 7 | Panicking, you realize you forgot to bring the dice, which would mean no D&D game. 8 | As you have some basic coding skills, you quickly come up with a solution: you'll write a program to simulate dice rolls. 9 | 10 | [dnd]: https://en.wikipedia.org/wiki/Dungeons_%26_Dragons 11 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "dnd-character.el" 8 | ], 9 | "test": [ 10 | "dnd-character-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Randomly generate Dungeons & Dragons characters.", 17 | "source": "Simon Shine, Erik Schierboom", 18 | "source_url": "https://github.com/exercism/problem-specifications/issues/616#issuecomment-437358945" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/dnd-character.el: -------------------------------------------------------------------------------- 1 | ;;; dnd-character.el --- D&D Character (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun modifier (score) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (defun ability () 13 | (error "Delete this S-Expression and write your own implementation")) 14 | 15 | 16 | (defun generate-dnd-character () 17 | (error "Delete this S-Expression and write your own implementation")) 18 | 19 | 20 | (provide 'dnd-character) 21 | ;;; dnd-character.el ends here 22 | 23 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to count the number of 1 bits in the binary representation of a number. 4 | 5 | ## Restrictions 6 | 7 | Keep your hands off that bit-count functionality provided by your standard library! 8 | Solve this one yourself using other basic tools instead. 9 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "eliuds-eggs.el" 8 | ], 9 | "test": [ 10 | "eliuds-eggs-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Help Eliud count the number of eggs in her chicken coop by counting the number of 1 bits in a binary representation.", 17 | "source": "Christian Willner, Eric Willigers", 18 | "source_url": "https://forum.exercism.org/t/new-exercise-suggestion-pop-count/7632/5" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; eliuds-eggs.el --- Eliud's Eggs (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun egg-count (number) 9 | (let ((eggs 0)) 10 | (while (> number 0) 11 | (setq eggs (+ eggs (% number 2)) 12 | number (truncate number 2))) 13 | eggs)) 14 | 15 | 16 | (provide 'eliuds-eggs) 17 | ;;; eliuds-eggs.el ends here 18 | 19 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.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 | [559e789d-07d1-4422-9004-3b699f83bca3] 13 | description = "0 eggs" 14 | 15 | [97223282-f71e-490c-92f0-b3ec9e275aba] 16 | description = "1 egg" 17 | 18 | [1f8fd18f-26e9-4144-9a0e-57cdfc4f4ff5] 19 | description = "4 eggs" 20 | 21 | [0c18be92-a498-4ef2-bcbb-28ac4b06cb81] 22 | description = "13 eggs" 23 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/eliuds-eggs-test.el: -------------------------------------------------------------------------------- 1 | ;;; eliuds-eggs-test.el --- Eliud's Eggs (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (load-file "eliuds-eggs.el") 9 | (declare-function egg-count "eliuds-eggs.el" (number)) 10 | 11 | 12 | (ert-deftest 0-eggs () 13 | (should (= 0 (egg-count 0)))) 14 | 15 | (ert-deftest 1-egg () 16 | (should (= 1 (egg-count 16)))) 17 | 18 | 19 | (ert-deftest 4-eggs () 20 | (should (= 4 (egg-count 89)))) 21 | 22 | 23 | (ert-deftest 13-eggs () 24 | (should (= 13 (egg-count 2000000000)))) 25 | 26 | 27 | (provide 'eliuds-eggs-test) 28 | ;;; eliuds-eggs-test.el ends here 29 | 30 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/eliuds-eggs.el: -------------------------------------------------------------------------------- 1 | ;;; eliuds-eggs.el --- Eliud's Eggs (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun egg-count (number) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'eliuds-eggs) 13 | ;;; eliuds-eggs.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/etl/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a company that makes an online multiplayer game called Lexiconia. 4 | 5 | To play the game, each player is given 13 letters, which they must rearrange to create words. 6 | Different letters have different point values, since it's easier to create words with some letters than others. 7 | 8 | The game was originally launched in English, but it is very popular, and now the company wants to expand to other languages as well. 9 | 10 | Different languages need to support different point values for letters. 11 | The point values are determined by how often letters are used, compared to other letters in that language. 12 | 13 | For example, the letter 'C' is quite common in English, and is only worth 3 points. 14 | But in Norwegian it's a very rare letter, and is worth 10 points. 15 | 16 | To make it easier to add new languages, your team needs to change the way letters and their point values are stored in the game. 17 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cpaulbond" 4 | ], 5 | "contributors": [ 6 | "canweriotnow", 7 | "vermiculus" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "etl.el" 12 | ], 13 | "test": [ 14 | "etl-test.el" 15 | ], 16 | "example": [ 17 | ".meta/example.el" 18 | ] 19 | }, 20 | "blurb": "Change the data format for scoring a game to more easily add other languages.", 21 | "source": "Based on an exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 22 | "source_url": "https://turing.edu" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; etl.el --- etl Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun etl (data) 9 | (let ((rtn (make-hash-table))) 10 | (maphash (lambda (k v) 11 | (when (< k 0) 12 | (error "Unexpected key value %s" k)) 13 | (dolist (i v) 14 | (when (not (stringp i)) 15 | (error "Non string value found %s" i)) 16 | (puthash (downcase i) k rtn))) 17 | data) 18 | rtn)) 19 | 20 | 21 | (provide 'etl) 22 | ;;; etl.el ends here 23 | -------------------------------------------------------------------------------- /exercises/practice/etl/.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 | [78a7a9f9-4490-4a47-8ee9-5a38bb47d28f] 13 | description = "single letter" 14 | 15 | [60dbd000-451d-44c7-bdbb-97c73ac1f497] 16 | description = "single score with multiple letters" 17 | 18 | [f5c5de0c-301f-4fdd-a0e5-df97d4214f54] 19 | description = "multiple scores with multiple letters" 20 | 21 | [5db8ea89-ecb4-4dcd-902f-2b418cc87b9d] 22 | description = "multiple scores with differing numbers of letters" 23 | -------------------------------------------------------------------------------- /exercises/practice/etl/etl.el: -------------------------------------------------------------------------------- 1 | ;;; etl.el --- etl Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun etl (data) 6 | ;;; Code: 7 | ) 8 | 9 | (provide 'etl) 10 | ;;; etl.el ends here 11 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions Append 2 | 3 | The input and output are represented as lists. 4 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Take a nested array of any depth and return a fully flattened array. 4 | 5 | Note that some language tracks may include null-like values in the input array, and the way these values are represented varies by track. 6 | Such values should be excluded from the flattened array. 7 | 8 | Additionally, the input may be of a different data type and contain different types, depending on the track. 9 | 10 | Check the test suite for details. 11 | 12 | ## Example 13 | 14 | input: `[1, [2, 6, null], [[null, [4]], 5]]` 15 | 16 | output: `[1, 2, 6, 4, 5]` 17 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | A shipment of emergency supplies has arrived, but there's a problem. 4 | To protect from damage, the items — flashlights, first-aid kits, blankets — are packed inside boxes, and some of those boxes are nested several layers deep inside other boxes! 5 | 6 | To be prepared for an emergency, everything must be easily accessible in one box. 7 | Can you unpack all the supplies and place them into a single box, so they're ready when needed most? 8 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "flatten-array.el" 8 | ], 9 | "test": [ 10 | "flatten-array-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Take a nested list and return a single list with all values except nil/null.", 17 | "source": "Interview Question", 18 | "source_url": "https://reference.wolfram.com/language/ref/Flatten.html" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; flatten-array.el --- Flatten Array (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun list-flatten (list) 9 | (flatten-tree list)) 10 | 11 | 12 | (provide 'flatten-array) 13 | ;;; flatten-array.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/flatten-array.el: -------------------------------------------------------------------------------- 1 | ;;; flatten-array.el --- Flatten Array (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun list-flatten (list) 9 | (error 10 | "Delete this S-Expression and write your own implementation")) 11 | 12 | 13 | (provide 'flatten-array) 14 | ;;; flatten-array.el ends here 15 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "food-chain.el" 8 | ], 9 | "test": [ 10 | "food-chain-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/There_Was_an_Old_Lady_Who_Swallowed_a_Fly" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/food-chain.el: -------------------------------------------------------------------------------- 1 | ;;; food-chain.el --- Food Chain (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun recite (start-verse end-verse) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'food-chain) 13 | ;;; food-chain.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/game-of-life/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | After each generation, the cells interact with their eight neighbors, which are cells adjacent horizontally, vertically, or diagonally. 4 | 5 | The following rules are applied to each cell: 6 | 7 | - Any live cell with two or three live neighbors lives on. 8 | - Any dead cell with exactly three live neighbors becomes a live cell. 9 | - All other cells die or stay dead. 10 | 11 | Given a matrix of 1s and 0s (corresponding to live and dead cells), apply the rules to each cell, and return the next generation. 12 | -------------------------------------------------------------------------------- /exercises/practice/game-of-life/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | [Conway's Game of Life][game-of-life] is a fascinating cellular automaton created by the British mathematician John Horton Conway in 1970. 4 | 5 | The game consists of a two-dimensional grid of cells that can either be "alive" or "dead." 6 | 7 | After each generation, the cells interact with their eight neighbors via a set of rules, which define the new generation. 8 | 9 | [game-of-life]: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life 10 | -------------------------------------------------------------------------------- /exercises/practice/game-of-life/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "game-of-life.el" 8 | ], 9 | "test": [ 10 | "game-of-life-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Implement Conway's Game of Life.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/game-of-life/game-of-life.el: -------------------------------------------------------------------------------- 1 | ;;; game-of-life.el --- Conway's Game of Life (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun tick (matrix) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'game-of-life) 13 | ;;; game-of-life.el ends here 14 | 15 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "gigasecond.el" 8 | ], 9 | "test": [ 10 | "gigasecond-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.", 17 | "source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.", 18 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=09" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; gigasecond.el --- Gigasecond (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | ;; Calculate the date one gigasecond (10^9 seconds) from the 5 | ;; given date. 6 | ;; 7 | ;; NB: Pay attention to Emacs' handling of time zones and dst 8 | ;; in the encode-time and decode-time functions. 9 | 10 | ;;; Code: 11 | 12 | (defun add (second minute hour day month year) 13 | "Calculate gigasecond from date given. 14 | Params are SECOND, MINUTE, HOUR, DAY, MONTH, and YEAR." 15 | (let ((gigasecond (seconds-to-time (expt 10 9))) 16 | (start-date (encode-time second minute hour day month year t))) 17 | (set-time-zone-rule t) 18 | (let ((end-date (decode-time (time-add start-date gigasecond)))) 19 | (butlast end-date (- (length end-date) 6))))) 20 | 21 | 22 | (provide 'gigasecond) 23 | ;;; gigasecond.el ends here 24 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/gigasecond.el: -------------------------------------------------------------------------------- 1 | ;;; gigasecond.el --- Gigasecond (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun add (second minute hour day month year) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'gigasecond) 13 | ;;; gigasecond.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "grade-school.el" 8 | ], 9 | "test": [ 10 | "grade-school-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given students' names along with the grade that they are in, create a roster for the school.", 17 | "source": "A pairing session with Phil Battos at gSchool" 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/grade-school.el: -------------------------------------------------------------------------------- 1 | ;;; grade-school.el --- Grade School (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defun make-school () 8 | (error "Delete this S-Expression and write your own implementation")) 9 | 10 | (defun roster (school) 11 | (error "Delete this S-Expression and write your own implementation")) 12 | 13 | (defun add (school name grade) 14 | (error "Delete this S-Expression and write your own implementation")) 15 | 16 | (defun grade (school grade) 17 | (error "Delete this S-Expression and write your own implementation")) 18 | 19 | 20 | (provide 'grade-school) 21 | ;;; grade-school.el ends here 22 | 23 | -------------------------------------------------------------------------------- /exercises/practice/grains/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Calculate the number of grains of wheat on a chessboard. 4 | 5 | A chessboard has 64 squares. 6 | Square 1 has one grain, square 2 has two grains, square 3 has four grains, and so on, doubling each time. 7 | 8 | Write code that calculates: 9 | 10 | - the number of grains on a given square 11 | - the total number of grains on the chessboard 12 | -------------------------------------------------------------------------------- /exercises/practice/grains/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | There once was a wise servant who saved the life of a prince. 4 | The king promised to pay whatever the servant could dream up. 5 | Knowing that the king loved chess, the servant told the king he would like to have grains of wheat. 6 | One grain on the first square of a chessboard, with the number of grains doubling on each successive square. 7 | -------------------------------------------------------------------------------- /exercises/practice/grains/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "vermiculus", 7 | "wasamasa", 8 | "yurrriq" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "grains.el" 13 | ], 14 | "test": [ 15 | "grains-test.el" 16 | ], 17 | "example": [ 18 | ".meta/example.el" 19 | ] 20 | }, 21 | "blurb": "Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.", 22 | "source": "The CodeRanch Cattle Drive, Assignment 6", 23 | "source_url": "https://web.archive.org/web/20240908084142/https://coderanch.com/wiki/718824/Grains" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/grains/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; grains.el --- Grains exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun square (n) 10 | "Find the number of grains on square N." 11 | (string-to-number (calc-eval (format "2^(%d - 1)" n)))) 12 | 13 | (defun total () 14 | "Find the total number of grains on the board." 15 | (string-to-number (calc-eval "2^64 - 1"))) 16 | 17 | (provide 'grains) 18 | ;;; grains.el ends here 19 | -------------------------------------------------------------------------------- /exercises/practice/grains/grains.el: -------------------------------------------------------------------------------- 1 | ;;; grains.el --- Grains exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun square (n) 6 | ;;; Code: 7 | ) 8 | 9 | (defun total () 10 | ;;; Code: 11 | ) 12 | 13 | (provide 'grains) 14 | ;;; grains.el ends here 15 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Calculate the Hamming distance between two DNA strands. 4 | 5 | We read DNA using the letters C, A, G and T. 6 | Two strands might look like this: 7 | 8 | GAGCCTACTAACGGGAT 9 | CATCGTAATGACGGCCT 10 | ^ ^ ^ ^ ^ ^^ 11 | 12 | They have 7 differences, and therefore the Hamming distance is 7. 13 | 14 | ## Implementation notes 15 | 16 | The Hamming distance is only defined for sequences of equal length, so an attempt to calculate it between sequences of different lengths should not work. 17 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your body is made up of cells that contain DNA. 4 | Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. 5 | In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! 6 | 7 | When cells divide, their DNA replicates too. 8 | Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. 9 | If we compare two strands of DNA and count the differences between them, we can see how many mistakes occurred. 10 | This is known as the "Hamming distance". 11 | 12 | The Hamming distance is useful in many areas of science, not just biology, so it's a nice phrase to be familiar with :) 13 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "PurityControl" 4 | ], 5 | "contributors": [ 6 | "benreyn", 7 | "vermiculus", 8 | "yurrriq" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "hamming.el" 13 | ], 14 | "test": [ 15 | "hamming-test.el" 16 | ], 17 | "example": [ 18 | ".meta/example.el" 19 | ] 20 | }, 21 | "blurb": "Calculate the Hamming distance between two DNA strands.", 22 | "source": "The Calculating Point Mutations problem at Rosalind", 23 | "source_url": "https://rosalind.info/problems/hamm/" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; hamming.el --- Hamming (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun hamming-distance (dna1 dna2) 10 | "Determine number of mutations between DNA strands DNA1 and DNA2." 11 | (if (= (length dna1) (length dna2)) 12 | (let ((dl1 (split-string-and-unquote dna1 "")) 13 | (dl2 (split-string-and-unquote dna2 ""))) 14 | (cl-loop with cnt = 0 15 | for x in dl1 16 | for y in dl2 17 | when (not (string= x y)) 18 | do 19 | (setq cnt (1+ cnt)) 20 | finally 21 | return cnt)) 22 | (error "Strands are of different lengths"))) 23 | 24 | 25 | (provide 'hamming) 26 | ;;; hamming.el ends here 27 | -------------------------------------------------------------------------------- /exercises/practice/hamming/hamming.el: -------------------------------------------------------------------------------- 1 | ;;; hamming.el --- Hamming (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun hamming-distance (dna1 dna2) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'hamming) 13 | ;;; hamming.el ends here 14 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "benreyn", 7 | "konrad", 8 | "kytrinyx", 9 | "vermiculus" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "hello-world.el" 14 | ], 15 | "test": [ 16 | "hello-world-test.el" 17 | ], 18 | "example": [ 19 | ".meta/example.el" 20 | ] 21 | }, 22 | "blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", 23 | "source": "This is an exercise to introduce users to using Exercism", 24 | "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; hello-world.el --- Hello World Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defun hello () 8 | "Hello, World!") 9 | 10 | (provide 'hello-world) 11 | ;;; hello-world.el ends here 12 | -------------------------------------------------------------------------------- /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/hello-world-test.el: -------------------------------------------------------------------------------- 1 | ;;; hello-world-test.el --- Tests for Hello World (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | ;; Common test data version: 1.1.0 be3ae66 5 | 6 | ;;; Code: 7 | 8 | (load-file "hello-world.el") 9 | (declare-function hello "hello-world.el") 10 | 11 | (ert-deftest hello-world-test () 12 | (should (string= (hello) "Hello, World!"))) 13 | 14 | (provide 'hello-world-test) 15 | 16 | ;;; hello-world-test.el ends here 17 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/hello-world.el: -------------------------------------------------------------------------------- 1 | ;;; hello-world.el --- Hello World exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun hello () 6 | "Goodbye, Mars!") 7 | 8 | (provide 'hello-world) 9 | ;;; hello-world.el ends here 10 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "isbn-verifier.el" 8 | ], 9 | "test": [ 10 | "isbn-verifier-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Check if a given string is a valid ISBN-10 number.", 17 | "source": "Converting a string into a number and some basic processing utilizing a relatable real world example.", 18 | "source_url": "https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; isbn-verifier.el --- ISBN Verifier (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun digit-value (c) 10 | (if (= ?X c) 10 (- c ?0))) 11 | 12 | (defun validp (isbn) 13 | (let ((total 0) 14 | (weight 10) 15 | (characters (remq ?- (cl-coerce isbn 'list)))) 16 | (cl-loop for c in characters 17 | always (or (cl-digit-char-p c) (and (= ?X c) (= weight 1))) 18 | do (setq total (+ total (* weight (digit-value c)))) 19 | do (setq weight (- weight 1)) 20 | finally return (and (= 0 weight) (= 0 (% total 11)))))) 21 | 22 | (provide 'isbn-verifier) 23 | ;;; isbn-verifier.el ends here 24 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/isbn-verifier.el: -------------------------------------------------------------------------------- 1 | ;;; isbn-verifier.el --- ISBN Verifier (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun validp (isbn) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'isbn-verifier) 13 | ;;; isbn-verifier.el ends here 14 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "isogram.el" 8 | ], 9 | "test": [ 10 | "isogram-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Determine if a word or phrase is an isogram.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Isogram" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; isogram.el --- isogram (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun upper-char-p (c) 10 | "Determine if char C is alphabetic and upper case." 11 | (and 12 | (>= c ?A) 13 | (<= c ?Z))) 14 | 15 | (defun isogramp (phrase) 16 | "Determine if a given phrase is an isogram." 17 | (let* ((bitset 0) 18 | (updated 0) 19 | (characters (cl-coerce (upcase phrase) 'list)) 20 | (letters (cl-remove-if-not 'upper-char-p characters))) 21 | (cl-loop for c in letters 22 | do (setq updated (logior bitset (lsh 1 (- c ?A)))) 23 | always (> updated bitset) 24 | do (setq bitset updated)))) 25 | 26 | (provide 'isogram) 27 | ;;; isogram.el ends here 28 | -------------------------------------------------------------------------------- /exercises/practice/isogram/isogram.el: -------------------------------------------------------------------------------- 1 | ;;; isogram.el --- isogram (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun isogramp (phrase) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'isogram) 13 | ;;; isogram.el ends here 14 | -------------------------------------------------------------------------------- /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/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "kindergarten-garden.el" 8 | ], 9 | "test": [ 10 | "kindergarten-garden-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a diagram, determine which plants each child in the kindergarten class is responsible for.", 17 | "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 18 | "source_url": "https://turing.edu" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; kindergarten-garden.el --- Kindergarten Garden (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun plants (diagram student) 10 | (cl-flet ((plant (index) 11 | (cl-case (aref diagram index) 12 | (?G "grass") 13 | (?C "clover") 14 | (?R "radishes") 15 | (?V "violets")))) 16 | (let* ((midpoint (/ (1+ (length diagram)) 2)) 17 | (student_index (- (aref student 0) ?A)) 18 | (first (* 2 student_index)) 19 | (second (1+ first)) 20 | (third (+ midpoint first)) 21 | (fourth (1+ third))) 22 | (mapcar #'plant (list first second third fourth))))) 23 | 24 | (provide 'plants) 25 | ;;; kindergarten-garden.el ends here 26 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/kindergarten-garden.el: -------------------------------------------------------------------------------- 1 | ;;; kindergarten-garden.el --- Kindergarten Garden (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun plants (diagram student) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'plants) 13 | ;;; kindergarten-garden.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine which items to take so that the total value of her selection is maximized, taking into account the knapsack's carrying capacity. 4 | 5 | Items will be represented as a list of items. 6 | Each item will have a weight and value. 7 | All values given will be strictly positive. 8 | Lhakpa can take only one of each item. 9 | 10 | For example: 11 | 12 | ```text 13 | Items: [ 14 | { "weight": 5, "value": 10 }, 15 | { "weight": 4, "value": 40 }, 16 | { "weight": 6, "value": 30 }, 17 | { "weight": 4, "value": 50 } 18 | ] 19 | 20 | Knapsack Maximum Weight: 10 21 | ``` 22 | 23 | For the above, the first item has weight 5 and value 10, the second item has weight 4 and value 40, and so on. 24 | In this example, Lhakpa should take the second and fourth item to maximize her value, which, in this case, is 90. 25 | She cannot get more than 90 as her knapsack has a weight limit of 10. 26 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Lhakpa is a [Sherpa][sherpa] mountain guide and porter. 4 | After months of careful planning, the expedition Lhakpa works for is about to leave. 5 | She will be paid the value she carried to the base camp. 6 | 7 | In front of her are many items, each with a value and weight. 8 | Lhakpa would gladly take all of the items, but her knapsack can only hold so much weight. 9 | 10 | [sherpa]: https://en.wikipedia.org/wiki/Sherpa_people#Mountaineering 11 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "knapsack.el" 8 | ], 9 | "test": [ 10 | "knapsack-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a knapsack that can only carry a certain weight, determine which items to put in the knapsack in order to maximize their combined value.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Knapsack_problem" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; knapsack.el --- Knapsack (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun maximum-value (maximum-weight items) 10 | (let ((table (make-vector (1+ maximum-weight) 0))) 11 | (dolist (item items) 12 | (let ((weight (alist-get :weight item)) 13 | (value (alist-get :value item))) 14 | (cl-loop for index from maximum-weight downto weight 15 | for new-value = (+ value (aref table (- index weight))) 16 | do (when (> new-value (aref table index)) 17 | (aset table index new-value))))) 18 | (aref table maximum-weight))) 19 | 20 | (provide 'knapsack) 21 | ;;; knapsack.el ends here 22 | 23 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/knapsack.el: -------------------------------------------------------------------------------- 1 | ;;; knapsack.el --- Knapsack (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun maximum-value (maximum-weight items) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'knapsack) 13 | ;;; knapsack.el ends here 14 | 15 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "largest-series-product.el" 8 | ], 9 | "test": [ 10 | "largest-series-product-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.", 17 | "source": "A variation on Problem 8 at Project Euler", 18 | "source_url": "https://projecteuler.net/problem=8" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; largest-series-product.el --- Largest Series Product (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun largest-product (digits span) 10 | (when (< span 0) 11 | (error "span must not be negative")) 12 | (when (> span (length digits)) 13 | (error "span must not exceed string length")) 14 | (unless (cl-every 'cl-digit-char-p (cl-coerce digits 'list)) 15 | (error "digits input must only contain digits")) 16 | (let ((largest 0)) 17 | (dotimes (i (+ 1 (- (length digits) span))) 18 | (let ((product 1)) 19 | (dotimes (j span) 20 | (setq product (* product (cl-digit-char-p (aref digits (+ i j)))))) 21 | (when (< largest product) 22 | (setq largest product)))) 23 | largest)) 24 | 25 | (provide 'largest-series-product) 26 | ;;; largest-series-product.el ends here 27 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/largest-series-product.el: -------------------------------------------------------------------------------- 1 | ;;; largest-series-product.el --- Largest Series Product (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun largest-product (digits span) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'largest-series-product) 13 | ;;; largest-series-product.el ends here 14 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "fominok" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "leap.el" 11 | ], 12 | "test": [ 13 | "leap-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 17 | ] 18 | }, 19 | "blurb": "Determine whether a given year is a leap year.", 20 | "source": "CodeRanch Cattle Drive, Assignment 3", 21 | "source_url": "https://web.archive.org/web/20240907033714/https://coderanch.com/t/718816/Leap" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; leap.el --- Leap exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defun leap-year-p (year) 8 | "Determine if YEAR is a leap year." 9 | (and (= 0 (mod year 4)) 10 | (or (not (= 0 (mod year 100))) 11 | (= 0 (mod year 400))))) 12 | 13 | (provide 'leap) 14 | ;;; leap.el ends here 15 | -------------------------------------------------------------------------------- /exercises/practice/leap/leap.el: -------------------------------------------------------------------------------- 1 | ;;; leap.el --- Leap exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun leap-year-p (year) 6 | ;;; Code: 7 | ) 8 | 9 | (provide 'leap-year-p) 10 | ;;; leap.el ends here 11 | -------------------------------------------------------------------------------- /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 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "linked-list.el" 8 | ], 9 | "test": [ 10 | "linked-list-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Implement a doubly linked list.", 17 | "source": "Classic computer science topic" 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/.docs/hints.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | 3 | ## General 4 | 5 | The `fold-left` and `fold-right` methods are "fold" functions, which is a concept from the functional programming world. See the Wikipedia page on folding for [general background](https://en.wikipedia.org/wiki/Fold_(higher-order_function)) and [signature/implementation hints](https://en.wikipedia.org/wiki/Fold_(higher-order_function)#Linear_folds). 6 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | ## Emacs Lisp track specific functions 2 | 3 | * `list-empty-p` (*given a list, return if the list is empty*) 4 | * `list-sum` (*given a list of numbers, return the sum of all elements*) 5 | 6 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "list-ops.el" 8 | ], 9 | "test": [ 10 | "list-ops-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Implement basic list operations." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | At the Global Verification Authority, you've just been entrusted with a critical assignment. 4 | Across the city, from online purchases to secure logins, countless operations rely on the accuracy of numerical identifiers like credit card numbers, bank account numbers, transaction codes, and tracking IDs. 5 | The Luhn algorithm is a simple checksum formula used to help identify mistyped numbers. 6 | 7 | A batch of identifiers has just arrived on your desk. 8 | All of them must pass the Luhn test to ensure they're legitimate. 9 | If any fail, they'll be flagged as invalid, preventing mistakes such as incorrect transactions or failed account verifications. 10 | 11 | Can you ensure this is done right? The integrity of many services depends on you. 12 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "yilkalargaw" 4 | ], 5 | "contributors": [ 6 | "vermiculus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "luhn.el" 11 | ], 12 | "test": [ 13 | "luhn-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 17 | ] 18 | }, 19 | "blurb": "Given a number determine whether or not it is valid per the Luhn formula.", 20 | "source": "The Luhn Algorithm on Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Luhn_algorithm" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/luhn/luhn.el: -------------------------------------------------------------------------------- 1 | ;;; luhn.el --- Luhn (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun luhn-p (str) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'luhn) 13 | ;;; luhn.el ends here 14 | 15 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "matching-brackets.el" 8 | ], 9 | "test": [ 10 | "matching-brackets-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Make sure the brackets and braces all match.", 17 | "source": "Ginna Baker" 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/matching-brackets.el: -------------------------------------------------------------------------------- 1 | ;;; matching-brackets.el --- Matching Brackets (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun is-paired (value) 9 | (error 10 | "Delete this S-Expression and write your own implementation")) 11 | 12 | 13 | (provide 'matching-brackets) 14 | ;;; matching-brackets.el ends here 15 | -------------------------------------------------------------------------------- /exercises/practice/meetup/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "meetup.el" 8 | ], 9 | "test": [ 10 | "meetup-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Calculate the date of meetups.", 17 | "source": "Jeremy Hinegardner mentioned a Boulder meetup that happens on the Wednesteenth of every month" 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/meetup/meetup.el: -------------------------------------------------------------------------------- 1 | ;;; meetup.el --- Meetup (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun meetup (year month dayofweek schedule) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'meetup) 13 | ;;; meetup.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to add the mine counts to empty squares in a completed Minesweeper board. 4 | The board itself is a rectangle composed of squares that are either empty (`' '`) or a mine (`'*'`). 5 | 6 | For each empty square, count the number of mines adjacent to it (horizontally, vertically, diagonally). 7 | If the empty square has no adjacent mines, leave it empty. 8 | Otherwise replace it with the adjacent mines count. 9 | 10 | For example, you may receive a 5 x 4 board like this (empty spaces are represented here with the '·' character for display on screen): 11 | 12 | ```text 13 | ·*·*· 14 | ··*·· 15 | ··*·· 16 | ····· 17 | ``` 18 | 19 | Which your code should transform into this: 20 | 21 | ```text 22 | 1*3*1 23 | 13*31 24 | ·2*2· 25 | ·111· 26 | ``` 27 | -------------------------------------------------------------------------------- /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 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "minesweeper.el" 8 | ], 9 | "test": [ 10 | "minesweeper-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Add the numbers to a minesweeper board." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/minesweeper.el: -------------------------------------------------------------------------------- 1 | ;;; minesweeper.el --- Minesweeper (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun annotate (minefield) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'minesweeper) 13 | ;;; minesweeper.el ends here 14 | 15 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "nth-prime.el" 8 | ], 9 | "test": [ 10 | "nth-prime-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a number n, determine what the nth prime is.", 17 | "source": "A variation on Problem 7 at Project Euler", 18 | "source_url": "https://projecteuler.net/problem=7" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.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 | [75c65189-8aef-471a-81de-0a90c728160c] 13 | description = "first prime" 14 | 15 | [2c38804c-295f-4701-b728-56dea34fd1a0] 16 | description = "second prime" 17 | 18 | [56692534-781e-4e8c-b1f9-3e82c1640259] 19 | description = "sixth prime" 20 | 21 | [fce1e979-0edb-412d-93aa-2c744e8f50ff] 22 | description = "big prime" 23 | 24 | [bd0a9eae-6df7-485b-a144-80e13c7d55b2] 25 | description = "there is no zeroth prime" 26 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/nth-prime-test.el: -------------------------------------------------------------------------------- 1 | ;;; nth-prime-test.el --- Tests for Nth Prime (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (load-file "nth-prime.el") 9 | (declare-function prime "nth-prime.el" (number)) 10 | 11 | 12 | (ert-deftest first-prime () 13 | (should (= 2 (prime 1)))) 14 | 15 | 16 | (ert-deftest second-prime () 17 | (should (= 3 (prime 2)))) 18 | 19 | 20 | (ert-deftest sixth-prime () 21 | (should (= 13 (prime 6)))) 22 | 23 | 24 | (ert-deftest big-prime () 25 | (should (= 104743 (prime 10001)))) 26 | 27 | 28 | (ert-deftest there-is-no-zeroth-prime () 29 | (should-error (prime 0))) 30 | 31 | 32 | (provide 'nth-prime-test) 33 | ;;; nth-prime-test.el ends here 34 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/nth-prime.el: -------------------------------------------------------------------------------- 1 | ;;; nth-prime.el --- Nth Prime (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun prime (number) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'nth-prime) 13 | ;;; nth-prime.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.docs/hints.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | 3 | ## General 4 | 5 | - The expected result is an `Association List` data structure (also called `alist`), not an string, or something else. You can find more information about it in this [link](https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html). So, for the correct example, the right output would be: 6 | 7 | ```text 8 | "GATTACA" -> '((?A . 3) (?C . 1) (?G . 1) (?T . 2)) 9 | ``` 10 | 11 | - The `?A` is the Emacs Lisp way to represent a character. You can find more information in the documentation: [link](https://www.gnu.org/software/emacs/manual/html_node/elisp/Basic-Char-Syntax.html). 12 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cpaulbond" 4 | ], 5 | "contributors": [ 6 | "canweriotnow" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "nucleotide-count.el" 11 | ], 12 | "test": [ 13 | "nucleotide-count-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 17 | ] 18 | }, 19 | "blurb": "Given a DNA string, compute how many times each nucleotide occurs in the string.", 20 | "source": "The Calculating DNA Nucleotides_problem at Rosalind", 21 | "source_url": "https://rosalind.info/problems/dna/" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; nucleotide-count.el --- nucleotide-count Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun nucleotide-count (sequence) 9 | (let ((counts (copy-alist '((?A . 0) (?C . 0) (?G . 0) (?T . 0))))) 10 | (dolist (i (append sequence nil)) 11 | (let ((n (assoc i counts))) 12 | (if n 13 | (setcdr n (1+ (cdr n))) 14 | (error "Invalid nucleotide '%c'" i)))) 15 | counts)) 16 | 17 | 18 | (provide 'nucleotide-count) 19 | ;;; nucleotide-count.el ends here 20 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/nucleotide-count.el: -------------------------------------------------------------------------------- 1 | ;;; nucleotide-count.el --- nucleotide-count Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun nucleotide-count (sequence) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'nucleotide-count) 13 | ;;; nucleotide-count.el ends here 14 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "benreyn" 4 | ], 5 | "contributors": [ 6 | "yurrriq" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "pangram.el" 11 | ], 12 | "test": [ 13 | "pangram-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 17 | ] 18 | }, 19 | "blurb": "Determine if a sentence is a pangram.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Pangram" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; pangram.el --- Pangram (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | (require 'cl-lib) 7 | 8 | (defun pangramp (phrase) 9 | "Determine if a given phrase is a pangram." 10 | (let ((alphabet "abcdefghijklmnopqrstuvwxyz")) 11 | (cl-every 12 | (lambda (c) (string-match-p (char-to-string c) phrase)) 13 | alphabet))) 14 | 15 | 16 | (provide 'pangram) 17 | ;;; pangram.el ends here 18 | -------------------------------------------------------------------------------- /exercises/practice/pangram/pangram.el: -------------------------------------------------------------------------------- 1 | ;;; pangram.el --- Pangram (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun pangramp (phrase) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'pangram) 13 | ;;; pangram.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | ## Using Parallelism 4 | 5 | The goal of this exercise is to practice parallelism with Emacs Lisp. 6 | 7 | In Emacs Lisp this can be achieved by using [`asynchronous processes`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Asynchronous-Processes.html#:~:text=An%20asynchronous%20process%20is%20controlled,%2Dtype%20(see%20below)). 8 | 9 | You may also want to look at the documentation for [`batch mode`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Batch-Mode.html), [`sentinels`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Sentinels.html) and [`receiving output from processes`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Output-from-Processes.html). 10 | -------------------------------------------------------------------------------- /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 | "kmarker1101" 4 | ], 5 | "contributors": [ 6 | "fapdash", 7 | "BNAndras" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "parallel-letter-frequency.el" 12 | ], 13 | "test": [ 14 | "parallel-letter-frequency-test.el" 15 | ], 16 | "example": [ 17 | ".meta/example.el" 18 | ] 19 | }, 20 | "blurb": "Count the frequency of letters in texts using parallel computation." 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/parallel-letter-frequency.el: -------------------------------------------------------------------------------- 1 | ;;; parallel-letter-frequency.el --- Parallel Letter Frequency (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun calculate-frequencies (texts) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'parallel-letter-frequency) 13 | ;;; parallel-letter-frequency.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "pascals-triangle.el" 8 | ], 9 | "test": [ 10 | "pascals-triangle-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Compute Pascal's triangle up to a given number of rows.", 17 | "source": "Pascal's Triangle at Wolfram Math World", 18 | "source_url": "https://www.wolframalpha.com/input/?i=Pascal%27s+triangle" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; pascals-triangle.el --- Pascal's Triangle (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun rows (count) 10 | (let ((result (make-vector count nil)) 11 | (current nil) 12 | (previous nil)) 13 | (cl-loop for r below count 14 | do (setq current (make-vector (1+ r) 1)) 15 | do (cl-loop for c from 1 below r 16 | do (aset current c (+ (aref previous (1- c)) (aref previous c)))) 17 | do (aset result r current) 18 | do (setq previous current)) 19 | result)) 20 | 21 | (provide 'pascals-triangle) 22 | ;;; pascals-triangle.el ends here 23 | 24 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/pascals-triangle.el: -------------------------------------------------------------------------------- 1 | ;;; pascals-triangle.el --- Pascal's Triangle (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun rows (count) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'pascals-triangle) 13 | ;;; pascals-triangle.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cpaulbond" 4 | ], 5 | "contributors": [ 6 | "canweriotnow", 7 | "guygastineau", 8 | "vermiculus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "perfect-numbers.el" 13 | ], 14 | "test": [ 15 | "perfect-numbers-test.el" 16 | ], 17 | "example": [ 18 | ".meta/example.el" 19 | ] 20 | }, 21 | "blurb": "Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for positive integers.", 22 | "source": "Taken from Chapter 2 of Functional Thinking by Neal Ford.", 23 | "source_url": "https://www.oreilly.com/library/view/functional-thinking/9781449365509/" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; perfect-numbers.el --- perfect-numbers Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | (require 'cl-lib) 7 | 8 | ;; Algorithm from https://www.geeksforgeeks.org/sum-of-all-proper-divisors-of-a-natural-number/ 9 | (defun classify (number) 10 | (unless (> number 0) (error "Classification is only possible for natural numbers")) 11 | (let ((sum 1)) 12 | (cl-loop for i from 2 to (sqrt number) 13 | when (zerop (% number i)) 14 | sum (+ i 15 | (if (= i (/ number i)) 16 | (cl-incf sum i) 17 | (cl-incf sum (+ i (/ number i)))))) 18 | (cond ((= 1 number) 'deficient) 19 | ((< sum number) 'deficient) 20 | ((= sum number) 'perfect) 21 | ((> sum number) 'abundant)))) 22 | 23 | (provide 'perfect-numbers) 24 | ;;; perfect-numbers.el ends here 25 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/perfect-numbers.el: -------------------------------------------------------------------------------- 1 | ;;; perfect-numbers.el --- perfect-numbers Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun classify (number) 6 | ;;; Code: 7 | ) 8 | 9 | (provide 'perfect-numbers) 10 | ;;; perfect-numbers.el ends here 11 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions Append 2 | 3 | In addition to the function, _numbers_, that cleans up phone numbers, you need to write two more functions, _area-code_ and _pprint_ in the Emacs Lisp track. 4 | 5 | Each of the extra functions takes the phone number as its only parameter. 6 | 7 | The first function _area-code_ extracts the area code from the input, while the second function _pprint_ transforms the input to a string in the format of 8 | ``` 9 | (NXX) NXX-XXXX 10 | ``` 11 | where `N` and `X` are as described above. 12 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You've joined LinkLine, a leading communications company working to ensure reliable connections for everyone. 4 | The team faces a big challenge: users submit phone numbers in all sorts of formats — dashes, spaces, dots, parentheses, and even prefixes. 5 | Some numbers are valid, while others are impossible to use. 6 | 7 | Your mission is to turn this chaos into order. 8 | You'll clean up valid numbers, formatting them appropriately for use in the system. 9 | At the same time, you'll identify and filter out any invalid entries. 10 | 11 | The success of LinkLine's operations depends on your ability to separate the useful from the unusable. 12 | Are you ready to take on the challenge and keep the connections running smoothly? 13 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cpaulbond" 4 | ], 5 | "contributors": [ 6 | "yurrriq", 7 | "borderite" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "phone-number.el" 12 | ], 13 | "test": [ 14 | "phone-number-test.el" 15 | ], 16 | "example": [ 17 | ".meta/example.el" 18 | ] 19 | }, 20 | "blurb": "Clean up user-entered phone numbers so that they can be sent SMS messages.", 21 | "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 22 | "source_url": "https://turing.edu" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/phone-number.el: -------------------------------------------------------------------------------- 1 | ;;; phone-number.el --- phone-number (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun numbers (num) 6 | ;;; Code: 7 | ) 8 | 9 | (defun area-code (num) 10 | ;;; Code: 11 | ) 12 | 13 | (defun pprint (num) 14 | ;;; Code: 15 | ) 16 | 17 | (provide 'phone-number) 18 | ;;; phone-number.el ends here 19 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "pig-latin.el" 8 | ], 9 | "test": [ 10 | "pig-latin-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Implement a program that translates from English to Pig Latin.", 17 | "source": "The Pig Latin exercise at Test First Teaching by Ultrasaurus", 18 | "source_url": "https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/pig-latin.el: -------------------------------------------------------------------------------- 1 | ;;; pig-latin.el --- Pig Latin (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun translate (phrase) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'pig-latin) 13 | ;;; pig-latin.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Compute the prime factors of a given natural number. 4 | 5 | A prime number is only evenly divisible by itself and 1. 6 | 7 | Note that 1 is not a prime number. 8 | 9 | ## Example 10 | 11 | What are the prime factors of 60? 12 | 13 | - Our first divisor is 2. 14 | 2 goes into 60, leaving 30. 15 | - 2 goes into 30, leaving 15. 16 | - 2 doesn't go cleanly into 15. 17 | So let's move on to our next divisor, 3. 18 | - 3 goes cleanly into 15, leaving 5. 19 | - 3 does not go cleanly into 5. 20 | The next possible factor is 4. 21 | - 4 does not go cleanly into 5. 22 | The next possible factor is 5. 23 | - 5 does go cleanly into 5. 24 | - We're left only with 1, so now, we're done. 25 | 26 | Our successful divisors in that computation represent the list of prime factors of 60: 2, 2, 3, and 5. 27 | 28 | You can check this yourself: 29 | 30 | ```text 31 | 2 * 2 * 3 * 5 32 | = 4 * 15 33 | = 60 34 | ``` 35 | 36 | Success! 37 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "prime-factors.el" 8 | ], 9 | "test": [ 10 | "prime-factors-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Compute the prime factors of a given natural number.", 17 | "source": "The Prime Factors Kata by Uncle Bob", 18 | "source_url": "https://web.archive.org/web/20221026171801/http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; prime-factors.el --- Prime Factors (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun factors-from (start value) 10 | (unless (= value 1) 11 | (cl-loop for p from start 12 | until (= 0 (% value p)) 13 | finally return (cons p (factors-from p (/ value p)))))) 14 | 15 | (defun factors (value) 16 | (factors-from 2 value)) 17 | 18 | (provide 'prime-factors) 19 | ;;; prime-factors.el ends here 20 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/prime-factors.el: -------------------------------------------------------------------------------- 1 | ;;; prime-factors.el --- Prime Factors (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun factors (value) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'prime-factors) 13 | ;;; prime-factors.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "protein-translation.el" 8 | ], 9 | "test": [ 10 | "protein-translation-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Translate RNA sequences into proteins.", 17 | "source": "Tyler Long" 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/protein-translation.el: -------------------------------------------------------------------------------- 1 | ;;; protein-translation.el --- Protein Translation (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun proteins (strand) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'protein-translation) 13 | ;;; protein-translation.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | For want of a horseshoe nail, a kingdom was lost, or so the saying goes. 4 | 5 | Given a list of inputs, generate the relevant proverb. 6 | For example, given the list `["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"]`, you will output the full text of this proverbial rhyme: 7 | 8 | ```text 9 | For want of a nail the shoe was lost. 10 | For want of a shoe the horse was lost. 11 | For want of a horse the rider was lost. 12 | For want of a rider the message was lost. 13 | For want of a message the battle was lost. 14 | For want of a battle the kingdom was lost. 15 | And all for the want of a nail. 16 | ``` 17 | 18 | Note that the list of inputs may vary; your solution should be able to handle lists of arbitrary length and content. 19 | No line of the output text should be a static, unchanging string; all should vary according to the input given. 20 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "proverb.el" 8 | ], 9 | "test": [ 10 | "proverb-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "For want of a horseshoe nail, a kingdom was lost, or so the saying goes. Output the full text of this proverbial rhyme.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/For_Want_of_a_Nail" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; proverb.el --- Proverb (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun recite (strings) 9 | (let ((n (length strings))) 10 | (cond ((= n 0) '()) 11 | ((= n 1) (list (format "And all for the want of a %s." (car strings)))) 12 | (t (append (cl-loop for i from 0 to (- n 2) 13 | collect (format "For want of a %s the %s was lost." (nth i strings) (nth (1+ i) strings))) 14 | (list (format "And all for the want of a %s." (car strings)))))))) 15 | 16 | 17 | (provide 'proverb) 18 | ;;; proverb.el ends here 19 | 20 | -------------------------------------------------------------------------------- /exercises/practice/proverb/proverb.el: -------------------------------------------------------------------------------- 1 | ;;; proverb.el --- Proverb (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun recite (strings) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'proverb) 13 | ;;; proverb.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Description 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/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "pythagorean-triplet.el" 8 | ], 9 | "test": [ 10 | "pythagorean-triplet-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given an integer N, find all Pythagorean triplets for which a + b + c = N.", 17 | "source": "A variation of Problem 9 from Project Euler", 18 | "source_url": "https://projecteuler.net/problem=9" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; pythagorean-triplet.el --- Pythagorean Triplet (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ; For every Pythagorean triplet with total a + b + c = n, 6 | ; a² + b² = c² 7 | ; <=> a² + b² = (n - a - b)², substituting c 8 | ; <=> 0 = n² - 2*n*a - 2*n*b + 2*a*b 9 | ; <=> (2*n - 2*a) b = (n² - 2*n*a) 10 | ; <=> b = (n² - 2*n*a) / (2*n - 2*a) 11 | 12 | ;;; Code: 13 | 14 | (require 'cl-lib) 15 | 16 | (defun triplets-with-sum (n) 17 | (cl-labels 18 | ((recur (start) 19 | (cl-loop for a from start 20 | for numerator = (* n (- n a a)) 21 | for denominator = (* 2 (- n a)) 22 | for b = (/ numerator denominator) 23 | always (< a b) 24 | until (= 0 (% numerator denominator)) 25 | finally return (cons (list a b (- n a b)) (recur (1+ a)))))) 26 | (unless (< n 2) 27 | (recur 1)))) 28 | 29 | (provide 'pythagorean-triplet) 30 | ;;; pythagorean-triplet.el ends here 31 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/pythagorean-triplet.el: -------------------------------------------------------------------------------- 1 | ;;; pythagorean-triplet.el --- Pythagorean Triplet (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun triplets-with-sum (n) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'pythagorean-triplet) 13 | ;;; pythagorean-triplet.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "queen-attack.el" 8 | ], 9 | "test": [ 10 | "queen-attack-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given the position of two queens on a chess board, indicate whether or not they are positioned so that they can attack each other.", 17 | "source": "J Dalbey's Programming Practice problems", 18 | "source_url": "https://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; queen-attack.el --- Queen Attack (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun valid-position-p (queen) 9 | (and (<= 0 (car queen) 7) (<= 0 (cdr queen) 7))) 10 | 11 | (defun can-attack-p (white-queen black-queen) 12 | (let ((row-white (car white-queen)) 13 | (column-white (cdr white-queen)) 14 | (row-black (car black-queen)) 15 | (column-black (cdr black-queen))) 16 | (or (= row-white row-black) 17 | (= column-white column-black) 18 | (= (- row-white column-white) (- row-black column-black)) 19 | (= (+ row-white column-white) (+ row-black column-black))))) 20 | 21 | 22 | (provide 'queen-attack) 23 | ;;; queen-attack.el ends here 24 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/queen-attack.el: -------------------------------------------------------------------------------- 1 | ;;; queen-attack.el --- Queen Attack (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun valid-position-p (queen) 9 | (error 10 | "Delete this S-Expression and write your own implementation")) 11 | 12 | (defun can-attack-p (white-queen black-queen) 13 | (error 14 | "Delete this S-Expression and write your own implementation")) 15 | 16 | 17 | (provide 'queen-attack) 18 | ;;; queen-attack.el ends here 19 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "rail-fence-cipher.el" 8 | ], 9 | "test": [ 10 | "rail-fence-cipher-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Implement encoding and decoding for the rail fence cipher.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Transposition_cipher#Rail_Fence_cipher" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/rail-fence-cipher.el: -------------------------------------------------------------------------------- 1 | ;;; rail-fence-cipher.el --- Rail Fence Cipher (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun encode (message rails) 9 | (error 10 | "Delete this S-Expression and write your own implementation")) 11 | 12 | (defun decode (message rails) 13 | (error 14 | "Delete this S-Expression and write your own implementation")) 15 | 16 | 17 | (provide 'rail-fence-cipher) 18 | ;;; rail-fence-cipher.el ends here 19 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "vermiculus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "raindrops.el" 11 | ], 12 | "test": [ 13 | "raindrops-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 17 | ] 18 | }, 19 | "blurb": "Convert a number into its corresponding raindrop sounds - Pling, Plang and Plong.", 20 | "source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division.", 21 | "source_url": "https://en.wikipedia.org/wiki/Fizz_buzz" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/raindrops.el: -------------------------------------------------------------------------------- 1 | ;;; raindrops.el --- Raindrops (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun convert (n) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'raindrops) 13 | ;;; raindrops.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "resistor-color-duo.el" 8 | ], 9 | "test": [ 10 | "resistor-color-duo-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Convert color codes, as used on resistors, to a numeric value.", 17 | "source": "Maud de Vries, Erik Schierboom", 18 | "source_url": "https://github.com/exercism/problem-specifications/issues/1464" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; resistor-color-duo.el --- Resistor Color Duo (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (setq band-values 8 | '(("black" . 0) 9 | ("brown" . 1) 10 | ("red" . 2) 11 | ("orange" . 3) 12 | ("yellow" . 4) 13 | ("green" . 5) 14 | ("blue" . 6) 15 | ("violet" . 7) 16 | ("grey" . 8) 17 | ("white" . 9))) 18 | 19 | (defun value (colors) 20 | (+ (* (get-value (nth 0 colors)) 10) 21 | (get-value (nth 1 colors)))) 22 | 23 | (defun get-value (color) 24 | (cdr (assoc color band-values))) 25 | 26 | (provide 'resistor-color-duo) 27 | ;;; resistor-color-duo.el ends here 28 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/resistor-color-duo.el: -------------------------------------------------------------------------------- 1 | ;;; resistor-color-duo.el --- Resistor Color Duo (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun value (colors) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'resistor-color-duo) 13 | ;;; resistor-color-duo.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | An input of `"orange", "orange", "green"` should return: 4 | 5 | > "3.3 megaohms" 6 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "resistor-color-trio.el" 8 | ], 9 | "test": [ 10 | "resistor-color-trio-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Convert color codes, as used on resistors, to a human-readable label.", 17 | "source": "Maud de Vries, Erik Schierboom", 18 | "source_url": "https://github.com/exercism/problem-specifications/issues/1549" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/resistor-color-trio.el: -------------------------------------------------------------------------------- 1 | ;;; resistor-color-trio.el --- Resistor Color Trio (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun label (colors) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'resistor-color-trio) 13 | ;;; resistor-color-trio.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "resistor-color.el" 8 | ], 9 | "test": [ 10 | "resistor-color-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Convert a resistor band's color to its numeric representation.", 17 | "source": "Maud de Vries, Erik Schierboom", 18 | "source_url": "https://github.com/exercism/problem-specifications/issues/1458" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; resistor-color.el --- Resistor Color (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (setq band-values 9 | '(("black" . 0) 10 | ("brown" . 1) 11 | ("red" . 2) 12 | ("orange" . 3) 13 | ("yellow" . 4) 14 | ("green" . 5) 15 | ("blue" . 6) 16 | ("violet" . 7) 17 | ("grey" . 8) 18 | ("white" . 9))) 19 | 20 | (defun color-code (color) 21 | (cdr (assoc color band-values))) 22 | 23 | (defun colors () 24 | (mapcar #'car band-values)) 25 | 26 | 27 | (provide 'resistor-color) 28 | ;;; resistor-color.el ends here 29 | 30 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.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 | [49eb31c5-10a8-4180-9f7f-fea632ab87ef] 13 | description = "Color codes -> Black" 14 | 15 | [0a4df94b-92da-4579-a907-65040ce0b3fc] 16 | description = "Color codes -> White" 17 | 18 | [5f81608d-f36f-4190-8084-f45116b6f380] 19 | description = "Color codes -> Orange" 20 | 21 | [581d68fa-f968-4be2-9f9d-880f2fb73cf7] 22 | description = "Colors" 23 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/resistor-color-test.el: -------------------------------------------------------------------------------- 1 | ;;; resistor-color-test.el --- Resistor Color (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (load-file "resistor-color.el") 9 | (declare-function color-code "resistor-color.el" (color)) 10 | (declare-function colors "resistor-color.el" ()) 11 | 12 | 13 | (ert-deftest black () 14 | (should (= 0 (color-code "black")))) 15 | 16 | 17 | (ert-deftest white () 18 | (should (= 9 (color-code "white")))) 19 | 20 | 21 | (ert-deftest orange () 22 | (should (= 3 (color-code "orange")))) 23 | 24 | 25 | (ert-deftest colors () 26 | (should (equal '("black" "brown" "red" "orange" "yellow" "green" "blue" "violet" "grey" "white") 27 | (colors)))) 28 | 29 | 30 | (provide 'resistor-color-test) 31 | ;;; resistor-color-test.el ends here 32 | 33 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/resistor-color.el: -------------------------------------------------------------------------------- 1 | ;;; resistor-color.el --- Resistor Color (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun color-code (color) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | (defun colors () 12 | (error "Delete this S-Expression and write your own implementation")) 13 | 14 | 15 | (provide 'resistor-color) 16 | ;;; resistor-color.el ends here 17 | 18 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "contributors": [ 6 | "kmarker1101" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "reverse-string.el" 11 | ], 12 | "test": [ 13 | "reverse-string-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 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/reverse-string.el: -------------------------------------------------------------------------------- 1 | ;;; reverse-string.el --- Reverse String (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun reverse-string (value) 9 | (error 10 | "Delete this S-Expression and write your own implementation")) 11 | 12 | 13 | (provide 'reverse-string) 14 | ;;; reverse-string.el ends here 15 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine the RNA complement of a given DNA sequence. 4 | 5 | Both DNA and RNA strands are a sequence of nucleotides. 6 | 7 | The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**), and thymine (**T**). 8 | 9 | The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**), and uracil (**U**). 10 | 11 | Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement: 12 | 13 | - `G` -> `C` 14 | - `C` -> `G` 15 | - `T` -> `A` 16 | - `A` -> `U` 17 | 18 | ~~~~exercism/note 19 | If you want to look at how the inputs and outputs are structured, take a look at the examples in the test suite. 20 | ~~~~ 21 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a bioengineering company that specializes in developing therapeutic solutions. 4 | 5 | Your team has just been given a new project to develop a targeted therapy for a rare type of cancer. 6 | 7 | ~~~~exercism/note 8 | It's all very complicated, but the basic idea is that sometimes people's bodies produce too much of a given protein. 9 | That can cause all sorts of havoc. 10 | 11 | But if you can create a very specific molecule (called a micro-RNA), it can prevent the protein from being produced. 12 | 13 | This technique is called [RNA Interference][rnai]. 14 | 15 | [rnai]: https://admin.acceleratingscience.com/ask-a-scientist/what-is-rnai/ 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "vermiculus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "rna-transcription.el" 11 | ], 12 | "test": [ 13 | "rna-transcription-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 17 | ] 18 | }, 19 | "blurb": "Given a DNA strand, return its RNA complement.", 20 | "source": "Hyperphysics", 21 | "source_url": "https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; rna-transcription.el -- RNA Transcription (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | ;; 5 | ;; Example derived pretty directly from xlisp example: 6 | ;; https://github.com/exercism/xlisp/blob/master/rna-transcription/example.lisp 7 | ;; 8 | 9 | ;;; Code: 10 | 11 | (require 'cl-lib) 12 | 13 | (defun validate-strand (strand) 14 | "Check to see if RNA STRAND is valid." 15 | (or (cl-every (lambda (c) (cl-find c "ATCGU")) (cl-coerce strand 'list)) 16 | (error "Bad strand"))) 17 | 18 | (defvar dna->rna 19 | '((?C . ?G) (?G . ?C) (?A . ?U) (?T . ?A))) 20 | 21 | (defun to-rna (strand) 22 | "Convert STRAND of DNA to RNA." 23 | (validate-strand strand) 24 | (cl-concatenate 'string 25 | (mapcar (lambda (c) (cdr (assoc c dna->rna))) 26 | (cl-coerce strand 'list)))) 27 | 28 | 29 | (provide 'rna-transcription) 30 | ;;; rna-transcription.el ends here 31 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/rna-transcription.el: -------------------------------------------------------------------------------- 1 | ;;; rna-transcription.el -- RNA Transcription (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun to-rna (strand) 6 | ;;; Code: 7 | ) 8 | 9 | (provide 'rna-transcription) 10 | ;;; rna-transcription.el ends here 11 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "canweriotnow" 4 | ], 5 | "contributors": [ 6 | "wasamasa", 7 | "yurrriq" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "robot-name.el" 12 | ], 13 | "test": [ 14 | "robot-name-test.el" 15 | ], 16 | "example": [ 17 | ".meta/example.el" 18 | ] 19 | }, 20 | "blurb": "Manage robot factory settings.", 21 | "source": "A debugging session with Paul Blackwell at gSchool." 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/robot-name.el: -------------------------------------------------------------------------------- 1 | ;;; robot-name.el --- Robot Name (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | ;; 5 | ;; Build a robot with a name like AA000, that can be reset 6 | ;; to a new name. Instructions are in README.md 7 | ;; 8 | 9 | (defun build-robot () 10 | "Build a new robot with a random name." 11 | ;;; Code: 12 | ) 13 | 14 | (defun robot-name (robot) 15 | "Get the ROBOT's name." 16 | ;;; Code: 17 | ) 18 | 19 | (defun reset-robot (robot) 20 | "Reset the name of ROBOT. Factory reset!" 21 | ;;; Code: 22 | ) 23 | 24 | (provide 'robot-name) 25 | ;;; robot-name.el ends here 26 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Write a robot simulator. 4 | 5 | A robot factory's test facility needs a program to verify robot movements. 6 | 7 | The robots have three possible movements: 8 | 9 | - turn right 10 | - turn left 11 | - advance 12 | 13 | Robots are placed on a hypothetical infinite grid, facing a particular direction (north, east, south, or west) at a set of {x,y} coordinates, 14 | e.g., {3,8}, with coordinates increasing to the north and east. 15 | 16 | The robot then receives a number of instructions, at which point the testing facility verifies the robot's new position, and in which direction it is pointing. 17 | 18 | - The letter-string "RAALAL" means: 19 | - Turn right 20 | - Advance twice 21 | - Turn left 22 | - Advance once 23 | - Turn left yet again 24 | - Say a robot starts at {7, 3} facing north. 25 | Then running this stream of instructions should leave it at {9, 4} facing west. 26 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "robot-simulator.el" 8 | ], 9 | "test": [ 10 | "robot-simulator-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Write a robot simulator.", 17 | "source": "Inspired by an interview question at a famous company." 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/robot-simulator.el: -------------------------------------------------------------------------------- 1 | ;;; robot-simulator.el --- robot-simulator (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun create-robot (x y direction) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (defun move (robot instructions) 13 | (error "Delete this S-Expression and write your own implementation")) 14 | 15 | 16 | (provide 'robot-simulator) 17 | ;;; robot-simulator.el ends here 18 | -------------------------------------------------------------------------------- /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/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cpaulbond" 4 | ], 5 | "contributors": [ 6 | "bakhti", 7 | "canweriotnow", 8 | "vermiculus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "roman-numerals.el" 13 | ], 14 | "test": [ 15 | "roman-numerals-test.el" 16 | ], 17 | "example": [ 18 | ".meta/example.el" 19 | ] 20 | }, 21 | "blurb": "Convert modern Arabic numbers into Roman numerals.", 22 | "source": "The Roman Numeral Kata", 23 | "source_url": "https://codingdojo.org/kata/RomanNumerals/" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/roman-numerals.el: -------------------------------------------------------------------------------- 1 | ;;; roman-numerals.el --- roman-numerals Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun to-roman (value) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'roman-numerals) 13 | ;;; roman-numerals.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "rotational-cipher.el" 8 | ], 9 | "test": [ 10 | "rotational-cipher-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Create an implementation of the rotational cipher, also sometimes called the Caesar cipher.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Caesar_cipher" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; rotational-cipher.el --- Rotational Cipher (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defconst shift-max 26) 8 | 9 | (defun rotate (text shift-key) 10 | (let ((normalized-shift-key (mod shift-key shift-max))) 11 | (concat 12 | (mapcar 13 | (lambda (char) 14 | (cond 15 | ((<= ?A char ?Z) 16 | (+ (mod (+ (- char ?A) normalized-shift-key) shift-max) ?A)) 17 | ((<= ?a char ?z) 18 | (+ (mod (+ (- char ?a) normalized-shift-key) shift-max) ?a)) 19 | (t 20 | char))) 21 | text)))) 22 | 23 | 24 | (provide 'rotational-cipher) 25 | ;;; rotational-cipher.el ends here 26 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/rotational-cipher.el: -------------------------------------------------------------------------------- 1 | ;;; rotational-cipher.el --- Rotational Cipher (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun rotate (text shift-key) 9 | (error 10 | "Delete this S-Expression and write your own implementation")) 11 | 12 | 13 | (provide 'rotational-cipher) 14 | ;;; rotational-cipher.el ends here 15 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Implement run-length encoding and decoding. 4 | 5 | Run-length encoding (RLE) is a simple form of data compression, where runs (consecutive data elements) are replaced by just one data value and count. 6 | 7 | For example we can represent the original 53 characters with only 13. 8 | 9 | ```text 10 | "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" -> "12WB12W3B24WB" 11 | ``` 12 | 13 | RLE allows the original data to be perfectly reconstructed from the compressed data, which makes it a lossless data compression. 14 | 15 | ```text 16 | "AABCCCDEEEE" -> "2AB3CD4E" -> "AABCCCDEEEE" 17 | ``` 18 | 19 | For simplicity, you can assume that the unencoded string will only contain the letters A through Z (either lower or upper case) and whitespace. 20 | This way data to be encoded will never contain any numbers and numbers inside data to be decoded always represent the count for the following character. 21 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cpaulbond" 4 | ], 5 | "contributors": [ 6 | "benreyn" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "run-length-encoding.el" 11 | ], 12 | "test": [ 13 | "run-length-encoding-test.el" 14 | ], 15 | "example": [ 16 | ".meta/example.el" 17 | ] 18 | }, 19 | "blurb": "Implement run-length encoding and decoding.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Run-length_encoding" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/run-length-encoding.el: -------------------------------------------------------------------------------- 1 | ;;; run-length-encoding.el --- run-length-encoding Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun run-length-encode (s) 6 | ;;; Code: 7 | ) 8 | 9 | (defun run-length-decode (s) 10 | ;;; Code: 11 | ) 12 | 13 | (provide 'run-length-encoding) 14 | ;;; run-length-encoding.el ends here 15 | -------------------------------------------------------------------------------- /exercises/practice/satellite/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "satellite.el" 8 | ], 9 | "test": [ 10 | "satellite-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Rebuild binary trees from pre-order and in-order traversals." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/satellite/satellite.el: -------------------------------------------------------------------------------- 1 | ;;; satellite.el --- Satellite (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun tree-from-traversals (preorder inorder) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'satellite) 13 | ;;; satellite.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/say/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "say.el" 8 | ], 9 | "test": [ 10 | "say-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a number from 0 to 999,999,999,999, spell out that number in English.", 17 | "source": "A variation on the JavaRanch CattleDrive, Assignment 4", 18 | "source_url": "https://web.archive.org/web/20240907035912/https://coderanch.com/wiki/718804" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/say/say.el: -------------------------------------------------------------------------------- 1 | ;;; say.el --- Say (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (define-error 'out-of-range 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (defun say (number) 13 | (error "Delete this S-Expression and write your own implementation")) 14 | 15 | 16 | (provide 'say) 17 | ;;; say.el ends here 18 | 19 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to compute a word's Scrabble score by summing the values of its letters. 4 | 5 | The letters are valued as follows: 6 | 7 | | Letter | Value | 8 | | ---------------------------- | ----- | 9 | | A, E, I, O, U, L, N, R, S, T | 1 | 10 | | D, G | 2 | 11 | | B, C, M, P | 3 | 12 | | F, H, V, W, Y | 4 | 13 | | K | 5 | 14 | | J, X | 8 | 15 | | Q, Z | 10 | 16 | 17 | For example, the word "cabbage" is worth 14 points: 18 | 19 | - 3 points for C 20 | - 1 point for A 21 | - 3 points for B 22 | - 3 points for B 23 | - 1 point for A 24 | - 2 points for G 25 | - 1 point for E 26 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "scrabble-score.el" 8 | ], 9 | "test": [ 10 | "scrabble-score-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a word, compute the Scrabble score for that word.", 17 | "source": "Inspired by the Extreme Startup game", 18 | "source_url": "https://github.com/rchatley/extreme_startup" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; scrabble-score.el --- Scrabble Score (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defvar letters->score '( 10 | ("AEIOULNRST" . 1) 11 | ("DG" . 2) 12 | ("BCMP" . 3) 13 | ("FHVWY" . 4) 14 | ("K" . 5) 15 | ("JX" . 8) 16 | ("QZ" . 10) 17 | )) 18 | 19 | (defun letter-score (letter) 20 | "The Scrabble score for letter" 21 | (let ((table letters->score)) 22 | (while 23 | (not (cl-find letter (caar table))) 24 | (setq table (cdr table))) 25 | (cdar table))) 26 | 27 | (defun score (word) 28 | "The Scrabble score for word" 29 | (let ((total 0) 30 | (letters (cl-coerce (upcase word) 'list))) 31 | (dolist (letter letters) 32 | (setq total (+ total (letter-score letter)))) 33 | total)) 34 | 35 | (provide 'scrabble-score) 36 | ;;; scrabble-score.el ends here 37 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/scrabble-score.el: -------------------------------------------------------------------------------- 1 | ;;; scrabble-score.el --- Scrabble Score (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defun score (word) 8 | (error "Delete this S-Expression and write your own implementation")) 9 | 10 | (provide 'scrabble-score) 11 | ;;; scrabble-score.el ends here 12 | -------------------------------------------------------------------------------- /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/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "secret-handshake.el" 8 | ], 9 | "test": [ 10 | "secret-handshake-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.", 17 | "source": "Bert, in Mary Poppins", 18 | "source_url": "https://www.imdb.com/title/tt0058331/quotes/?item=qt0437047" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; secret-handshake.el --- Secret Handshake (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun commands (number) 10 | (let ((all-commands '("wink" "double blink" "close your eyes" "jump")) 11 | (result nil)) 12 | (cl-labels 13 | ((extract (action shift pending) 14 | (cl-loop until (null pending) 15 | if (/= (logand number action) 0) 16 | do (setq result (cons (car pending) result)) 17 | do (setq pending (cdr pending)) 18 | do (setq action (lsh action shift)) 19 | finally return result))) 20 | (if (= (logand number 16) 0) 21 | (funcall #'extract 8 -1 (reverse all-commands)) 22 | (funcall #'extract 1 1 all-commands))))) 23 | 24 | (provide 'secret-handshake) 25 | ;;; secret-handshake.el ends here 26 | 27 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/secret-handshake.el: -------------------------------------------------------------------------------- 1 | ;;; secret-handshake.el --- Secret Handshake (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun commands (number) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'secret-handshake) 13 | ;;; secret-handshake.el ends here 14 | 15 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "series.el" 8 | ], 9 | "test": [ 10 | "series-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a string of digits, output all the contiguous substrings of length `n` in that string.", 17 | "source": "A subset of the Problem 8 at Project Euler", 18 | "source_url": "https://projecteuler.net/problem=8" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/series/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; series.el --- Series (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | 9 | (defun slices (series slice-length) 10 | (cond 11 | ((equal "" series) (error "series cannot be empty")) 12 | ((> slice-length (length series)) (error "slice length cannot be greater than series length")) 13 | ((= slice-length 0) (error "slice length cannot be zero")) 14 | ((< slice-length 0) (error "slice length cannot be negative")) 15 | (t (mapcar (lambda (start) 16 | (substring series start (+ start slice-length))) 17 | (number-sequence 0 (- (length series) slice-length)))))) 18 | 19 | 20 | (provide 'series) 21 | ;;; series.el ends here 22 | 23 | -------------------------------------------------------------------------------- /exercises/practice/series/series.el: -------------------------------------------------------------------------------- 1 | ;;; series.el --- Series (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun slices (series slice-length) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'series) 13 | ;;; series.el ends here 14 | 15 | -------------------------------------------------------------------------------- /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 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "sieve.el" 8 | ], 9 | "test": [ 10 | "sieve-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.", 17 | "source": "Sieve of Eratosthenes at Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; sieve.el --- Sieve (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun primes (limit) 10 | (let ((table (make-bool-vector (1+ limit) t)) 11 | (result nil)) 12 | (cl-loop for p from 2 13 | for psq = (* p p) 14 | until (< limit psq) 15 | do (when (aref table p) 16 | (cl-loop for m from psq to limit by p 17 | do (aset table m nil)))) 18 | (cl-loop for p from limit downto 2 19 | do (when (aref table p) 20 | (setq result (cons p result)))) 21 | result)) 22 | 23 | (provide 'sieve) 24 | ;;; sieve.el ends here 25 | 26 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.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 | [88529125-c4ce-43cc-bb36-1eb4ddd7b44f] 13 | description = "no primes under two" 14 | 15 | [4afe9474-c705-4477-9923-840e1024cc2b] 16 | description = "find first prime" 17 | 18 | [974945d8-8cd9-4f00-9463-7d813c7f17b7] 19 | description = "find primes up to 10" 20 | 21 | [2e2417b7-3f3a-452a-8594-b9af08af6d82] 22 | description = "limit is prime" 23 | 24 | [92102a05-4c7c-47de-9ed0-b7d5fcd00f21] 25 | description = "find primes up to 1000" 26 | -------------------------------------------------------------------------------- /exercises/practice/sieve/sieve.el: -------------------------------------------------------------------------------- 1 | ;;; sieve.el --- Sieve (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun primes (limit) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'sieve) 13 | ;;; sieve.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "simple-cipher.el" 8 | ], 9 | "test": [ 10 | "simple-cipher-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Implement a simple shift cipher like Caesar and a more secure substitution cipher.", 17 | "source": "Substitution Cipher at Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Substitution_cipher" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/simple-cipher.el: -------------------------------------------------------------------------------- 1 | ;;; simple-cipher.el --- Simple Cipher (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun encode (plaintext key) 9 | (error 10 | "Delete this S-Expression and write your own implementation")) 11 | 12 | (defun decode (ciphertext key) 13 | (error 14 | "Delete this S-Expression and write your own implementation")) 15 | 16 | (defun generate-key () 17 | (error 18 | "Delete this S-Expression and write your own implementation")) 19 | 20 | 21 | (provide 'simple-cipher) 22 | ;;; simple-cipher.el ends here 23 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "space-age.el" 8 | ], 9 | "test": [ 10 | "space-age-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.", 17 | "source": "Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial.", 18 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=01" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; space-age.el --- Space Age (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun orbital-period (planet) 9 | (pcase planet 10 | (:mercury 0.2408467) 11 | (:venus 0.61519726) 12 | (:earth 1.0) 13 | (:mars 1.8808158) 14 | (:jupiter 11.862615) 15 | (:saturn 29.447498) 16 | (:uranus 84.016846) 17 | (:neptune 164.79132) 18 | (_ (error "not a planet")))) 19 | 20 | (defun age (planet seconds) 21 | (/ seconds (* (orbital-period planet) 31557600))) 22 | 23 | 24 | (provide 'space-age) 25 | ;;; space-age.el ends here 26 | 27 | -------------------------------------------------------------------------------- /exercises/practice/space-age/space-age.el: -------------------------------------------------------------------------------- 1 | ;;; space-age.el --- Space Age (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun age (planet seconds) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'space-age) 13 | ;;; space-age.el ends here 14 | 15 | -------------------------------------------------------------------------------- /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/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | In a small village near an ancient forest, there was a legend of a hidden treasure buried deep within the woods. 4 | Despite numerous attempts, no one had ever succeeded in finding it. 5 | This was about to change, however, thanks to a young explorer named Elara. 6 | She had discovered an old document containing instructions on how to locate the treasure. 7 | Using these instructions, Elara was able to draw a map that revealed the path to the treasure. 8 | 9 | To her surprise, the path followed a peculiar clockwise spiral. 10 | It was no wonder no one had been able to find the treasure before! 11 | With the map in hand, Elara embarks on her journey to uncover the hidden treasure. 12 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "spiral-matrix.el" 8 | ], 9 | "test": [ 10 | "spiral-matrix-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given the size, return a square matrix of numbers in spiral order.", 17 | "source": "Reddit r/dailyprogrammer challenge #320 [Easy] Spiral Ascension.", 18 | "source_url": "https://web.archive.org/web/20230607064729/https://old.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/spiral-matrix.el: -------------------------------------------------------------------------------- 1 | ;;; spiral-matrix.el --- Spiral Matrix (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun spiral-matrix (size) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'spiral-matrix) 13 | ;;; spiral-matrix.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to calculate the square root of a given number. 4 | 5 | - Try to avoid using the pre-existing math libraries of your language. 6 | - As input you'll be given a positive whole number, i.e. 1, 2, 3, 4… 7 | - You are only required to handle cases where the result is a positive whole number. 8 | 9 | Some potential approaches: 10 | 11 | - Linear or binary search for a number that gives the input number when squared. 12 | - Successive approximation using Newton's or Heron's method. 13 | - Calculating one digit at a time or one bit at a time. 14 | 15 | You can check out the Wikipedia pages on [integer square root][integer-square-root] and [methods of computing square roots][computing-square-roots] to help with choosing a method of calculation. 16 | 17 | [integer-square-root]: https://en.wikipedia.org/wiki/Integer_square_root 18 | [computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots 19 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | We are launching a deep space exploration rocket and we need a way to make sure the navigation system stays on target. 4 | 5 | As the first step in our calculation, we take a target number and find its square root (that is, the number that when multiplied by itself equals the target number). 6 | 7 | The journey will be very long. 8 | To make the batteries last as long as possible, we had to make our rocket's onboard computer very power efficient. 9 | Unfortunately that means that we can't rely on fancy math libraries and functions, as they use more power. 10 | Instead we want to implement our own square root calculation. 11 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "square-root.el" 8 | ], 9 | "test": [ 10 | "square-root-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a natural radicand, return its square root.", 17 | "source": "wolf99", 18 | "source_url": "https://github.com/exercism/problem-specifications/pull/1582" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; square-root.el --- Square Root (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun square-root (radicand) 10 | (cl-loop for num from 0 11 | until (<= radicand (* num num)) 12 | finally return num)) 13 | 14 | (provide 'square-root) 15 | ;;; square-root.el ends here 16 | -------------------------------------------------------------------------------- /exercises/practice/square-root/square-root-test.el: -------------------------------------------------------------------------------- 1 | ;;; square-root-test.el --- Tests for Square Root (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (load-file "square-root.el") 8 | (declare-function square-root "square-root.el" (radicand)) 9 | 10 | 11 | (ert-deftest root-of-1 () 12 | (should (= 1 (square-root 1)))) 13 | 14 | 15 | (ert-deftest root-of-4 () 16 | (should (= 2 (square-root 4)))) 17 | 18 | 19 | (ert-deftest root-of-25 () 20 | (should (= 5 (square-root 25)))) 21 | 22 | 23 | (ert-deftest root-of-81 () 24 | (should (= 9 (square-root 81)))) 25 | 26 | 27 | (ert-deftest root-of-196 () 28 | (should (= 14 (square-root 196)))) 29 | 30 | 31 | (ert-deftest root-of-65025 () 32 | (should (= 255 (square-root 65025)))) 33 | 34 | 35 | (provide 'square-root-test) 36 | ;;; square-root-test.el ends here 37 | -------------------------------------------------------------------------------- /exercises/practice/square-root/square-root.el: -------------------------------------------------------------------------------- 1 | ;;; square-root.el --- Square Root (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun square-root (radicand) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'square-root) 13 | ;;; square-root.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/strain/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "strain.el" 8 | ], 9 | "test": [ 10 | "strain-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Implement the `keep` and `discard` operation on collections.", 17 | "source": "Conversation with James Edward Gray II", 18 | "source_url": "http://graysoftinc.com/" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/strain/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; strain.el --- Strain (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun keep (predicate list) 9 | "Return a list of elements in COLLECTION for which PREDICATE returns true." 10 | (let (result) 11 | (dolist (element list (nreverse result)) 12 | (when (funcall predicate element) 13 | (push element result))))) 14 | 15 | (defun discard (predicate list) 16 | "Return a list of elements in COLLECTION for which PREDICATE returns false." 17 | (let (result) 18 | (dolist (element list (nreverse result)) 19 | (unless (funcall predicate element) 20 | (push element result))))) 21 | 22 | 23 | (provide 'strain) 24 | ;;; strain.el ends here 25 | -------------------------------------------------------------------------------- /exercises/practice/strain/strain.el: -------------------------------------------------------------------------------- 1 | ;;; strain.el --- Strain (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun keep (predicate list) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | (defun discard (predicate list) 12 | (error "Delete this S-Expression and write your own implementation")) 13 | 14 | 15 | (provide 'strain) 16 | ;;; strain.el ends here 17 | 18 | -------------------------------------------------------------------------------- /exercises/practice/sublist/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "fapdash" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "sublist.el" 8 | ], 9 | "test": [ 10 | "sublist-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Write a function to determine if a list is a sublist of another list." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/sublist/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; sublist.el --- Sublist (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun list--partition (list cell-size) 10 | (cl-loop for index from 0 11 | ;; we can ignore the rest because this can never contain our sublist 12 | while (<= index (- (length list) cell-size)) 13 | collect (cl-subseq list index (+ index cell-size)))) 14 | 15 | (defun list-sublist (list1 list2) 16 | (cl-some (lambda (partition) 17 | (equal list1 partition)) 18 | (list--partition list2 (length list1)))) 19 | 20 | (defun list-classify (list1 list2) 21 | (cond ((equal list1 list2) :equal) 22 | ((list-sublist list2 list1) :superlist) 23 | ((list-sublist list1 list2) :sublist) 24 | ('t :unequal))) 25 | 26 | (provide 'sublist) 27 | ;;; sublist.el ends here 28 | -------------------------------------------------------------------------------- /exercises/practice/sublist/sublist.el: -------------------------------------------------------------------------------- 1 | ;;; sublist.el --- Sublist (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defun list-classify (list1 list2) 8 | (error "Delete this S-Expression and write your own implementation")) 9 | 10 | (provide 'sublist) 11 | ;;; sublist.el ends here 12 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "sum-of-multiples.el" 8 | ], 9 | "test": [ 10 | "sum-of-multiples-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given a number, find the sum of all the multiples of particular numbers up to but not including that number.", 17 | "source": "A variation on Problem 1 at Project Euler", 18 | "source_url": "https://projecteuler.net/problem=1" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; sum-of-multiples.el --- Sum of Multiples (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (require 'cl-lib) 8 | 9 | (defun sum (factors limit) 10 | (let* ((set (make-hash-table)) 11 | (total 0)) 12 | (dolist (factor (remove 0 factors)) 13 | (cl-loop for multiple from factor below limit by factor 14 | do (puthash multiple t set))) 15 | (maphash (lambda (key value) (setq total (+ total key))) 16 | set) 17 | total)) 18 | 19 | (provide 'sum-of-multiples) 20 | ;;; sum-of-multiples.el ends here 21 | 22 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/sum-of-multiples.el: -------------------------------------------------------------------------------- 1 | ;;; sum-of-multiples.el --- Sum of Multiples (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun sum (factors limit) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'sum-of-multiples) 13 | ;;; sum-of-multiples.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "triangle.el" 8 | ], 9 | "test": [ 10 | "triangle-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Determine if a triangle is equilateral, isosceles, or scalene.", 17 | "source": "The Ruby Koans triangle project, parts 1 & 2", 18 | "source_url": "https://web.archive.org/web/20220831105330/http://rubykoans.com" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/triangle/triangle.el: -------------------------------------------------------------------------------- 1 | ;;; triangle.el --- Triangle (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun equilateralp (sides) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | (defun isoscelesp (sides) 12 | (error "Delete this S-Expression and write your own implementation")) 13 | 14 | (defun scalenep (sides) 15 | (error "Delete this S-Expression and write your own implementation")) 16 | 17 | (provide 'triangle) 18 | ;;; triangle.el ends here 19 | -------------------------------------------------------------------------------- /exercises/practice/trinary/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Convert a trinary number, represented as a string (e.g. '102012'), to its decimal equivalent using first principles. 4 | 5 | The program should consider strings specifying an invalid trinary as the value 0. 6 | 7 | Trinary numbers contain three symbols: 0, 1, and 2. 8 | 9 | The last place in a trinary number is the 1's place. 10 | The second to last is the 3's place, the third to last is the 9's place, etc. 11 | 12 | ```shell 13 | # "102012" 14 | 1 0 2 0 1 2 # the number 15 | 1*3^5 + 0*3^4 + 2*3^3 + 0*3^2 + 1*3^1 + 2*3^0 # the value 16 | 243 + 0 + 54 + 0 + 3 + 2 = 302 17 | ``` 18 | 19 | If your language provides a method in the standard library to perform the conversion, pretend it doesn't exist and implement it yourself. 20 | -------------------------------------------------------------------------------- /exercises/practice/trinary/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wasamasa" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "trinary.el" 8 | ], 9 | "test": [ 10 | "trinary-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Convert a trinary number, represented as a string (e.g. '102012'), to its decimal equivalent using first principles.", 17 | "source": "All of Computer Science", 18 | "source_url": "https://www.wolframalpha.com/examples/mathematics/numbers/base-conversions" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/trinary/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; trinary.el --- Trinary (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | (require 'cl-lib) 7 | 8 | (defun trinary-to-decimal (string) 9 | "Convert STRING from trinary to decimal. 10 | If STRING is not a valid trinary number then return 0." 11 | (if (string-match-p "[^0-2]" string) 12 | 0 13 | (let ((result 0)) 14 | (dotimes (i (length string)) 15 | (let ((digit (- (aref string i) ?0))) 16 | (setq result (+ (* result 3) digit)))) 17 | result))) 18 | 19 | 20 | (provide 'trinary) 21 | ;;; trinary.el ends here 22 | -------------------------------------------------------------------------------- /exercises/practice/trinary/trinary.el: -------------------------------------------------------------------------------- 1 | ;;; trinary.el --- Trinary (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun trinary-to-decimal (string) 6 | ;;; Code: 7 | ) 8 | 9 | (provide 'trinary) 10 | ;;; trinary.el ends here 11 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "two-bucket.el" 8 | ], 9 | "test": [ 10 | "two-bucket-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Given two buckets of different size, demonstrate how to measure an exact number of liters.", 17 | "source": "Water Pouring Problem", 18 | "source_url": "https://demonstrations.wolfram.com/WaterPouringProblem/" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/two-bucket.el: -------------------------------------------------------------------------------- 1 | ;;; two-bucket.el --- Two Bucket (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (define-error 'goal-not-possible 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | (defun measure (bucket-one bucket-two goal start-bucket) 12 | (error "Delete this S-Expression and write your own implementation")) 13 | 14 | 15 | (provide 'two-bucket) 16 | ;;; two-bucket.el ends here 17 | 18 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "benreyn" 4 | ], 5 | "contributors": [ 6 | "bcfurtado", 7 | "vermiculus" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "two-fer.el" 12 | ], 13 | "test": [ 14 | "two-fer-test.el" 15 | ], 16 | "example": [ 17 | ".meta/example.el" 18 | ] 19 | }, 20 | "blurb": "Create a sentence of the form \"One for X, one for me.\".", 21 | "source_url": "https://github.com/exercism/problem-specifications/issues/757" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; two-fer.el --- Two-fer Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | (defun two-fer (&optional name) 8 | (let ((player (or name "you"))) 9 | (concat "One for " player ", one for me."))) 10 | 11 | (provide 'two-fer) 12 | 13 | ;;; two-fer.el ends here 14 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.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 | [1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce] 13 | description = "no name given" 14 | 15 | [b4c6dbb8-b4fb-42c2-bafd-10785abe7709] 16 | description = "a name given" 17 | 18 | [3549048d-1a6e-4653-9a79-b0bda163e8d5] 19 | description = "another name given" 20 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/two-fer-test.el: -------------------------------------------------------------------------------- 1 | ;;; two-fer-test.el --- Tests for Two-fer (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | ;; Common test data version: 1.2.0 4fc1acb 5 | 6 | ;;; Code: 7 | 8 | (load-file "two-fer.el") 9 | (declare-function two-fer "two-fer.el" (&optional name)) 10 | 11 | (ert-deftest no-name-given () 12 | (should (string= (two-fer) "One for you, one for me."))) 13 | 14 | (ert-deftest a-name-given () 15 | (should (string= (two-fer "Alice") "One for Alice, one for me."))) 16 | 17 | (ert-deftest another-name-given () 18 | (should (string= (two-fer "Bob") "One for Bob, one for me."))) 19 | 20 | (provide 'two-fer-test) 21 | 22 | ;;; two-fer-test.el ends here 23 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/two-fer.el: -------------------------------------------------------------------------------- 1 | ;;; two-fer.el --- Two-fer Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun two-fer (&optional name) 6 | ;;; Code: 7 | ) 8 | 9 | (provide 'two-fer) 10 | ;;; two-fer.el ends here 11 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "variable-length-quantity.el" 8 | ], 9 | "test": [ 10 | "variable-length-quantity-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Implement variable length quantity encoding and decoding.", 17 | "source": "A poor Splice developer having to implement MIDI encoding/decoding.", 18 | "source_url": "https://splice.com" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/variable-length-quantity.el: -------------------------------------------------------------------------------- 1 | ;;; variable-length-quantity.el --- Variable Length Quantity (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun encode (integers) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (defun decode (integers) 13 | (error "Delete this S-Expression and write your own implementation")) 14 | 15 | 16 | (provide 'variable-length-quantity) 17 | ;;; variable-length-quantity.el ends here 18 | 19 | -------------------------------------------------------------------------------- /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/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cpaulbond" 4 | ], 5 | "contributors": [ 6 | "canweriotnow", 7 | "npostavs", 8 | "vermiculus", 9 | "wasamasa", 10 | "yurrriq", 11 | "fapdash" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "word-count.el" 16 | ], 17 | "test": [ 18 | "word-count-test.el" 19 | ], 20 | "example": [ 21 | ".meta/example.el" 22 | ] 23 | }, 24 | "blurb": "Given a phrase, count the occurrences of each word in that phrase.", 25 | "source": "This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.meta/example.el: -------------------------------------------------------------------------------- 1 | ;;; word-count.el --- word-count Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defvar exercisms--word-regexp "\\(\\([a-zA-Z]+\\('[a-zA-Z]+\\)?\\)\\|[0-9]+\\)") 9 | 10 | (defun word-count (sentence) 11 | (let ((start 0) 12 | (word-counts '())) 13 | (save-match-data (while (string-match exercisms--word-regexp sentence start) 14 | (let ((match (downcase (match-string 1 sentence)))) 15 | (if (assoc match word-counts) 16 | (setf (cdr (assoc match word-counts)) 17 | (1+ (assoc-default match word-counts 'equal 0))) 18 | (push `(,match . 1) word-counts))) 19 | (setq start (match-end 1)))) 20 | word-counts)) 21 | 22 | 23 | (provide 'word-count) 24 | ;;; word-count.el ends here 25 | -------------------------------------------------------------------------------- /exercises/practice/word-count/word-count.el: -------------------------------------------------------------------------------- 1 | ;;; word-count.el --- word-count Exercise (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | (defun word-count (sentence) 6 | ;;; Code: 7 | ) 8 | 9 | (provide 'word-count) 10 | ;;; word-count.el ends here 11 | -------------------------------------------------------------------------------- /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 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "yacht.el" 8 | ], 9 | "test": [ 10 | "yacht-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Score a single throw of dice in the game Yacht.", 17 | "source": "James Kilfiger, using Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/yacht/yacht.el: -------------------------------------------------------------------------------- 1 | ;;; yacht.el --- Yacht (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun score (scores category) 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (provide 'yacht) 13 | ;;; yacht.el ends here 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The Zebra Puzzle is a famous logic puzzle in which there are five houses, each painted a different color. 4 | The houses have different inhabitants, who have different nationalities, own different pets, drink different beverages and enjoy different hobbies. 5 | 6 | To help you solve the puzzle, you're given 15 statements describing the solution. 7 | However, only by combining the information in _all_ statements will you be able to find the solution to the puzzle. 8 | 9 | ~~~~exercism/note 10 | The Zebra Puzzle is a [Constraint satisfaction problem (CSP)][constraint-satisfaction-problem]. 11 | In such a problem, you have a set of possible values and a set of constraints that limit which values are valid. 12 | Another well-known CSP is Sudoku. 13 | 14 | [constraint-satisfaction-problem]: https://en.wikipedia.org/wiki/Constraint_satisfaction_problem 15 | ~~~~ 16 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "kmarker1101" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "zebra-puzzle.el" 8 | ], 9 | "test": [ 10 | "zebra-puzzle-test.el" 11 | ], 12 | "example": [ 13 | ".meta/example.el" 14 | ] 15 | }, 16 | "blurb": "Solve the zebra puzzle.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Zebra_Puzzle" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/.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 | [16efb4e4-8ad7-4d5e-ba96-e5537b66fd42] 13 | description = "resident who drinks water" 14 | 15 | [084d5b8b-24e2-40e6-b008-c800da8cd257] 16 | description = "resident who owns zebra" 17 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/zebra-puzzle-test.el: -------------------------------------------------------------------------------- 1 | ;;; zebra-puzzle-test.el --- Zebra Puzzle (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (load-file "zebra-puzzle.el") 9 | (declare-function drinks-water "zebra-puzzle.el" ()) 10 | (declare-function owns-zebra "zebra-puzzle.el" ()) 11 | 12 | 13 | (ert-deftest resident-who-drinks-water () 14 | (should (string= (drinks-water) "Norwegian"))) 15 | 16 | 17 | (ert-deftest resident-who-owns-zebra () 18 | (should (string= (owns-zebra) "Japanese"))) 19 | 20 | 21 | (provide 'zebra-puzzle-test) 22 | ;;; zebra-puzzle-test.el ends here 23 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/zebra-puzzle.el: -------------------------------------------------------------------------------- 1 | ;;; zebra-puzzle.el --- Zebra Puzzle (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | 7 | 8 | (defun drinks-water () 9 | (error "Delete this S-Expression and write your own implementation")) 10 | 11 | 12 | (defun owns-zebra () 13 | (error "Delete this S-Expression and write your own implementation")) 14 | 15 | 16 | (provide 'zebra-puzzle) 17 | ;;; zebra-puzzle.el ends here 18 | 19 | -------------------------------------------------------------------------------- /exercises/shared/.docs/debug.md: -------------------------------------------------------------------------------- 1 | # Debug 2 | 3 | To help with debugging, you can use the fact that any [console output](https://www.gnu.org/software/emacs/manual/html_node/elisp/Output-Functions.html) will be shown in the test results window. 4 | -------------------------------------------------------------------------------- /reference/implementing-a-concept-exercise.md: -------------------------------------------------------------------------------- 1 | # How to implement an Emacs Lisp concept exercise 2 | 3 | To implement an Emacs Lisp concept exercise, the following files must be added: 4 | 5 | ``` 6 | languages 7 | └── emacs-lisp 8 | ├── concepts 9 | | └── <CONCEPT_SLUG> 10 | | ├── about.md 11 | | └── links.json 12 | └── exercises 13 | └── concept 14 | └── 15 | ├── .docs 16 | | ├── instructions.md 17 | | ├── introduction.md 18 | | └── hints.md 19 | ├── .meta 20 | | |── design.md 21 | | └── Exemplar.el 22 | ├── .el 23 | └── _test.el 24 | ``` 25 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | # Exercism Emacs Lisp track tools 2 | 3 | ## practice-exercise-generator.el 4 | 5 | The exercise generator creates solution stub files and test stub files from the canonical data json. 6 | Don't call it directly, instead call via /bin/generate_practice_exercise . 7 | -------------------------------------------------------------------------------- /tools/install-packages.el: -------------------------------------------------------------------------------- 1 | (require 'cl-extra) 2 | (defun exercism//install-required-packages () 3 | (require 'package) 4 | (package-initialize) 5 | (let ((required-packages '(mustache ht string-inflection))) 6 | (when (not (cl-every #'package-installed-p required-packages)) 7 | (add-to-list 8 | 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") 9 | t) 10 | (add-to-list 11 | 'package-archives '("melpa" . "https://melpa.org/packages/") 12 | t) 13 | (package-refresh-contents) 14 | (dolist (pkg required-packages) 15 | (package-install pkg))))) 16 | -------------------------------------------------------------------------------- /tools/templates/exercises/practice/solution.mustache: -------------------------------------------------------------------------------- 1 | {{> header}} 2 | 3 | {{#functions}} 4 | 5 | (defun {{function-name}} ({{function-parameters}}) 6 | (error "Delete this S-Expression and write your own implementation")) 7 | {{/functions}} 8 | 9 | 10 | {{> footer}} 11 | -------------------------------------------------------------------------------- /tools/templates/exercises/practice/test.mustache: -------------------------------------------------------------------------------- 1 | {{> header}} 2 | 3 | (load-file "{{solution-filename}}.el") 4 | {{#functions}} 5 | (declare-function {{function-name}} "{{solution-filename}}.el" ({{function-parameters}})) 6 | {{/functions}} 7 | 8 | 9 | {{#tests}} 10 | 11 | 12 | (ert-deftest {{test-name}} () 13 | ;; Function under test: {{function-under-test}} 14 | ;; Input: {{{input}}} 15 | ;; Expected: {{{expected}}} 16 | (error "Delete this S-Expression and implement the test")) 17 | {{/tests}} 18 | 19 | 20 | {{> footer}} 21 | -------------------------------------------------------------------------------- /tools/templates/partials/footer.mustache: -------------------------------------------------------------------------------- 1 | (provide '{{filename}}) 2 | ;;; {{filename}}.el ends here 3 | -------------------------------------------------------------------------------- /tools/templates/partials/header.mustache: -------------------------------------------------------------------------------- 1 | ;;; {{filename}}.el --- {{package-title}} (exercism) -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | 5 | ;;; Code: 6 | --------------------------------------------------------------------------------