├── exercises ├── practice │ ├── isogram │ │ ├── .meta │ │ │ ├── version │ │ │ ├── example.rkt │ │ │ └── config.json │ │ ├── isogram.rkt │ │ └── .docs │ │ │ └── instructions.md │ ├── affine-cipher │ │ ├── .meta │ │ │ ├── version │ │ │ └── config.json │ │ └── affine-cipher.rkt │ ├── reverse-string │ │ ├── .meta │ │ │ ├── version │ │ │ ├── example.rkt │ │ │ └── config.json │ │ ├── reverse-string.rkt │ │ └── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ ├── anagram │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ ├── anagram.rkt │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── robot-name │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── robot-name.rkt │ │ └── .meta │ │ │ └── config.json │ ├── hello-world │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ ├── tests.toml │ │ │ └── config.json │ │ ├── hello-world.rkt │ │ ├── hello-world-test.rkt │ │ └── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ ├── leap │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── leap.rkt │ │ ├── .approaches │ │ │ ├── boolean-chain │ │ │ │ └── snippet.txt │ │ │ ├── cond-form │ │ │ │ └── snippet.txt │ │ │ ├── pattern-matching │ │ │ │ └── snippet.txt │ │ │ └── config.json │ │ └── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ ├── etl │ │ ├── etl.rkt │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rkt │ │ │ └── tests.toml │ │ └── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ ├── say │ │ ├── say.rkt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── darts │ │ ├── darts.rkt │ │ └── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ ├── luhn │ │ ├── luhn.rkt │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ │ └── .docs │ │ │ └── introduction.md │ ├── sieve │ │ ├── sieve.rkt │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ ├── config.json │ │ │ ├── example.rkt │ │ │ └── tests.toml │ ├── diamond │ │ ├── diamond.rkt │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── grep │ │ ├── grep.rkt │ │ ├── midsummer-night.txt │ │ ├── paradise-lost.txt │ │ ├── iliad.txt │ │ └── .meta │ │ │ └── config.json │ ├── proverb │ │ ├── proverb.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ ├── config.json │ │ │ └── tests.toml │ │ └── .docs │ │ │ └── instructions.md │ ├── two-fer │ │ ├── two-fer.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ └── two-fer-test.rkt │ ├── yacht │ │ ├── yacht.rkt │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── acronym │ │ ├── acronym.rkt │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ │ └── .docs │ │ │ └── instructions.md │ ├── alphametics │ │ ├── alphametics.rkt │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── bob │ │ ├── bob.rkt │ │ ├── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── bowling │ │ ├── bowling.rkt │ │ └── .meta │ │ │ └── config.json │ ├── house │ │ ├── house.rkt │ │ └── .meta │ │ │ └── config.json │ ├── pangram │ │ ├── pangram.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ │ └── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ ├── pig-latin │ │ ├── pig-latin.rkt │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── raindrops │ │ ├── raindrops.rkt │ │ ├── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── scrabble-score │ │ ├── scrabble-score.rkt │ │ ├── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── flower-field │ │ ├── flower-field.rkt │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ ├── nth-prime │ │ ├── nth-prime.rkt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rkt │ │ │ └── tests.toml │ │ └── nth-prime-test.rkt │ ├── pascals-triangle │ │ ├── pascals-triangle.rkt │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── food-chain │ │ ├── food-chain.rkt │ │ └── .meta │ │ │ └── config.json │ ├── minesweeper │ │ ├── minesweeper.rkt │ │ ├── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ └── .meta │ │ │ └── config.json │ ├── phone-number │ │ ├── phone-number.rkt │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── rna-transcription │ │ ├── rna-transcription.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ │ └── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ ├── roman-numerals │ │ ├── roman-numerals.rkt │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ │ └── .docs │ │ │ └── instructions.md │ ├── sublist │ │ ├── sublist.rkt │ │ └── .meta │ │ │ └── config.json │ ├── triangle │ │ ├── triangle.rkt │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── word-count │ │ ├── word-count.rkt │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ ├── atbash-cipher │ │ ├── .docs │ │ │ └── instructions.append.md │ │ ├── atbash-cipher.rkt │ │ └── .meta │ │ │ └── config.json │ ├── collatz-conjecture │ │ ├── collatz-conjecture.rkt │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ ├── eliuds-eggs │ │ ├── eliuds-eggs.rkt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ ├── config.json │ │ │ └── tests.toml │ │ └── eliuds-eggs-test.rkt │ ├── matching-brackets │ │ ├── matching-brackets.rkt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── perfect-numbers │ │ ├── perfect-numbers.rkt │ │ ├── .docs │ │ │ └── instructions.append.md │ │ └── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ ├── rotational-cipher │ │ ├── rotational-cipher.rkt │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── secret-handshake │ │ ├── secret-handshake.rkt │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ ├── square-root │ │ ├── square-root.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ └── square-root-test.rkt │ ├── twelve-days │ │ ├── twelve-days.rkt │ │ └── .meta │ │ │ └── config.json │ ├── accumulate │ │ ├── accumulate.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ ├── config.json │ │ │ └── tests.toml │ │ └── .docs │ │ │ └── instructions.md │ ├── grade-school │ │ ├── grade-school.rkt │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── line-up │ │ ├── line-up.rkt │ │ ├── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── protein-translation │ │ ├── protein-translation.rkt │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── robot-simulator │ │ ├── robot-simulator.rkt │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── spiral-matrix │ │ ├── spiral-matrix.rkt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ └── .meta │ │ │ ├── config.json │ │ │ ├── example.rkt │ │ │ └── tests.toml │ ├── all-your-base │ │ ├── all-your-base.rkt │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ ├── gigasecond │ │ ├── gigasecond.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── kindergarten-garden │ │ ├── kindergarten-garden.rkt │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── meetup │ │ ├── meetup.rkt │ │ └── .meta │ │ │ └── config.json │ ├── resistor-color-duo │ │ ├── resistor-color-duo.rkt │ │ └── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ ├── resistor-color-trio │ │ ├── resistor-color-trio.rkt │ │ └── .meta │ │ │ └── config.json │ ├── binary-search │ │ ├── binary-search.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ │ └── .docs │ │ │ ├── instructions.append.md │ │ │ └── introduction.md │ ├── hamming │ │ ├── hamming.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ │ └── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ ├── high-scores │ │ ├── high-scores.rkt │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── two-bucket │ │ ├── two-bucket.rkt │ │ └── .meta │ │ │ └── config.json │ ├── bank-account │ │ ├── bank-account.rkt │ │ ├── .meta │ │ │ └── config.json │ │ └── .docs │ │ │ └── instructions.md │ ├── armstrong-numbers │ │ ├── armstrong-numbers.rkt │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ │ └── .docs │ │ │ └── instructions.md │ ├── grains │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ │ ├── grains.rkt │ │ ├── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ └── grains-test.rkt │ ├── nucleotide-count │ │ ├── nucleotide-count.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ ├── config.json │ │ │ └── tests.toml │ │ └── nucleotide-count-test.rkt │ ├── pythagorean-triplets │ │ ├── pythagorean-triplets.rkt │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── circular-buffer │ │ ├── circular-buffer.rkt │ │ └── .meta │ │ │ └── config.json │ ├── largest-series-product │ │ ├── largest-series-product.rkt │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── parallel-letter-frequency │ │ ├── parallel-letter-frequency.rkt │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── knapsack │ │ ├── knapsack.rkt │ │ ├── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── strain │ │ ├── strain.rkt │ │ └── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ ├── resistor-color │ │ ├── resistor-color.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ ├── config.json │ │ │ └── tests.toml │ │ └── resistor-color-test.rkt │ ├── clock │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── clock.rkt │ │ └── .meta │ │ │ └── config.json │ ├── run-length-encoding │ │ ├── run-length-encoding.rkt │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ │ └── .docs │ │ │ └── instructions.md │ ├── zebra-puzzle │ │ ├── zebra-puzzle.rkt │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── tests.toml │ │ ├── zebra-puzzle-test.rkt │ │ └── .docs │ │ │ └── introduction.md │ ├── allergies │ │ ├── allergies.rkt │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── queen-attack │ │ ├── queen-attack.rkt │ │ └── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ ├── difference-of-squares │ │ ├── difference-of-squares.rkt │ │ ├── .meta │ │ │ ├── example.rkt │ │ │ └── config.json │ │ ├── .docs │ │ │ └── instructions.md │ │ └── difference-of-squares-test.rkt │ ├── variable-length-quantity │ │ ├── variable-length-quantity.rkt │ │ └── .meta │ │ │ └── config.json │ ├── dnd-character │ │ ├── dnd-character.rkt │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rkt │ │ └── .docs │ │ │ └── introduction.md │ ├── list-ops │ │ ├── .meta │ │ │ └── config.json │ │ └── list-ops.rkt │ └── space-age │ │ ├── .meta │ │ ├── config.json │ │ └── example.rkt │ │ └── space-age.rkt └── shared │ └── .docs │ ├── tests.md │ └── help.md ├── docs ├── SNIPPET.txt ├── RESOURCES.md ├── TESTS.md └── LEARNING.md ├── .github ├── CODEOWNERS ├── dependabot.yml └── workflows │ ├── run-configlet-sync.yml │ ├── configlet.yml │ ├── sync-labels.yml │ ├── ping-cross-track-maintainers-team.yml │ └── no-important-files-changed.yml ├── reference └── implementing-a-concept-exercise.md ├── .gitignore ├── bin └── check-exercises.sh └── .appends └── .github └── labels.yml /exercises/practice/isogram/.meta/version: -------------------------------------------------------------------------------- 1 | 1.7.0 2 | -------------------------------------------------------------------------------- /exercises/practice/affine-cipher/.meta/version: -------------------------------------------------------------------------------- 1 | 2.0.0 2 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/version: -------------------------------------------------------------------------------- 1 | 1.1.0 2 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions Append 2 | 3 | The anagrams can be returned in any order. 4 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | For this problem, you will need to write the test. 4 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide hello) 4 | 5 | (define (hello) 6 | "Hello, World!") 7 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/hello-world.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide hello) 4 | 5 | (define (hello) 6 | "Goodbye, Mars!") 7 | -------------------------------------------------------------------------------- /exercises/practice/leap/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine whether a given year is a leap year. 4 | -------------------------------------------------------------------------------- /docs/SNIPPET.txt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide hello) 4 | 5 | (define (hello [name "World"]) 6 | (string-append "Hello, " name "!")) 7 | -------------------------------------------------------------------------------- /exercises/practice/etl/etl.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide etl) 4 | 5 | (define (etl input) 6 | (error "Please implement 'etl'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/say/say.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide say) 4 | 5 | (define (say number) 6 | (error "Please implement 'say'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/darts/darts.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide score) 4 | 5 | (define (score x y) 6 | (error "Please implement 'score'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/luhn/luhn.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide valid?) 4 | 5 | (define (valid? digits) 6 | (error "Please implement 'valid?'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/sieve/sieve.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide primes) 4 | 5 | (define (primes limit) 6 | (error "Please implement 'primes'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/diamond/diamond.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide rows) 4 | 5 | (define (rows high-char) 6 | (error "Please implement 'rows'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/grep/grep.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide grep) 4 | 5 | (define (grep flags pattern files) 6 | (error "Please implement 'grep'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/isogram/isogram.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide isogram?) 4 | 5 | (define (isogram? s) 6 | (error "Please implement 'isogram?'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/proverb/proverb.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide recite) 4 | 5 | (define (recite lst) 6 | (error "Please implement 'recite'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/two-fer.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide two-fer) 4 | 5 | (define (two-fer name) 6 | (error "Please implement 'two-fer'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/yacht/yacht.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide yacht) 4 | 5 | (define (yacht dice category) 6 | (error "Please implement 'yacht'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/acronym/acronym.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide acronym) 4 | 5 | (define (acronym string) 6 | (error "Please implement 'acronym'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/alphametics.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide solve) 4 | 5 | (define (solve puzzle) 6 | (error "Please implement 'solve'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/leap/leap.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide leap-year?) 4 | 5 | (define (leap-year? year) 6 | (error "Please implement 'leap-year?'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/bob/bob.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide response-for) 4 | 5 | (define (response-for prompt) 6 | (error "Please implement 'response-for'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/bowling/bowling.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide game%) 4 | 5 | (define game% 6 | (class object% 7 | (error "Please implement 'game'"))) 8 | -------------------------------------------------------------------------------- /exercises/practice/house/house.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide house) 4 | 5 | (define (house [start 1] [end 12]) 6 | (error "Please implement 'house'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/pangram/pangram.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide pangram?) 4 | 5 | (define (pangram? sentence) 6 | (error "Please implement 'pangram?'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/pig-latin.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide translate) 4 | 5 | (define (translate text) 6 | (error "Please implement 'translate'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/raindrops.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide convert) 4 | 5 | (define (convert number) 6 | (error "Please implement 'convert'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/scrabble-score.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide score) 4 | 5 | (define (score word) 6 | (error "Please implement 'score'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/flower-field/flower-field.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide annotate) 4 | 5 | (define (annotate garden) 6 | (error "Please implement 'annotate'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/nth-prime.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide nth-prime) 4 | 5 | (define (nth-prime number) 6 | (error "Please implement 'nth-prime'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/pascals-triangle.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide rows) 4 | 5 | (define (rows height) 6 | (error "Please implement 'rows'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/food-chain.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide recite) 4 | 5 | (define (recite start-verse end-verse) 6 | (error "Please implement 'recite'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/minesweeper.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide annotate) 4 | 5 | (define (annotate minefield) 6 | (error "Please implement 'annotate'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/phone-number.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide nanp-clean) 4 | 5 | (define (nanp-clean s) 6 | (error "Please implement 'nanp-clean'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/reverse-string.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide my-reverse) 4 | 5 | (define (my-reverse s) 6 | (error "Please implement 'my-reverse'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/rna-transcription.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide to-rna) 4 | 5 | (define (to-rna dna) 6 | (error "Please implement 'to-rna'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/roman-numerals.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide to-roman) 4 | 5 | (define (to-roman number) 6 | (error "Please implement 'to-roman'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/sublist/sublist.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide sublist?) 4 | 5 | (define (sublist? list-one list-two) 6 | (error "Please implement 'sublist?'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/triangle/triangle.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide triangle?) 4 | 5 | (define (triangle? sides kind) 6 | (error "Please implement 'triangle?'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/word-count/word-count.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide word-count) 4 | 5 | (define (word-count string) 6 | (error "Please implement 'word-count'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Note 2 | 3 | The tests for this problem assume that numbers are passed through without being encrypted/decrypted. 4 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/collatz-conjecture.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide collatz) 4 | 5 | (define (collatz num) 6 | (error "Please implement 'collatz'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/eliuds-eggs.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide number->eggs) 4 | 5 | (define (number->eggs n) 6 | (error "Please implement 'number->eggs'")) 7 | 8 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/matching-brackets.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide balanced?) 4 | 5 | (define (balanced? str) 6 | (error "Please implement 'balanced?'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/perfect-numbers.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide classify) 4 | 5 | (define (classify number) 6 | (error "Please implement 'classify'")) 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/rotational-cipher/rotational-cipher.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide rotate) 4 | 5 | (define (rotate text key) 6 | (error "Please implement 'rotate'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/secret-handshake.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide commands) 4 | 5 | (define (commands code) 6 | (error "Please implement 'commands'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/square-root/square-root.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide square-root) 4 | 5 | (define (square-root radicand) 6 | (error "Please implement 'square-root'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/twelve-days/twelve-days.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide twelve-days) 4 | 5 | (define (twelve-days start end) 6 | (error "Please implement 'twelve-days'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide two-fer) 4 | 5 | (define (two-fer [name "you"]) 6 | (string-append "One for " name ", one for me.")) 7 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/accumulate.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide accumulate) 4 | 5 | (define (accumulate sequence operation) 6 | (error "Please implement 'accumulate'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/anagram/anagram.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide anagrams-for) 4 | 5 | (define (anagrams-for subject candidates) 6 | (error "Please implement 'anagrams-for'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/grade-school.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide school%) 4 | 5 | (define school% 6 | (class object% 7 | (error "Please implement 'school'"))) 8 | -------------------------------------------------------------------------------- /exercises/practice/line-up/line-up.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide format-message) 4 | 5 | (define (format-message name number) 6 | (error "Please implement 'format-message'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/protein-translation.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide proteins) 4 | 5 | (define (proteins strand) 6 | (error "Please implement 'proteins'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/robot-simulator.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide robot%) 4 | 5 | (define robot% 6 | (class object% 7 | (error "Please implement 'robot'"))) 8 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/spiral-matrix.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide spiral-matrix) 4 | 5 | (define (spiral-matrix n) 6 | (error "Please implement 'spiral-matrix'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/all-your-base.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide rebase) 4 | 5 | (define (rebase list-digits in-base out-base) 6 | (error "Please implement rebase")) 7 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/gigasecond.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide add-gigasecond) 4 | 5 | (define (add-gigasecond datetime) 6 | (error "Please implement 'add-gigasecond'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/kindergarten-garden.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide plants) 4 | 5 | (define (plants diagram student) 6 | (error "Please implement 'plants'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/meetup/meetup.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide meetup-day) 4 | 5 | (define (meetup-day year month weekday week-of-month) 6 | (error "Please implement 'meetup-day'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/resistor-color-duo.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide color-code) 4 | 5 | (define (color-code color) 6 | (error "Please implement 'color-code'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/resistor-color-trio.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide color-code) 4 | 5 | (define (color-code colors) 6 | (error "Please implement 'color-code'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/binary-search.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide binary-search) 4 | 5 | (define (binary-search array value) 6 | (error "Please implement 'binary-search'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/hamming/hamming.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide hamming-distance) 4 | 5 | (define (hamming-distance source target) 6 | (error "Please implement 'hamming-distance'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/high-scores.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide high-scores%) 4 | 5 | (define high-scores% 6 | (class object% 7 | (error "Please implement 'high-scores'"))) 8 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/two-bucket.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide measure) 4 | 5 | (define (measure bucketOne bucketTwo goal startBucket) 6 | (error "Please implement 'measure'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/bank-account.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide bank-account%) 4 | 5 | (define bank-account% 6 | (class object% 7 | (error "Please implement 'bank-account'"))) 8 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/armstrong-numbers.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide armstrong-number?) 4 | 5 | (define (armstrong-number? n) 6 | (error "Please implement 'armstrong-number?'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/grains/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide square total) 4 | 5 | (define (square n) 6 | (expt 2 (- n 1))) 7 | 8 | (define (total) 9 | (- (square 65) 1)) 10 | -------------------------------------------------------------------------------- /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/leap/.approaches/boolean-chain/snippet.txt: -------------------------------------------------------------------------------- 1 | (define (leap-year? year) 2 | (and (zero? (modulo year 4)) 3 | (or (not (zero? (modulo year 100))) 4 | (zero? (modulo year 400))))) -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/nucleotide-count.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide nucleotide-counts) 4 | 5 | (define (nucleotide-counts nucleotides) 6 | (error "Please implement 'nucleotide-counts'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplets/pythagorean-triplets.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide triplets-with-sum) 4 | 5 | (define (triplets-with-sum p) 6 | (error "Please implement 'triplets-with-sum'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/circular-buffer.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide circular-buffer%) 4 | 5 | (define circular-buffer% 6 | (class object% 7 | (error "Please implement 'circular-buffer'"))) 8 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide add-gigasecond) 4 | 5 | (require racket/date) 6 | 7 | (define (add-gigasecond date) 8 | (seconds->date (+ 1e9 (date->seconds date)))) 9 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/largest-series-product.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide largest-product) 4 | 5 | (define (largest-product digits span) 6 | (error "Please implement 'largest-product'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide accumulate) 4 | 5 | (define (accumulate lst op) 6 | (cond 7 | [(empty? lst) lst] 8 | [(cons (op (car lst)) (accumulate (cdr lst) op))])) -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/cond-form/snippet.txt: -------------------------------------------------------------------------------- 1 | (define (leap-year? year) 2 | (cond 3 | [(zero? (modulo year 400)) #t] 4 | [(zero? (modulo year 100)) #f] 5 | [(zero? (modulo year 4)) #t] 6 | [else #f])) -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/parallel-letter-frequency.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide calculate-frequencies) 4 | 5 | (define (calculate-frequencies texts) 6 | (error "Please implement 'calculate-frequencies'")) 7 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Implementation 2 | 3 | Implement a procedure named `classify` that takes a number as argument and returns either `'perfect`, 4 | `'abundant`, or `'deficient`. 5 | 6 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /exercises/practice/grains/grains.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide square total) 4 | 5 | (define (square a-square) 6 | (error "Please implement 'square'")) 7 | 8 | (define (total) 9 | (error "Please implement 'total'")) 10 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide leap-year?) 4 | 5 | (define (leap-year? year) 6 | (and (= (modulo year 4) 0) 7 | (or (not (= (modulo year 100) 0)) 8 | (= (modulo year 400) 0)))) 9 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide (contract-out 4 | [my-reverse (string? . -> . string?)])) 5 | 6 | (define (my-reverse str) 7 | (list->string (foldl cons '() (string->list str)))) 8 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/atbash-cipher.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide encode decode) 4 | 5 | (define (encode m) 6 | (error "Please implement 'encode'")) 7 | 8 | (define (decode m) 9 | (error "Please implement 'decode'")) 10 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/knapsack.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide item maximum-value) 4 | 5 | (struct item (weight value) #:transparent) 6 | 7 | (define (maximum-value maximum-weight items) 8 | (error "Please implement 'maximum-value'")) 9 | -------------------------------------------------------------------------------- /exercises/practice/strain/strain.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide keep discard) 4 | 5 | (define (keep lst predicate) 6 | (error "Please implement 'keep'")) 7 | 8 | (define (discard lst predicate) 9 | (error "Please implement 'discard'")) 10 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/resistor-color.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide color-code colors) 4 | 5 | (define (color-code color) 6 | (error "Please implement 'color-code'")) 7 | 8 | (define (colors) 9 | (error "Please implement 'colors'")) 10 | -------------------------------------------------------------------------------- /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/run-length-encoding/run-length-encoding.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide encode decode) 4 | 5 | (define (encode text) 6 | (error "Please implement 'encode'")) 7 | 8 | (define (decode code) 9 | (error "Please implement 'decode'")) 10 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/zebra-puzzle.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide owns-zebra drinks-water) 4 | 5 | (define (owns-zebra) 6 | (error "Please implement 'owns-zebra'")) 7 | 8 | (define (drinks-water) 9 | (error "Please implement 'drinks-water'")) 10 | -------------------------------------------------------------------------------- /.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/leap/.approaches/pattern-matching/snippet.txt: -------------------------------------------------------------------------------- 1 | (define (leap-year? year) 2 | (match (list (zero? (modulo year 4)) (zero? (modulo year 100)) (zero? (modulo year 400))) 3 | [(list _ _ #t) #t] 4 | [(list _ #t _) #f] 5 | [(list #t _ _) #t] 6 | [_ #f])) -------------------------------------------------------------------------------- /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/allergies/allergies.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide list-allergies allergic-to?) 4 | 5 | (define (list-allergies score) 6 | (error "Please implement 'list-allergies'")) 7 | 8 | (define (allergic-to? str score) 9 | (error "Please implement 'allergic-to?'")) 10 | -------------------------------------------------------------------------------- /exercises/practice/strain/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide keep discard) 4 | 5 | (define (keep lst predicate) 6 | (for/list ([value lst] 7 | #:when (predicate value)) 8 | value)) 9 | 10 | (define (discard lst predicate) 11 | (keep lst (negate predicate))) 12 | -------------------------------------------------------------------------------- /.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/darts/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide score) 4 | 5 | (define (score x y) 6 | (let ([distance (sqrt (+ (* x x) (* y y)))]) 7 | (cond 8 | [(<= distance 1.0) 10] 9 | [(<= distance 5.0) 5] 10 | [(<= distance 10.0) 1] 11 | [else 0] 12 | ))) 13 | -------------------------------------------------------------------------------- /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/queen-attack/queen-attack.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide create-queen 4 | can-attack?) 5 | 6 | (define (create-queen row column) 7 | (error "Please implement 'create-queen'")) 8 | 9 | (define (can-attack? white-queen black-queen) 10 | (error "Please implement 'can-attack?'")) 11 | -------------------------------------------------------------------------------- /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/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/hello-world/hello-world-test.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (require "hello-world.rkt") 4 | 5 | (module+ test 6 | (require rackunit rackunit/text-ui) 7 | 8 | (define suite 9 | (test-suite 10 | "hello world tests" 11 | 12 | (test-equal? "returns Hello, World!" (hello) "Hello, World!"))) 13 | 14 | (run-tests suite)) 15 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a string containing brackets `[]`, braces `{}`, parentheses `()`, or any combination thereof, verify that any and all pairs are matched and nested correctly. 4 | Any other characters should be ignored. 5 | For example, `"{what is (42)}?"` is balanced and `"[text}"` is not. 6 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": ["blakelewis"], 3 | "files": { 4 | "solution": [ 5 | "minesweeper.rkt" 6 | ], 7 | "test": [ 8 | "minesweeper-test.rkt" 9 | ], 10 | "example": [ 11 | ".meta/example.rkt" 12 | ] 13 | }, 14 | "blurb": "Add the numbers to a minesweeper board." 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide to-rna) 4 | 5 | (define (to-rna dna) 6 | (let ([dna-seq (string->list dna)]) 7 | (apply string 8 | (map (lambda (c) (cdr (assoc c lookup))) dna-seq)))) 9 | 10 | (define lookup 11 | '((#\C . #\G) 12 | (#\G . #\C) 13 | (#\A . #\U) 14 | (#\T . #\A))) 15 | -------------------------------------------------------------------------------- /reference/implementing-a-concept-exercise.md: -------------------------------------------------------------------------------- 1 | # How to implement an Racket concept exercise 2 | 3 | TODO: describe how to implement a concept exercise for the Racket track. For inspiration, check out the [C# version of this file][csharp-implementing]. 4 | 5 | [csharp-implementing]: https://github.com/exercism/v3/blob/main/csharp/reference/implementing-a-concept-exercise.md 6 | -------------------------------------------------------------------------------- /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/eliuds-eggs/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide number->eggs) 4 | 5 | (define (number->eggs n) 6 | (define (recurse val eggs) 7 | (define updated (floor (/ val 2))) 8 | (or (and (zero? val) eggs) 9 | (if (odd? val) 10 | (recurse updated (add1 eggs)) 11 | (recurse updated eggs)))) 12 | (recurse n 0)) 13 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide (contract-out 4 | [isogram? (string? . -> . boolean?)])) 5 | 6 | (define (isogram? s) 7 | (if (check-duplicates 8 | (filter (λ (c) 9 | (char-alphabetic? c)) 10 | (string->list 11 | (string-downcase s)))) 12 | #f 13 | #t)) 14 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide color-code colors) 4 | 5 | (define resistor-colors 6 | (vector "black" "brown" "red" "orange" "yellow" "green" "blue" "violet" "grey" "white")) 7 | 8 | (define (color-code color) 9 | (vector-member color resistor-colors)) 10 | 11 | (define (colors) 12 | (vector->list resistor-colors)) 13 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide square-root) 4 | 5 | (define/contract (square-root radicand) 6 | (-> exact-positive-integer? (or/c exact-positive-integer? 7 | false?)) 8 | (for/first ([num (in-inclusive-range 1 radicand)] 9 | #:when (equal? (expt num 2) radicand)) 10 | num)) 11 | -------------------------------------------------------------------------------- /exercises/practice/clock/clock.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide clock 4 | add 5 | subtract 6 | clock->string) 7 | 8 | (define (clock->string c) 9 | (error "Please implement 'clock->string'")) 10 | 11 | (define (add c minutes) 12 | (error "Please implement 'add'")) 13 | 14 | (define (subtract c minutes) 15 | (error "Please implement 'subtract'")) 16 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Count the frequency of letters in texts using parallel computation. 4 | 5 | Parallelism is about doing things in parallel that can also be done sequentially. 6 | A common example is counting the frequency of letters. 7 | Employ parallelism to calculate the total frequency of each letter in a list of texts. 8 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "chip" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "alphametics.rkt" 8 | ], 9 | "test": [ 10 | "alphametics-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Given an alphametics puzzle, find the correct solution." 17 | } 18 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/word-count/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You teach English as a foreign language to high school students. 4 | 5 | You've decided to base your entire curriculum on TV shows. 6 | You need to analyze which words are used, and how often they're repeated. 7 | 8 | This will let you choose the simplest shows to start with, and to gradually increase the difficulty as time passes. 9 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide word-count) 4 | 5 | (define (word-count sentence) 6 | (let* ([lowered (string-downcase sentence)] 7 | [words (regexp-match* #px"[a-z0-9]+(?:'[a-z0-9]+)?" lowered)]) 8 | (for/fold ([counts (hash)]) 9 | ([word (in-list words)]) 10 | (hash-set counts word (add1 (hash-ref counts word 0)))))) 11 | -------------------------------------------------------------------------------- /exercises/shared/.docs/tests.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right. 4 | 5 | To run the test from the command line, run the test from the exercise directory with the following command: 6 | 7 | ``` 8 | raco test -test.rkt 9 | ``` 10 | 11 | where `` should be replaced with the exercise's slug. 12 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/difference-of-squares.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide sum-of-squares square-of-sum difference) 4 | 5 | (define (sum-of-squares number) 6 | (error "Please implement 'sum-of-squares'")) 7 | 8 | (define (square-of-sum number) 9 | (error "Please implement 'square-of-sum'")) 10 | 11 | (define (difference number) 12 | (error "Please implement 'difference'")) 13 | -------------------------------------------------------------------------------- /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/hamming/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide hamming-distance) 4 | 5 | (define (hamming-distance dna1 dna2) 6 | (if (= (string-length dna1) (string-length dna2)) 7 | (length 8 | (filter not 9 | (map char=? 10 | (string->list dna1) 11 | (string->list dna2)))) 12 | (error "String length mismatch."))) 13 | -------------------------------------------------------------------------------- /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/pangram/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide pangram?) 4 | 5 | (define alphabet-length 6 | (length (string->list "abcdefghijklmnopqrstuvwxyz"))) 7 | 8 | (define (pangram? sentence) 9 | (define letters (for/set ([chr sentence] 10 | #:when (char-alphabetic? chr)) 11 | (char-downcase chr))) 12 | (eq? (set-count letters) alphabet-length)) 13 | -------------------------------------------------------------------------------- /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/clock/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "clock.rkt" 8 | ], 9 | "test": [ 10 | "clock-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Implement a clock that handles times without dates.", 17 | "source": "Pairing session with Erin Drummond" 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/proverb/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide recite) 4 | 5 | (define (recite lst) 6 | (cond 7 | [(empty? lst) '()] 8 | [else (append 9 | (for/list ([value lst] 10 | [next-value (rest lst)]) 11 | (format "For want of a ~a the ~a was lost." value next-value)) 12 | (list (format "And all for the want of a ~a." (first lst))))])) 13 | -------------------------------------------------------------------------------- /exercises/practice/flower-field/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "contributors": [ 6 | "BNAndras" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "flower-field.rkt" 11 | ], 12 | "test": [ 13 | "flower-field-test.rkt" 14 | ], 15 | "example": [ 16 | ".meta/example.rkt" 17 | ] 18 | }, 19 | "blurb": "Mark all the flowers in a garden." 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "czrpb" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "matching-brackets.rkt" 8 | ], 9 | "test": [ 10 | "matching-brackets-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Make sure the brackets and braces all match.", 17 | "source": "Ginna Baker" 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "high-scores.rkt" 8 | ], 9 | "test": [ 10 | "high-scores-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Manage a player's High Score list.", 17 | "source": "Tribute to the eighties' arcade game Frogger" 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "Adrien-LUDWIG" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "protein-translation.rkt" 8 | ], 9 | "test": [ 10 | "protein-translation-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Translate RNA sequences into proteins.", 17 | "source": "Tyler Long" 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/practice/perfect-numbers/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide classify) 4 | 5 | (define (divisor-sum n) 6 | (for/sum ([i (in-range 1 (add1 (quotient n 2)))] 7 | #:when (zero? (remainder n i))) 8 | i)) 9 | 10 | (define (classify n) 11 | (let ([sumdivisors (divisor-sum n)]) 12 | (cond [(= n sumdivisors) 'perfect] 13 | [(> n sumdivisors) 'deficient] 14 | [else 'abundant]))) 15 | -------------------------------------------------------------------------------- /.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/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/parallel-letter-frequency/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "parallel-letter-frequency.rkt" 8 | ], 9 | "test": [ 10 | "parallel-letter-frequency-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Count the frequency of letters in texts using parallel computation." 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "robot-simulator.rkt" 8 | ], 9 | "test": [ 10 | "robot-simulator-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Write a robot simulator.", 17 | "source": "Inspired by an interview question at a famous company." 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/sublist/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "czrpb" 4 | ], 5 | "contributors": [ 6 | "charmparticle" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "sublist.rkt" 11 | ], 12 | "test": [ 13 | "sublist-test.rkt" 14 | ], 15 | "example": [ 16 | ".meta/example.rkt" 17 | ] 18 | }, 19 | "blurb": "Write a function to determine if a list is a sublist of another list." 20 | } 21 | -------------------------------------------------------------------------------- /docs/RESOURCES.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | 3 | * [The Racket Guide](http://docs.racket-lang.org/guide/index.html) 4 | * [The Racket Reference](http://docs.racket-lang.org/reference/index.html) 5 | * [DrRacket: The Racket Programming Environment](http://docs.racket-lang.org/drracket/index.html) 6 | * [Command Line Tools and Your Editor of Choice](http://docs.racket-lang.org/guide/other-editors.html). 7 | * [StackOverflow](http://stackoverflow.com/questions/tagged/racket) 8 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide collatz) 4 | 5 | (define (collatz-length n [acc 0]) 6 | (if (= n 1) 7 | acc 8 | (collatz-length (if (even? n) 9 | (/ n 2) 10 | (add1 (* 3 n))) 11 | (add1 acc)))) 12 | 13 | (define/contract (collatz n) 14 | (-> exact-positive-integer? exact-integer?) 15 | (collatz-length n)) 16 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide sum-of-squares square-of-sum difference) 4 | 5 | (define (sum-of-squares n) 6 | (for/sum 7 | ([i (in-range (add1 n))]) 8 | (* i i))) 9 | 10 | (define (square-of-sum n) 11 | (let ([sum (for/sum 12 | ([i (in-range (add1 n))]) i)]) 13 | (* sum sum))) 14 | 15 | (define (difference n) 16 | (- (square-of-sum n) (sum-of-squares n))) 17 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "pangram.rkt" 8 | ], 9 | "test": [ 10 | "pangram-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Determine if a sentence is a pangram.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Pangram" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "zebra-puzzle.rkt" 8 | ], 9 | "test": [ 10 | "zebra-puzzle-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Solve the zebra puzzle.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Zebra_Puzzle" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "bank-account.rkt" 8 | ], 9 | "test": [ 10 | "bank-account-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Simulate a bank account supporting opening/closing, withdraws, and deposits of money. Watch out for concurrent transactions!" 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/variable-length-quantity.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide encode decode) 4 | 5 | ;;; Both of these should expect to take a variable number of arguments. 6 | ;;; You may wish to make a version that accepts a single argument first 7 | ;;; as that will make debugging easier. 8 | (define (encode . nums) 9 | (error "Please implement 'encode'")) 10 | 11 | (define (decode . nums) 12 | (error "Please implement 'decode'")) 13 | -------------------------------------------------------------------------------- /exercises/shared/.docs/help.md: -------------------------------------------------------------------------------- 1 | # Help 2 | 3 | To get help if you're having trouble, you can use one of the following resources: 4 | 5 | - [The Racket Reference](http://docs.racket-lang.org/reference/index.html) 6 | - [/r/racket](https://www.reddit.com/r/racket) is the Racket subreddit. 7 | - [StackOverflow](http://stackoverflow.com/questions/tagged/racket) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. 8 | -------------------------------------------------------------------------------- /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/zebra-puzzle/zebra-puzzle-test.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "zebra-puzzle.rkt") 4 | 5 | (module+ test 6 | (require rackunit rackunit/text-ui)) 7 | 8 | (module+ test 9 | (define suite 10 | (test-suite 11 | "zebra puzzle tests" 12 | 13 | (test-equal? "who owns the zebra?" 14 | (owns-zebra) 'Japanese) 15 | 16 | (test-equal? "who drinks water?" 17 | (drinks-water) 'Norwegian))) 18 | (run-tests suite)) 19 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/robot-name.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide make-robot 4 | name 5 | reset! 6 | reset-name-cache!) 7 | 8 | (define (make-robot) 9 | (error "Please implement 'make-robot'")) 10 | 11 | (define (name robot) 12 | (error "Please implement 'name'")) 13 | 14 | (define (reset! robot) 15 | (error "Please implement 'reset!'")) 16 | 17 | (define (reset-name-cache!) 18 | (error "Please implement 'reset-name-cache!'")) 19 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "erikschierboom" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "darts.rkt" 8 | ], 9 | "test": [ 10 | "darts-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/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/dnd-character/dnd-character.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide (struct-out character) 4 | ability 5 | make-character 6 | modifier) 7 | 8 | (struct character 9 | ()) ; Add necessary struct fields 10 | 11 | (define (ability) 12 | (error "Please implement 'ability'")) 13 | 14 | (define (modifier value) 15 | (error "Please implement 'modifier'")) 16 | 17 | (define (make-character) 18 | (error "Please implement 'make-character'")) 19 | -------------------------------------------------------------------------------- /exercises/practice/yacht/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "yacht.rkt" 8 | ], 9 | "test": [ 10 | "yacht-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Score a single throw of dice in the game Yacht.", 17 | "source": "James Kilfiger, using Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/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 | "Adrien-LUDWIG" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "strain.rkt" 8 | ], 9 | "test": [ 10 | "strain-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/binary-search/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide binary-search) 4 | 5 | (define (binary-search array target) 6 | (let loop ([lo 0] [hi (vector-length array)]) 7 | (define mid (quotient (+ lo hi) 2)) 8 | (cond 9 | [(= lo hi) (and (< lo (vector-length array)) 10 | (= (vector-ref array lo) target) 11 | lo)] 12 | [(< (vector-ref array mid) target) (loop (+ 1 mid) hi)] 13 | [else (loop lo mid)]))) 14 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "grade-school.rkt" 8 | ], 9 | "test": [ 10 | "grade-school-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Given students' names along with the grade that they are in, create a roster for the school.", 17 | "source": "A pairing session with Phil Battos at gSchool" 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "nth-prime.rkt" 8 | ], 9 | "test": [ 10 | "nth-prime-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Given a number n, determine what the nth prime is.", 17 | "source": "A variation on Problem 7 at Project Euler", 18 | "source_url": "https://projecteuler.net/problem=7" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "square-root.rkt" 8 | ], 9 | "test": [ 10 | "square-root-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/all-your-base/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "serialhex" 4 | ], 5 | "contributors": [ 6 | "robertpostill", 7 | "timotheosh" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "all-your-base.rkt" 12 | ], 13 | "test": [ 14 | "all-your-base-test.rkt" 15 | ], 16 | "example": [ 17 | ".meta/example.rkt" 18 | ] 19 | }, 20 | "blurb": "Convert a number, represented as a sequence of digits in one base, to any other base." 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | ## Functions and testing 4 | 5 | The starting code you're provided with, 6 | ```scheme 7 | (provide hello) 8 | 9 | (define (hello) 10 | "Goodbye, Mars!") 11 | ``` 12 | defines a function named `hello` and makes it available to run. 13 | The test runner takes this function and runs it, comparing the value it returns to the value it expects. 14 | Use this starting function definition as the basis for your solution. 15 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "luhn.rkt" 8 | ], 9 | "test": [ 10 | "luhn-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Given a number determine whether or not it is valid per the Luhn formula.", 17 | "source": "The Luhn Algorithm on Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Luhn_algorithm" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "run-length-encoding.rkt" 8 | ], 9 | "test": [ 10 | "run-length-encoding-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Implement run-length encoding and decoding.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Run-length_encoding" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/eliuds-eggs-test.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "eliuds-eggs.rkt") 4 | 5 | (module+ test 6 | (require rackunit rackunit/text-ui) 7 | 8 | (define suite 9 | (test-suite 10 | "eliud's eggs tests" 11 | 12 | (test-equal? "0 eggs" (number->eggs 0) 0) 13 | 14 | (test-equal? "1 egg" (number->eggs 16) 1) 15 | 16 | (test-equal? "4 eggs" (number->eggs 89) 4) 17 | 18 | (test-equal? "13 eggs" (number->eggs 2000000000) 13))) 19 | 20 | (run-tests suite)) -------------------------------------------------------------------------------- /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/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/robot-name/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cousinitt" 4 | ], 5 | "contributors": [ 6 | "guygastineau", 7 | "robertpostill" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "robot-name.rkt" 12 | ], 13 | "test": [ 14 | "robot-name-test.rkt" 15 | ], 16 | "example": [ 17 | ".meta/example.rkt" 18 | ] 19 | }, 20 | "blurb": "Manage robot factory settings.", 21 | "source": "A debugging session with Paul Blackwell at gSchool." 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You are starting a secret coding club with some friends and friends-of-friends. 4 | Not everyone knows each other, so you and your friends have decided to create a secret handshake that you can use to recognize that someone is a member. 5 | You don't want anyone who isn't in the know to be able to crack the code. 6 | 7 | You've designed the code so that one person says a number between 1 and 31, and the other person turns it into a series of actions. 8 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | In Racket, this exercise uses sorted [vectors] rather than lists because vectors support constant-time access of its elements. Like several other Lisp tracks, when an item isn't present in the vector, the expectation is that the [Boolean literal `#f`][booleans] will be returned rather than raising an exception. 4 | 5 | [vectors]: https://docs.racket-lang.org/guide/vectors.html 6 | [booleans]: https://docs.racket-lang.org/reference/booleans.html 7 | -------------------------------------------------------------------------------- /exercises/practice/bowling/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "bowling.rkt" 8 | ], 9 | "test": [ 10 | "bowling-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Score a bowling game.", 17 | "source": "The Bowling Game Kata from UncleBob", 18 | "source_url": "https://web.archive.org/web/20221001111000/http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "food-chain.rkt" 8 | ], 9 | "test": [ 10 | "food-chain-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/There_Was_an_Old_Lady_Who_Swallowed_a_Fly" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide commands) 4 | 5 | (define actions '((1 . "wink") (2 . "double blink") 6 | (4 . "close your eyes") (8 . "jump"))) 7 | 8 | (define (bit-set? b n) 9 | (not (zero? (bitwise-and b n)))) 10 | 11 | (define (commands code) 12 | (let ([acts (filter-map 13 | (λ (a) (and (bit-set? (car a) code) (cdr a))) 14 | actions)]) 15 | (if (bit-set? 16 code) 16 | (reverse acts) 17 | acts))) 18 | 19 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "sieve.rkt" 8 | ], 9 | "test": [ 10 | "sieve-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.", 17 | "source": "Sieve of Eratosthenes at Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "circular-buffer.rkt" 8 | ], 9 | "test": [ 10 | "circular-buffer-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Circular_buffer" 19 | } 20 | -------------------------------------------------------------------------------- /.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/practice/binary-search/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "Adrien-LUDWIG" 4 | ], 5 | "contributors": [ 6 | "dreig" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "binary-search.rkt" 11 | ], 12 | "test": [ 13 | "binary-search-test.rkt" 14 | ], 15 | "example": [ 16 | ".meta/example.rkt" 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/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 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "resistor-color.rkt" 8 | ], 9 | "test": [ 10 | "resistor-color-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "rotational-cipher.rkt" 8 | ], 9 | "test": [ 10 | "rotational-cipher-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/dnd-character/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "dnd-character.rkt" 8 | ], 9 | "test": [ 10 | "dnd-character-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/pascals-triangle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "pascals-triangle.rkt" 8 | ], 9 | "test": [ 10 | "pascals-triangle-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Compute Pascal's triangle up to a given number of rows.", 17 | "source": "Pascal's Triangle at Wolfram Math World", 18 | "source_url": "https://www.wolframalpha.com/input/?i=Pascal%27s+triangle" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "Adrien-LUDWIG" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "proverb.rkt" 8 | ], 9 | "test": [ 10 | "proverb-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/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 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "two-bucket.rkt" 8 | ], 9 | "test": [ 10 | "two-bucket-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/acronym/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "tautologico" 4 | ], 5 | "contributors": [ 6 | "cousinitt", 7 | "robertpostill", 8 | "yurrriq" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "acronym.rkt" 13 | ], 14 | "test": [ 15 | "acronym-test.rkt" 16 | ], 17 | "example": [ 18 | ".meta/example.rkt" 19 | ] 20 | }, 21 | "blurb": "Convert a long phrase to its acronym.", 22 | "source": "Julien Vanier", 23 | "source_url": "https://github.com/monkbroc" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/line-up/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "line-up.rkt" 8 | ], 9 | "test": [ 10 | "line-up-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/list-ops/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "BNAndras", 7 | "mbertheau", 8 | "PurityControl", 9 | "robertpostill", 10 | "sjwarner-bp", 11 | "timotheosh", 12 | "yurrriq" 13 | ], 14 | "files": { 15 | "solution": [ 16 | "list-ops.rkt" 17 | ], 18 | "test": [ 19 | "list-ops-test.rkt" 20 | ], 21 | "example": [ 22 | ".meta/example.rkt" 23 | ] 24 | }, 25 | "blurb": "Implement basic list operations." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide color-code) 4 | 5 | (define resistor-colors 6 | '#("black" "brown" "red" "orange" "yellow" "green" "blue" "violet" "grey" "white")) 7 | 8 | (define (color-code colors) 9 | (match colors 10 | [(list first second _ ...) 11 | (let* ([tens (vector-member first resistor-colors)] 12 | [ones (vector-member second resistor-colors)] 13 | [value (+ (* tens 10) ones)]) 14 | value)] 15 | [ _ (error "Invalid colors argument")])) 16 | -------------------------------------------------------------------------------- /exercises/practice/meetup/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "mbertheau" 4 | ], 5 | "contributors": [ 6 | "arguello", 7 | "jgilray", 8 | "yurrriq" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "meetup.rkt" 13 | ], 14 | "test": [ 15 | "meetup-test.rkt" 16 | ], 17 | "example": [ 18 | ".meta/example.rkt" 19 | ] 20 | }, 21 | "blurb": "Calculate the date of meetups.", 22 | "source": "Jeremy Hinegardner mentioned a Boulder meetup that happens on the Wednesteenth of every month" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "resistor-color-duo.rkt" 8 | ], 9 | "test": [ 10 | "resistor-color-duo-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/diamond/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "diamond.rkt" 8 | ], 9 | "test": [ 10 | "diamond-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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 | "serialhex" 4 | ], 5 | "contributors": [ 6 | "kytrinyx" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "house.rkt" 11 | ], 12 | "test": [ 13 | "house-test.rkt" 14 | ], 15 | "example": [ 16 | ".meta/example.rkt" 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/pascals-triangle/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide rows) 4 | 5 | (define (next-row bottom) 6 | (do ([xs bottom (cdr xs)] 7 | [left 0 (car xs)] 8 | [row '() (cons (+ left (car xs)) row)]) 9 | ((null? xs) (cons 1 row)))) 10 | 11 | (define (rows height) 12 | (for/fold ([triangle '(())] 13 | #:result (if (null? triangle) 14 | triangle 15 | (cdr (reverse triangle)))) 16 | ([r (in-range height)]) 17 | (cons (next-row (car triangle)) triangle))) 18 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplets/.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/twelve-days/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "serialhex" 4 | ], 5 | "contributors": [ 6 | "kytrinyx" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "twelve-days.rkt" 11 | ], 12 | "test": [ 13 | "twelve-days-test.rkt" 14 | ], 15 | "example": [ 16 | ".meta/example.rkt" 17 | ] 18 | }, 19 | "blurb": "Output the lyrics to 'The Twelve Days of Christmas'.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/The_Twelve_Days_of_Christmas_(song)" 22 | } 23 | -------------------------------------------------------------------------------- /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/isogram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cousinitt" 4 | ], 5 | "contributors": [ 6 | "guygastineau", 7 | "robertpostill", 8 | "timotheosh" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "isogram.rkt" 13 | ], 14 | "test": [ 15 | "isogram-test.rkt" 16 | ], 17 | "example": [ 18 | ".meta/example.rkt" 19 | ] 20 | }, 21 | "blurb": "Determine if a word or phrase is an isogram.", 22 | "source": "Wikipedia", 23 | "source_url": "https://en.wikipedia.org/wiki/Isogram" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "resistor-color-trio.rkt" 8 | ], 9 | "test": [ 10 | "resistor-color-trio-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/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/high-scores/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide high-scores%) 4 | 5 | (define high-scores% 6 | (class object% 7 | (init values) 8 | (define current-values values) 9 | (super-new) 10 | (define/public (scores) current-values) 11 | (define/public (latest) (car (reverse (scores)))) 12 | (define/public (personal-best) (apply max (scores))) 13 | (define/public (personal-top-three) 14 | (define sorted (sort (scores) >)) 15 | (if (< (length sorted) 3) 16 | sorted 17 | (take sorted 3))))) 18 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "knapsack.rkt" 8 | ], 9 | "test": [ 10 | "knapsack-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/secret-handshake/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "secret-handshake.rkt" 8 | ], 9 | "test": [ 10 | "secret-handshake-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/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/collatz-conjecture/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "jgilray" 4 | ], 5 | "contributors": [ 6 | "yurrriq" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "collatz-conjecture.rkt" 11 | ], 12 | "test": [ 13 | "collatz-conjecture-test.rkt" 14 | ], 15 | "example": [ 16 | ".meta/example.rkt" 17 | ] 18 | }, 19 | "blurb": "Calculate the number of steps to reach 1 using the Collatz conjecture.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Collatz_conjecture" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "pig-latin.rkt" 8 | ], 9 | "test": [ 10 | "pig-latin-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Implement a program that translates from English to Pig Latin.", 17 | "source": "The Pig Latin exercise at Test First Teaching by Ultrasaurus", 18 | "source_url": "https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/affine-cipher/affine-cipher.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (require racket/contract) 4 | 5 | (provide (contract-out 6 | [encode (string? 7 | exact-nonnegative-integer? 8 | exact-nonnegative-integer? . -> . string?)] 9 | [decode (string? 10 | exact-nonnegative-integer? 11 | exact-nonnegative-integer? . -> . string?)])) 12 | 13 | (define (encode msg a b) 14 | (error "Please implement 'encode'")) 15 | 16 | (define (decode msg a b) 17 | (error "Please implement 'decode'")) 18 | -------------------------------------------------------------------------------- /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/armstrong-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cousinitt" 4 | ], 5 | "contributors": [ 6 | "robertpostill", 7 | "timotheosh" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "armstrong-numbers.rkt" 12 | ], 13 | "test": [ 14 | "armstrong-numbers-test.rkt" 15 | ], 16 | "example": [ 17 | ".meta/example.rkt" 18 | ] 19 | }, 20 | "blurb": "Determine if a number is an Armstrong number.", 21 | "source": "Wikipedia", 22 | "source_url": "https://en.wikipedia.org/wiki/Narcissistic_number" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "space-age.rkt" 8 | ], 9 | "test": [ 10 | "space-age-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.", 17 | "source": "Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial.", 18 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=01" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "benreyn" 4 | ], 5 | "contributors": [ 6 | "cousinitt", 7 | "robertpostill", 8 | "sjwarner-bp", 9 | "timotheosh" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "two-fer.rkt" 14 | ], 15 | "test": [ 16 | "two-fer-test.rkt" 17 | ], 18 | "example": [ 19 | ".meta/example.rkt" 20 | ] 21 | }, 22 | "blurb": "Create a sentence of the form \"One for X, one for me.\".", 23 | "source_url": "https://github.com/exercism/problem-specifications/issues/757" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cousinitt" 4 | ], 5 | "contributors": [ 6 | "robertpostill" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "atbash-cipher.rkt" 11 | ], 12 | "test": [ 13 | "atbash-cipher-test.rkt" 14 | ], 15 | "example": [ 16 | ".meta/example.rkt" 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/eliuds-eggs/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "eliuds-eggs.rkt" 8 | ], 9 | "test": [ 10 | "eliuds-eggs-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/largest-series-product/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "largest-series-product.rkt" 8 | ], 9 | "test": [ 10 | "largest-series-product-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.", 17 | "source": "A variation on Problem 8 at Project Euler", 18 | "source_url": "https://projecteuler.net/problem=8" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "serialhex" 4 | ], 5 | "contributors": [ 6 | "kytrinyx" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "triangle.rkt" 11 | ], 12 | "test": [ 13 | "triangle-test.rkt" 14 | ], 15 | "example": [ 16 | ".meta/example.rkt" 17 | ] 18 | }, 19 | "blurb": "Determine if a triangle is equilateral, isosceles, or scalene.", 20 | "source": "The Ruby Koans triangle project, parts 1 & 2", 21 | "source_url": "https://web.archive.org/web/20220831105330/http://rubykoans.com" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide item maximum-value) 4 | 5 | (struct item (weight value)) 6 | 7 | (define (maximum-value maximum-weight items) 8 | (for/fold 9 | ([top-value (make-vector (add1 maximum-weight) 0)] 10 | #:result (vector-ref top-value maximum-weight)) 11 | ([it items]) 12 | (for/vector ([w (in-inclusive-range 0 maximum-weight)]) 13 | (if (> (item-weight it) w) 14 | (vector-ref top-value w) 15 | (max (vector-ref top-value w) 16 | (+ (vector-ref top-value (- w (item-weight it))) 17 | (item-value it))))))) 18 | -------------------------------------------------------------------------------- /exercises/practice/line-up/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide format-message) 4 | 5 | (define (format-message name number) 6 | (string-append name 7 | ", you are the " 8 | (number->string number) 9 | (suffix number) 10 | " customer we serve today. Thank you!")) 11 | 12 | (define (suffix n) 13 | (match (list (modulo n 10) (modulo n 100)) 14 | [(list 1 11) "th"] 15 | [(list 2 12) "th"] 16 | [(list 3 13) "th"] 17 | [(list 1 _) "st"] 18 | [(list 2 _) "nd"] 19 | [(list 3 _) "rd"] 20 | [else "th"])) 21 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide (contract-out 4 | [armstrong-number? (exact-nonnegative-integer? . -> . boolean?)])) 5 | 6 | (define (list-digits n) 7 | (let loop ([N n] 8 | [a '()]) 9 | (let-values ([(q r) (quotient/remainder N 10)]) 10 | (if (zero? N) 11 | a 12 | (loop q (cons r a)))))) 13 | 14 | (define (armstrong-number? n) 15 | (let* ([digits (list-digits n)] 16 | [number-of-digits (length digits)]) 17 | (= n 18 | (for/sum ([d digits]) 19 | (expt d number-of-digits))))) -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "kindergarten-garden.rkt" 8 | ], 9 | "test": [ 10 | "kindergarten-garden-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 14 | ] 15 | }, 16 | "blurb": "Given a diagram, determine which plants each child in the kindergarten class is responsible for.", 17 | "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 18 | "source_url": "https://turing.edu" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplets/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "contributors": [ 6 | "SimaDovakin" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "pythagorean-triplets.rkt" 11 | ], 12 | "test": [ 13 | "pythagorean-triplets-test.rkt" 14 | ], 15 | "example": [ 16 | ".meta/example.rkt" 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/variable-length-quantity/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "serialhex" 4 | ], 5 | "contributors": [ 6 | "robertpostill" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "variable-length-quantity.rkt" 11 | ], 12 | "test": [ 13 | "variable-length-quantity-test.rkt" 14 | ], 15 | "example": [ 16 | ".meta/example.rkt" 17 | ] 18 | }, 19 | "blurb": "Implement variable length quantity encoding and decoding.", 20 | "source": "A poor Splice developer having to implement MIDI encoding/decoding.", 21 | "source_url": "https://splice.com" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "BNAndras" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "queen-attack.rkt" 8 | ], 9 | "test": [ 10 | "queen-attack-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/scrabble-score/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "zenspider" 4 | ], 5 | "contributors": [ 6 | "cousinitt", 7 | "robertpostill", 8 | "yurrriq" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "scrabble-score.rkt" 13 | ], 14 | "test": [ 15 | "scrabble-score-test.rkt" 16 | ], 17 | "example": [ 18 | ".meta/example.rkt" 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/affine-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cousinitt" 4 | ], 5 | "contributors": [ 6 | "guygastineau", 7 | "robertpostill", 8 | "timotheosh" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "affine-cipher.rkt" 13 | ], 14 | "test": [ 15 | "affine-cipher-test.rkt" 16 | ], 17 | "example": [ 18 | ".meta/example.rkt" 19 | ] 20 | }, 21 | "blurb": "Create an implementation of the Affine cipher, an ancient encryption algorithm from the Middle East.", 22 | "source": "Wikipedia", 23 | "source_url": "https://en.wikipedia.org/wiki/Affine_cipher" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "mbertheau", 7 | "mfelleisen", 8 | "PurityControl", 9 | "yurrriq" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "anagram.rkt" 14 | ], 15 | "test": [ 16 | "anagram-test.rkt" 17 | ], 18 | "example": [ 19 | ".meta/example.rkt" 20 | ] 21 | }, 22 | "blurb": "Given a word and a list of possible anagrams, select the correct sublist.", 23 | "source": "Inspired by the Extreme Startup game", 24 | "source_url": "https://github.com/rchatley/extreme_startup" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "sturmer" 4 | ], 5 | "contributors": [ 6 | "arguello", 7 | "PurityControl", 8 | "yurrriq" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "etl.rkt" 13 | ], 14 | "test": [ 15 | "etl-test.rkt" 16 | ], 17 | "example": [ 18 | ".meta/example.rkt" 19 | ] 20 | }, 21 | "blurb": "Change the data format for scoring a game to more easily add other languages.", 22 | "source": "Based on an exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 23 | "source_url": "https://turing.edu" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide nucleotide-counts) 4 | 5 | (define (nucleotide-counts strand) 6 | (if (valid-nucleotides? strand) 7 | (map (lambda (c) (cons c (dna-count c strand))) (string->list "ACGT")) 8 | (raise-argument-error 'nucleotide-counts "strand with valid nucleotides" strand))) 9 | 10 | (define (valid-nucleotides? strand) 11 | (if (andmap (lambda (n) (member n (string->list "ACGT"))) (string->list strand)) 12 | #t 13 | #f)) 14 | 15 | (define (dna-count nucleotide strand) 16 | (length (filter (lambda (x) (char=? nucleotide x)) (string->list strand)))) 17 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide (contract-out 4 | [etl (-> valid-input valid-output)])) 5 | 6 | (define (lower-case? s) (not (regexp-match? #rx"[A-Z]" s))) 7 | 8 | ;; Accept upper- or lower-case-letters strings as values 9 | (define valid-input 10 | (hash/c exact-nonnegative-integer? (listof string?))) 11 | 12 | ;; Keys will always be lower-case 13 | (define valid-output 14 | (hash/c lower-case? exact-nonnegative-integer?)) 15 | 16 | (define (etl h) 17 | (for*/hash ([(score letter*) (in-hash h)] 18 | [letter (in-list letter*)]) 19 | (values (string-downcase letter) score))) 20 | 21 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "gavinmcgimpsey" 4 | ], 5 | "contributors": [ 6 | "arguello", 7 | "cousinitt", 8 | "PurityControl", 9 | "robertpostill", 10 | "yurrriq" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "roman-numerals.rkt" 15 | ], 16 | "test": [ 17 | "roman-numerals-test.rkt" 18 | ], 19 | "example": [ 20 | ".meta/example.rkt" 21 | ] 22 | }, 23 | "blurb": "Convert modern Arabic numbers into Roman numerals.", 24 | "source": "The Roman Numeral Kata", 25 | "source_url": "https://codingdojo.org/kata/RomanNumerals/" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [af9ffe10-dc13-42d8-a742-e7bdafac449d] 13 | description = "Say Hi!" 14 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "mbertheau", 7 | "PurityControl", 8 | "yurrriq" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "nucleotide-count.rkt" 13 | ], 14 | "test": [ 15 | "nucleotide-count-test.rkt" 16 | ], 17 | "example": [ 18 | ".meta/example.rkt" 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/spiral-matrix/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "blakelewis" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "spiral-matrix.rkt" 8 | ], 9 | "test": [ 10 | "spiral-matrix-test.rkt" 11 | ], 12 | "example": [ 13 | ".meta/example.rkt" 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/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/leap/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "mbertheau", 7 | "PurityControl", 8 | "robertpostill", 9 | "timotheosh", 10 | "yurrriq" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "leap.rkt" 15 | ], 16 | "test": [ 17 | "leap-test.rkt" 18 | ], 19 | "example": [ 20 | ".meta/example.rkt" 21 | ] 22 | }, 23 | "blurb": "Determine whether a given year is a leap year.", 24 | "source": "CodeRanch Cattle Drive, Assignment 3", 25 | "source_url": "https://web.archive.org/web/20240907033714/https://coderanch.com/t/718816/Leap" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "cousinitt" 4 | ], 5 | "contributors": [ 6 | "guygastineau", 7 | "robertpostill", 8 | "timotheosh" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "reverse-string.rkt" 13 | ], 14 | "test": [ 15 | "reverse-string-test.rkt" 16 | ], 17 | "example": [ 18 | ".meta/example.rkt" 19 | ] 20 | }, 21 | "blurb": "Reverse a given string.", 22 | "source": "Introductory challenge to reverse an input string", 23 | "source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require racket/match) 4 | 5 | (provide score) 6 | 7 | (define (score word) 8 | (for/sum ([c (in-string (string-downcase word))]) 9 | (match c 10 | [(or #\a #\e #\i #\o #\u #\l #\n #\r #\s #\t) 1] 11 | [(or #\d #\g) 2] 12 | [(or #\b #\c #\m #\p) 3] 13 | [(or #\f #\h #\v #\w #\y) 4] 14 | [(or #\k) 5] 15 | [(or #\j #\x) 8] 16 | [(or #\q #\z) 10] 17 | [_ 0]))) 18 | -------------------------------------------------------------------------------- /docs/TESTS.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | You can run the provided tests through DrRacket, or via the command line. 4 | 5 | To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right. 6 | 7 | To run the test from the command line, simply run the test from the exercise directory. For example, if the test suite is called `hello-world-test.rkt`, you can run the following command: 8 | 9 | ``` 10 | raco test hello-world-test.rkt 11 | ``` 12 | 13 | which will display the following: 14 | 15 | ``` 16 | raco test: (submod "hello-world-test.rkt" test) 17 | 2 success(es) 0 failure(s) 0 error(s) 2 test(s) run 18 | 0 19 | 2 tests passed 20 | ``` 21 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "mbertheau" 4 | ], 5 | "contributors": [ 6 | "arguello", 7 | "BNAndras", 8 | "cousinitt", 9 | "PurityControl", 10 | "robertpostill", 11 | "yurrriq" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "word-count.rkt" 16 | ], 17 | "test": [ 18 | "word-count-test.rkt" 19 | ], 20 | "example": [ 21 | ".meta/example.rkt" 22 | ] 23 | }, 24 | "blurb": "Given a phrase, count the occurrences of each word in that phrase.", 25 | "source": "This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | The classical introductory exercise. 4 | Just say "Hello, World!". 5 | 6 | ["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. 7 | 8 | The objectives are simple: 9 | 10 | - Modify the provided code so that it produces the string "Hello, World!". 11 | - Run the test suite and make sure that it succeeds. 12 | - Submit your solution and check it at the website. 13 | 14 | If everything goes well, you will be ready to fetch your first real exercise. 15 | 16 | [hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program 17 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "benreyn", 7 | "mbertheau", 8 | "PurityControl", 9 | "yurrriq" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "hello-world.rkt" 14 | ], 15 | "test": [ 16 | "hello-world-test.rkt" 17 | ], 18 | "example": [ 19 | ".meta/example.rkt" 20 | ] 21 | }, 22 | "blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", 23 | "source": "This is an exercise to introduce users to using Exercism", 24 | "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/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/acronym/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Convert a phrase to its acronym. 4 | 5 | Techies love their TLA (Three Letter Acronyms)! 6 | 7 | Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG). 8 | 9 | Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input. 10 | 11 | For example: 12 | 13 | | Input | Output | 14 | | ------------------------- | ------ | 15 | | As Soon As Possible | ASAP | 16 | | Liquid-crystal display | LCD | 17 | | Thank George It's Friday! | TGIF | 18 | -------------------------------------------------------------------------------- /exercises/practice/grains/grains-test.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "grains.rkt") 4 | 5 | (module+ test 6 | (require rackunit rackunit/text-ui) 7 | 8 | (define suite 9 | (test-suite 10 | "grains tests" 11 | 12 | (test-eqv? "square 1" (square 1) 1) 13 | (test-eqv? "square 2" (square 2) 2) 14 | (test-eqv? "square 3" (square 3) 4) 15 | (test-eqv? "square 4" (square 4) 8) 16 | (test-eqv? "square 16" (square 16) 32768) 17 | (test-eqv? "square 32" (square 32) 2147483648) 18 | (test-eqv? "square 64" (square 64) 9223372036854775808) 19 | (test-eqv? "total grains" (total) 18446744073709551615))) 20 | 21 | (run-tests suite)) 22 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "mbertheau" 4 | ], 5 | "contributors": [ 6 | "arguello", 7 | "PurityControl", 8 | "robertpostill", 9 | "sjwarner-bp", 10 | "timotheosh", 11 | "yurrriq" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "hamming.rkt" 16 | ], 17 | "test": [ 18 | "hamming-test.rkt" 19 | ], 20 | "example": [ 21 | ".meta/example.rkt" 22 | ] 23 | }, 24 | "blurb": "Calculate the Hamming distance between two DNA strands.", 25 | "source": "The Calculating Point Mutations problem at Rosalind", 26 | "source_url": "https://rosalind.info/problems/hamm/" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/grains/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "mbertheau", 7 | "PurityControl", 8 | "yurrriq" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "grains.rkt" 13 | ], 14 | "test": [ 15 | "grains-test.rkt" 16 | ], 17 | "example": [ 18 | ".meta/example.rkt" 19 | ] 20 | }, 21 | "blurb": "Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.", 22 | "source": "The CodeRanch Cattle Drive, Assignment 6", 23 | "source_url": "https://web.archive.org/web/20240908084142/https://coderanch.com/wiki/718824/Grains" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/grep/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "bennn" 4 | ], 5 | "contributors": [ 6 | "arguello", 7 | "PurityControl", 8 | "tautologico", 9 | "yurrriq" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "grep.rkt" 14 | ], 15 | "test": [ 16 | "grep-test.rkt" 17 | ], 18 | "example": [ 19 | ".meta/example.rkt" 20 | ] 21 | }, 22 | "blurb": "Search a file for lines matching a regular expression pattern. Return the line number and contents of each matching line.", 23 | "source": "Conversation with Nate Foster.", 24 | "source_url": "https://www.cs.cornell.edu/Courses/cs3110/2014sp/hw/0/ps0.pdf" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You're given the opportunity to write software for the Bracketeer™, an ancient but powerful mainframe. 4 | The software that runs on it is written in a proprietary language. 5 | Much of its syntax is familiar, but you notice _lots_ of brackets, braces and parentheses. 6 | Despite the Bracketeer™ being powerful, it lacks flexibility. 7 | If the source code has any unbalanced brackets, braces or parentheses, the Bracketeer™ crashes and must be rebooted. 8 | To avoid such a scenario, you start writing code that can verify that brackets, braces, and parentheses are balanced before attempting to run it on the Bracketeer™. 9 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide valid?) 4 | 5 | (define (value d) 6 | (- (char->integer d) (char->integer #\0))) 7 | 8 | (define (valid? digits) 9 | (let ([xs (string-replace digits " " "")]) 10 | (if (or (regexp-match #px"[^0-9]" xs) 11 | (< (string-length xs) 2)) 12 | #f 13 | (let* ([ds (map value (string->list xs))] 14 | [total 15 | (for/sum ([d ds] 16 | [i (in-range (length ds))]) 17 | (if (zero? (modulo (- (length ds) i) 2)) 18 | (- (* 2 d) (if (> d 4) 9 0)) 19 | d))]) 20 | (zero? (modulo total 10)))))) 21 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | We are launching a deep space exploration rocket and we need a way to make sure the navigation system stays on target. 4 | 5 | As the first step in our calculation, we take a target number and find its square root (that is, the number that when multiplied by itself equals the target number). 6 | 7 | The journey will be very long. 8 | To make the batteries last as long as possible, we had to make our rocket's onboard computer very power efficient. 9 | Unfortunately that means that we can't rely on fancy math libraries and functions, as they use more power. 10 | Instead we want to implement our own square root calculation. 11 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | An [Armstrong number][armstrong-number] is a number that is the sum of its own digits each raised to the power of the number of digits. 4 | 5 | For example: 6 | 7 | - 9 is an Armstrong number, because `9 = 9^1 = 9` 8 | - 10 is _not_ an Armstrong number, because `10 != 1^2 + 0^2 = 1` 9 | - 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153` 10 | - 154 is _not_ an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190` 11 | 12 | Write some code to determine whether a number is an Armstrong number. 13 | 14 | [armstrong-number]: https://en.wikipedia.org/wiki/Narcissistic_number 15 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "cousinitt", 7 | "mbertheau", 8 | "PurityControl", 9 | "robertpostill", 10 | "yurrriq" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "phone-number.rkt" 15 | ], 16 | "test": [ 17 | "phone-number-test.rkt" 18 | ], 19 | "example": [ 20 | ".meta/example.rkt" 21 | ] 22 | }, 23 | "blurb": "Clean up user-entered phone numbers so that they can be sent SMS messages.", 24 | "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 25 | "source_url": "https://turing.edu" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide rotate) 4 | 5 | (define (rotate text key) 6 | (list->string 7 | (map (lambda (char) (rotate-char char key)) 8 | (string->list text)))) 9 | 10 | (define (rotate-char char key) 11 | (cond 12 | [(char-alphabetic? char) 13 | (let* ([alphabet-length 26] 14 | [offset (if (char-upper-case? char) (char->integer #\A) (char->integer #\a))] 15 | [calc-rel-position (lambda () (modulo (+ (- (char->integer char) offset) key) alphabet-length))] 16 | [calc-new-position (lambda () (+ offset (calc-rel-position)))]) 17 | (integer->char (calc-new-position)))] 18 | [else char])) 19 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "mbertheau", 7 | "nebkor", 8 | "PurityControl", 9 | "Scientifica96", 10 | "yurrriq" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "difference-of-squares.rkt" 15 | ], 16 | "test": [ 17 | "difference-of-squares-test.rkt" 18 | ], 19 | "example": [ 20 | ".meta/example.rkt" 21 | ] 22 | }, 23 | "blurb": "Find the difference between the square of the sum and the sum of the squares of the first N natural numbers.", 24 | "source": "Problem 6 at Project Euler", 25 | "source_url": "https://projecteuler.net/problem=6" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/two-fer-test.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | ; Tests adapted from `problem-specifications/canonical-data.json v1.2.0 4 | (require "two-fer.rkt") 5 | 6 | (module+ test 7 | (require rackunit rackunit/text-ui) 8 | 9 | (define suite 10 | (test-suite 11 | "two fer tests" 12 | 13 | (test-equal? "no name given" 14 | (two-fer) 15 | "One for you, one for me.") 16 | (test-equal? "a name given" 17 | (two-fer "Alice") 18 | "One for Alice, one for me.") 19 | (test-equal? "another name given" 20 | (two-fer "Bob") 21 | "One for Bob, one for me."))) 22 | 23 | (run-tests suite)) 24 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "zenspider" 4 | ], 5 | "contributors": [ 6 | "cousinitt", 7 | "robertpostill", 8 | "timotheosh", 9 | "yurrriq" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "allergies.rkt" 14 | ], 15 | "test": [ 16 | "allergies-test.rkt" 17 | ], 18 | "example": [ 19 | ".meta/example.rkt" 20 | ] 21 | }, 22 | "blurb": "Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.", 23 | "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 24 | "source_url": "https://turing.edu" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "mbertheau" 4 | ], 5 | "contributors": [ 6 | "arguello", 7 | "PurityControl", 8 | "robertpostill", 9 | "sjwarner-bp", 10 | "timotheosh", 11 | "yurrriq" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "gigasecond.rkt" 16 | ], 17 | "test": [ 18 | "gigasecond-test.rkt" 19 | ], 20 | "example": [ 21 | ".meta/example.rkt" 22 | ] 23 | }, 24 | "blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.", 25 | "source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.", 26 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=09" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/bob/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "mbertheau", 7 | "PurityControl", 8 | "robertpostill", 9 | "sjwarner-bp", 10 | "timotheosh", 11 | "yurrriq" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "bob.rkt" 16 | ], 17 | "test": [ 18 | "bob-test.rkt" 19 | ], 20 | "example": [ 21 | ".meta/example.rkt" 22 | ] 23 | }, 24 | "blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.", 25 | "source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.", 26 | "source_url": "https://pine.fm/LearnToProgram/?Chapter=06" 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a company that sells fonts through their website. 4 | They'd like to show a different sentence each time someone views a font on their website. 5 | To give a comprehensive sense of the font, the random sentences should use **all** the letters in the English alphabet. 6 | 7 | They're running a competition to get suggestions for sentences that they can use. 8 | You're in charge of checking the submissions to see if they are valid. 9 | 10 | ~~~~exercism/note 11 | Pangram comes from Greek, παν γράμμα, pan gramma, which means "every letter". 12 | 13 | The best known English pangram is: 14 | 15 | > The quick brown fox jumps over the lazy dog. 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Manage robot factory settings. 4 | 5 | When a robot comes off the factory floor, it has no name. 6 | 7 | The first time you turn on a robot, a random name is generated in the format of two uppercase letters followed by three digits, such as RX837 or BC811. 8 | 9 | Every once in a while we need to reset a robot to its factory settings, which means that its name gets wiped. 10 | The next time you ask, that robot will respond with a new random name. 11 | 12 | The names must be random: they should not follow a predictable sequence. 13 | Using random names means a risk of collisions. 14 | Your solution must ensure that every existing robot has a unique name. 15 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine what you will say as you give away the extra cookie. 4 | 5 | If you know the person's name (e.g. if they're named Do-yun), then you will say: 6 | 7 | ```text 8 | One for Do-yun, one for me. 9 | ``` 10 | 11 | If you don't know the person's name, you will say _you_ instead. 12 | 13 | ```text 14 | One for you, one for me. 15 | ``` 16 | 17 | Here are some examples: 18 | 19 | | Name | Dialogue | 20 | | :----- | :-------------------------- | 21 | | Alice | One for Alice, one for me. | 22 | | Bohdan | One for Bohdan, one for me. | 23 | | | One for you, one for me. | 24 | | Zaphod | One for Zaphod, one for me. | 25 | -------------------------------------------------------------------------------- /docs/LEARNING.md: -------------------------------------------------------------------------------- 1 | # Learning 2 | 3 | Exercism provides exercises and feedback but can be difficult to jump into for those learning Racket for the first time. 4 | These resources can help you get started: 5 | 6 | * [Quick: An Introduction to Racket with Pictures](http://docs.racket-lang.org/quick/) 7 | * [Continue: Web Applications in Racket](http://docs.racket-lang.org/continue/index.html) 8 | * [More: Systems Programming with Racket](http://docs.racket-lang.org/more/index.html) 9 | * [How to Design Programs](http://htdp.org/), by Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, and Shiriam Krishnamurthi 10 | * [The Little Schemer](http://mitpress.mit.edu/books/little-schemer-fourth-edition), by Daniel P. Friedman and Matthias Felleisen 11 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide 4 | ;; String [Listof String] -> [Listof String] 5 | ;; pick candidates for anagrams from the given list 6 | ;; def. a candidate consists of the same letters as subject 7 | anagrams-for) 8 | 9 | ;; ----------------------------------------------------------------------------- 10 | (define (anagrams-for subject candidates) 11 | (filter (lambda (w) (anagram? w subject)) candidates)) 12 | 13 | ;; String String -> Boolean 14 | ;; is a an anagram for b? 15 | (define (anagram? a b) 16 | (define (sorted-string s) 17 | (list->string (sort (string->list s) char-cichar (+ c (char->integer #\A))))] 9 | [middle (if (zero? (string-length inside)) 10 | mark 11 | (string-append mark inside mark))]) 12 | (string-append outside middle outside))) 13 | 14 | 15 | (define (rows high-char) 16 | (let* ([n (- (char->integer high-char) (char->integer #\A))] 17 | [top-rows (for/list ([c (in-range n)]) 18 | (make-row n c))] 19 | [bottom-rows (reverse top-rows)] 20 | [middle-row (make-row n n)]) 21 | (append top-rows (list middle-row) bottom-rows))) 22 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Implement the `accumulate` operation, which, given a collection and an operation to perform on each element of the collection, returns a new collection containing the result of applying that operation to each element of the input collection.", 3 | "authors": [ 4 | "sturmer" 5 | ], 6 | "contributors": [ 7 | "arguello", 8 | "PurityControl", 9 | "yurrriq" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "accumulate.rkt" 14 | ], 15 | "test": [ 16 | "accumulate-test.rkt" 17 | ], 18 | "example": [ 19 | ".meta/example.rkt" 20 | ] 21 | }, 22 | "source": "Conversation with James Edward Gray II", 23 | "source_url": "https://twitter.com/jeg2" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/nth-prime-test.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "nth-prime.rkt") 4 | 5 | (module+ test 6 | (require rackunit rackunit/text-ui) 7 | 8 | (define suite 9 | (test-suite 10 | "nth prime tests" 11 | (test-equal? "first prime" 12 | (nth-prime 1) 13 | 2) 14 | (test-equal? "second prime" 15 | (nth-prime 2) 16 | 3) 17 | (test-equal? "sixth prime" 18 | (nth-prime 6) 19 | 13) 20 | (test-equal? "big prime" 21 | (nth-prime 10001) 22 | 104743) 23 | (test-exn "there is no zeroth prime" 24 | exn:fail? (lambda () (nth-prime 0))))) 25 | 26 | (run-tests suite)) 27 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your body is made up of cells that contain DNA. 4 | Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. 5 | In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! 6 | 7 | When cells divide, their DNA replicates too. 8 | Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. 9 | If we compare two strands of DNA and count the differences between them, we can see how many mistakes occurred. 10 | This is known as the "Hamming distance". 11 | 12 | The Hamming distance is useful in many areas of science, not just biology, so it's a nice phrase to be familiar with :) 13 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide plants) 4 | 5 | (define plant-abbrev 6 | (hash #\C "clover" #\G "grass" #\R "radishes" #\V "violets")) 7 | 8 | (define (plant-name row ix) 9 | (hash-ref plant-abbrev (string-ref row ix))) 10 | 11 | (define (name->index name) 12 | (- (char->integer (string-ref name 0)) (char->integer #\A))) 13 | 14 | (define (plants diagram student) 15 | (let* ([rows (string-split diagram "\n")] 16 | [s (name->index student)] 17 | [i1 (* 2 s)] 18 | [i2 (add1 i1)] 19 | [p1 (plant-name (car rows) i1)] 20 | [p2 (plant-name (car rows) i2)] 21 | [p3 (plant-name (cadr rows) i1)] 22 | [p4 (plant-name (cadr rows) i2)]) 23 | (list p1 p2 p3 p4))) 24 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide create-queen 4 | can-attack?) 5 | 6 | (struct queen (row column)) 7 | 8 | (define (grid-position? n) 9 | (and (exact-nonnegative-integer? n) 10 | (> 8 n))) 11 | 12 | (define/contract (create-queen row column) 13 | (-> grid-position? grid-position? queen?) 14 | (queen row column)) 15 | 16 | (define/contract (can-attack? white-queen black-queen) 17 | (-> queen? queen? boolean?) 18 | (match (list white-queen black-queen) 19 | [(list (queen r _) (queen r _)) 20 | #t] 21 | [(list (queen _ c) (queen _ c)) 22 | #t] 23 | [(list (queen wr wc) (queen br bc)) 24 | #:when (= (abs (- wr br)) 25 | (abs (- wc bc))) 26 | #t] 27 | [_ #f])) 28 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide school%) 4 | 5 | (define school% 6 | (class object% 7 | (super-new) 8 | (define students (mutable-set)) 9 | (define grade-list (make-hash)) 10 | 11 | (define/public (add name grade) 12 | (and 13 | (not (set-member? students name)) 14 | (begin 15 | (set-add! students name) 16 | (let* ([current (hash-ref grade-list grade '())] 17 | [updated (sort (cons name current) stringlist grade-list) < #:key car)))) 26 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine the RNA complement of a given DNA sequence. 4 | 5 | Both DNA and RNA strands are a sequence of nucleotides. 6 | 7 | The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**), and thymine (**T**). 8 | 9 | The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**), and uracil (**U**). 10 | 11 | Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement: 12 | 13 | - `G` -> `C` 14 | - `C` -> `G` 15 | - `T` -> `A` 16 | - `A` -> `U` 17 | 18 | ~~~~exercism/note 19 | If you want to look at how the inputs and outputs are structured, take a look at the examples in the test suite. 20 | ~~~~ 21 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide allergic-to? list-allergies) 4 | 5 | (define allergies 6 | #hash(("eggs" . 1) 7 | ("peanuts" . 2) 8 | ("shellfish" . 4) 9 | ("strawberries" . 8) 10 | ("tomatoes" . 16) 11 | ("chocolate" . 32) 12 | ("pollen" . 64) 13 | ("cats" . 128))) 14 | 15 | (define codes 16 | (for/hash ([(k v) (in-hash allergies)]) 17 | (values v k))) 18 | 19 | (define (has-bit? n m) 20 | (> (bitwise-and n m) 0)) 21 | 22 | (define (allergic-to? name code) 23 | (has-bit? (hash-ref allergies name 0) code)) 24 | 25 | (define (list-allergies n) 26 | (for/list ([(code name) (in-hash codes)] 27 | #:when (has-bit? code n)) 28 | name)) 29 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Find the difference between the square of the sum and the sum of the squares of the first N natural numbers. 4 | 5 | The square of the sum of the first ten natural numbers is 6 | (1 + 2 + ... + 10)² = 55² = 3025. 7 | 8 | The sum of the squares of the first ten natural numbers is 9 | 1² + 2² + ... + 10² = 385. 10 | 11 | Hence the difference between the square of the sum of the first ten natural numbers and the sum of the squares of the first ten natural numbers is 3025 - 385 = 2640. 12 | 13 | You are not expected to discover an efficient solution to this yourself from first principles; research is allowed, indeed, encouraged. 14 | Finding the best algorithm for the problem is a key skill in software engineering. 15 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | After weeks of anticipation, you and your friends get together for your very first game of [Dungeons & Dragons][dnd] (D&D). 4 | Since this is the first session of the game, each player has to generate a character to play with. 5 | The character's abilities are determined by rolling 6-sided dice, but where _are_ the dice? 6 | With a shock, you realize that your friends are waiting for _you_ to produce the dice; after all it was your idea to play D&D! 7 | Panicking, you realize you forgot to bring the dice, which would mean no D&D game. 8 | As you have some basic coding skills, you quickly come up with a solution: you'll write a program to simulate dice rolls. 9 | 10 | [dnd]: https://en.wikipedia.org/wiki/Dungeons_%26_Dragons 11 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You've joined LinkLine, a leading communications company working to ensure reliable connections for everyone. 4 | The team faces a big challenge: users submit phone numbers in all sorts of formats — dashes, spaces, dots, parentheses, and even prefixes. 5 | Some numbers are valid, while others are impossible to use. 6 | 7 | Your mission is to turn this chaos into order. 8 | You'll clean up valid numbers, formatting them appropriately for use in the system. 9 | At the same time, you'll identify and filter out any invalid entries. 10 | 11 | The success of LinkLine's operations depends on your ability to separate the useful from the unusable. 12 | Are you ready to take on the challenge and keep the connections running smoothly? 13 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide translate) 4 | 5 | (define (leading-vowel? word) 6 | (regexp-match #px"^[aeiou]|^[xy][^aeiou]" word)) 7 | 8 | (define (leading-consonants word) 9 | (let ([head (if (string-prefix? word "y") 10 | "y" 11 | (car (string-split word #px"[aeiouy]")))]) 12 | (if (and (string-suffix? head "q") 13 | (string-prefix? (substring word (string-length head)) "u")) 14 | (string-append head "u") 15 | head))) 16 | 17 | (define (translate-word word) 18 | (let* ([head (if (leading-vowel? word) "" (leading-consonants word))] 19 | [tail (substring word (string-length head))]) 20 | (string-append tail head "ay"))) 21 | 22 | (define (translate text) 23 | (string-join (map translate-word (string-split text)))) 24 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | At the Global Verification Authority, you've just been entrusted with a critical assignment. 4 | Across the city, from online purchases to secure logins, countless operations rely on the accuracy of numerical identifiers like credit card numbers, bank account numbers, transaction codes, and tracking IDs. 5 | The Luhn algorithm is a simple checksum formula used to help identify mistyped numbers. 6 | 7 | A batch of identifiers has just arrived on your desk. 8 | All of them must pass the Luhn test to ensure they're legitimate. 9 | If any fail, they'll be flagged as invalid, preventing mistakes such as incorrect transactions or failed account verifications. 10 | 11 | Can you ensure this is done right? The integrity of many services depends on you. 12 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide triangle?) 4 | 5 | (define (triangle? sides kind) 6 | (let ([a (first sides)] 7 | [b (second sides)] 8 | [c (third sides)]) 9 | (if (and (< 0 a) (< 0 b) (< 0 c) 10 | (> (+ a b) c) 11 | (> (+ a c) b) 12 | (> (+ b c) a)) 13 | (case kind 14 | [(equilateral) (test-equilateral a b c)] 15 | [(isosceles) (test-isosceles a b c)] 16 | [(scalene) (test-scalene a b c)]) 17 | #f))) 18 | 19 | (define (test-equilateral a b c) 20 | (= a b c)) 21 | 22 | (define (test-isosceles a b c) 23 | (or (= a b) 24 | (= a c) 25 | (= b c))) 26 | 27 | (define (test-scalene a b c) 28 | (not (test-isosceles a b c))) 29 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to implement bank accounts supporting opening/closing, withdrawals, and deposits of money. 4 | 5 | As bank accounts can be accessed in many different ways (internet, mobile phones, automatic charges), your bank software must allow accounts to be safely accessed from multiple threads/processes (terminology depends on your programming language) in parallel. 6 | For example, there may be many deposits and withdrawals occurring in parallel; you need to ensure there are no [race conditions][wikipedia] between when you read the account balance and set the new balance. 7 | 8 | It should be possible to close an account; operations against a closed account must fail. 9 | 10 | [wikipedia]: https://en.wikipedia.org/wiki/Race_condition#In_software 11 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given an alphametics puzzle, find the correct solution. 4 | 5 | [Alphametics][alphametics] is a puzzle where letters in words are replaced with numbers. 6 | 7 | For example `SEND + MORE = MONEY`: 8 | 9 | ```text 10 | S E N D 11 | M O R E + 12 | ----------- 13 | M O N E Y 14 | ``` 15 | 16 | Replacing these with valid numbers gives: 17 | 18 | ```text 19 | 9 5 6 7 20 | 1 0 8 5 + 21 | ----------- 22 | 1 0 6 5 2 23 | ``` 24 | 25 | This is correct because every letter is replaced by a different number and the words, translated into numbers, then make a valid sum. 26 | 27 | Each letter must represent a different digit, and the leading digit of a multi-digit number must not be zero. 28 | 29 | [alphametics]: https://en.wikipedia.org/wiki/Alphametics 30 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to add the mine counts to empty squares in a completed Minesweeper board. 4 | The board itself is a rectangle composed of squares that are either empty (`' '`) or a mine (`'*'`). 5 | 6 | For each empty square, count the number of mines adjacent to it (horizontally, vertically, diagonally). 7 | If the empty square has no adjacent mines, leave it empty. 8 | Otherwise replace it with the adjacent mines count. 9 | 10 | For example, you may receive a 5 x 4 board like this (empty spaces are represented here with the '·' character for display on screen): 11 | 12 | ```text 13 | ·*·*· 14 | ··*·· 15 | ··*·· 16 | ····· 17 | ``` 18 | 19 | Which your code should transform into this: 20 | 21 | ```text 22 | 1*3*1 23 | 13*31 24 | ·2*2· 25 | ·111· 26 | ``` 27 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplets/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide triplets-with-sum) 4 | 5 | (define (primitives pmax) 6 | (for*/list 7 | ([m (in-naturals 2)] 8 | #:break (> (* 2 (* m (add1 m))) pmax) 9 | [n (in-range (add1 (remainder m 2)) m 2)] 10 | #:when (= 1 (gcd m n))) 11 | (define a (- (* m m) (* n n))) 12 | (define b (* 2 (* m n))) 13 | (define c (+ (* m m) (* n n))) 14 | (sort (list a b c) < ))) 15 | 16 | (define (triplets-with-sum p) 17 | (define (scale-up triple) 18 | (define perimeter (for/sum ([t triple]) t)) 19 | (cond 20 | [(zero? (remainder p perimeter)) 21 | (define k (quotient p perimeter)) 22 | (for/list ([t triple]) (* k t))] 23 | [else #f])) 24 | (sort (filter-map scale-up (primitives p)) < #:key car)) 25 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce] 13 | description = "no name given" 14 | 15 | [b4c6dbb8-b4fb-42c2-bafd-10785abe7709] 16 | description = "a name given" 17 | 18 | [3549048d-1a6e-4653-9a79-b0bda163e8d5] 19 | description = "another name given" 20 | -------------------------------------------------------------------------------- /exercises/practice/line-up/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a name and a number, your task is to produce a sentence using that name and that number as an [ordinal numeral][ordinal-numeral]. 4 | Yaʻqūb expects to use numbers from 1 up to 999. 5 | 6 | Rules: 7 | 8 | - Numbers ending in 1 (unless ending in 11) → `"st"` 9 | - Numbers ending in 2 (unless ending in 12) → `"nd"` 10 | - Numbers ending in 3 (unless ending in 13) → `"rd"` 11 | - All other numbers → `"th"` 12 | 13 | Examples: 14 | 15 | - `"Mary", 1` → `"Mary, you are the 1st customer we serve today. Thank you!"` 16 | - `"John", 12` → `"John, you are the 12th customer we serve today. Thank you!"` 17 | - `"Dahir", 162` → `"Dahir, you are the 162nd customer we serve today. Thank you!"` 18 | 19 | [ordinal-numeral]: https://en.wikipedia.org/wiki/Ordinal_numeral 20 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to compute a word's Scrabble score by summing the values of its letters. 4 | 5 | The letters are valued as follows: 6 | 7 | | Letter | Value | 8 | | ---------------------------- | ----- | 9 | | A, E, I, O, U, L, N, R, S, T | 1 | 10 | | D, G | 2 | 11 | | B, C, M, P | 3 | 12 | | F, H, V, W, Y | 4 | 13 | | K | 5 | 14 | | J, X | 8 | 15 | | Q, Z | 10 | 16 | 17 | For example, the word "cabbage" is worth 14 points: 18 | 19 | - 3 points for C 20 | - 1 point for A 21 | - 3 points for B 22 | - 3 points for B 23 | - 1 point for A 24 | - 2 points for G 25 | - 1 point for E 26 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "codingbum", 7 | "mbertheau", 8 | "PurityControl", 9 | "robertpostill", 10 | "sjwarner-bp", 11 | "timotheosh", 12 | "yurrriq" 13 | ], 14 | "files": { 15 | "solution": [ 16 | "perfect-numbers.rkt" 17 | ], 18 | "test": [ 19 | "perfect-numbers-test.rkt" 20 | ], 21 | "example": [ 22 | ".meta/example.rkt" 23 | ] 24 | }, 25 | "blurb": "Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for positive integers.", 26 | "source": "Taken from Chapter 2 of Functional Thinking by Neal Ford.", 27 | "source_url": "https://www.oreilly.com/library/view/functional-thinking/9781449365509/" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "arguello" 4 | ], 5 | "contributors": [ 6 | "cousinitt", 7 | "mbertheau", 8 | "PurityControl", 9 | "robertpostill", 10 | "yurrriq" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "raindrops.rkt" 15 | ], 16 | "test": [ 17 | "raindrops-test.rkt" 18 | ], 19 | "example": [ 20 | ".meta/example.rkt" 21 | ] 22 | }, 23 | "blurb": "Convert a number into its corresponding raindrop sounds - Pling, Plang and Plong.", 24 | "source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division.", 25 | "source_url": "https://en.wikipedia.org/wiki/Fizz_buzz" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Implement the `accumulate` operation, which, given a collection and an 4 | operation to perform on each element of the collection, returns a new 5 | collection containing the result of applying that operation to each element of 6 | the input collection. 7 | 8 | Given the collection of numbers: 9 | 10 | - 1, 2, 3, 4, 5 11 | 12 | And the operation: 13 | 14 | - square a number (`x => x * x`) 15 | 16 | Your code should be able to produce the collection of squares: 17 | 18 | - 1, 4, 9, 16, 25 19 | 20 | Check out the test suite to see the expected function signature. 21 | 22 | ## Restrictions 23 | 24 | Keep your hands off that collect/map/fmap/whatchamacallit functionality 25 | provided by your standard library! 26 | Solve this one yourself using other basic tools instead. 27 | -------------------------------------------------------------------------------- /exercises/practice/flower-field/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to add flower counts to empty squares in a completed Flower Field garden. 4 | The garden itself is a rectangle board composed of squares that are either empty (`' '`) or a flower (`'*'`). 5 | 6 | For each empty square, count the number of flowers adjacent to it (horizontally, vertically, diagonally). 7 | If the empty square has no adjacent flowers, leave it empty. 8 | Otherwise replace it with the count of adjacent flowers. 9 | 10 | For example, you may receive a 5 x 4 board like this (empty spaces are represented here with the '·' character for display on screen): 11 | 12 | ```text 13 | ·*·*· 14 | ··*·· 15 | ··*·· 16 | ····· 17 | ``` 18 | 19 | Which your code should transform into this: 20 | 21 | ```text 22 | 1*3*1 23 | 13*31 24 | ·2*2· 25 | ·111· 26 | ``` 27 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide primes) 4 | 5 | (define (i->p i) 6 | (+ (* 2 i) 3)) 7 | 8 | (define (p->i p) 9 | (quotient (- p 3) 2)) 10 | 11 | (define (cross-out i table) 12 | (let ([p (i->p i)]) 13 | (do 14 | ([i (p->i (* p p)) (+ i p)]) 15 | ((>= i (vector-length table))) 16 | (vector-set! table i #t)))) 17 | 18 | (define (sieve limit) 19 | (let* ([odds (quotient (sub1 limit) 2)] 20 | [crossed-out (make-vector odds #f)]) 21 | (let search ([i 0] [ps '(2)]) 22 | (cond [(= i odds) (reverse ps)] 23 | [(vector-ref crossed-out i) (search (add1 i) ps)] 24 | [else 25 | (begin 26 | (cross-out i crossed-out) 27 | (search (add1 i) (cons (i->p i) ps)))])))) 28 | 29 | 30 | (define (primes limit) 31 | (if (< limit 2) 32 | null 33 | (sieve limit))) 34 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | At a garage sale, you find a lovely vintage typewriter at a bargain price! 4 | Excitedly, you rush home, insert a sheet of paper, and start typing away. 5 | However, your excitement wanes when you examine the output: all words are garbled! 6 | For example, it prints "stop" instead of "post" and "least" instead of "stale." 7 | Carefully, you try again, but now it prints "spot" and "slate." 8 | After some experimentation, you find there is a random delay before each letter is printed, which messes up the order. 9 | You now understand why they sold it for so little money! 10 | 11 | You realize this quirk allows you to generate anagrams, which are words formed by rearranging the letters of another word. 12 | Pleased with your finding, you spend the rest of the day generating hundreds of anagrams. 13 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide nth-prime) 4 | 5 | (define/contract (nth-prime number) 6 | (-> exact-positive-integer? exact-positive-integer?) 7 | (let loop ([candidate 2] 8 | [count 0]) 9 | (cond 10 | [(prime? candidate) 11 | (cond 12 | [(= (add1 count) number) candidate] 13 | [else (loop (add1 candidate) 14 | (add1 count))])] 15 | [else (loop (add1 candidate) 16 | count)]))) 17 | 18 | (define (prime? number) 19 | (cond 20 | [(zero? number) #f] 21 | [(= number 1) #f] 22 | [(= number 2) #t] 23 | [(even? number) #f] 24 | [else 25 | (let loop ([factor 3]) 26 | (cond 27 | [(> (expt factor 2) number) #t] 28 | [(zero? (remainder number factor)) #f] 29 | [else (loop (+ factor 2))]))])) -------------------------------------------------------------------------------- /exercises/practice/bob/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide response-for) 4 | 5 | (define (response-for phrase) 6 | (cond 7 | [(silent? phrase) "Fine. Be that way!"] 8 | [(and (shouting? phrase) 9 | (question? phrase)) "Calm down, I know what I'm doing!"] 10 | [(shouting? phrase) "Whoa, chill out!"] 11 | [(question? phrase) "Sure."] 12 | [else "Whatever."])) 13 | 14 | (define (silent? phrase) 15 | (or (null? phrase) 16 | (equal? (string-normalize-spaces phrase) ""))) 17 | 18 | (define (shouting? phrase) 19 | (and (equal? (string-upcase phrase) phrase) 20 | (ormap (lambda (x) (char-alphabetic? x)) (string->list phrase)))) 21 | 22 | (define (question? phrase) 23 | (let ([trimmed (string-trim phrase)]) 24 | (and (not (string=? trimmed "")) 25 | (char=? #\? (string-ref trimmed (sub1 (string-length trimmed))))))) 26 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [559e789d-07d1-4422-9004-3b699f83bca3] 13 | description = "0 eggs" 14 | 15 | [97223282-f71e-490c-92f0-b3ec9e275aba] 16 | description = "1 egg" 17 | 18 | [1f8fd18f-26e9-4144-9a0e-57cdfc4f4ff5] 19 | description = "4 eggs" 20 | 21 | [0c18be92-a498-4ef2-bcbb-28ac4b06cb81] 22 | description = "13 eggs" 23 | -------------------------------------------------------------------------------- /exercises/practice/square-root/square-root-test.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "square-root.rkt") 4 | 5 | (module+ test 6 | (require rackunit rackunit/text-ui) 7 | 8 | (define suite 9 | (test-suite 10 | "square-root tests" 11 | 12 | (test-eqv? "root of 1" 13 | (square-root 1) 14 | 1) 15 | 16 | (test-eqv? "root of 4" 17 | (square-root 4) 18 | 2) 19 | 20 | (test-eqv? "root of 25" 21 | (square-root 25) 22 | 5) 23 | 24 | (test-eqv? "root of 81" 25 | (square-root 81) 26 | 9) 27 | 28 | (test-eqv? "root of 196" 29 | (square-root 196) 30 | 14) 31 | 32 | (test-eqv? "root of 65025" 33 | (square-root 65025) 34 | 255))) 35 | 36 | (run-tests suite)) 37 | -------------------------------------------------------------------------------- /exercises/practice/bob/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine what Bob will reply to someone when they say something to him or ask him a question. 4 | 5 | Bob only ever answers one of five things: 6 | 7 | - **"Sure."** 8 | This is his response if you ask him a question, such as "How are you?" 9 | The convention used for questions is that it ends with a question mark. 10 | - **"Whoa, chill out!"** 11 | This is his answer if you YELL AT HIM. 12 | The convention used for yelling is ALL CAPITAL LETTERS. 13 | - **"Calm down, I know what I'm doing!"** 14 | This is what he says if you yell a question at him. 15 | - **"Fine. Be that way!"** 16 | This is how he responds to silence. 17 | The convention used for silence is nothing, or various combinations of whitespace characters. 18 | - **"Whatever."** 19 | This is what he answers to anything else. 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | .DS_Store 3 | bin/configlet 4 | bin/configlet.exe 5 | CHECKLIST 6 | 7 | # The "build" and "bundle" directories are used when creating installers 8 | # via the `server', `client', and/or `farm' maefile targets. 9 | /build/ 10 | /bundle/ 11 | 12 | # It's common to configure the PLTADDONDIR to be here. 13 | /add-on/ 14 | 15 | # This is where to put packages installed with `--clone` 16 | /extra-pkgs/ 17 | 18 | # Everything below makes sense on any package repository, so it's 19 | # stuff that should be put into each such repository. The same holds 20 | # for ".mailmap" (which some people can decide if they want to thin it 21 | # out or not include it) and for ".gitattributes" (which is probably 22 | # irrelevant except maybe for the core repo). 23 | 24 | compiled/ 25 | 26 | # common backups, autosaves, lock files, OS meta-files 27 | *~ 28 | \#* 29 | .#* 30 | *.bak 31 | TAGS 32 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide acronym) 4 | 5 | (define (all-upper-case? s) 6 | (equal? s (string-upcase s))) 7 | 8 | (define (all-lower-case? s) 9 | (equal? s (string-downcase s))) 10 | 11 | (define (process-word word) 12 | (define (first-letter s) 13 | (~a (if (zero? (string-length s)) 14 | "" 15 | (char-upcase (string-ref s 0))))) 16 | 17 | (define (filter-caps s) 18 | (list->string (filter char-upper-case? (string->list s)))) 19 | 20 | (cond 21 | [(all-upper-case? word) (first-letter word)] 22 | [(all-lower-case? word) (first-letter word)] 23 | [else (filter-caps word)])) ;; camelcase/mixed case 24 | 25 | (define (acronym str) 26 | (let ([words (string-split str #px"(\\s+)|-")]) 27 | (apply string-append 28 | (for/list ([w (in-list words)]) 29 | (process-word w))))) 30 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You have stumbled upon a group of mathematicians who are also singer-songwriters. 4 | They have written a song for each of their favorite numbers, and, as you can imagine, they have a lot of favorite numbers (like [0][zero] or [73][seventy-three] or [6174][kaprekars-constant]). 5 | 6 | You are curious to hear the song for your favorite number, but with so many songs to wade through, finding the right song could take a while. 7 | Fortunately, they have organized their songs in a playlist sorted by the title — which is simply the number that the song is about. 8 | 9 | You realize that you can use a binary search algorithm to quickly find a song given the title. 10 | 11 | [zero]: https://en.wikipedia.org/wiki/0 12 | [seventy-three]: https://en.wikipedia.org/wiki/73_(number) 13 | [kaprekars-constant]: https://en.wikipedia.org/wiki/6174_(number) 14 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide balanced?) 4 | 5 | (define (balanced? str) 6 | (let* ([open->closed? (lambda (close-char expected-open) 7 | (match (~a close-char) 8 | [")" (equal? expected-open "(")] 9 | ["]" (equal? expected-open "[")] 10 | ["}" (equal? expected-open "{")] 11 | [_ #t]))] 12 | 13 | [m? (lambda (c a) 14 | (case (~a c) 15 | [("(" "[" "{") (cons (~a c) a)] 16 | [(")" "]" "}") (case a 17 | [(() #f) #f] 18 | [else (if (open->closed? c (car a)) (cdr a) #f)])] 19 | [else a]) 20 | )]) 21 | 22 | (equal? (foldl m? '() (string->list str)) '()) 23 | 24 | )) 25 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [49eb31c5-10a8-4180-9f7f-fea632ab87ef] 13 | description = "Color codes -> Black" 14 | 15 | [0a4df94b-92da-4579-a907-65040ce0b3fc] 16 | description = "Color codes -> White" 17 | 18 | [5f81608d-f36f-4190-8084-f45116b6f380] 19 | description = "Color codes -> Orange" 20 | 21 | [581d68fa-f968-4be2-9f9d-880f2fb73cf7] 22 | description = "Colors" 23 | -------------------------------------------------------------------------------- /exercises/practice/space-age/space-age.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide on-mercury 4 | on-venus 5 | on-earth 6 | on-mars 7 | on-jupiter 8 | on-saturn 9 | on-uranus 10 | on-neptune) 11 | 12 | (define (on-mercury seconds) 13 | (error "Please implement 'on-mercury'")) 14 | 15 | (define (on-venus seconds) 16 | (error "Please implement 'on-venus'")) 17 | 18 | (define (on-earth seconds) 19 | (error "Please implement 'on-earth'")) 20 | 21 | (define (on-mars seconds) 22 | (error "Please implement 'on-mars'")) 23 | 24 | (define (on-jupiter seconds) 25 | (error "Please implement 'on-jupiter'")) 26 | 27 | (define (on-saturn seconds) 28 | (error "Please implement 'on-saturn'")) 29 | 30 | (define (on-uranus seconds) 31 | (error "Please implement 'on-uranus'")) 32 | 33 | (define (on-neptune seconds) 34 | (error "Please implement 'on-neptune'")) 35 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | For want of a horseshoe nail, a kingdom was lost, or so the saying goes. 4 | 5 | Given a list of inputs, generate the relevant proverb. 6 | For example, given the list `["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"]`, you will output the full text of this proverbial rhyme: 7 | 8 | ```text 9 | For want of a nail the shoe was lost. 10 | For want of a shoe the horse was lost. 11 | For want of a horse the rider was lost. 12 | For want of a rider the message was lost. 13 | For want of a message the battle was lost. 14 | For want of a battle the kingdom was lost. 15 | And all for the want of a nail. 16 | ``` 17 | 18 | Note that the list of inputs may vary; your solution should be able to handle lists of arbitrary length and content. 19 | No line of the output text should be a static, unchanging string; all should vary according to the input given. 20 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The Zebra Puzzle is a famous logic puzzle in which there are five houses, each painted a different color. 4 | The houses have different inhabitants, who have different nationalities, own different pets, drink different beverages and enjoy different hobbies. 5 | 6 | To help you solve the puzzle, you're given 15 statements describing the solution. 7 | However, only by combining the information in _all_ statements will you be able to find the solution to the puzzle. 8 | 9 | ~~~~exercism/note 10 | The Zebra Puzzle is a [Constraint satisfaction problem (CSP)][constraint-satisfaction-problem]. 11 | In such a problem, you have a set of possible values and a set of constraints that limit which values are valid. 12 | Another well-known CSP is Sudoku. 13 | 14 | [constraint-satisfaction-problem]: https://en.wikipedia.org/wiki/Constraint_satisfaction_problem 15 | ~~~~ 16 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/difference-of-squares-test.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "difference-of-squares.rkt") 4 | 5 | (module+ test 6 | (require rackunit rackunit/text-ui) 7 | 8 | (define suite 9 | (test-suite 10 | "difference of squares" 11 | 12 | (test-eqv? "square-of-sum-to-5" (square-of-sum 5) 225) 13 | (test-eqv? "sum-of-squares-to-5" (sum-of-squares 5) 55) 14 | (test-eqv? "difference-of-squares-to-5" (difference 5) 170) 15 | (test-eqv? "square-of-sum-to-10" (square-of-sum 10) 3025) 16 | (test-eqv? "sum-of-squares-to-10" (sum-of-squares 10) 385) 17 | (test-eqv? "difference-of-squares-to-10" (difference 10) 2640) 18 | (test-eqv? "square-of-sum-to-100" (square-of-sum 100) 25502500) 19 | (test-eqv? "sum-of-squares-to-100" (sum-of-squares 100) 338350) 20 | (test-eqv? "difference-of-squares-to-100" (difference 100) 25164150))) 21 | 22 | (run-tests suite)) 23 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide convert) 4 | 5 | (define (convert n) 6 | (let ([drops ""] 7 | (factors (filter (lambda (v) 8 | (and (>= v 3) (<= v 7))) 9 | (prime-factors n)))) 10 | (if (not (null? factors)) 11 | (begin 12 | (when (member 3 factors) 13 | (set! drops (string-append drops "Pling"))) 14 | (when (member 5 factors) 15 | (set! drops (string-append drops "Plang"))) 16 | (when (member 7 factors) 17 | (set! drops (string-append drops "Plong")))) 18 | (set! drops (string-append drops (number->string n)))) 19 | drops)) 20 | 21 | (define (prime-factors n) 22 | (let loop ([n n] [m 2] [factors '()]) 23 | (cond [(= n 1) factors] 24 | [(= 0 (modulo n m)) (loop (/ n m) 2 (cons m factors))] 25 | [else (loop n (+ 1 m) factors)]))) 26 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/resistor-color-test.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | ; Tests adapted from `problem-specifications/canonical-data.json v1.1.0 4 | (require "resistor-color.rkt") 5 | 6 | (module+ test 7 | (require rackunit rackunit/text-ui) 8 | 9 | (run-tests 10 | (test-suite "resistor-color tests" 11 | (test-equal? "Color codes -> Black" 12 | (color-code "black") 13 | 0) 14 | (test-equal? "Color codes -> White" 15 | (color-code "white") 16 | 9) 17 | (test-equal? "Color codes -> Orange" 18 | (color-code "orange") 19 | 3) 20 | (test-equal? "Colors" 21 | (colors) 22 | '("black" "brown" "red" "orange" "yellow" "green" "blue" "violet" "grey" "white"))))) 23 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide on-mercury 4 | on-venus 5 | on-earth 6 | on-mars 7 | on-jupiter 8 | on-saturn 9 | on-uranus 10 | on-neptune) 11 | 12 | (define-values (earth-seconds) 31557600) 13 | 14 | (define (get-local-age seconds ratio) (/ seconds (* earth-seconds ratio))) 15 | 16 | (define (on-mercury seconds) (get-local-age seconds 0.2408467)) 17 | 18 | (define (on-venus seconds) (get-local-age seconds 0.61519726)) 19 | 20 | (define (on-earth seconds) (get-local-age seconds 1)) 21 | 22 | (define (on-mars seconds) (get-local-age seconds 1.8808158)) 23 | 24 | (define (on-jupiter seconds) (get-local-age seconds 11.862615)) 25 | 26 | (define (on-saturn seconds) (get-local-age seconds 29.447498)) 27 | 28 | (define (on-uranus seconds) (get-local-age seconds 84.016846)) 29 | 30 | (define (on-neptune seconds) (get-local-age seconds 164.79132)) 31 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide spiral-matrix) 4 | 5 | (define (extract-row r coord) 6 | (let* ([row (filter (λ (c) (= (caar c) r)) coord)] 7 | [sorted-row (sort row < #:key cdar)]) 8 | (map cdr sorted-row))) 9 | 10 | (define (take-step x y dx dy n h) 11 | (let ([x1 (+ x dx)] [y1 (+ y dy)]) 12 | (if (or (negative? x1) (negative? y1) 13 | (= x1 n) (= y1 n) (hash-has-key? h (cons y1 x1))) 14 | (values (- x dy) (+ y dx) (- dy) dx) 15 | (values x1 y1 dx dy)))) 16 | 17 | (define (coordinates n) 18 | (let ([h (make-hash)]) 19 | (for/fold 20 | ([x 0] [y 0] [dx 1] [dy 0] #:result (hash->list h)) 21 | ([i (in-inclusive-range 1 (* n n))]) 22 | (hash-set! h (cons y x) i) 23 | (take-step x y dx dy n h)))) 24 | 25 | (define (spiral-matrix n) 26 | (let ([coord (coordinates n)]) 27 | (for/list ([i (in-range n)]) 28 | (extract-row i coord)))) 29 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a target word and one or more candidate words, your task is to find the candidates that are anagrams of the target. 4 | 5 | An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`. 6 | A word is _not_ its own anagram: for example, `"stop"` is not an anagram of `"stop"`. 7 | 8 | The target word and candidate words are made up of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`). 9 | Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `"StoP"` is not an anagram of `"sTOp"`. 10 | The words you need to find should be taken from the candidate words, using the same letter case. 11 | 12 | Given the target `"stone"` and the candidate words `"stone"`, `"tones"`, `"banana"`, `"tons"`, `"notes"`, and `"Seton"`, the anagram words you need to find are `"tones"`, `"notes"`, and `"Seton"`. 13 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Write a robot simulator. 4 | 5 | A robot factory's test facility needs a program to verify robot movements. 6 | 7 | The robots have three possible movements: 8 | 9 | - turn right 10 | - turn left 11 | - advance 12 | 13 | Robots are placed on a hypothetical infinite grid, facing a particular direction (north, east, south, or west) at a set of {x,y} coordinates, 14 | e.g., {3,8}, with coordinates increasing to the north and east. 15 | 16 | The robot then receives a number of instructions, at which point the testing facility verifies the robot's new position, and in which direction it is pointing. 17 | 18 | - The letter-string "RAALAL" means: 19 | - Turn right 20 | - Advance twice 21 | - Turn left 22 | - Advance once 23 | - Turn left yet again 24 | - Say a robot starts at {7, 3} facing north. 25 | Then running this stream of instructions should leave it at {9, 4} facing west. 26 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine which items to take so that the total value of her selection is maximized, taking into account the knapsack's carrying capacity. 4 | 5 | Items will be represented as a list of items. 6 | Each item will have a weight and value. 7 | All values given will be strictly positive. 8 | Lhakpa can take only one of each item. 9 | 10 | For example: 11 | 12 | ```text 13 | Items: [ 14 | { "weight": 5, "value": 10 }, 15 | { "weight": 4, "value": 40 }, 16 | { "weight": 6, "value": 30 }, 17 | { "weight": 4, "value": 50 } 18 | ] 19 | 20 | Knapsack Maximum Weight: 10 21 | ``` 22 | 23 | For the above, the first item has weight 5 and value 10, the second item has weight 4 and value 40, and so on. 24 | In this example, Lhakpa should take the second and fourth item to maximize her value, which, in this case, is 90. 25 | She cannot get more than 90 as her knapsack has a weight limit of 10. 26 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [78a7a9f9-4490-4a47-8ee9-5a38bb47d28f] 13 | description = "single letter" 14 | 15 | [60dbd000-451d-44c7-bdbb-97c73ac1f497] 16 | description = "single score with multiple letters" 17 | 18 | [f5c5de0c-301f-4fdd-a0e5-df97d4214f54] 19 | description = "multiple scores with multiple letters" 20 | 21 | [5db8ea89-ecb4-4dcd-902f-2b418cc87b9d] 22 | description = "multiple scores with differing numbers of letters" 23 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide encode decode) 4 | 5 | (define (add-run len c code) 6 | (cond [(zero? len) code] 7 | [(= 1 len) (string-append code (string c))] 8 | [else (string-append code (~a len) (string c))])) 9 | 10 | (define (encode text) 11 | (for/fold ([run-length 0] 12 | [lastc #\?] 13 | [code ""] 14 | #:result (add-run run-length lastc code)) 15 | ([c (in-string text)]) 16 | (if (char=? c lastc) 17 | (values (add1 run-length) c code) 18 | (values 1 c (add-run run-length lastc code))))) 19 | 20 | (define (expand-run run-spec) 21 | (let ([run-length (if (non-empty-string? (first run-spec)) 22 | (string->number (first run-spec)) 23 | 1)]) 24 | (make-string run-length (string-ref (second run-spec) 0)))) 25 | 26 | (define (decode code) 27 | (let ([runs (regexp-match* #px"(\\d*)(.)" #:match-select cdr code)]) 28 | (string-append* (map expand-run runs)))) 29 | -------------------------------------------------------------------------------- /exercises/practice/etl/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a company that makes an online multiplayer game called Lexiconia. 4 | 5 | To play the game, each player is given 13 letters, which they must rearrange to create words. 6 | Different letters have different point values, since it's easier to create words with some letters than others. 7 | 8 | The game was originally launched in English, but it is very popular, and now the company wants to expand to other languages as well. 9 | 10 | Different languages need to support different point values for letters. 11 | The point values are determined by how often letters are used, compared to other letters in that language. 12 | 13 | For example, the letter 'C' is quite common in English, and is only worth 3 points. 14 | But in Norwegian it's a very rare letter, and is worth 10 points. 15 | 16 | To make it easier to add new languages, your team needs to change the way letters and their point values are stored in the game. 17 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Implement run-length encoding and decoding. 4 | 5 | Run-length encoding (RLE) is a simple form of data compression, where runs (consecutive data elements) are replaced by just one data value and count. 6 | 7 | For example we can represent the original 53 characters with only 13. 8 | 9 | ```text 10 | "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" -> "12WB12W3B24WB" 11 | ``` 12 | 13 | RLE allows the original data to be perfectly reconstructed from the compressed data, which makes it a lossless data compression. 14 | 15 | ```text 16 | "AABCCCDEEEE" -> "2AB3CD4E" -> "AABCCCDEEEE" 17 | ``` 18 | 19 | For simplicity, you can assume that the unencoded string will only contain the letters A through Z (either lower or upper case) and whitespace. 20 | This way data to be encoded will never contain any numbers and numbers inside data to be decoded always represent the count for the following character. 21 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [75c65189-8aef-471a-81de-0a90c728160c] 13 | description = "first prime" 14 | 15 | [2c38804c-295f-4701-b728-56dea34fd1a0] 16 | description = "second prime" 17 | 18 | [56692534-781e-4e8c-b1f9-3e82c1640259] 19 | description = "sixth prime" 20 | 21 | [fce1e979-0edb-412d-93aa-2c744e8f50ff] 22 | description = "big prime" 23 | 24 | [bd0a9eae-6df7-485b-a144-80e13c7d55b2] 25 | description = "there is no zeroth prime" 26 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to calculate the square root of a given number. 4 | 5 | - Try to avoid using the pre-existing math libraries of your language. 6 | - As input you'll be given a positive whole number, i.e. 1, 2, 3, 4… 7 | - You are only required to handle cases where the result is a positive whole number. 8 | 9 | Some potential approaches: 10 | 11 | - Linear or binary search for a number that gives the input number when squared. 12 | - Successive approximation using Newton's or Heron's method. 13 | - Calculating one digit at a time or one bit at a time. 14 | 15 | You can check out the Wikipedia pages on [integer square root][integer-square-root] and [methods of computing square roots][computing-square-roots] to help with choosing a method of calculation. 16 | 17 | [integer-square-root]: https://en.wikipedia.org/wiki/Integer_square_root 18 | [computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots 19 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Convert a sequence of digits in one base, representing a number, into a sequence of digits in another base, representing the same number. 4 | 5 | ~~~~exercism/note 6 | Try to implement the conversion yourself. 7 | Do not use something else to perform the conversion for you. 8 | ~~~~ 9 | 10 | ## About [Positional Notation][positional-notation] 11 | 12 | In positional notation, a number in base **b** can be understood as a linear combination of powers of **b**. 13 | 14 | The number 42, _in base 10_, means: 15 | 16 | `(4 × 10¹) + (2 × 10⁰)` 17 | 18 | The number 101010, _in base 2_, means: 19 | 20 | `(1 × 2⁵) + (0 × 2⁴) + (1 × 2³) + (0 × 2²) + (1 × 2¹) + (0 × 2⁰)` 21 | 22 | The number 1120, _in base 3_, means: 23 | 24 | `(1 × 3³) + (1 × 3²) + (2 × 3¹) + (0 × 3⁰)` 25 | 26 | _Yes. Those three numbers above are exactly the same. Congratulations!_ 27 | 28 | [positional-notation]: https://en.wikipedia.org/wiki/Positional_notation 29 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/list-ops.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide my-append 4 | my-concatenate 5 | my-filter 6 | my-length 7 | my-map 8 | my-foldl 9 | my-foldr 10 | my-reverse) 11 | 12 | (define (my-append sequence1 sequence2) 13 | (error "Please implement 'my-append'")) 14 | 15 | (define (my-concatenate sequence-of-sequences) 16 | (error "Please implement 'my-concatenate'")) 17 | 18 | (define (my-filter pred sequence) 19 | (error "Please implement 'my-filter'")) 20 | 21 | (define (my-length sequence) 22 | (error "Please implement 'my-length'")) 23 | 24 | (define (my-map operation sequence) 25 | (error "Please implement 'my-map'")) 26 | 27 | (define (my-foldl operation accumulator sequence) 28 | (error "Please implement 'my-foldl'")) 29 | 30 | (define (my-foldr operation accumulator sequence) 31 | (error "Please implement 'my-foldr'")) 32 | 33 | (define (my-reverse sequence) 34 | (error "Please implement 'my-reverse'")) 35 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [88529125-c4ce-43cc-bb36-1eb4ddd7b44f] 13 | description = "no primes under two" 14 | 15 | [4afe9474-c705-4477-9923-840e1024cc2b] 16 | description = "find first prime" 17 | 18 | [974945d8-8cd9-4f00-9463-7d813c7f17b7] 19 | description = "find primes up to 10" 20 | 21 | [2e2417b7-3f3a-452a-8594-b9af08af6d82] 22 | description = "limit is prime" 23 | 24 | [92102a05-4c7c-47de-9ed0-b7d5fcd00f21] 25 | description = "find primes up to 1000" 26 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/nucleotide-count-test.rkt: -------------------------------------------------------------------------------- 1 | #lang racket/base 2 | 3 | (require "nucleotide-count.rkt") 4 | 5 | (module+ test 6 | (require rackunit rackunit/text-ui) 7 | 8 | (define suite 9 | (test-suite 10 | "nucleotide count tests" 11 | 12 | (test-equal? "empty dna strand has no nucleotides" 13 | (nucleotide-counts "") 14 | '((#\A . 0) (#\C . 0) (#\G . 0) (#\T . 0))) 15 | 16 | (test-equal? "repetitive sequence has only guanine" 17 | (nucleotide-counts "GGGGGGGG") 18 | '((#\A . 0) (#\C . 0) (#\G . 8) (#\T . 0))) 19 | 20 | (test-equal? "counts all nucleotides" 21 | (nucleotide-counts 22 | "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC") 23 | '((#\A . 20) (#\C . 12) (#\G . 17) (#\T . 21))) 24 | 25 | (test-exn "invalid nucleotide" exn:fail? (lambda () (nucleotide-counts "AGGTCCXGA"))))) 26 | 27 | (run-tests suite)) 28 | -------------------------------------------------------------------------------- /bin/check-exercises.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -e 4 | 5 | cd exercises/practice 6 | 7 | for exercise in *; do 8 | if [ -d "$exercise" ]; then 9 | if [ -f "$exercise/$exercise"-test.rkt ]; then 10 | if [ -f "$exercise/$exercise".rkt ]; then 11 | mv "$exercise/$exercise".rkt "$exercise/$exercise".rkt_ 12 | else 13 | echo "$exercise needs a stub!" 14 | fi 15 | mv "$exercise"/.meta/example.rkt "$exercise/$exercise".rkt 16 | fi 17 | fi 18 | done 19 | 20 | raco test -x --jobs 5 -Q --table . 21 | SUCCESS=$? 22 | 23 | for exercise in *; do 24 | if [ -d "$exercise" ]; then 25 | if [ -f "$exercise/$exercise"-test.rkt ]; then 26 | mv "$exercise/$exercise".rkt "$exercise"/.meta/example.rkt 27 | if [ -f "$exercise/$exercise".rkt_ ]; then 28 | mv "$exercise/$exercise".rkt_ "$exercise/$exercise".rkt 29 | fi 30 | fi 31 | fi 32 | done 33 | 34 | if [ $SUCCESS -ne 0 ]; then 35 | exit $SUCCESS 36 | fi 37 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [64d97c14-36dd-44a8-9621-2cecebd6ed23] 13 | description = "accumulate empty" 14 | 15 | [00008ed2-4651-4929-8c08-8b4dbd70872e] 16 | description = "accumulate squares" 17 | 18 | [551016da-4396-4cae-b0ec-4c3a1a264125] 19 | description = "accumulate upcases" 20 | 21 | [cdf95597-b6ec-4eac-a838-3480d13d0d05] 22 | description = "accumulate reversed strings" 23 | 24 | [bee8e9b6-b16f-4cd2-be3b-ccf7457e50bb] 25 | description = "accumulate recursively" 26 | -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": [ 4 | "BNAndras" 5 | ] 6 | }, 7 | "approaches": [ 8 | { 9 | "uuid": "b163b6d5-92ed-4073-8169-03e2a1b09fab", 10 | "slug": "boolean-chain", 11 | "title": "Boolean chain", 12 | "blurb": "Use operators to check boolean values in a chain", 13 | "authors": [ 14 | "BNAndras" 15 | ] 16 | }, 17 | { 18 | "uuid": "22229478-54ce-48ec-867f-1adcf04c42ac", 19 | "slug": "cond-form", 20 | "title": "Cond", 21 | "blurb": "Use the cond form to check boolean values sequentially.", 22 | "authors": [ 23 | "BNAndras" 24 | ] 25 | }, 26 | { 27 | "uuid": "45f28b96-4803-424c-9973-f2b4445f7227", 28 | "slug": "pattern-matching", 29 | "title": "Pattern matching", 30 | "blurb": "Use the match form to check a list of boolean values at once.", 31 | "authors": [ 32 | "BNAndras" 33 | ] 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide to-roman) 4 | 5 | (define (to-roman num) 6 | (cond ((>= num 1000) (string-append "M" (to-roman (- num 1000)))) 7 | ((>= num 900) (string-append "CM" (to-roman (- num 900)))) 8 | ((>= num 500) (string-append "D" (to-roman (- num 500)))) 9 | ((>= num 400) (string-append "CD" (to-roman (- num 400)))) 10 | ((>= num 100) (string-append "C" (to-roman (- num 100)))) 11 | ((>= num 90) (string-append "XC" (to-roman (- num 90)))) 12 | ((>= num 50) (string-append "L" (to-roman (- num 50)))) 13 | ((>= num 40) (string-append "XL" (to-roman (- num 40)))) 14 | ((>= num 10) (string-append "X" (to-roman (- num 10)))) 15 | ((>= num 9) (string-append "IX" (to-roman (- num 9)))) 16 | ((>= num 5) (string-append "V" (to-roman (- num 5)))) 17 | ((>= num 4) (string-append "IV" (to-roman (- num 4)))) 18 | ((>= num 1) (string-append "I" (to-roman (- num 1)))) 19 | (else ""))) -------------------------------------------------------------------------------- /exercises/practice/etl/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to change the data format of letters and their point values in the game. 4 | 5 | Currently, letters are stored in groups based on their score, in a one-to-many mapping. 6 | 7 | - 1 point: "A", "E", "I", "O", "U", "L", "N", "R", "S", "T", 8 | - 2 points: "D", "G", 9 | - 3 points: "B", "C", "M", "P", 10 | - 4 points: "F", "H", "V", "W", "Y", 11 | - 5 points: "K", 12 | - 8 points: "J", "X", 13 | - 10 points: "Q", "Z", 14 | 15 | This needs to be changed to store each individual letter with its score in a one-to-one mapping. 16 | 17 | - "a" is worth 1 point. 18 | - "b" is worth 3 points. 19 | - "c" is worth 3 points. 20 | - "d" is worth 2 points. 21 | - etc. 22 | 23 | As part of this change, the team has also decided to change the letters to be lower-case rather than upper-case. 24 | 25 | ~~~~exercism/note 26 | If you want to look at how the data was previously structured and how it needs to change, take a look at the examples in the test suite. 27 | ~~~~ 28 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide proteins) 4 | 5 | (define (empty-string? str) ((negate non-empty-string?) str)) 6 | (define (string-length-3? str) (and (string? str) (= (string-length str) 3))) 7 | 8 | (define/contract (unsafe-translate protein) 9 | (string-length-3? . -> . string?) 10 | (case protein 11 | [("AUG") "Methionine"] 12 | [("UUU" "UUC") "Phenylalanine"] 13 | [("UUA" "UUG") "Leucine"] 14 | [("UCU" "UCC" "UCA" "UCG") "Serine"] 15 | [("UAU" "UAC") "Tyrosine"] 16 | [("UGU" "UGC") "Cysteine"] 17 | [("UGG") "Tryptophan"] 18 | [("UAA" "UAG" "UGA") ""] 19 | [else (error "Invalid codon")])) 20 | 21 | (define (proteins strand) 22 | (define (codon) (unsafe-translate (substring strand 0 3))) 23 | (cond 24 | [(zero? (string-length strand)) '()] 25 | [(< (string-length strand) 3) (error "Incomplete RNA sequence can't translate")] 26 | [else (cond [(empty-string? (codon)) '()] 27 | [else (cons (codon) (proteins (substring strand 3)))])])) 28 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [9b748478-7b0a-490c-b87a-609dacf631fd] 13 | description = "root of 1" 14 | 15 | [7d3aa9ba-9ac6-4e93-a18b-2e8b477139bb] 16 | description = "root of 4" 17 | 18 | [6624aabf-3659-4ae0-a1c8-25ae7f33c6ef] 19 | description = "root of 25" 20 | 21 | [93beac69-265e-4429-abb1-94506b431f81] 22 | description = "root of 81" 23 | 24 | [fbddfeda-8c4f-4bc4-87ca-6991af35360e] 25 | description = "root of 196" 26 | 27 | [c03d0532-8368-4734-a8e0-f96a9eb7fc1d] 28 | description = "root of 65025" 29 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [e974b73e-7851-484f-8d6d-92e07fe742fc] 13 | description = "zero pieces" 14 | 15 | [2fcd5f5e-8b82-4e74-b51d-df28a5e0faa4] 16 | description = "one piece" 17 | 18 | [d9d0a8a1-d933-46e2-aa94-eecf679f4b0e] 19 | description = "two pieces" 20 | 21 | [c95ef757-5e94-4f0d-a6cb-d2083f5e5a83] 22 | description = "three pieces" 23 | 24 | [433fb91c-35a2-4d41-aeab-4de1e82b2126] 25 | description = "full proverb" 26 | 27 | [c1eefa5a-e8d9-41c7-91d4-99fab6d6b9f7] 28 | description = "four pieces modernized" 29 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to convert a number into its corresponding raindrop sounds. 4 | 5 | If a given number: 6 | 7 | - is divisible by 3, add "Pling" to the result. 8 | - is divisible by 5, add "Plang" to the result. 9 | - is divisible by 7, add "Plong" to the result. 10 | - **is not** divisible by 3, 5, or 7, the result should be the number as a string. 11 | 12 | ## Examples 13 | 14 | - 28 is divisible by 7, but not 3 or 5, so the result would be `"Plong"`. 15 | - 30 is divisible by 3 and 5, but not 7, so the result would be `"PlingPlang"`. 16 | - 34 is not divisible by 3, 5, or 7, so the result would be `"34"`. 17 | 18 | ~~~~exercism/note 19 | A common way to test if one number is evenly divisible by another is to compare the [remainder][remainder] or [modulus][modulo] to zero. 20 | Most languages provide operators or functions for one (or both) of these. 21 | 22 | [remainder]: https://exercism.org/docs/programming/operators/remainder 23 | [modulo]: https://en.wikipedia.org/wiki/Modulo_operation 24 | ~~~~ 25 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide (struct-out character) 4 | ability 5 | make-character 6 | modifier) 7 | 8 | (struct character 9 | (strength dexterity constitution intelligence wisdom charisma hitpoints)) 10 | 11 | (define (ability) 12 | (define (dice-rolls n) 13 | (for/list ([i n]) 14 | (add1 (random 6)))) 15 | (define (drop-lowest lst) 16 | (cdr (sort lst <))) 17 | (define (total-score n) 18 | (define dice (dice-rolls n)) 19 | (for/sum ([i (drop-lowest dice)]) 20 | i)) 21 | (total-score 4)) 22 | 23 | (define (modifier value) 24 | (floor (/ (- value 10) 2))) 25 | 26 | (define (make-character) 27 | (define strength (ability)) 28 | (define dexterity (ability)) 29 | (define constitution (ability)) 30 | (define intelligence (ability)) 31 | (define wisdom (ability)) 32 | (define charisma (ability)) 33 | (define hitpoints (+ (modifier constitution) 10)) 34 | (character strength dexterity constitution intelligence wisdom charisma hitpoints)) 35 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [3e5c30a8-87e2-4845-a815-a49671ade970] 13 | description = "empty strand" 14 | 15 | [a0ea42a6-06d9-4ac6-828c-7ccaccf98fec] 16 | description = "can count one nucleotide in single-character input" 17 | 18 | [eca0d565-ed8c-43e7-9033-6cefbf5115b5] 19 | description = "strand with repeated nucleotide" 20 | 21 | [40a45eac-c83f-4740-901a-20b22d15a39f] 22 | description = "strand with multiple nucleotides" 23 | 24 | [b4c47851-ee9e-4b0a-be70-a86e343bd851] 25 | description = "strand with invalid nucleotides" 26 | -------------------------------------------------------------------------------- /.appends/.github/labels.yml: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------------------- # 2 | # These are the repository-specific labels that augment the Exercise-wide labels defined in # 3 | # https://github.com/exercism/org-wide-files/blob/main/global-files/.github/labels.yml. # 4 | # ----------------------------------------------------------------------------------------- # 5 | 6 | - name: "bug" 7 | description: "" 8 | color: "fc2929" 9 | 10 | - name: "duplicate" 11 | description: "" 12 | color: "cccccc" 13 | 14 | - name: "enhancement" 15 | description: "" 16 | color: "84b6eb" 17 | 18 | - name: "first-timers only" 19 | description: "" 20 | color: "159818" 21 | 22 | - name: "good first patch" 23 | description: "" 24 | color: "159818" 25 | 26 | - name: "help wanted" 27 | description: "" 28 | color: "159818" 29 | 30 | - name: "invalid" 31 | description: "" 32 | color: "e6e6e6" 33 | 34 | - name: "question" 35 | description: "" 36 | color: "cc317c" 37 | 38 | - name: "wontfix" 39 | description: "" 40 | color: "ffffff" 41 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/.meta/example.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | (provide calculate-frequencies) 4 | 5 | (require racket/hash) 6 | 7 | (define (chunk texts) 8 | (let* ([all-text (string-downcase (string-join texts " "))] 9 | [chunk-size 64] 10 | [nchunk (ceiling (/ (string-length all-text) chunk-size))]) 11 | (for/list ([i (in-range nchunk)]) 12 | (let* ([start (* i chunk-size)] 13 | [size (min chunk-size (- (string-length all-text) start))] 14 | [stop (+ start size)]) 15 | (substring all-text start stop))))) 16 | 17 | (define (count-letters text) 18 | (let [(h (make-hash))] 19 | (for ([c (string->list text)] 20 | #:when (char-alphabetic? c)) 21 | (hash-set! h c (add1 (hash-ref h c 0)))) 22 | h)) 23 | 24 | (define (calculate-frequencies texts) 25 | (let ([pieces (chunk texts)] 26 | [counts (make-hash)]) 27 | (for/async ([piece pieces]) 28 | (hash-union! counts (count-letters piece) 29 | #:combine/key (λ (k c1 c2) (+ c1 c2)))) 30 | counts)) 31 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [8f584201-b446-4bc9-b132-811c8edd9040] 13 | description = "empty spiral" 14 | 15 | [e40ae5f3-e2c9-4639-8116-8a119d632ab2] 16 | description = "trivial spiral" 17 | 18 | [cf05e42d-eb78-4098-a36e-cdaf0991bc48] 19 | description = "spiral of size 2" 20 | 21 | [1c475667-c896-4c23-82e2-e033929de939] 22 | description = "spiral of size 3" 23 | 24 | [05ccbc48-d891-44f5-9137-f4ce462a759d] 25 | description = "spiral of size 4" 26 | 27 | [f4d2165b-1738-4e0c-bed0-c459045ae50d] 28 | description = "spiral of size 5" 29 | --------------------------------------------------------------------------------