├── exercises ├── practice │ ├── say │ │ ├── say.lua │ │ ├── .busted │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── matrix │ │ ├── matrix.lua │ │ ├── .busted │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── sieve │ │ ├── sieve.lua │ │ ├── .busted │ │ ├── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── acronym │ │ ├── acronym.lua │ │ ├── .busted │ │ ├── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── diamond │ │ ├── diamond.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── isogram │ │ ├── isogram.lua │ │ ├── .busted │ │ ├── .meta │ │ │ ├── example.lua │ │ │ ├── spec_generator.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── meetup │ │ ├── meetup.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── nth-prime │ │ ├── nth-prime.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── config.json │ │ │ ├── example.lua │ │ │ └── tests.toml │ ├── pangram │ │ ├── pangram.lua │ │ ├── .busted │ │ ├── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── raindrops │ │ ├── raindrops.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── example.lua │ ├── transpose │ │ ├── transpose.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── clock │ │ ├── clock.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ └── config.json │ ├── custom-set │ │ ├── custom-set.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ └── config.json │ ├── grep │ │ ├── grep.lua │ │ ├── .busted │ │ ├── midsummer-night.txt │ │ ├── paradise-lost.txt │ │ └── iliad.txt │ ├── linked-list │ │ ├── linked-list.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── pig-latin │ │ ├── pig-latin.lua │ │ ├── .busted │ │ ├── .meta │ │ │ ├── spec_generator.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── series │ │ ├── series.lua │ │ ├── .busted │ │ ├── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── sublist │ │ ├── sublist.lua │ │ ├── .busted │ │ └── .meta │ │ │ ├── spec_generator.lua │ │ │ └── config.json │ ├── accumulate │ │ ├── accumulate.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── example.lua │ ├── change │ │ ├── change.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ └── config.json │ ├── queen-attack │ │ ├── queen-attack.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── reverse-string │ │ ├── reverse-string.lua │ │ ├── .busted │ │ ├── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ │ └── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ ├── tournament │ │ ├── tournament.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── word-search │ │ ├── word-search.lua │ │ ├── .busted │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── anagram │ │ ├── anagram.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── luhn │ │ ├── luhn.lua │ │ ├── .busted │ │ └── .meta │ │ │ ├── spec_generator.lua │ │ │ └── config.json │ ├── pascals-triangle │ │ ├── pascals-triangle.lua │ │ ├── .busted │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── prime-factors │ │ ├── prime-factors.lua │ │ ├── .busted │ │ └── .meta │ │ │ ├── example.lua │ │ │ ├── spec_generator.lua │ │ │ └── config.json │ ├── robot-name │ │ ├── robot-name.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── secret-handshake │ │ ├── secret-handshake.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── spiral-matrix │ │ ├── spiral-matrix.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── binary-search │ │ ├── binary-search.lua │ │ ├── .busted │ │ ├── TracedArray.lua │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.lua │ │ └── assertions.lua │ ├── collatz-conjecture │ │ ├── collatz-conjecture.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── grade-school │ │ ├── grade-school.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── kindergarten-garden │ │ ├── kindergarten-garden.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── rna-transcription │ │ ├── rna-transcription.lua │ │ ├── .busted │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── robot-simulator │ │ ├── robot-simulator.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── saddle-points │ │ ├── saddle-points.lua │ │ ├── .busted │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── space-age │ │ ├── space-age.lua │ │ └── .busted │ ├── sum-of-multiples │ │ ├── sum-of-multiples.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── bob │ │ ├── .busted │ │ ├── bob.lua │ │ ├── .meta │ │ │ ├── spec_generator.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── etl │ │ ├── .busted │ │ ├── etl.lua │ │ └── .meta │ │ │ ├── example.lua │ │ │ ├── config.json │ │ │ └── tests.toml │ ├── nucleotide-count │ │ ├── nucleotide-count.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── pov │ │ ├── .busted │ │ ├── pov.lua │ │ └── .meta │ │ │ └── config.json │ ├── pythagorean-triplet │ │ ├── pythagorean-triplet.lua │ │ ├── .busted │ │ ├── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── bank-account │ │ ├── bank-account.lua │ │ ├── .busted │ │ └── .meta │ │ │ └── config.json │ ├── binary │ │ ├── .busted │ │ ├── binary.lua │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── bowling │ │ ├── .busted │ │ ├── bowling.lua │ │ └── .meta │ │ │ └── config.json │ ├── connect │ │ ├── .busted │ │ ├── connect.lua │ │ └── .meta │ │ │ └── config.json │ ├── darts │ │ ├── .busted │ │ ├── darts.lua │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── dominoes │ │ ├── .busted │ │ ├── dominoes.lua │ │ └── .meta │ │ │ └── config.json │ ├── forth │ │ ├── .busted │ │ ├── forth.lua │ │ └── .meta │ │ │ └── config.json │ ├── grains │ │ ├── .busted │ │ ├── grains.lua │ │ ├── .meta │ │ │ └── example.lua │ │ └── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ ├── hamming │ │ ├── .busted │ │ ├── hamming.lua │ │ ├── .meta │ │ │ ├── example.lua │ │ │ ├── spec_generator.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── house │ │ ├── .busted │ │ ├── house.lua │ │ └── .meta │ │ │ └── config.json │ ├── knapsack │ │ ├── .busted │ │ ├── knapsack.lua │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── leap │ │ ├── .busted │ │ ├── leap.lua │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── line-up │ │ ├── .busted │ │ ├── line-up.lua │ │ ├── .meta │ │ │ ├── spec_generator.lua │ │ │ ├── example.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── list-ops │ │ ├── .busted │ │ ├── .meta │ │ │ └── config.json │ │ └── list-ops.lua │ ├── ocr-numbers │ │ ├── ocr-numbers.lua │ │ ├── .busted │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── octal │ │ ├── .busted │ │ ├── octal.lua │ │ └── .meta │ │ │ └── example.lua │ ├── proverb │ │ ├── .busted │ │ ├── proverb.lua │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.lua │ ├── react │ │ ├── .busted │ │ ├── react.lua │ │ └── .meta │ │ │ └── config.json │ ├── rectangles │ │ ├── rectangles.lua │ │ ├── .busted │ │ └── .meta │ │ │ ├── config.json │ │ │ └── spec_generator.lua │ ├── strain │ │ ├── .busted │ │ ├── strain.lua │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── triangle │ │ ├── .busted │ │ ├── triangle.lua │ │ ├── .docs │ │ │ └── instructions.append.md │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── two-fer │ │ ├── .busted │ │ ├── two-fer.lua │ │ ├── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ │ ├── two-fer_spec.lua │ │ └── .docs │ │ │ └── introduction.md │ ├── wordy │ │ ├── .busted │ │ ├── wordy.lua │ │ └── .meta │ │ │ ├── config.json │ │ │ └── spec_generator.lua │ ├── yacht │ │ ├── .busted │ │ ├── yacht.lua │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── affine-cipher │ │ ├── .busted │ │ ├── affine-cipher.lua │ │ └── .meta │ │ │ └── config.json │ ├── all-your-base │ │ ├── .busted │ │ ├── all-your-base.lua │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── allergies │ │ ├── .busted │ │ ├── allergies.lua │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── alphametics │ │ ├── .busted │ │ ├── alphametics.lua │ │ └── .meta │ │ │ └── config.json │ ├── atbash-cipher │ │ ├── .busted │ │ ├── atbash-cipher.lua │ │ └── .meta │ │ │ └── config.json │ ├── beer-song │ │ ├── .busted │ │ ├── beer-song.lua │ │ └── .meta │ │ │ └── config.json │ ├── book-store │ │ ├── .busted │ │ ├── book-store.lua │ │ └── .meta │ │ │ ├── spec_generator.lua │ │ │ └── config.json │ ├── bottle-song │ │ ├── .busted │ │ ├── bottle-song.lua │ │ └── .meta │ │ │ └── config.json │ ├── crypto-square │ │ ├── .busted │ │ ├── crypto-square.lua │ │ └── .meta │ │ │ └── config.json │ ├── dnd-character │ │ ├── .busted │ │ ├── dnd-character.lua │ │ ├── .meta │ │ │ └── config.json │ │ └── assertions.lua │ ├── eliuds-eggs │ │ ├── .busted │ │ ├── eliuds-eggs.lua │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ │ └── eliuds-eggs_spec.lua │ ├── flatten-array │ │ ├── .busted │ │ ├── flatten-array.lua │ │ ├── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── flower-field │ │ ├── .busted │ │ ├── flower-field.lua │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── food-chain │ │ ├── .busted │ │ ├── food-chain.lua │ │ └── .meta │ │ │ └── config.json │ ├── game-of-life │ │ ├── .busted │ │ ├── game-of-life.lua │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ ├── gigasecond │ │ ├── .busted │ │ ├── gigasecond.lua │ │ ├── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── hello-world │ │ ├── .busted │ │ ├── .meta │ │ │ ├── example.lua │ │ │ ├── tests.toml │ │ │ └── config.json │ │ ├── hello-world.lua │ │ ├── hello-world_spec.lua │ │ └── .docs │ │ │ └── instructions.md │ ├── high-scores │ │ ├── .busted │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .articles │ │ │ ├── oop │ │ │ │ └── snippet.md │ │ │ └── config.json │ │ ├── .meta │ │ │ └── config.json │ │ └── high-scores.lua │ ├── isbn-verifier │ │ ├── .busted │ │ ├── isbn-verifier.lua │ │ └── .meta │ │ │ ├── spec_generator.lua │ │ │ ├── example.lua │ │ │ └── config.json │ ├── largest-series-product │ │ ├── largest-series-product.lua │ │ ├── .busted │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── minesweeper │ │ ├── .busted │ │ ├── minesweeper.lua │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── phone-number │ │ ├── .busted │ │ ├── phone-number.lua │ │ └── .meta │ │ │ ├── example.lua │ │ │ ├── spec_generator.lua │ │ │ └── config.json │ ├── square-root │ │ ├── .busted │ │ ├── square-root.lua │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── twelve-days │ │ ├── .busted │ │ ├── twelve-days.lua │ │ └── .meta │ │ │ └── config.json │ ├── two-bucket │ │ ├── .busted │ │ ├── two-bucket.lua │ │ └── .meta │ │ │ └── config.json │ ├── word-count │ │ ├── .busted │ │ ├── word-count.lua │ │ ├── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── armstrong-numbers │ │ ├── .busted │ │ ├── armstrong-numbers.lua │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.lua │ ├── binary-search-tree │ │ ├── .busted │ │ ├── binary-search-tree.lua │ │ └── .meta │ │ │ └── config.json │ ├── circular-buffer │ │ ├── .busted │ │ ├── circular-buffer.lua │ │ └── .meta │ │ │ └── config.json │ ├── complex-numbers │ │ ├── .busted │ │ ├── complex-numbers.lua │ │ ├── .docs │ │ │ └── instructions.append.md │ │ └── .meta │ │ │ └── config.json │ ├── matching-brackets │ │ ├── .busted │ │ ├── matching-brackets.lua │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.lua │ ├── perfect-numbers │ │ ├── .busted │ │ ├── perfect-numbers.lua │ │ └── .meta │ │ │ └── example.lua │ ├── rail-fence-cipher │ │ ├── .busted │ │ ├── rail-fence-cipher.lua │ │ └── .meta │ │ │ └── config.json │ ├── rational-numbers │ │ ├── .busted │ │ ├── .meta │ │ │ └── config.json │ │ └── rational-numbers.lua │ ├── resistor-color-duo │ │ ├── .busted │ │ ├── resistor-color-duo.lua │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── resistor-color │ │ ├── .busted │ │ ├── resistor-color.lua │ │ ├── .docs │ │ │ └── instructions.append.md │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── roman-numerals │ │ ├── .busted │ │ ├── roman-numerals.lua │ │ ├── .meta │ │ │ ├── spec_generator.lua │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── rotational-cipher │ │ ├── .busted │ │ ├── rotational-cipher.lua │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── scrabble-score │ │ ├── .busted │ │ ├── scrabble-score.lua │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── difference-of-squares │ │ ├── .busted │ │ ├── difference-of-squares.lua │ │ └── .meta │ │ │ ├── example.lua │ │ │ └── config.json │ ├── killer-sudoku-helper │ │ ├── .busted │ │ ├── killer-sudoku-helper.lua │ │ └── .meta │ │ │ └── config.json │ ├── palindrome-products │ │ ├── .busted │ │ ├── palindrome-products.lua │ │ └── .meta │ │ │ └── config.json │ ├── protein-translation │ │ ├── .busted │ │ ├── protein-translation.lua │ │ └── .meta │ │ │ └── config.json │ ├── resistor-color-trio │ │ ├── .busted │ │ ├── resistor-color-trio.lua │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.lua │ ├── run-length-encoding │ │ ├── .busted │ │ ├── run-length-encoding.lua │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.lua │ ├── state-of-tic-tac-toe │ │ ├── .busted │ │ ├── state-of-tic-tac-toe.lua │ │ └── .meta │ │ │ └── config.json │ └── variable-length-quantity │ │ ├── .busted │ │ ├── variable-length-quantity.lua │ │ └── .meta │ │ └── config.json ├── concept │ ├── lasagna │ │ ├── .docs │ │ │ └── introduction.md.tpl │ │ ├── .busted │ │ └── .meta │ │ │ ├── config.json │ │ │ └── exemplar.lua │ ├── cars-assemble │ │ ├── .busted │ │ ├── .docs │ │ │ └── introduction.md.tpl │ │ └── .meta │ │ │ ├── config.json │ │ │ └── exemplar.lua │ └── pacman-rules │ │ ├── .busted │ │ ├── .docs │ │ └── introduction.md.tpl │ │ └── .meta │ │ ├── config.json │ │ └── exemplar.lua └── shared │ └── .docs │ └── tests.md ├── bin ├── format ├── install-dev-dependencies └── test-all ├── docs ├── SNIPPET.txt └── LEARNING.md ├── concepts ├── booleans │ ├── .meta │ │ └── config.json │ └── links.json ├── numbers │ ├── .meta │ │ └── config.json │ └── links.json └── basics │ └── .meta │ └── config.json ├── .github ├── CODEOWNERS ├── dependabot.yml └── workflows │ ├── run-configlet-sync.yml │ ├── configlet.yml │ ├── sync-labels.yml │ ├── ping-cross-track-maintainers-team.yml │ └── test.yml ├── .gitignore └── dev-dependencies-git-0.rockspec /exercises/practice/say/say.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/matrix/matrix.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/sieve/sieve.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/acronym/acronym.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/diamond/diamond.lua: -------------------------------------------------------------------------------- 1 | return function(which) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/isogram/isogram.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/meetup/meetup.lua: -------------------------------------------------------------------------------- 1 | return function(config) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/nth-prime.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/pangram/pangram.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/raindrops.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/transpose/transpose.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/clock/clock.lua: -------------------------------------------------------------------------------- 1 | local Clock = {} 2 | 3 | return Clock 4 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/custom-set.lua: -------------------------------------------------------------------------------- 1 | return function() 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/grep/grep.lua: -------------------------------------------------------------------------------- 1 | return function(options) 2 | 3 | end 4 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/linked-list.lua: -------------------------------------------------------------------------------- 1 | return function() 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/pig-latin.lua: -------------------------------------------------------------------------------- 1 | return function(phrase) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/series/series.lua: -------------------------------------------------------------------------------- 1 | return function(s, length) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/sublist/sublist.lua: -------------------------------------------------------------------------------- 1 | return function(l1, l2) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/accumulate.lua: -------------------------------------------------------------------------------- 1 | return function(xs, f) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/change/change.lua: -------------------------------------------------------------------------------- 1 | return function(amount, values) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/queen-attack.lua: -------------------------------------------------------------------------------- 1 | return function(pos) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/reverse-string.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/tournament/tournament.lua: -------------------------------------------------------------------------------- 1 | return function(results) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/word-search/word-search.lua: -------------------------------------------------------------------------------- 1 | return function(grid) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/anagram/anagram.lua: -------------------------------------------------------------------------------- 1 | local Anagram = {} 2 | 3 | return Anagram 4 | -------------------------------------------------------------------------------- /exercises/practice/luhn/luhn.lua: -------------------------------------------------------------------------------- 1 | return { 2 | valid = function(s) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/pascals-triangle.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/prime-factors.lua: -------------------------------------------------------------------------------- 1 | return function(input) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/robot-name.lua: -------------------------------------------------------------------------------- 1 | local Robot = {} 2 | 3 | return Robot 4 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/secret-handshake.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/spiral-matrix.lua: -------------------------------------------------------------------------------- 1 | return function(size) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/binary-search.lua: -------------------------------------------------------------------------------- 1 | return function(array, target) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/collatz-conjecture.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/grade-school.lua: -------------------------------------------------------------------------------- 1 | local School = {} 2 | 3 | return School 4 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/kindergarten-garden.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/rna-transcription.lua: -------------------------------------------------------------------------------- 1 | return function(dna) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/robot-simulator.lua: -------------------------------------------------------------------------------- 1 | return function(config) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/saddle-points.lua: -------------------------------------------------------------------------------- 1 | return function(matrix) 2 | 3 | end 4 | -------------------------------------------------------------------------------- /exercises/practice/space-age/space-age.lua: -------------------------------------------------------------------------------- 1 | local SpaceAge = {} 2 | 3 | return SpaceAge 4 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/sum-of-multiples.lua: -------------------------------------------------------------------------------- 1 | return function(numbers) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/concept/lasagna/.docs/introduction.md.tpl: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | %{concept:basics} 4 | -------------------------------------------------------------------------------- /exercises/practice/bob/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/etl/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/etl/etl.lua: -------------------------------------------------------------------------------- 1 | return { 2 | transform = function(dataset) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/nucleotide-count.lua: -------------------------------------------------------------------------------- 1 | local DNA = {} 2 | 3 | return DNA 4 | -------------------------------------------------------------------------------- /exercises/practice/pov/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/pythagorean-triplet.lua: -------------------------------------------------------------------------------- 1 | return function(sum) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/say/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/concept/lasagna/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/bank-account.lua: -------------------------------------------------------------------------------- 1 | local BankAccount = {} 2 | 3 | return BankAccount 4 | -------------------------------------------------------------------------------- /exercises/practice/binary/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/bowling/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/change/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/clock/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/connect/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/connect/connect.lua: -------------------------------------------------------------------------------- 1 | return { 2 | winner = function(board) 3 | 4 | end 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/darts/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/diamond/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/forth/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/grains/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/grep/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/house/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/leap/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/line-up/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/matrix/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/meetup/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/ocr-numbers.lua: -------------------------------------------------------------------------------- 1 | return { 2 | convert = function(s) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/octal/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/react/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/rectangles/rectangles.lua: -------------------------------------------------------------------------------- 1 | return { 2 | count = function(grid) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/series/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/strain/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/sublist/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/wordy/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/yacht/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/concept/cars-assemble/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/concept/cars-assemble/.docs/introduction.md.tpl: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | %{concept:numbers} 4 | -------------------------------------------------------------------------------- /exercises/concept/pacman-rules/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/concept/pacman-rules/.docs/introduction.md.tpl: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | %{concept:booleans} 4 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/affine-cipher/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/bob/bob.lua: -------------------------------------------------------------------------------- 1 | local bob = {} 2 | 3 | function bob.hey(say) 4 | end 5 | 6 | return bob 7 | -------------------------------------------------------------------------------- /exercises/practice/book-store/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/bottle-song/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/flower-field/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/game-of-life/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/isbn-verifier.lua: -------------------------------------------------------------------------------- 1 | return { 2 | valid = function(isbn) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/largest-series-product.lua: -------------------------------------------------------------------------------- 1 | return function(config) 2 | end 3 | -------------------------------------------------------------------------------- /exercises/practice/leap/leap.lua: -------------------------------------------------------------------------------- 1 | local leap_year = function(number) 2 | end 3 | 4 | return leap_year 5 | -------------------------------------------------------------------------------- /exercises/practice/line-up/line-up.lua: -------------------------------------------------------------------------------- 1 | return { 2 | format = function(name, number) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/rectangles/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/tournament/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/transpose/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/twelve-days/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/two-bucket.lua: -------------------------------------------------------------------------------- 1 | return { 2 | measure = function(args) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/word-search/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /bin/format: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | find exercises -iname '*.lua' -print0 | xargs --null lua-format -i 4 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/matching-brackets.lua: -------------------------------------------------------------------------------- 1 | return { 2 | valid = function(s) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/rational-numbers/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/react/react.lua: -------------------------------------------------------------------------------- 1 | local function Reactor() 2 | end 3 | 4 | return { Reactor = Reactor } 5 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/roman-numerals.lua: -------------------------------------------------------------------------------- 1 | return { 2 | to_roman = function(n) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/atbash-cipher.lua: -------------------------------------------------------------------------------- 1 | return { 2 | encode = function(plaintext) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/circular-buffer.lua: -------------------------------------------------------------------------------- 1 | local CircularBuffer = {} 2 | 3 | return CircularBuffer 4 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/crypto-square.lua: -------------------------------------------------------------------------------- 1 | return { 2 | ciphertext = function(plaintext) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/flatten-array.lua: -------------------------------------------------------------------------------- 1 | local function flatten(input) 2 | end 3 | 4 | return flatten 5 | -------------------------------------------------------------------------------- /exercises/practice/killer-sudoku-helper/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/resistor-color.lua: -------------------------------------------------------------------------------- 1 | return { 2 | color_code = function(color) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/state-of-tic-tac-toe/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/alphametics.lua: -------------------------------------------------------------------------------- 1 | local function solve(puzzle) 2 | end 3 | 4 | return { solve = solve } 5 | -------------------------------------------------------------------------------- /exercises/practice/book-store/book-store.lua: -------------------------------------------------------------------------------- 1 | local function total(basket) 2 | end 3 | 4 | return { total = total } 5 | -------------------------------------------------------------------------------- /exercises/practice/darts/darts.lua: -------------------------------------------------------------------------------- 1 | local Darts = {} 2 | 3 | function Darts.score(x, y) 4 | end 5 | 6 | return Darts 7 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/phone-number.lua: -------------------------------------------------------------------------------- 1 | local function clean(s) 2 | 3 | end 4 | 5 | return { clean = clean } 6 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/resistor-color-duo.lua: -------------------------------------------------------------------------------- 1 | return { 2 | value = function(colors) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/rotational-cipher.lua: -------------------------------------------------------------------------------- 1 | return { 2 | rotate = function(input, key) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/.busted: -------------------------------------------------------------------------------- 1 | return { 2 | default = { 3 | ROOT = { '.' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/wordy/wordy.lua: -------------------------------------------------------------------------------- 1 | local function answer(question) 2 | 3 | end 4 | 5 | return { answer = answer } 6 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/binary-search-tree.lua: -------------------------------------------------------------------------------- 1 | local BinarySearchTree = {} 2 | 3 | return BinarySearchTree 4 | -------------------------------------------------------------------------------- /exercises/practice/binary/binary.lua: -------------------------------------------------------------------------------- 1 | local function to_decimal(input) 2 | end 3 | 4 | return { to_decimal = to_decimal } 5 | -------------------------------------------------------------------------------- /exercises/practice/game-of-life/game-of-life.lua: -------------------------------------------------------------------------------- 1 | local function tick(matrix) 2 | 3 | end 4 | 5 | return { tick = tick } 6 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/resistor-color-trio.lua: -------------------------------------------------------------------------------- 1 | return { 2 | decode = function(c1, c2, c3) 3 | end 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/scrabble-score.lua: -------------------------------------------------------------------------------- 1 | local function score(word) 2 | end 3 | 4 | return { score = score } 5 | -------------------------------------------------------------------------------- /exercises/practice/flower-field/flower-field.lua: -------------------------------------------------------------------------------- 1 | local function annotate(garden) 2 | end 3 | 4 | return { annotate = annotate } 5 | -------------------------------------------------------------------------------- /exercises/practice/forth/forth.lua: -------------------------------------------------------------------------------- 1 | local function evaluate(instructions) 2 | 3 | end 4 | 5 | return { evaluate = evaluate } 6 | -------------------------------------------------------------------------------- /exercises/practice/hamming/hamming.lua: -------------------------------------------------------------------------------- 1 | local Hamming = {} 2 | 3 | function Hamming.compute(a, b) 4 | end 5 | 6 | return Hamming 7 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/minesweeper.lua: -------------------------------------------------------------------------------- 1 | local function transform(board) 2 | end 3 | 4 | return { transform = transform } 5 | -------------------------------------------------------------------------------- /exercises/practice/octal/octal.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | return { 3 | to_decimal = function() 4 | end 5 | } 6 | end 7 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/two-fer.lua: -------------------------------------------------------------------------------- 1 | local TwoFer = {} 2 | 3 | function TwoFer.two_fer(name) 4 | end 5 | 6 | return TwoFer 7 | -------------------------------------------------------------------------------- /exercises/practice/word-count/word-count.lua: -------------------------------------------------------------------------------- 1 | local function count_words(s) 2 | end 3 | 4 | return { count_words = count_words } 5 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/dominoes.lua: -------------------------------------------------------------------------------- 1 | local function can_chain(dominoes) 2 | 3 | end 4 | 5 | return { can_chain = can_chain } 6 | -------------------------------------------------------------------------------- /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/proverb/proverb.lua: -------------------------------------------------------------------------------- 1 | local Proverb = {} 2 | 3 | function Proverb.recite(strings) 4 | end 5 | 6 | return Proverb 7 | -------------------------------------------------------------------------------- /exercises/practice/triangle/triangle.lua: -------------------------------------------------------------------------------- 1 | local triangle = {} 2 | 3 | function triangle.kind(a, b, c) 4 | end 5 | 6 | return triangle 7 | -------------------------------------------------------------------------------- /exercises/practice/yacht/yacht.lua: -------------------------------------------------------------------------------- 1 | local yacht = {} 2 | 3 | yacht.score = function(dice, category) 4 | 5 | end 6 | 7 | return yacht 8 | -------------------------------------------------------------------------------- /docs/SNIPPET.txt: -------------------------------------------------------------------------------- 1 | local hello_world = {} 2 | 3 | function hello_world.hello() 4 | return 'Hello, World!' 5 | end 6 | 7 | return hello_world 8 | -------------------------------------------------------------------------------- /exercises/practice/twelve-days/twelve-days.lua: -------------------------------------------------------------------------------- 1 | local function recite(start_verse, end_verse) 2 | 3 | end 4 | 5 | return { recite = recite } 6 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/protein-translation.lua: -------------------------------------------------------------------------------- 1 | local function proteins(strand) 2 | 3 | end 4 | 5 | return { proteins = proteins } 6 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/eliuds-eggs.lua: -------------------------------------------------------------------------------- 1 | local EliudsEggs = {} 2 | 3 | function EliudsEggs.egg_count(number) 4 | end 5 | 6 | return EliudsEggs 7 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/gigasecond.lua: -------------------------------------------------------------------------------- 1 | local gigasecond = {} 2 | 3 | function gigasecond.anniversary(any_date) 4 | end 5 | 6 | return gigasecond 7 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/run-length-encoding.lua: -------------------------------------------------------------------------------- 1 | return { 2 | encode = function(s) 3 | end, 4 | decode = function(s) 5 | end 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/square-root/square-root.lua: -------------------------------------------------------------------------------- 1 | local SquareRoot = {} 2 | 3 | function SquareRoot.square_root(radicand) 4 | end 5 | 6 | return SquareRoot 7 | -------------------------------------------------------------------------------- /exercises/practice/state-of-tic-tac-toe/state-of-tic-tac-toe.lua: -------------------------------------------------------------------------------- 1 | local function gamestate(board) 2 | 3 | end 4 | 5 | return { gamestate = gamestate } 6 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/knapsack.lua: -------------------------------------------------------------------------------- 1 | local function maximum_value(maximum_weight, items) 2 | 3 | end 4 | 5 | return { maximum_value = maximum_value } 6 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | For this exercise, returning the list of colors is not required. 4 | -------------------------------------------------------------------------------- /bin/install-dev-dependencies: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | luarocks install --server=https://luarocks.org/dev --only-deps dev-dependencies-git-0.rockspec 6 | -------------------------------------------------------------------------------- /exercises/practice/bottle-song/bottle-song.lua: -------------------------------------------------------------------------------- 1 | local BottleSong = {} 2 | 3 | function BottleSong.recite(start_bottles, take_down) 4 | end 5 | 6 | return BottleSong 7 | -------------------------------------------------------------------------------- /exercises/practice/bowling/bowling.lua: -------------------------------------------------------------------------------- 1 | return function() 2 | return { 3 | roll = function(pins) 4 | end, 5 | score = function() 6 | end 7 | } 8 | end 9 | -------------------------------------------------------------------------------- /exercises/practice/grains/grains.lua: -------------------------------------------------------------------------------- 1 | local grains = {} 2 | 3 | function grains.square(n) 4 | end 5 | 6 | function grains.total() 7 | end 8 | 9 | return grains 10 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local hello_world = {} 2 | 3 | function hello_world.hello() 4 | return 'Hello, World!' 5 | end 6 | 7 | return hello_world 8 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/hello-world.lua: -------------------------------------------------------------------------------- 1 | local hello_world = {} 2 | 3 | function hello_world.hello() 4 | return 'Goodbye, Mars!' 5 | end 6 | 7 | return hello_world 8 | -------------------------------------------------------------------------------- /exercises/practice/house/house.lua: -------------------------------------------------------------------------------- 1 | local house = {} 2 | 3 | house.verse = function(which) 4 | end 5 | 6 | house.recite = function() 7 | end 8 | 9 | return house 10 | -------------------------------------------------------------------------------- /exercises/practice/killer-sudoku-helper/killer-sudoku-helper.lua: -------------------------------------------------------------------------------- 1 | local function combinations(sum, size, exclude) 2 | 3 | end 4 | 5 | return { combinations = combinations } 6 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/all-your-base.lua: -------------------------------------------------------------------------------- 1 | local all_your_base = {} 2 | 3 | all_your_base.convert = function(from_digits, from_base) 4 | end 5 | 6 | return all_your_base 7 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Raindrops is a slightly more complex version of the FizzBuzz challenge, a classic interview question. 4 | -------------------------------------------------------------------------------- /exercises/practice/strain/strain.lua: -------------------------------------------------------------------------------- 1 | local function keep(xs, pred) 2 | end 3 | 4 | local function discard(xs, pred) 5 | end 6 | 7 | return { keep = keep, discard = discard } 8 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/beer-song.lua: -------------------------------------------------------------------------------- 1 | local beer = {} 2 | 3 | function beer.verse(number) 4 | end 5 | 6 | function beer.sing(start, finish) 7 | end 8 | 9 | return beer 10 | -------------------------------------------------------------------------------- /exercises/practice/pov/pov.lua: -------------------------------------------------------------------------------- 1 | local function pov_from(node_name) 2 | end 3 | 4 | local function path_from(source) 5 | end 6 | 7 | return { pov_from = pov_from, path_from = path_from } 8 | -------------------------------------------------------------------------------- /exercises/practice/allergies/allergies.lua: -------------------------------------------------------------------------------- 1 | local function list(score) 2 | end 3 | 4 | local function allergic_to(score, which) 5 | end 6 | 7 | return { list = list, allergic_to = allergic_to } 8 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/armstrong-numbers.lua: -------------------------------------------------------------------------------- 1 | local ArmstrongNumbers = {} 2 | 3 | function ArmstrongNumbers.is_armstrong_number(number) 4 | end 5 | 6 | return ArmstrongNumbers 7 | -------------------------------------------------------------------------------- /concepts/booleans/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Introduction to booleans", 3 | "authors": [ 4 | "imolein" 5 | ], 6 | "contributors": [ 7 | "ryanplusplus" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /concepts/numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Introduction to numbers", 3 | "authors": [ 4 | "imolein" 5 | ], 6 | "contributors": [ 7 | "ryanplusplus" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(xs, f) 2 | local result = {} 3 | for _, x in ipairs(xs) do 4 | table.insert(result, f(x)) 5 | end 6 | return result 7 | end 8 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/perfect-numbers.lua: -------------------------------------------------------------------------------- 1 | local function aliquot_sum(n) 2 | end 3 | 4 | local function classify(n) 5 | end 6 | 7 | return { aliquot_sum = aliquot_sum, classify = classify } 8 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | local reversed = '' 3 | for c in s:gmatch('.') do 4 | reversed = c .. reversed 5 | end 6 | return reversed 7 | end 8 | -------------------------------------------------------------------------------- /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/variable-length-quantity/variable-length-quantity.lua: -------------------------------------------------------------------------------- 1 | local function decode(bytes) 2 | end 3 | 4 | local function encode(values) 5 | end 6 | 7 | return { decode = decode, encode = encode } 8 | -------------------------------------------------------------------------------- /exercises/practice/affine-cipher/affine-cipher.lua: -------------------------------------------------------------------------------- 1 | local function encode(phrase, key) 2 | 3 | end 4 | 5 | local function decode(phrase, key) 6 | 7 | end 8 | 9 | return { encode = encode, decode = decode } 10 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local TwoFer = {} 2 | 3 | function TwoFer.two_fer(name) 4 | local val = name or 'you' 5 | return string.format('One for %s, one for me.', val) 6 | end 7 | 8 | return TwoFer 9 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/rail-fence-cipher.lua: -------------------------------------------------------------------------------- 1 | local function encode(plaintext, rail_count) 2 | end 3 | 4 | local function decode(ciphertext, rail_count) 5 | end 6 | 7 | return { encode = encode, decode = decode } 8 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # ignore 2 | 3 | ## Further reading 4 | 5 | You can read more about OO programming in Lua [in this article][oop]. 6 | 7 | [oop]: https://glennj.github.io/exercism/lua/oop 8 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/palindrome-products.lua: -------------------------------------------------------------------------------- 1 | local function smallest(min, max) 2 | 3 | end 4 | 5 | local function largest(min, max) 6 | 7 | end 8 | 9 | return { smallest = smallest, largest = largest } 10 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners 2 | .github/CODEOWNERS @exercism/maintainers-admin 3 | 4 | # Changes to `fetch-configlet` should be made in the `exercism/configlet` repo 5 | bin/fetch-configlet @exercism/maintainers-admin 6 | 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | 5 | # Keep dependencies for GitHub Actions up-to-date 6 | - package-ecosystem: 'github-actions' 7 | directory: '/' 8 | schedule: 9 | interval: 'monthly' 10 | -------------------------------------------------------------------------------- /concepts/basics/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Introduction to comments, variables, functions, tables and modules", 3 | "authors": [ 4 | "imolein" 5 | ], 6 | "contributors": [ 7 | "ryanplusplus" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | local letters = {} 3 | s:gsub('[A-Z]*[a-z]*', function(match) 4 | table.insert(letters, match:sub(1, 1):upper()) 5 | end) 6 | return table.concat(letters) 7 | end 8 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/complex-numbers.lua: -------------------------------------------------------------------------------- 1 | local Complex 2 | 3 | Complex = function(r, i) 4 | local c = { 5 | -- 6 | } 7 | 8 | return setmetatable(c, { 9 | -- 10 | }) 11 | end 12 | 13 | return Complex 14 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/food-chain.lua: -------------------------------------------------------------------------------- 1 | local function verse(which) 2 | end 3 | 4 | local function verses(from, to) 5 | end 6 | 7 | local function sing() 8 | end 9 | 10 | return { verse = verse, verses = verses, sing = sing } 11 | -------------------------------------------------------------------------------- /exercises/practice/grains/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local grains = {} 2 | 3 | function grains.square(n) 4 | return 2 ^ (n - 1) 5 | end 6 | 7 | function grains.total() 8 | return grains.square(65) - 1 9 | end 10 | 11 | return grains 12 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/dnd-character.lua: -------------------------------------------------------------------------------- 1 | local Character = {} 2 | 3 | local function ability(scores) 4 | end 5 | 6 | local function modifier(input) 7 | end 8 | 9 | return { Character = Character, ability = ability, modifier = modifier } 10 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | local seen = {} 3 | for c in s:lower():gmatch('%a') do 4 | if seen[c] then 5 | return false 6 | end 7 | seen[c] = true 8 | end 9 | return true 10 | end 11 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.articles/oop/snippet.md: -------------------------------------------------------------------------------- 1 | ```lua 2 | local Robot = {} 3 | Robot.__index = Robot 4 | function Robot:new(attributes) 5 | local robot = { name = attributes.name or "Anonymous" } 6 | return setmetatable(robot, self) 7 | end 8 | ``` 9 | -------------------------------------------------------------------------------- /exercises/practice/clock/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Implement a clock that handles times without dates. 4 | 5 | You should be able to add and subtract minutes to it. 6 | 7 | Two clocks that represent the same time should be equal to each other. 8 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(dna) 2 | local complements = { C = 'G', G = 'C', T = 'A', A = 'U' } 3 | local rna = '' 4 | for i = 1, #dna do 5 | rna = rna .. complements[dna:sub(i, i)] 6 | end 7 | return rna 8 | end 9 | -------------------------------------------------------------------------------- /.github/workflows/run-configlet-sync.yml: -------------------------------------------------------------------------------- 1 | name: Run Configlet Sync 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '0 0 15 * *' 7 | 8 | jobs: 9 | call-gha-workflow: 10 | uses: exercism/github-actions/.github/workflows/configlet-sync.yml@main 11 | -------------------------------------------------------------------------------- /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/square-root/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local SquareRoot = {} 2 | 3 | function SquareRoot.square_root(radicand) 4 | local root = 0 5 | while root ^ 2 ~= radicand do 6 | root = root + 1 7 | end 8 | 9 | return root 10 | end 11 | 12 | return SquareRoot 13 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'luhn', 3 | 4 | generate_test = function(case) 5 | local template = [[ 6 | assert.is_%s(luhn.valid('%s'))]] 7 | return template:format(case.expected, case.input.value) 8 | end 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'is_isogram', 3 | 4 | generate_test = function(case) 5 | local template = [[ 6 | assert.is_%s(is_isogram('%s'))]] 7 | return template:format(case.expected, case.input.phrase) 8 | end 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'translate', 3 | 4 | generate_test = function(case) 5 | local template = [[ 6 | assert.equal('%s', translate('%s'))]] 7 | return template:format(case.expected, case.input.phrase) 8 | end 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local leap_year = function(number) 2 | local function is_divisible_by(a_number) 3 | return number % a_number == 0 4 | end 5 | 6 | return is_divisible_by(400) or (is_divisible_by(4) and (not is_divisible_by(100))) 7 | end 8 | 9 | return leap_year 10 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'isbn_verifier', 3 | 4 | generate_test = function(case) 5 | local template = [[ 6 | assert.is_%s(isbn_verifier.valid('%s'))]] 7 | return template:format(case.expected, case.input.isbn) 8 | end 9 | } 10 | -------------------------------------------------------------------------------- /exercises/shared/.docs/tests.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | To run the tests, run the command `busted` from within the exercise directory. 4 | 5 | Refer to the [Installing Lua locally][install] documentation to get Lua and busted installed correctly. 6 | 7 | [install]: https://exercism.org/docs/tracks/lua/installation 8 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return { 2 | transform = function(dataset) 3 | local transformed = {} 4 | for k, values in pairs(dataset) do 5 | for _, v in pairs(values) do 6 | transformed[v:lower()] = k 7 | end 8 | end 9 | return transformed 10 | end 11 | } 12 | -------------------------------------------------------------------------------- /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/hello-world/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [af9ffe10-dc13-42d8-a742-e7bdafac449d] 6 | description = "Say Hi!" 7 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | local letters = {} 3 | for c in s:lower():gmatch('%a') do 4 | letters[c:byte()] = true 5 | end 6 | for i = ('a'):byte(), ('z'):byte() do 7 | if not letters[i] then 8 | return false 9 | end 10 | end 11 | return true 12 | end 13 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'roman_numerals', 3 | 4 | generate_test = function(case) 5 | local template = [[ 6 | assert.are.equal('%s', roman_numerals.to_roman(%s))]] 7 | return template:format(case.expected, case.input.number) 8 | end 9 | } 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /concepts/booleans/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://www.lua.org/manual/5.4/manual.html#3.4.5", 4 | "description": "Lua Reference Manual: Logical Operators" 5 | }, 6 | { 7 | "url": "https://www.lua.org/manual/5.4/manual.html#3.4.8", 8 | "description": "Lua Reference Manual: Precedence" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Create a custom set type. 4 | 5 | Sometimes it is necessary to define a custom data structure of some type, like a set. 6 | In this exercise you will define your own set. 7 | How it works internally doesn't matter, as long as it behaves like a set of unique elements. 8 | -------------------------------------------------------------------------------- /exercises/practice/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/grep/midsummer-night.txt: -------------------------------------------------------------------------------- 1 | I do entreat your grace to pardon me. 2 | I know not by what power I am made bold, 3 | Nor how it may concern my modesty, 4 | In such a presence here to plead my thoughts; 5 | But I beseech your grace that I may know 6 | The worst that may befall me in this case, 7 | If I refuse to wed Demetrius. 8 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/difference-of-squares.lua: -------------------------------------------------------------------------------- 1 | local function square_of_sum(n) 2 | end 3 | 4 | local function sum_of_squares(n) 5 | end 6 | 7 | local function difference_of_squares(n) 8 | end 9 | 10 | return { square_of_sum = square_of_sum, sum_of_squares = sum_of_squares, difference_of_squares = difference_of_squares } 11 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/example.lua: -------------------------------------------------------------------------------- 1 | -- In Lua Time is only available in seconds 2 | -- http://stackoverflow.com/questions/463101/lua-current-time-in-milliseconds 3 | local gigasecond = {} 4 | 5 | function gigasecond.anniversary(any_date) 6 | return os.date('%x', any_date + math.pow(10, 9)) 7 | end 8 | 9 | return gigasecond 10 | -------------------------------------------------------------------------------- /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/prime-factors/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(input) 2 | local prime_factors = {} 3 | local i = 2 4 | while input ~= 1 do 5 | if input % i == 0 then 6 | input = input / i 7 | table.insert(prime_factors, i) 8 | else 9 | i = i + 1 10 | end 11 | end 12 | return prime_factors 13 | end 14 | -------------------------------------------------------------------------------- /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/resistor-color/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local value = { 2 | black = 0, 3 | brown = 1, 4 | red = 2, 5 | orange = 3, 6 | yellow = 4, 7 | green = 5, 8 | blue = 6, 9 | violet = 7, 10 | grey = 8, 11 | white = 9 12 | } 13 | 14 | return { 15 | color_code = function(color) 16 | return value[color] 17 | end 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "e7d1d34b-ace8-4cf6-88d3-e59643190a6b", 5 | "slug": "oop", 6 | "title": "Object Oriented Programming in Lua", 7 | "blurb": "A brief OOP tutorial", 8 | "authors": [ 9 | "glennj" 10 | ] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/line-up/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'line_up', 3 | 4 | generate_test = function(case) 5 | local template = [[ 6 | local expected = '%s' 7 | assert.are.same(expected, line_up.format('%s', %d))]] 8 | return template:format(case.expected, case.input.name, case.input.number) 9 | end 10 | } 11 | -------------------------------------------------------------------------------- /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/collatz-conjecture/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | assert(n > 0, 'Only positive integers are allowed') 3 | 4 | local steps = 0 5 | 6 | while n > 1 do 7 | if n % 2 == 0 then 8 | n = n / 2 9 | else 10 | n = 3 * n + 1 11 | end 12 | steps = steps + 1 13 | end 14 | 15 | return steps 16 | end 17 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "dominoes.lua" 8 | ], 9 | "test": [ 10 | "dominoes_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Make a chain of dominoes." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/react/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "react.lua" 8 | ], 9 | "test": [ 10 | "react_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Implement a basic reactive system." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local Darts = {} 2 | 3 | function Darts.score(x, y) 4 | local distance = math.sqrt(x ^ 2 + y ^ 2) 5 | if distance <= 1 then 6 | return 10 7 | elseif distance <= 5 then 8 | return 5 9 | elseif distance <= 10 then 10 | return 1 11 | else 12 | return 0 13 | end 14 | end 15 | 16 | return Darts 17 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | local result = '' 3 | if n % 3 == 0 then 4 | result = result .. 'Pling' 5 | end 6 | if n % 5 == 0 then 7 | result = result .. 'Plang' 8 | end 9 | if n % 7 == 0 then 10 | result = result .. 'Plong' 11 | end 12 | return result ~= '' and result or tostring(n) 13 | end 14 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local function count_words(s) 2 | local counts = {} 3 | for w in s:gmatch('[%w%d\']+') do 4 | local w = w:lower():gsub("^'", ''):gsub("'$", '') 5 | if #w > 0 then 6 | counts[w] = (counts[w] or 0) + 1 7 | end 8 | end 9 | return counts 10 | end 11 | 12 | return { count_words = count_words } 13 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | local rows = { { 1 } } 3 | 4 | for i = 1, n - 1 do 5 | local row = {} 6 | for j = 1, i + 1 do 7 | row[j] = (rows[i][j - 1] or 0) + (rows[i][j] or 0) 8 | end 9 | table.insert(rows, row) 10 | end 11 | 12 | return { rows = rows, last_row = rows[#rows] } 13 | end 14 | -------------------------------------------------------------------------------- /exercises/practice/bob/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'bob', 3 | 4 | generate_test = function(case) 5 | local template = [[ 6 | local result = bob.hey("%s") 7 | assert.are.equals("%s", result)]] 8 | return template:format(case.input.heyBob:gsub("\n", "\\n"):gsub("\r", "\\r"):gsub("\t", "\\t"), case.expected) 9 | end 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local Hamming = {} 2 | 3 | function Hamming.compute(a, b) 4 | assert(#a == #b, 'strands must be of equal length') 5 | local distance = 0 6 | for i = 1, a:len() do 7 | if (a:sub(i, i) ~= b:sub(i, i)) then 8 | distance = distance + 1 9 | end 10 | end 11 | return distance 12 | end 13 | 14 | return Hamming 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/connect/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "connect.lua" 8 | ], 9 | "test": [ 10 | "connect_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Compute the result for a game of Hex / Polygon." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/flower-field/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "flower-field.lua" 8 | ], 9 | "test": [ 10 | "flower-field_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Mark all the flowers in a garden." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local EliudsEggs = {} 2 | 3 | function EliudsEggs.egg_count(number) 4 | local eggs = 0 5 | 6 | local current = number 7 | while current ~= 0 do 8 | if current % 2 ~= 0 then 9 | eggs = eggs + 1 10 | end 11 | 12 | current = current // 2 13 | end 14 | 15 | return eggs 16 | end 17 | 18 | return EliudsEggs 19 | -------------------------------------------------------------------------------- /exercises/practice/forth/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "forth.lua" 8 | ], 9 | "test": [ 10 | "forth_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Implement an evaluator for a very simple subset of Forth." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(sum) 2 | local triplets = {} 3 | 4 | for a = 1, sum // 3 - 1 do 5 | for b = a, (sum - a) // 2 do 6 | local c = sum - a - b 7 | 8 | if a ^ 2 + b ^ 2 == c ^ 2 then 9 | table.insert(triplets, { a, b, c }) 10 | end 11 | end 12 | end 13 | 14 | return triplets 15 | end 16 | -------------------------------------------------------------------------------- /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/resistor-color-duo/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local color_code = { 2 | black = 0, 3 | brown = 1, 4 | red = 2, 5 | orange = 3, 6 | yellow = 4, 7 | green = 5, 8 | blue = 6, 9 | violet = 7, 10 | grey = 8, 11 | white = 9 12 | } 13 | 14 | return { 15 | value = function(colors) 16 | return color_code[colors[1]] * 10 + color_code[colors[2]] 17 | end 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/tournament/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "tournament.lua" 8 | ], 9 | "test": [ 10 | "tournament_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Tally the results of a small football competition." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/binary/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local function to_decimal(input) 2 | if string.match(input, '%D') then 3 | return 0 4 | end 5 | local str = string.reverse(input) 6 | local decimal = 0 7 | for i = 1, #str do 8 | local c = str:sub(i, i) 9 | decimal = decimal + c * (2 ^ (i - 1)) 10 | end 11 | return decimal 12 | end 13 | 14 | return { to_decimal = to_decimal } 15 | -------------------------------------------------------------------------------- /exercises/practice/grep/paradise-lost.txt: -------------------------------------------------------------------------------- 1 | Of Mans First Disobedience, and the Fruit 2 | Of that Forbidden Tree, whose mortal tast 3 | Brought Death into the World, and all our woe, 4 | With loss of Eden, till one greater Man 5 | Restore us, and regain the blissful Seat, 6 | Sing Heav'nly Muse, that on the secret top 7 | Of Oreb, or of Sinai, didst inspire 8 | That Shepherd, who first taught the chosen Seed 9 | -------------------------------------------------------------------------------- /bin/test-all: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | RESULT=0 4 | 5 | rm -r test-exercises 6 | cp -r exercises/practice test-exercises 7 | cd test-exercises || exit 1 8 | 9 | for i in * 10 | do 11 | if test -d "$i" 12 | then 13 | echo "Testing $i..." 14 | pushd "$i" 15 | mv .meta/example.lua "$i.lua" 16 | busted --verbose || RESULT=1 17 | popd 18 | fi 19 | done 20 | 21 | exit $RESULT 22 | -------------------------------------------------------------------------------- /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/say/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a number, your task is to express it in English words exactly as your friend should say it out loud. 4 | Yaʻqūb expects to use numbers from 0 up to 999,999,999,999. 5 | 6 | Examples: 7 | 8 | - 0 → zero 9 | - 1 → one 10 | - 12 → twelve 11 | - 123 → one hundred twenty-three 12 | - 1,234 → one thousand two hundred thirty-four 13 | -------------------------------------------------------------------------------- /exercises/practice/sublist/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'sublist', 3 | 4 | generate_test = function(case) 5 | local template = [[ 6 | assert.equal('%s', %s({ %s }, { %s }))]] 7 | return template:format(case.expected, case.property, table.concat(case.input.listOne, ', '), 8 | table.concat(case.input.listTwo, ', ')) 9 | end 10 | } 11 | -------------------------------------------------------------------------------- /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/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/isbn-verifier/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return { 2 | valid = function(isbn) 3 | isbn = isbn:gsub('-', '') 4 | 5 | if not isbn:match('^%d%d%d%d%d%d%d%d%d[%dX]$') then 6 | return false 7 | end 8 | 9 | local sum = 0 10 | for i = 1, 10 do 11 | sum = sum + (11 - i) * (tonumber(isbn:sub(i, i)) or 10) 12 | end 13 | 14 | return sum % 11 == 0 15 | end 16 | } 17 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return { 2 | rotate = function(input, key) 3 | return input:gsub('.', function(c) 4 | if c:match('%a') then 5 | local base = c:match('%l') and 'a' or 'A' 6 | local offset = c:byte() - base:byte() 7 | return string.char(base:byte() + (offset + key) % 26) 8 | end 9 | return c 10 | end) 11 | end 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/strain/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local function keep(xs, pred) 2 | local acc = {} 3 | for _, x in ipairs(xs) do 4 | if pred(x) then 5 | table.insert(acc, x) 6 | end 7 | end 8 | return acc 9 | end 10 | 11 | local function discard(xs, pred) 12 | return keep(xs, function(x) 13 | return not pred(x) 14 | end) 15 | end 16 | 17 | return { keep = keep, discard = discard } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile ~/.gitignore_global 6 | 7 | .DS_Store 8 | bin/configlet.exe 9 | bin/configlet 10 | test-exercises/ 11 | canonical-data/ 12 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "custom-set.lua" 11 | ], 12 | "test": [ 13 | "custom-set_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Create a custom set type." 20 | } 21 | -------------------------------------------------------------------------------- /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/high-scores/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Manage a game player's High Score list. 4 | 5 | Your task is to build a high-score component of the classic Frogger game, one of the highest selling and most addictive games of all time, and a classic of the arcade era. 6 | Your task is to write methods that return the highest score from the list, the last added score and the three highest scores. 7 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "list-ops.lua" 11 | ], 12 | "test": [ 13 | "list-ops_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Implement basic list operations." 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/grep/iliad.txt: -------------------------------------------------------------------------------- 1 | Achilles sing, O Goddess! Peleus' son; 2 | His wrath pernicious, who ten thousand woes 3 | Caused to Achaia's host, sent many a soul 4 | Illustrious into Ades premature, 5 | And Heroes gave (so stood the will of Jove) 6 | To dogs and to all ravening fowls a prey, 7 | When fierce dispute had separated once 8 | The noble Chief Achilles from the son 9 | Of Atreus, Agamemnon, King of men. 10 | -------------------------------------------------------------------------------- /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/linked-list/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "linked-list.lua" 8 | ], 9 | "test": [ 10 | "linked-list_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Implement a doubly linked list.", 17 | "source": "Classic computer science topic" 18 | } 19 | -------------------------------------------------------------------------------- /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/prime-factors/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | local function render_numbers(numbers) 2 | return table.concat(numbers, ', ') 3 | end 4 | 5 | return { 6 | module_name = 'prime_factors', 7 | 8 | generate_test = function(case) 9 | local template = [[ 10 | assert.are.same({ %s }, prime_factors(%s))]] 11 | return template:format(render_numbers(case.expected), case.input.value) 12 | end 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | ### Error handling & Assertion 4 | 5 | Use error handling or assertion to check if the shape is a triangle at all: 6 | 7 | - [Error Keyword][error-keyword] 8 | - [Assertion][assertion] 9 | 10 | [error-keyword]: https://www.lua.org/manual/5.4/manual.html#pdf-error 11 | [assertion]: https://www.lua.org/manual/5.4/manual.html#pdf-assert 12 | -------------------------------------------------------------------------------- /docs/LEARNING.md: -------------------------------------------------------------------------------- 1 | # Learning 2 | 3 | Lua is a very small language and you can [learn the basics of the language in 15 minutes][1]. For an exhaustive look at the language, written by the authors of Lua, you can read [Programming in Lua][2] (the first edition which covers Lua 5.0 [is available online for free][3]). 4 | 5 | [1]: http://tylerneylon.com/a/learn-lua/ 6 | [2]: http://www.lua.org/pil/ 7 | [3]: https://www.lua.org/pil/contents.html 8 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "minesweeper.lua" 11 | ], 12 | "test": [ 13 | "minesweeper_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Add the numbers to a minesweeper board." 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/rectangles/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "rectangles.lua" 11 | ], 12 | "test": [ 13 | "rectangles_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Count the rectangles in an ASCII diagram." 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "high-scores.lua" 8 | ], 9 | "test": [ 10 | "high-scores_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Manage a player's High Score list.", 17 | "source": "Tribute to the eighties' arcade game Frogger" 18 | } 19 | -------------------------------------------------------------------------------- /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/concept/lasagna/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "imolein" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "lasagna.lua" 8 | ], 9 | "test": [ 10 | "lasagna_spec.lua" 11 | ], 12 | "exemplar": [ 13 | ".meta/exemplar.lua" 14 | ] 15 | }, 16 | "forked_from": [ 17 | "go/lasagna" 18 | ], 19 | "blurb": "Learn about the basics of Lua by following a lasagna recipe." 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/word-search/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "word-search.lua" 11 | ], 12 | "test": [ 13 | "word-search_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Create a program to solve a word search puzzle." 20 | } 21 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/TracedArray.lua: -------------------------------------------------------------------------------- 1 | return function(array) 2 | local accessed = {} 3 | 4 | return setmetatable({ access_count = 0 }, { 5 | __index = function(self, i) 6 | if not accessed[i] then 7 | self.access_count = self.access_count + 1 8 | accessed[i] = true 9 | end 10 | return array[i] 11 | end, 12 | __len = function() 13 | return #array 14 | end 15 | }) 16 | end 17 | -------------------------------------------------------------------------------- /exercises/practice/say/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your friend Yaʻqūb works the counter at the busiest deli in town, slicing, weighing, and wrapping orders for a never-ending line of hungry customers. 4 | To keep things moving, each customer takes a numbered ticket when they arrive. 5 | 6 | When it’s time to call the next person, Yaʻqūb reads their number out loud, always in full English words to make sure everyone hears it clearly. 7 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | return coroutine.create(function() 3 | local is_prime = {} 4 | 5 | for i = 2, n do 6 | is_prime[i] = true 7 | end 8 | 9 | for i = 2, n do 10 | if is_prime[i] then 11 | coroutine.yield(i) 12 | 13 | for multiple = i * i, n, i do 14 | is_prime[multiple] = false 15 | end 16 | end 17 | end 18 | end) 19 | end 20 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "alphametics.lua" 11 | ], 12 | "test": [ 13 | "alphametics_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Given an alphametics puzzle, find the correct solution." 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/sublist/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "sublist.lua" 11 | ], 12 | "test": [ 13 | "sublist_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Write a function to determine if a list is a sublist of another list." 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | This exercise requires you to use Closure-based objects. You can read more about this approach to object orientation in Lua [in this article][oot]. 2 | 3 | This exercise also requires you to use operator overloading via metatable metamethods. You can read more about this in [Programming in Lua][am]. 4 | 5 | [oot]: http://lua-users.org/wiki/ObjectOrientationTutorial 6 | [am]: https://www.lua.org/pil/13.1.html 7 | -------------------------------------------------------------------------------- /exercises/practice/octal/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local function to_decimal(s) 2 | local decimal = 0 3 | for i = #s, 1, -1 do 4 | local digit = tonumber(s:sub(i, i)) 5 | if not digit or digit >= 8 then 6 | return 0 7 | end 8 | decimal = decimal + digit * 8 ^ (#s - i) 9 | end 10 | return decimal 11 | end 12 | 13 | return function(s) 14 | return { 15 | to_decimal = function() 16 | return to_decimal(s) 17 | end 18 | } 19 | end 20 | -------------------------------------------------------------------------------- /exercises/concept/pacman-rules/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "imolein" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "pacman-rules.lua" 8 | ], 9 | "test": [ 10 | "pacman-rules_spec.lua" 11 | ], 12 | "exemplar": [ 13 | ".meta/exemplar.lua" 14 | ] 15 | }, 16 | "forked_from": [ 17 | "elixir/pacman-rules" 18 | ], 19 | "blurb": "Learn about booleans by implementing the rules of the Pac-Man game." 20 | } 21 | -------------------------------------------------------------------------------- /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/meetup/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "meetup.lua" 8 | ], 9 | "test": [ 10 | "meetup_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/two-fer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "two-fer.lua" 8 | ], 9 | "test": [ 10 | "two-fer_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Create a sentence of the form \"One for X, one for me.\".", 17 | "source_url": "https://github.com/exercism/problem-specifications/issues/757" 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/book-store/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | local function render_basket(basket) 2 | return table.concat(basket, ', ') 3 | end 4 | 5 | return { 6 | module_name = 'book_store', 7 | 8 | generate_test = function(case) 9 | local template = [[ 10 | local basket = { 11 | %s 12 | } 13 | assert.are.same(%s, book_store.total(basket))]] 14 | return template:format(render_basket(case.input.basket), case.expected) 15 | end 16 | } 17 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "darts.lua" 8 | ], 9 | "test": [ 10 | "darts_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/pov/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "pov.lua" 8 | ], 9 | "test": [ 10 | "pov_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Reparent a graph on a selected node.", 17 | "source": "Adaptation of exercise from 4clojure", 18 | "source_url": "https://github.com/oxalorg/4ever-clojure" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/concept/cars-assemble/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "imolein" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "cars-assemble.lua" 8 | ], 9 | "test": [ 10 | "cars-assemble_spec.lua" 11 | ], 12 | "exemplar": [ 13 | ".meta/exemplar.lua" 14 | ] 15 | }, 16 | "forked_from": [ 17 | "go/cars-assemble" 18 | ], 19 | "blurb": "Learn about numbers in Lua by analyzing an assembly line in a car factory." 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "complex-numbers.lua" 8 | ], 9 | "test": [ 10 | "complex-numbers_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Implement complex numbers.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Complex_number" 19 | } 20 | -------------------------------------------------------------------------------- /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/all-your-base/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "all-your-base.lua" 11 | ], 12 | "test": [ 13 | "all-your-base_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Convert a number, represented as a sequence of digits in one base, to any other base." 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/game-of-life/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "game-of-life.lua" 8 | ], 9 | "test": [ 10 | "game-of-life_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/hello-world/hello-world_spec.lua: -------------------------------------------------------------------------------- 1 | -- Require the hello-world module 2 | local hello_world = require('hello-world') 3 | 4 | -- Define a module named hello-world. This module should return a single 5 | -- function named hello that takes no arguments and returns a string. 6 | 7 | describe('hello-world', function() 8 | it('says hello world', function() 9 | local result = hello_world.hello() 10 | assert.are.equal('Hello, World!', result) 11 | end) 12 | end) 13 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "protein-translation.lua" 11 | ], 12 | "test": [ 13 | "protein-translation_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Translate RNA sequences into proteins.", 20 | "source": "Tyler Long" 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/rational-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "rational-numbers.lua" 8 | ], 9 | "test": [ 10 | "rational-numbers_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Implement rational numbers.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Rational_number" 19 | } 20 | -------------------------------------------------------------------------------- /dev-dependencies-git-0.rockspec: -------------------------------------------------------------------------------- 1 | package = 'dev-dependencies' 2 | version = 'git-0' 3 | source = { 4 | url = 'https://github.com/exercism/lua' 5 | } 6 | description = { 7 | summary = 'Development dependencies for the Exercism Lua track.', 8 | homepage = 'https://github.com/exercism/lua/' 9 | } 10 | dependencies = { 11 | 'lua >= 5.3', 12 | 'busted >= 2.2.0-1', 13 | 'dkjson ~> 2.8-1', 14 | 'luaformatter' 15 | } 16 | build = { 17 | type = 'builtin', 18 | modules = {} 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "binary-search-tree.lua" 11 | ], 12 | "test": [ 13 | "binary-search-tree_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Insert and search for numbers in a binary tree.", 20 | "source": "Josh Cheek" 21 | } 22 | -------------------------------------------------------------------------------- /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/strain/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "strain.lua" 8 | ], 9 | "test": [ 10 | "strain_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/yacht/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "yacht.lua" 8 | ], 9 | "test": [ 10 | "yacht_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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 | -------------------------------------------------------------------------------- /concepts/numbers/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://www.lua.org/manual/5.4/manual.html#3.4.1", 4 | "description": "Lua Reference Manual: Arithmetic Operators" 5 | }, 6 | { 7 | "url": "https://www.lua.org/manual/5.4/manual.html#6.7", 8 | "description": "Lua Reference Manual: Mathematical Functions" 9 | }, 10 | { 11 | "url": "https://www.lua.org/manual/5.4/manual.html#3.4.3", 12 | "description": "Lua Reference Manual: Coercions and Conversions" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/series/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(s, length) 2 | assert(string.len(s) > 0, "series cannot be empty") 3 | assert(length >= 0, "slice length cannot be negative") 4 | assert(length > 0, "slice length cannot be zero") 5 | assert(length <= string.len(s), "slice length cannot be greater than series length") 6 | 7 | return coroutine.wrap(function() 8 | for i = 1, #s - length + 1 do 9 | coroutine.yield(s:sub(i, i + length - 1)) 10 | end 11 | end) 12 | end 13 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "square-root.lua" 8 | ], 9 | "test": [ 10 | "square-root_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/two-fer/two-fer_spec.lua: -------------------------------------------------------------------------------- 1 | local TwoFer = require 'two-fer' 2 | 3 | describe('two-fer', function() 4 | it('no name given', function() 5 | assert.equal('One for you, one for me.', TwoFer.two_fer()) 6 | end) 7 | 8 | it('a name given', function() 9 | assert.equal('One for Alice, one for me.', TwoFer.two_fer('Alice')) 10 | end) 11 | 12 | it('another name given', function() 13 | assert.equal('One for Bob, one for me.', TwoFer.two_fer('Bob')) 14 | end) 15 | end) 16 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "acronym.lua" 11 | ], 12 | "test": [ 13 | "acronym_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Convert a long phrase to its acronym.", 20 | "source": "Julien Vanier", 21 | "source_url": "https://github.com/monkbroc" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "armstrong-numbers.lua" 8 | ], 9 | "test": [ 10 | "armstrong-numbers_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Determine if a number is an Armstrong number.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Narcissistic_number" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "robot-simulator.lua" 11 | ], 12 | "test": [ 13 | "robot-simulator_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Write a robot simulator.", 20 | "source": "Inspired by an interview question at a famous company." 21 | } 22 | -------------------------------------------------------------------------------- /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/matching-brackets/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti", 7 | "elyashiv" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "matching-brackets.lua" 12 | ], 13 | "test": [ 14 | "matching-brackets_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Make sure the brackets and braces all match.", 21 | "source": "Ginna Baker" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "pangram.lua" 11 | ], 12 | "test": [ 13 | "pangram_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 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/robot-name/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "ryanplusplus" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "robot-name.lua" 12 | ], 13 | "test": [ 14 | "robot-name_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Manage robot factory settings.", 21 | "source": "A debugging session with Paul Blackwell at gSchool." 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "isogram.lua" 11 | ], 12 | "test": [ 13 | "isogram_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Determine if a word or phrase is an isogram.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Isogram" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "palindrome-products.lua" 8 | ], 9 | "test": [ 10 | "palindrome-products_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Detect palindrome products in a given range.", 17 | "source": "Problem 4 at Project Euler", 18 | "source_url": "https://projecteuler.net/problem=4" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/twelve-days/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "twelve-days.lua" 8 | ], 9 | "test": [ 10 | "twelve-days_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Output the lyrics to 'The Twelve Days of Christmas'.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/The_Twelve_Days_of_Christmas_(song)" 19 | } 20 | -------------------------------------------------------------------------------- /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/change/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Determine the fewest number of coins to give a customer so that the sum of their values equals the correct amount of change. 4 | 5 | ## Examples 6 | 7 | - An amount of 15 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5 and one coin of value 10, or [5, 10]. 8 | - An amount of 40 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5, one coin of value 10, and one coin of value 25, or [5, 10, 25]. 9 | -------------------------------------------------------------------------------- /exercises/practice/clock/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "clock.lua" 13 | ], 14 | "test": [ 15 | "clock_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Implement a clock that handles times without dates.", 22 | "source": "Pairing session with Erin Drummond" 23 | } 24 | -------------------------------------------------------------------------------- /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/perfect-numbers/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local function aliquot_sum(n) 2 | local sum = 0 3 | for i = 1, n - 1 do 4 | if n % i == 0 then 5 | sum = sum + i 6 | end 7 | end 8 | return sum 9 | end 10 | 11 | local function classify(n) 12 | local sum = aliquot_sum(n) 13 | if sum < n then 14 | return 'deficient' 15 | end 16 | if sum > n then 17 | return 'abundant' 18 | end 19 | return 'perfect' 20 | end 21 | 22 | return { aliquot_sum = aliquot_sum, classify = classify } 23 | -------------------------------------------------------------------------------- /exercises/practice/bottle-song/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "bottle-song.lua" 8 | ], 9 | "test": [ 10 | "bottle-song_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Produce the lyrics to the popular children's repetitive song: Ten Green Bottles.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Ten_Green_Bottles" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local function append(destination, to_append) 2 | for _, v in ipairs(to_append) do 3 | table.insert(destination, v) 4 | end 5 | end 6 | 7 | local function flatten(input) 8 | local flattened = {} 9 | for _, element in ipairs(input) do 10 | if type(element) == 'table' then 11 | append(flattened, flatten(element)) 12 | else 13 | table.insert(flattened, element) 14 | end 15 | end 16 | return flattened 17 | end 18 | 19 | return flatten 20 | -------------------------------------------------------------------------------- /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/high-scores/high-scores.lua: -------------------------------------------------------------------------------- 1 | local HighScores = {} 2 | 3 | function HighScores:scores() 4 | 5 | end 6 | 7 | function HighScores:latest() 8 | 9 | end 10 | 11 | function HighScores:personal_best() 12 | 13 | end 14 | 15 | function HighScores:personal_top_three() 16 | 17 | end 18 | 19 | return function(scores) 20 | local high_scores = {} 21 | setmetatable(high_scores, { __index = HighScores }) 22 | 23 | -- TODO: store the scores in the high_scores object 24 | 25 | return high_scores 26 | end 27 | -------------------------------------------------------------------------------- /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/concept/lasagna/.meta/exemplar.lua: -------------------------------------------------------------------------------- 1 | local lasagna = {} 2 | 3 | lasagna.oven_time = 40 4 | 5 | function lasagna.remaining_oven_time(actual_minutes_in_oven) 6 | return lasagna.oven_time - actual_minutes_in_oven 7 | end 8 | 9 | function lasagna.preparation_time(number_of_layers) 10 | return number_of_layers * 2 11 | end 12 | 13 | function lasagna.elapsed_time(number_of_layers, actual_minutes_in_oven) 14 | return actual_minutes_in_oven + lasagna.preparation_time(number_of_layers) 15 | end 16 | 17 | return lasagna 18 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local ArmstrongNumbers = {} 2 | 3 | function ArmstrongNumbers.is_armstrong_number(number) 4 | local digits = tostring(number) 5 | local pow_special = function(digit) 6 | return tonumber(digit) ^ string.len(digits) 7 | end 8 | 9 | local sum = 0 10 | for i = 1, string.len(digits) do 11 | local digit = tonumber(string.sub(digits, i, i)) 12 | sum = sum + pow_special(digit) 13 | end 14 | 15 | return sum == number 16 | end 17 | 18 | return ArmstrongNumbers 19 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "collatz-conjecture.lua" 8 | ], 9 | "test": [ 10 | "collatz-conjecture_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/bank-account/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti", 7 | "refacto" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "bank-account.lua" 12 | ], 13 | "test": [ 14 | "bank-account_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Simulate a bank account supporting opening/closing, withdraws, and deposits of money. Watch out for concurrent transactions!" 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/eliuds-eggs_spec.lua: -------------------------------------------------------------------------------- 1 | local EliudsEggs = require 'eliuds-eggs' 2 | 3 | describe('eliuds-eggs', function() 4 | it('0 eggs', function() 5 | assert.equal(0, EliudsEggs.egg_count(0)) 6 | end) 7 | 8 | it('1 egg', function() 9 | assert.equal(1, EliudsEggs.egg_count(16)) 10 | end) 11 | 12 | it('4 eggs', function() 13 | assert.equal(4, EliudsEggs.egg_count(89)) 14 | end) 15 | 16 | it('13 eggs', function() 17 | assert.equal(13, EliudsEggs.egg_count(2000000000)) 18 | end) 19 | end) 20 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "flatten-array.lua" 8 | ], 9 | "test": [ 10 | "flatten-array_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/phone-number/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local function clean(s) 2 | s = s:gsub('[()-. ]', '') 3 | 4 | assert(not s:match('%D')) 5 | assert(#s == 10 or #s == 11) 6 | assert(#s ~= 11 or s:sub(1, 1) == '1') 7 | 8 | s = s:sub(#s - 9) 9 | 10 | local area_code, exchange_code, line_number = s:match('(...)(...)(....)') 11 | 12 | assert(not area_code:match('^[01]')) 13 | assert(not exchange_code:match('^[01]')) 14 | 15 | return area_code .. exchange_code .. line_number 16 | end 17 | 18 | return { clean = clean } 19 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "saddle-points.lua" 8 | ], 9 | "test": [ 10 | "saddle-points_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Detect saddle points in a matrix.", 17 | "source": "J Dalbey's Programming Practice problems", 18 | "source_url": "https://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" 19 | } 20 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /exercises/concept/cars-assemble/.meta/exemplar.lua: -------------------------------------------------------------------------------- 1 | local cars = {} 2 | 3 | function cars.calculate_working_cars_per_hour(production_rate, success_rate) 4 | return production_rate * success_rate / 100 5 | end 6 | 7 | function cars.calculate_working_cars_per_minute(production_rate, success_rate) 8 | return cars.calculate_working_cars_per_hour(production_rate, success_rate) // 60 9 | end 10 | 11 | function cars.calculate_cost(cars_count) 12 | return (cars_count // 10) * 95000 + (cars_count % 10) * 10000 13 | end 14 | 15 | return cars 16 | -------------------------------------------------------------------------------- /exercises/practice/affine-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "affine-cipher.lua" 8 | ], 9 | "test": [ 10 | "affine-cipher_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/binary-search/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "binary-search.lua" 11 | ], 12 | "test": [ 13 | "binary-search_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Implement a binary search algorithm.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Binary_search_algorithm" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/line-up/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your friend Yaʻqūb works the counter at a deli in town, slicing, weighing, and wrapping orders for a line of hungry customers that gets longer every day. 4 | Waiting customers are starting to lose track of who is next, so he wants numbered tickets they can use to track the order in which they arrive. 5 | 6 | To make the customers feel special, he does not want the ticket to have only a number on it. 7 | They shall get a proper English sentence with their name and number on it. 8 | -------------------------------------------------------------------------------- /exercises/practice/line-up/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return { 2 | format = function(name, number) 3 | local suffix = 'th' 4 | if number // 10 % 10 ~= 1 then 5 | local last = number % 10 6 | if last == 1 then 7 | suffix = 'st' 8 | end 9 | if last == 2 then 10 | suffix = 'nd' 11 | end 12 | if last == 3 then 13 | suffix = 'rd' 14 | end 15 | end 16 | return string.format('%s, you are the %d%s customer we serve today. Thank you!', name, number, suffix) 17 | end 18 | } 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/resistor-color/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "resistor-color.lua" 8 | ], 9 | "test": [ 10 | "resistor-color_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/rotational-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "rotational-cipher.lua" 8 | ], 9 | "test": [ 10 | "rotational-cipher_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/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/two-bucket/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "two-bucket.lua" 8 | ], 9 | "test": [ 10 | "two-bucket_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/dnd-character/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "dnd-character.lua" 8 | ], 9 | "test": [ 10 | "dnd-character_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/proverb/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "proverb.lua" 8 | ], 9 | "test": [ 10 | "proverb_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/line-up/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "line-up.lua" 8 | ], 9 | "test": [ 10 | "line-up_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Help lining up customers at Yaʻqūb's Deli.", 17 | "source": "mk-mxp, based on previous work from Exercism contributors codedge and neenjaw", 18 | "source_url": "https://forum.exercism.org/t/new-exercise-ordinal-numbers/19147" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "nth-prime.lua" 11 | ], 12 | "test": [ 13 | "nth-prime_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Given a number n, determine what the nth prime is.", 20 | "source": "A variation on Problem 7 at Project Euler", 21 | "source_url": "https://projecteuler.net/problem=7" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local Proverb = {} 2 | 3 | function Proverb.recite(strings) 4 | if #strings == 0 then 5 | return '' 6 | end 7 | 8 | local lines = {} 9 | local template = "For want of a %s the %s was lost.\n" 10 | for index = 2, #strings do 11 | table.insert(lines, template:format(strings[index - 1], strings[index])) 12 | end 13 | 14 | template = "And all for the want of a %s.\n" 15 | table.insert(lines, template:format(strings[1])) 16 | return table.concat(lines) 17 | end 18 | 19 | return Proverb 20 | -------------------------------------------------------------------------------- /exercises/practice/diamond/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "diamond.lua" 8 | ], 9 | "test": [ 10 | "diamond_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/house/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "house.lua" 11 | ], 12 | "test": [ 13 | "house_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Output the nursery rhyme 'This is the House that Jack Built'.", 20 | "source": "British nursery rhyme", 21 | "source_url": "https://en.wikipedia.org/wiki/This_Is_The_House_That_Jack_Built" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "luhn.lua" 11 | ], 12 | "test": [ 13 | "luhn_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 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/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/resistor-color-duo/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "resistor-color-duo.lua" 8 | ], 9 | "test": [ 10 | "resistor-color-duo_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/run-length-encoding/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "run-length-encoding.lua" 11 | ], 12 | "test": [ 13 | "run-length-encoding_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 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/wordy/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "wordy.lua" 8 | ], 9 | "test": [ 10 | "wordy_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Parse and evaluate simple math word problems returning the answer as an integer.", 17 | "source": "Inspired by one of the generated questions in the Extreme Startup game.", 18 | "source_url": "https://github.com/rchatley/extreme_startup" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/flower-field/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | [Flower Field][history] is a compassionate reimagining of the popular game Minesweeper. 4 | The object of the game is to find all the flowers in the garden using numeric hints that indicate how many flowers are directly adjacent (horizontally, vertically, diagonally) to a square. 5 | "Flower Field" shipped in regional versions of Microsoft Windows in Italy, Germany, South Korea, Japan and Taiwan. 6 | 7 | [history]: https://web.archive.org/web/20020409051321fw_/http://rcm.usr.dsi.unimi.it/rcmweb/fnm/ 8 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "resistor-color-trio.lua" 8 | ], 9 | "test": [ 10 | "resistor-color-trio_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/reverse-string/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "reverse-string.lua" 8 | ], 9 | "test": [ 10 | "reverse-string_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Reverse a given string.", 17 | "source": "Introductory challenge to reverse an input string", 18 | "source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/say/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "say.lua" 8 | ], 9 | "test": [ 10 | "say_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/variable-length-quantity/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "variable-length-quantity.lua" 8 | ], 9 | "test": [ 10 | "variable-length-quantity_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/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/grade-school/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "ryanplusplus" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "grade-school.lua" 12 | ], 13 | "test": [ 14 | "grade-school_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Given students' names along with the grade that they are in, create a roster for the school.", 21 | "source": "A pairing session with Phil Battos at gSchool" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "knapsack.lua" 8 | ], 9 | "test": [ 10 | "knapsack_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/sum-of-multiples/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(numbers) 2 | return { 3 | to = function(limit) 4 | local multiples = {} 5 | local sum = 0 6 | 7 | for candidate = 1, limit - 1 do 8 | for _, number in ipairs(numbers) do 9 | if candidate % number == 0 then 10 | multiples[candidate] = true 11 | end 12 | end 13 | end 14 | 15 | for multiple in pairs(multiples) do 16 | sum = sum + multiple 17 | end 18 | 19 | return sum 20 | end 21 | } 22 | end 23 | -------------------------------------------------------------------------------- /exercises/practice/wordy/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'wordy', 3 | 4 | generate_test = function(case) 5 | if type(case.expected) == 'number' then 6 | local template = [[ 7 | assert.are.same(%s, wordy.answer('%s'))]] 8 | return template:format(case.expected, case.input.question) 9 | else 10 | local template = [[ 11 | assert.has_error(function() 12 | wordy.answer('%s') 13 | end, 'Invalid question')]] 14 | return template:format(case.input.question) 15 | end 16 | end 17 | } 18 | -------------------------------------------------------------------------------- /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/phone-number/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'phone_number', 3 | 4 | generate_test = function(case) 5 | if case.expected.error then 6 | local template = [[ 7 | assert.has_error(function() 8 | phone_number.clean('%s') 9 | end)]] 10 | 11 | return template:format(case.input.phrase) 12 | else 13 | local template = [[ 14 | assert.are.equal('%s', phone_number.clean('%s'))]] 15 | 16 | return template:format(case.expected, case.input.phrase) 17 | end 18 | end 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "secret-handshake.lua" 8 | ], 9 | "test": [ 10 | "secret-handshake_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/bowling/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "bowling.lua" 11 | ], 12 | "test": [ 13 | "bowling_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Score a bowling game.", 20 | "source": "The Bowling Game Kata from UncleBob", 21 | "source_url": "https://web.archive.org/web/20221001111000/http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "sieve.lua" 11 | ], 12 | "test": [ 13 | "sieve_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.", 20 | "source": "Sieve of Eratosthenes at Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" 22 | } 23 | -------------------------------------------------------------------------------- /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/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/rail-fence-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "rail-fence-cipher.lua" 11 | ], 12 | "test": [ 13 | "rail-fence-cipher_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Implement encoding and decoding for the rail fence cipher.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Transposition_cipher#Rail_Fence_cipher" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/series/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "series.lua" 11 | ], 12 | "test": [ 13 | "series_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Given a string of digits, output all the contiguous substrings of length `n` in that string.", 20 | "source": "A subset of the Problem 8 at Project Euler", 21 | "source_url": "https://projecteuler.net/problem=8" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "atbash-cipher.lua" 11 | ], 12 | "test": [ 13 | "atbash-cipher_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Create an implementation of the Atbash cipher, an ancient encryption system created in the Middle East.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Atbash" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "kytrinyx", 7 | "ryanplusplus" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "anagram.lua" 12 | ], 13 | "test": [ 14 | "anagram_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Given a word and a list of possible anagrams, select the correct sublist.", 21 | "source": "Inspired by the Extreme Startup game", 22 | "source_url": "https://github.com/rchatley/extreme_startup" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "eliuds-eggs.lua" 8 | ], 9 | "test": [ 10 | "eliuds-eggs_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/killer-sudoku-helper/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "killer-sudoku-helper.lua" 8 | ], 9 | "test": [ 10 | "killer-sudoku-helper_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Write a tool that makes it easier to solve Killer Sudokus", 17 | "source": "Created by Sascha Mann, Jeremy Walker, and BethanyG for the Julia track on Exercism.", 18 | "source_url": "https://github.com/exercism/julia/pull/413" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local triangle = {} 2 | 3 | function triangle.kind(a, b, c) 4 | local function violates_inequality() 5 | local sides = { a, b, c } 6 | table.sort(sides) 7 | return sides[1] + sides[2] <= sides[3] 8 | end 9 | 10 | if (a <= 0 or b <= 0 or c <= 0 or violates_inequality()) then 11 | error("Input Error") 12 | end 13 | if (a == b and a == c) then 14 | return "equilateral" 15 | end 16 | if (a == b or a == c or c == b) then 17 | return "isosceles" 18 | end 19 | return "scalene" 20 | end 21 | 22 | return triangle 23 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(n) 2 | assert(n > 0, 'n must be positive') 3 | 4 | local primes = {} 5 | 6 | local function is_prime(n) 7 | for _, p in ipairs(primes) do 8 | if n % p == 0 then 9 | return false 10 | end 11 | if p ^ 2 > n then 12 | return true 13 | end 14 | end 15 | return true 16 | end 17 | 18 | for i = 2, math.huge do 19 | if is_prime(i) then 20 | table.insert(primes, i) 21 | end 22 | if #primes == n then 23 | return primes[#primes] 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "pascals-triangle.lua" 11 | ], 12 | "test": [ 13 | "pascals-triangle_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Compute Pascal's triangle up to a given number of rows.", 20 | "source": "Pascal's Triangle at Wolfram Math World", 21 | "source_url": "https://www.wolframalpha.com/input/?i=Pascal%27s+triangle" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "roman-numerals.lua" 13 | ], 14 | "test": [ 15 | "roman-numerals_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 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/book-store/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "book-store.lua" 8 | ], 9 | "test": [ 10 | "book-store_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "To try and encourage more sales of different books from a popular 5 book series, a bookshop has decided to offer discounts of multiple-book purchases.", 17 | "source": "Inspired by the harry potter kata from Cyber-Dojo.", 18 | "source_url": "https://cyber-dojo.org" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "etl.lua" 11 | ], 12 | "test": [ 13 | "etl_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Change the data format for scoring a game to more easily add other languages.", 20 | "source": "Based on an 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/pythagorean-triplet/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "pythagorean-triplet.lua" 11 | ], 12 | "test": [ 13 | "pythagorean-triplet_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Given an integer N, find all Pythagorean triplets for which a + b + c = N.", 20 | "source": "A variation of Problem 9 from Project Euler", 21 | "source_url": "https://projecteuler.net/problem=9" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "leap.lua" 13 | ], 14 | "test": [ 15 | "leap_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Determine whether a given year is a leap year.", 22 | "source": "CodeRanch Cattle Drive, Assignment 3", 23 | "source_url": "https://web.archive.org/web/20240907033714/https://coderanch.com/t/718816/Leap" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/matrix/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(s) 2 | local rows = {} 3 | 4 | for line in s:gmatch('[%d ]+') do 5 | local row = {} 6 | for element in line:gmatch('%d+') do 7 | table.insert(row, tonumber(element)) 8 | end 9 | table.insert(rows, row) 10 | end 11 | 12 | return { 13 | row = function(which) 14 | return rows[which] 15 | end, 16 | 17 | column = function(which) 18 | local column = {} 19 | for _, row in ipairs(rows) do 20 | table.insert(column, row[which]) 21 | end 22 | return column 23 | end 24 | } 25 | end 26 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(size) 2 | local matrix = {} 3 | for i = 1, size do 4 | matrix[i] = {} 5 | for j = 1, size do 6 | matrix[i][j] = 0 7 | end 8 | end 9 | 10 | local x, y = 1, 1 11 | local dx, dy = 1, 0 12 | 13 | for i = 1, size * size do 14 | matrix[y][x] = i 15 | local at_edge = (x + dx > size) or (x + dx < 1) or (y + dy > size) or (y + dy < 1) 16 | if at_edge or (matrix[y + dy][x + dx] ~= 0) then 17 | dx, dy = -dy, dx 18 | end 19 | x = x + dx 20 | y = y + dy 21 | end 22 | 23 | return matrix 24 | end 25 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "kytrinyx", 7 | "ryanplusplus" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "beer-song.lua" 12 | ], 13 | "test": [ 14 | "beer-song_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.", 21 | "source": "Learn to Program by Chris Pine", 22 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=06" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/assertions.lua: -------------------------------------------------------------------------------- 1 | local assert = require('luassert.assert') 2 | local say = require('say') 3 | 4 | local function lteq(state, arguments) 5 | assert(#arguments == 2, 'expected two argument to assert.lteq') 6 | 7 | local a = arguments[1] 8 | local b = arguments[2] 9 | 10 | return a <= b 11 | end 12 | 13 | say:set("assertion.lteq.positive", "Expected\n%s\nto be less than or equal to\n%s") 14 | say:set("assertion.lteq.negative", "Expected\n%s\nto not be less than or equal to\n%s") 15 | assert:register("assertion", "lteq", lteq, 'assertion.lteq.positive', 'assertion.lteq.negative') 16 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/assertions.lua: -------------------------------------------------------------------------------- 1 | local assert = require('luassert.assert') 2 | local say = require('say') 3 | 4 | local function lteq(state, arguments) 5 | assert(#arguments == 2, 'expected two argument to assert.lteq') 6 | 7 | local a = arguments[1] 8 | local b = arguments[2] 9 | 10 | return a <= b 11 | end 12 | 13 | say:set("assertion.lteq.positive", "Expected\n%s\nto be less than or equal to\n%s") 14 | say:set("assertion.lteq.negative", "Expected\n%s\nto not be less than or equal to\n%s") 15 | assert:register("assertion", "lteq", lteq, 'assertion.lteq.positive', 'assertion.lteq.negative') 16 | -------------------------------------------------------------------------------- /exercises/practice/matrix/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "matrix.lua" 11 | ], 12 | "test": [ 13 | "matrix_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Given a string representing a matrix of numbers, return the rows and columns of that matrix.", 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/scrabble-score/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "scrabble-score.lua" 13 | ], 14 | "test": [ 15 | "scrabble-score_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Given a word, compute the Scrabble score for that word.", 22 | "source": "Inspired by the Extreme Startup game", 23 | "source_url": "https://github.com/rchatley/extreme_startup" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local function square_of_sum(n) 2 | local sum = 0 3 | for i = 1, n do 4 | sum = sum + i 5 | end 6 | return sum ^ 2 7 | end 8 | 9 | local function sum_of_squares(n) 10 | local sum_of_squares = 0 11 | for i = 1, n do 12 | sum_of_squares = sum_of_squares + i ^ 2 13 | end 14 | return sum_of_squares 15 | end 16 | 17 | local function difference_of_squares(n) 18 | return square_of_sum(n) - sum_of_squares(n) 19 | end 20 | 21 | return { square_of_sum = square_of_sum, sum_of_squares = sum_of_squares, difference_of_squares = difference_of_squares } 22 | -------------------------------------------------------------------------------- /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/food-chain/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "food-chain.lua" 13 | ], 14 | "test": [ 15 | "food-chain_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'.", 22 | "source": "Wikipedia", 23 | "source_url": "https://en.wikipedia.org/wiki/There_Was_an_Old_Lady_Who_Swallowed_a_Fly" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/state-of-tic-tac-toe/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "state-of-tic-tac-toe.lua" 8 | ], 9 | "test": [ 10 | "state-of-tic-tac-toe_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 14 | ] 15 | }, 16 | "blurb": "Determine the game state of a match of Tic-Tac-Toe.", 17 | "source": "Created by Sascha Mann for the Julia track of the Exercism Research Experiment.", 18 | "source_url": "https://github.com/exercism/research_experiment_1/tree/julia-dev/exercises/julia-1-a" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "queen-attack.lua" 8 | ], 9 | "test": [ 10 | "queen-attack_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/sum-of-multiples/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "sum-of-multiples.lua" 11 | ], 12 | "test": [ 13 | "sum-of-multiples_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Given a number, find the sum of all the multiples of particular numbers up to but not including that number.", 20 | "source": "A variation on Problem 1 at Project Euler", 21 | "source_url": "https://projecteuler.net/problem=1" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/change/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "change.lua" 11 | ], 12 | "test": [ 13 | "change_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Correctly determine change to be given using the least number of coins.", 20 | "source": "Software Craftsmanship - Coin Change Kata", 21 | "source_url": "https://web.archive.org/web/20130115115225/http://craftsmanship.sv.cmu.edu:80/exercises/coin-change-kata" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "crypto-square.lua" 11 | ], 12 | "test": [ 13 | "crypto-square_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 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/hamming/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | return { 2 | module_name = 'hamming', 3 | 4 | generate_test = function(case) 5 | if type(case.expected) == 'number' then 6 | local template = [[ 7 | assert.are.equal(%s, hamming.compute("%s", "%s"))]] 8 | return template:format(case.expected, case.input.strand1, case.input.strand2) 9 | else 10 | local template = [[ 11 | assert.has_error(function() 12 | hamming.compute("%s", "%s") 13 | end, "%s")]] 14 | return template:format(case.input.strand1, case.input.strand2, case.expected.error) 15 | end 16 | end 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "isbn-verifier.lua" 8 | ], 9 | "test": [ 10 | "isbn-verifier_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/ocr-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti", 7 | "fyrchik" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "ocr-numbers.lua" 12 | ], 13 | "test": [ 14 | "ocr-numbers_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Given a 3 x 4 grid of pipes, underscores, and spaces, determine which number is represented, or whether it is garbled.", 21 | "source": "Inspired by the Bank OCR kata", 22 | "source_url": "https://codingdojo.org/kata/BankOCR/" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "pig-latin.lua" 11 | ], 12 | "test": [ 13 | "pig-latin_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Implement a program that translates from English to Pig Latin.", 20 | "source": "The Pig Latin exercise at Test First Teaching by Ultrasaurus", 21 | "source_url": "https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/" 22 | } 23 | -------------------------------------------------------------------------------- /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/triangle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "triangle.lua" 13 | ], 14 | "test": [ 15 | "triangle_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Determine if a triangle is equilateral, isosceles, or scalene.", 22 | "source": "The Ruby Koans triangle project, parts 1 & 2", 23 | "source_url": "https://web.archive.org/web/20220831105330/http://rubykoans.com" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return function(array, target) 2 | local function aux(start_index, end_index) 3 | if start_index >= end_index then 4 | return array[start_index] == target and start_index or -1 5 | end 6 | 7 | local search_index = math.floor((end_index + start_index) / 2) 8 | 9 | if array[search_index] == target then 10 | return search_index 11 | elseif array[search_index] > target then 12 | return aux(start_index, search_index - 1) 13 | else 14 | return aux(search_index + 1, end_index) 15 | end 16 | end 17 | 18 | return aux(1, #array) 19 | end 20 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "kytrinyx", 7 | "ryanplusplus" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "phone-number.lua" 12 | ], 13 | "test": [ 14 | "phone-number_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 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/word-count/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "elyashiv", 7 | "etandel", 8 | "kytrinyx", 9 | "ryanplusplus", 10 | "trayo" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "word-count.lua" 15 | ], 16 | "test": [ 17 | "word-count_spec.lua" 18 | ], 19 | "example": [ 20 | ".meta/example.lua" 21 | ] 22 | }, 23 | "blurb": "Given a phrase, count the occurrences of each word in that phrase.", 24 | "source": "This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour." 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "robphoenix", 9 | "ryanplusplus", 10 | "trayo" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "hamming.lua" 15 | ], 16 | "test": [ 17 | "hamming_spec.lua" 18 | ], 19 | "example": [ 20 | ".meta/example.lua" 21 | ] 22 | }, 23 | "blurb": "Calculate the Hamming distance between two DNA strands.", 24 | "source": "The Calculating Point Mutations problem at Rosalind", 25 | "source_url": "https://rosalind.info/problems/hamm/" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your best friend Marta recently landed their dream job working with a local history museum's collections. 4 | Knowing of your interests in programming, they confide in you about an issue at work for an upcoming exhibit on computing history. 5 | A local university's math department had donated several boxes of historical printouts, but given the poor condition of the documents, the decision has been made to digitize the text. 6 | However, the university's old printer had some quirks in how text was represented, and your friend could use your help to extract the data successfully. 7 | -------------------------------------------------------------------------------- /exercises/practice/rational-numbers/rational-numbers.lua: -------------------------------------------------------------------------------- 1 | local function reduce(a) 2 | end 3 | 4 | local function add(a, b) 5 | end 6 | 7 | local function subtract(a, b) 8 | end 9 | 10 | local function multiply(a, b) 11 | end 12 | 13 | local function divide(a, b) 14 | end 15 | 16 | local function abs(a) 17 | end 18 | 19 | local function exp_rational(a, p) 20 | end 21 | 22 | local function exp_real(p, a) 23 | end 24 | 25 | return { 26 | add = add, 27 | subtract = subtract, 28 | multiply = multiply, 29 | divide = divide, 30 | abs = abs, 31 | exp_rational = exp_rational, 32 | exp_real = exp_real, 33 | reduce = reduce 34 | } 35 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You plan to build a tree house in the woods near your house so that you can watch the sun rise and set. 4 | 5 | You've obtained data from a local survey company that show the height of every tree in each rectangular section of the map. 6 | You need to analyze each grid on the map to find good trees for your tree house. 7 | 8 | A good tree is both: 9 | 10 | - taller than every tree to the east and west, so that you have the best possible view of the sunrises and sunsets. 11 | - shorter than every tree to the north and south, to minimize the amount of tree climbing. 12 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local opening_bracket = { ['('] = true, ['['] = true, ['{'] = true } 2 | 3 | local closing_bracket = { [')'] = '(', [']'] = '[', ['}'] = '{' } 4 | 5 | return { 6 | valid = function(s) 7 | local history = {} 8 | 9 | for c in s:gmatch('.') do 10 | if opening_bracket[c] then 11 | table.insert(history, c) 12 | elseif closing_bracket[c] then 13 | if history[#history] ~= closing_bracket[c] then 14 | return false 15 | end 16 | table.remove(history, #history) 17 | end 18 | end 19 | 20 | return #history == 0 21 | end 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "petertseng", 9 | "ryanplusplus" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "circular-buffer.lua" 14 | ], 15 | "test": [ 16 | "circular-buffer_spec.lua" 17 | ], 18 | "example": [ 19 | ".meta/example.lua" 20 | ] 21 | }, 22 | "blurb": "A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.", 23 | "source": "Wikipedia", 24 | "source_url": "https://en.wikipedia.org/wiki/Circular_buffer" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [78a7a9f9-4490-4a47-8ee9-5a38bb47d28f] 6 | description = "single letter" 7 | 8 | [60dbd000-451d-44c7-bdbb-97c73ac1f497] 9 | description = "single score with multiple letters" 10 | 11 | [f5c5de0c-301f-4fdd-a0e5-df97d4214f54] 12 | description = "multiple scores with multiple letters" 13 | 14 | [5db8ea89-ecb4-4dcd-902f-2b418cc87b9d] 15 | description = "multiple scores with differing numbers of letters" 16 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "gigasecond.lua" 13 | ], 14 | "test": [ 15 | "gigasecond_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.", 22 | "source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.", 23 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=09" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "trayo" 4 | ], 5 | "contributors": [ 6 | "aarti", 7 | "robphoenix", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "hello-world.lua" 13 | ], 14 | "test": [ 15 | "hello-world_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", 22 | "source": "This is an exercise to introduce users to using Exercism", 23 | "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "kytrinyx", 7 | "ryanplusplus", 8 | "sjakobi" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "nucleotide-count.lua" 13 | ], 14 | "test": [ 15 | "nucleotide-count_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Given a DNA string, compute how many times each nucleotide occurs in the string.", 22 | "source": "The Calculating DNA Nucleotides_problem at Rosalind", 23 | "source_url": "https://rosalind.info/problems/dna/" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.meta/example.lua: -------------------------------------------------------------------------------- 1 | return { 2 | encode = function(s) 3 | local result = '' 4 | local i = 1 5 | while i <= #s do 6 | local c = s:sub(i, i) 7 | local _, _, run = s:find('(' .. c .. '+)', i) 8 | result = result .. ((#run > 1) and #run or '') .. c 9 | i = i + #run 10 | end 11 | return result 12 | end, 13 | 14 | decode = function(s) 15 | local result = '' 16 | for length, c in s:gmatch('(%d*)(.)') do 17 | if length == '' then 18 | length = 1 19 | end 20 | result = result .. c:rep(length) 21 | end 22 | return result 23 | end 24 | } 25 | -------------------------------------------------------------------------------- /exercises/concept/pacman-rules/.meta/exemplar.lua: -------------------------------------------------------------------------------- 1 | local rules = {} 2 | 3 | function rules.eat_ghost(power_pellet_active, touching_ghost) 4 | return power_pellet_active and touching_ghost 5 | end 6 | 7 | function rules.score(touching_power_pellet, touching_dot) 8 | return touching_power_pellet or touching_dot 9 | end 10 | 11 | function rules.lose(power_pellet_active, touching_ghost) 12 | return not power_pellet_active and touching_ghost 13 | end 14 | 15 | function rules.win(has_eaten_all_dots, power_pellet_active, touching_ghost) 16 | return has_eaten_all_dots and not rules.lose(power_pellet_active, touching_ghost) 17 | end 18 | 19 | return rules 20 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti", 7 | "Scientifica96" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "difference-of-squares.lua" 12 | ], 13 | "test": [ 14 | "difference-of-squares_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Find the difference between the square of the sum and the sum of the squares of the first N natural numbers.", 21 | "source": "Problem 6 at Project Euler", 22 | "source_url": "https://projecteuler.net/problem=6" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local allergens = { 'eggs', 'peanuts', 'shellfish', 'strawberries', 'tomatoes', 'chocolate', 'pollen', 'cats' } 2 | 3 | local function list(score) 4 | local results = {} 5 | for i, allergen in ipairs(allergens) do 6 | if score & 1 << (i - 1) > 0 then 7 | table.insert(results, allergen) 8 | end 9 | end 10 | return results 11 | end 12 | 13 | local function allergic_to(score, which) 14 | for _, allergen in ipairs(list(score)) do 15 | if allergen == which then 16 | return true 17 | end 18 | end 19 | return false 20 | end 21 | 22 | return { list = list, allergic_to = allergic_to } 23 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "kindergarten-garden.lua" 11 | ], 12 | "test": [ 13 | "kindergarten-garden_spec.lua" 14 | ], 15 | "example": [ 16 | ".meta/example.lua" 17 | ] 18 | }, 19 | "blurb": "Given a diagram, determine which plants each child in the kindergarten class is responsible for.", 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/nth-prime/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [75c65189-8aef-471a-81de-0a90c728160c] 6 | description = "first prime" 7 | 8 | [2c38804c-295f-4701-b728-56dea34fd1a0] 9 | description = "second prime" 10 | 11 | [56692534-781e-4e8c-b1f9-3e82c1640259] 12 | description = "sixth prime" 13 | 14 | [fce1e979-0edb-412d-93aa-2c744e8f50ff] 15 | description = "big prime" 16 | 17 | [bd0a9eae-6df7-485b-a144-80e13c7d55b2] 18 | description = "there is no zeroth prime" 19 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "rna-transcription.lua" 13 | ], 14 | "test": [ 15 | "rna-transcription_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Given a DNA strand, return its RNA complement.", 22 | "source": "Hyperphysics", 23 | "source_url": "https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html" 24 | } 25 | -------------------------------------------------------------------------------- /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/spiral-matrix/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "spiral-matrix.lua" 8 | ], 9 | "test": [ 10 | "spiral-matrix_spec.lua" 11 | ], 12 | "example": [ 13 | ".meta/example.lua" 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/word-search/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | In word search puzzles you get a square of letters and have to find specific words in them. 4 | 5 | For example: 6 | 7 | ```text 8 | jefblpepre 9 | camdcimgtc 10 | oivokprjsm 11 | pbwasqroua 12 | rixilelhrs 13 | wolcqlirpc 14 | screeaumgr 15 | alxhpburyi 16 | jalaycalmp 17 | clojurermt 18 | ``` 19 | 20 | There are several programming languages hidden in the above square. 21 | 22 | Words can be hidden in all kinds of directions: left-to-right, right-to-left, vertical and diagonal. 23 | 24 | Given a puzzle and a list of words return the location of the first and last letter of each word. 25 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | pull_request: 9 | 10 | jobs: 11 | test: 12 | runs-on: ubuntu-24.04 13 | 14 | steps: 15 | - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 16 | 17 | - uses: leafo/gh-actions-lua@8c9e175e7a3d77e21f809eefbee34a19b858641b 18 | with: 19 | luaVersion: 5.4 20 | 21 | - uses: leafo/gh-actions-luarocks@97053c556d6ce2c8e26eb7ac93743437c7af7248 22 | 23 | - name: build 24 | run: | 25 | luarocks install busted 26 | 27 | - name: test 28 | run: | 29 | bin/test-all 30 | -------------------------------------------------------------------------------- /exercises/practice/binary/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "binary.lua" 13 | ], 14 | "test": [ 15 | "binary_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles.", 22 | "source": "All of Computer Science", 23 | "source_url": "https://www.wolframalpha.com/examples/mathematics/numbers/base-conversions" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti", 7 | "petertseng" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "largest-series-product.lua" 12 | ], 13 | "test": [ 14 | "largest-series-product_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.", 21 | "source": "A variation on Problem 8 at Project Euler", 22 | "source_url": "https://projecteuler.net/problem=8" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/list-ops.lua: -------------------------------------------------------------------------------- 1 | local function append(xs, ys) 2 | 3 | end 4 | 5 | local function concat(...) 6 | 7 | end 8 | 9 | local function length(xs) 10 | 11 | end 12 | 13 | local function reverse(xs) 14 | 15 | end 16 | 17 | local function foldl(xs, value, f) 18 | 19 | end 20 | 21 | local function foldr(xs, value, f) 22 | 23 | end 24 | 25 | local function map(xs, f) 26 | 27 | end 28 | 29 | local function filter(xs, pred) 30 | 31 | end 32 | 33 | return { 34 | append = append, 35 | concat = concat, 36 | length = length, 37 | reverse = reverse, 38 | map = map, 39 | foldl = foldl, 40 | foldr = foldr, 41 | filter = filter 42 | } 43 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "etandel", 7 | "kytrinyx", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "prime-factors.lua" 13 | ], 14 | "test": [ 15 | "prime-factors_spec.lua" 16 | ], 17 | "example": [ 18 | ".meta/example.lua" 19 | ] 20 | }, 21 | "blurb": "Compute the prime factors of a given natural number.", 22 | "source": "The Prime Factors Kata by Uncle Bob", 23 | "source_url": "https://web.archive.org/web/20221026171801/http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/.meta/example.lua: -------------------------------------------------------------------------------- 1 | local value = { 2 | black = 0, 3 | brown = 1, 4 | red = 2, 5 | orange = 3, 6 | yellow = 4, 7 | green = 5, 8 | blue = 6, 9 | violet = 7, 10 | grey = 8, 11 | white = 9 12 | } 13 | 14 | return { 15 | decode = function(c1, c2, c3) 16 | local value = (value[c1] * 10 + value[c2]) * 10 ^ value[c3] 17 | 18 | if value >= 1e9 then 19 | return value / 1e9, 'gigaohms' 20 | elseif value >= 1e6 then 21 | return value / 1e6, 'megaohms' 22 | elseif value >= 1e3 then 23 | return value / 1e3, 'kiloohms' 24 | else 25 | return value, 'ohms' 26 | end 27 | end 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti", 7 | "imolein" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "allergies.lua" 12 | ], 13 | "test": [ 14 | "allergies_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.", 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/bob/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "aarti" 4 | ], 5 | "contributors": [ 6 | "austinlyons", 7 | "kytrinyx", 8 | "ryanplusplus", 9 | "vstanifo" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "bob.lua" 14 | ], 15 | "test": [ 16 | "bob_spec.lua" 17 | ], 18 | "example": [ 19 | ".meta/example.lua" 20 | ] 21 | }, 22 | "blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.", 23 | "source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.", 24 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=06" 25 | } 26 | -------------------------------------------------------------------------------- /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/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/rectangles/.meta/spec_generator.lua: -------------------------------------------------------------------------------- 1 | local map = function(t, f) 2 | local mapped = {} 3 | for i, v in ipairs(t) do 4 | mapped[i] = f(v) 5 | end 6 | return mapped 7 | end 8 | 9 | local function render_strings(strings) 10 | return table.concat(map(strings, function(row) 11 | return "'" .. row .. "', --" 12 | end), ',\n ') 13 | end 14 | 15 | return { 16 | module_name = 'rectangles', 17 | 18 | generate_test = function(case) 19 | local template = [[ 20 | assert.equal(%s, rectangles.count({ 21 | %s 22 | }))]] 23 | 24 | return template:format(case.expected, render_strings(case.input.strings)) 25 | end 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/transpose/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "aarti", 7 | "fyrchik" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "transpose.lua" 12 | ], 13 | "test": [ 14 | "transpose_spec.lua" 15 | ], 16 | "example": [ 17 | ".meta/example.lua" 18 | ] 19 | }, 20 | "blurb": "Take input text and output it transposed.", 21 | "source": "Reddit r/dailyprogrammer challenge #270 [Easy].", 22 | "source_url": "https://web.archive.org/web/20230630051421/https://old.reddit.com/r/dailyprogrammer/comments/4msu2x/challenge_270_easy_transpose_the_input_text/" 23 | } 24 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------