├── .appends └── .github │ └── labels.yml ├── .editorconfig ├── .github ├── CODEOWNERS ├── dependabot.yml ├── labels.yml └── workflows │ ├── configlet.yml │ ├── sync-labels.yml │ └── tests.yml ├── .gitignore ├── .markdownlint.yaml ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── _test ├── WINDOWS_README.md ├── cargo_clean_all.sh ├── check_exercise_crate.sh ├── check_exercises.sh ├── check_exercises_for_authors.sh ├── check_uuids.sh ├── count_ignores.sh ├── ensure_lib_src_rs_exist.sh ├── ensure_stubs_compile.sh └── verify_exercise_difficulties.sh ├── bin ├── build_exercise_crate.sh ├── clean_topics_vs_practices.py ├── fetch-configlet ├── format_exercises ├── lint_markdown.sh ├── lint_tool_file_names.sh ├── lint_trailing_spaces.sh └── test-exercise ├── concepts ├── booleans │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── box │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── char │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── collect │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── destructuring │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── entry-api │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── enums │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── external-crates │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── floating-point-numbers │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── fold │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── functions │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── hashmap │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── integers │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── iterators │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── loops │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── match-basics │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── methods │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── mutability │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── option │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── planned ├── references │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── string-slices │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── string-vs-str │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── strings │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── structs │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── tuples │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── vec-macro │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json └── vec-stack │ ├── .meta │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── config.json ├── docs ├── ABOUT.md ├── CONTRIBUTING.md ├── INSTALLATION.md ├── LEARNING.md ├── RESOURCES.md ├── SNIPPET.txt ├── TESTS.md ├── archived │ ├── README.md │ ├── exercise-concepts │ │ ├── armstrong-numbers.md │ │ ├── decimal.md │ │ ├── leap.md │ │ ├── luhn.md │ │ ├── macros.md │ │ ├── paasio.md │ │ ├── parallel-letter-frequency.md │ │ ├── poker.md │ │ └── robot-simulator.md │ ├── merge-strategy.md │ ├── out-of-scope.md │ └── problem_ordering.md ├── config.json └── maintaining.md ├── exercises ├── concept │ ├── assembly-line │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── design.md │ │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── assembly-line.rs │ ├── csv-builder │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── design.md │ │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── csv-builder.rs │ ├── health-statistics │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── design.md │ │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── health-statistics.rs │ ├── low-power-embedded-game │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── design.md │ │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── low-power-embedded-game.rs │ ├── lucians-luscious-lasagna │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── design.md │ │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── lucians-luscious-lasagna.rs │ ├── magazine-cutout │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── design.md │ │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── magazine-cutout.rs │ ├── resistor-color │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── resistor-color.rs │ ├── role-playing-game │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── design.md │ │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── role-playing-game.rs │ ├── rpn-calculator │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── design.md │ │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── rpn-calculator.rs │ ├── semi-structured-logs │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── design.md │ │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── semi-structured-logs.rs │ └── short-fibonacci │ │ ├── .docs │ │ ├── hints.md │ │ ├── instructions.md │ │ └── introduction.md │ │ ├── .gitignore │ │ ├── .meta │ │ ├── config.json │ │ ├── design.md │ │ └── exemplar.rs │ │ ├── Cargo.toml │ │ ├── src │ │ └── lib.rs │ │ └── tests │ │ └── short-fibonacci.rs ├── practice │ ├── accumulate │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── accumulate.rs │ ├── acronym │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── acronym.rs │ ├── affine-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── affine-cipher.rs │ ├── all-your-base │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── all-your-base.rs │ ├── allergies │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── allergies.rs │ ├── alphametics │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── Cargo-example.toml │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── alphametics.rs │ ├── anagram │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── anagram.rs │ ├── armstrong-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── armstrong-numbers.rs │ ├── atbash-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── atbash-cipher.rs │ ├── beer-song │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── beer-song.rs │ ├── binary-search │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── binary-search.rs │ ├── bob │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── bob.rs │ ├── book-store │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── Cargo-example.toml │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── book-store.rs │ ├── bowling │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── bowling.rs │ ├── circular-buffer │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── circular-buffer.rs │ ├── clock │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── clock.rs │ ├── collatz-conjecture │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── collatz-conjecture.rs │ ├── crypto-square │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── Cargo-example.toml │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── crypto-square.rs │ ├── custom-set │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── custom-set.rs │ ├── decimal │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── Cargo-example.toml │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── decimal.rs │ ├── diamond │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── diamond.rs │ ├── difference-of-squares │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── difference-of-squares.rs │ ├── diffie-hellman │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── Cargo-example.toml │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── diffie-hellman.rs │ ├── dominoes │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── dominoes.rs │ ├── dot-dsl │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── dot-dsl.rs │ ├── doubly-linked-list │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── lib.rs │ │ │ └── pre_implemented.rs │ │ └── tests │ │ │ ├── doubly-linked-list.rs │ │ │ ├── step_4_leak_test_1.rs │ │ │ └── step_4_leak_test_2.rs │ ├── etl │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── etl.rs │ ├── fizzy │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── fizzy.rs │ ├── forth │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ ├── alloc-attack.rs │ │ │ └── forth.rs │ ├── gigasecond │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── gigasecond.rs │ ├── grade-school │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── grade-school.rs │ ├── grains │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── grains.rs │ ├── grep │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── Cargo-example.toml │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── grep.rs │ ├── hamming │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── hamming.rs │ ├── hello-world │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── GETTING_STARTED.md │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── hello-world.rs │ ├── hexadecimal │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── hexadecimal.rs │ ├── high-scores │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── high-scores.rs │ ├── isbn-verifier │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── isbn-verifier.rs │ ├── isogram │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── isogram.rs │ ├── largest-series-product │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── largest-series-product.rs │ ├── leap │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── leap.rs │ ├── luhn-from │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── luhn-from.rs │ ├── luhn-trait │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── luhn-trait.rs │ ├── luhn │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── luhn.rs │ ├── macros │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ ├── invalid │ │ │ ├── Cargo.toml │ │ │ ├── comma-sep.rs │ │ │ ├── double-commas.rs │ │ │ ├── leading-comma.rs │ │ │ ├── missing-argument.rs │ │ │ ├── no-comma.rs │ │ │ ├── only-arrow.rs │ │ │ ├── only-comma.rs │ │ │ ├── single-argument.rs │ │ │ ├── triple-arguments.rs │ │ │ └── two-arrows.rs │ │ │ └── macros.rs │ ├── matching-brackets │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── matching-brackets.rs │ ├── minesweeper │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── minesweeper.rs │ ├── nth-prime │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── nth-prime.rs │ ├── nucleotide-codons │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── nucleotide-codons.rs │ ├── nucleotide-count │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── nucleotide-count.rs │ ├── ocr-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── ocr-numbers.rs │ ├── paasio │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── paasio.rs │ ├── palindrome-products │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── palindrome-products.rs │ ├── pangram │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── pangram.rs │ ├── parallel-letter-frequency │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── benches │ │ │ └── benchmark.rs │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── parallel-letter-frequency.rs │ ├── pascals-triangle │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── pascals-triangle.rs │ ├── perfect-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── perfect-numbers.rs │ ├── phone-number │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── phone-number.rs │ ├── pig-latin │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── Cargo-example.toml │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── pig-latin.rs │ ├── poker │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── Cargo-example.toml │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── poker.rs │ ├── prime-factors │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── prime-factors.rs │ ├── protein-translation │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── protein-translation.rs │ ├── proverb │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── proverb.rs │ ├── pythagorean-triplet │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── pythagorean-triplet.rs │ ├── queen-attack │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── queen-attack.rs │ ├── rail-fence-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── rail-fence-cipher.rs │ ├── raindrops │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── raindrops.rs │ ├── react │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── react.rs │ ├── rectangles │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── rectangles.rs │ ├── reverse-string │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── reverse-string.rs │ ├── rna-transcription │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── rna-transcription.rs │ ├── robot-name │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── Cargo-example.toml │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── robot-name.rs │ ├── robot-simulator │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── robot-simulator.rs │ ├── roman-numerals │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── roman-numerals.rs │ ├── rotational-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── rotational-cipher.rs │ ├── run-length-encoding │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── run-length-encoding.rs │ ├── saddle-points │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── saddle-points.rs │ ├── say │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── say.rs │ ├── scale-generator │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── Cargo-example.toml │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── scale-generator.rs │ ├── scrabble-score │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── scrabble-score.rs │ ├── series │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── series.rs │ ├── sieve │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── sieve.rs │ ├── simple-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── simple-cipher.rs │ ├── simple-linked-list │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── simple-linked-list.rs │ ├── space-age │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── space-age.rs │ ├── spiral-matrix │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── spiral-matrix.rs │ ├── sublist │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── sublist.rs │ ├── sum-of-multiples │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── sum-of-multiples.rs │ ├── tournament │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tournament.rs │ ├── triangle │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── triangle.rs │ ├── two-bucket │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── two-bucket.rs │ ├── two-fer │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── two-fer.rs │ ├── variable-length-quantity │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── variable-length-quantity.rs │ ├── word-count │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── word-count.rs │ ├── wordy │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .gitignore │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.rs │ │ │ └── tests.toml │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── wordy.rs │ └── xorcism │ │ ├── .docs │ │ ├── instructions.append.md │ │ └── instructions.md │ │ ├── .meta │ │ ├── config.json │ │ └── example.rs │ │ ├── Cargo.toml │ │ ├── src │ │ └── lib.rs │ │ └── tests │ │ └── xorcism.rs └── shared │ └── .docs │ ├── help.md │ └── tests.md └── util └── exercise ├── Cargo.lock ├── Cargo.toml └── src ├── cmd ├── configure.rs ├── defaults │ ├── README.md │ ├── description.md │ ├── example.rs │ ├── gitignore │ └── metadata.yml ├── fetch_configlet.rs ├── generate.rs ├── mod.rs ├── templates │ ├── macros.rs │ ├── property_fn.rs │ ├── test_file.rs │ └── test_fn.rs └── update.rs ├── errors.rs ├── lib.rs ├── main.rs └── structs.rs /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | end_of_line = lf 10 | 11 | -------------------------------------------------------------------------------- /.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: 'daily' 10 | -------------------------------------------------------------------------------- /.github/workflows/configlet.yml: -------------------------------------------------------------------------------- 1 | name: Configlet 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | workflow_dispatch: 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | configlet: 15 | uses: exercism/github-actions/.github/workflows/configlet.yml@main 16 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yml: -------------------------------------------------------------------------------- 1 | name: Tools 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - .github/labels.yml 9 | - .github/workflows/sync-labels.yml 10 | workflow_dispatch: 11 | schedule: 12 | - cron: 0 0 1 * * # First day of each month 13 | 14 | permissions: 15 | issues: write 16 | 17 | jobs: 18 | sync-labels: 19 | uses: exercism/github-actions/.github/workflows/labels.yml@main 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.bk 3 | .DS_Store 4 | **/target 5 | tmp 6 | bin/configlet 7 | bin/configlet.exe 8 | bin/exercise 9 | bin/exercise.exe 10 | exercises/*/*/Cargo.lock 11 | exercises/*/*/clippy.log 12 | -------------------------------------------------------------------------------- /_test/cargo_clean_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | status=0 4 | repo="$(cd "$(dirname "$0")/.." && pwd)" 5 | 6 | for ex in "$repo"/exercises/*/*/; do 7 | name=$(grep '^name =' "$ex/Cargo.toml" | cut -d\" -f2) 8 | if [ -z "$name" ]; then 9 | echo "don't know name of $ex" 10 | status=1 11 | continue 12 | fi 13 | cargo clean --manifest-path "$ex/Cargo.toml" --package "$name" 14 | done 15 | 16 | exit $status 17 | -------------------------------------------------------------------------------- /_test/check_exercises_for_authors.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | repo=$(cd "$(dirname "$0")/.." && pwd) 4 | 5 | if grep -rnw "$repo/exercises/" --include="*.toml" -e "authors"; then 6 | echo "Found 'authors' field in exercises"; 7 | exit 1; 8 | fi 9 | -------------------------------------------------------------------------------- /_test/check_uuids.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | repo=$(cd "$(dirname "$0")/.." && pwd) 5 | 6 | # Check for invalid UUIDs. 7 | # can be removed once `configlet lint` gains this ability. 8 | # Check issue https://github.com/exercism/configlet/issues/99 9 | 10 | bad_uuid=$(jq --raw-output '.exercises | .concept[], .practice[] | .uuid' "$repo"/config.json | grep -vE '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' || test 1) 11 | if [ -n "$bad_uuid" ]; then 12 | echo "invalid UUIDs found! please correct these to be valid UUIDs:" 13 | echo "$bad_uuid" 14 | exit 1 15 | fi 16 | -------------------------------------------------------------------------------- /bin/lint_markdown.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | npx markdownlint-cli concepts/**/*.md exercises/**/*.md docs/maintaining.md docs/CONTRIBUTING.md 4 | -------------------------------------------------------------------------------- /bin/lint_trailing_spaces.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Report any .toml files that have trailing white space 4 | # so user can fix them 5 | set -eo pipefail 6 | 7 | files=$(find . \( -iname '*.toml' -o -iname '*.sh' -o -iname '*.rs' \) -exec grep -l '[[:space:]]$' {} \;) 8 | 9 | if [ -n "$files" ]; then 10 | echo "These files have trailing whitespace:" 11 | echo "$files" 12 | echo "Our conventions disallow this so please remove the trailing whitespace." 13 | exit 1 14 | fi 15 | -------------------------------------------------------------------------------- /concepts/booleans/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Boolean values store either `true` or `false` and are fundamental to computing.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/booleans/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/box/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Box stores values on the heap.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/box/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | TODO 4 | -------------------------------------------------------------------------------- /concepts/box/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://fasterthanli.me/articles/whats-in-the-box", 4 | "description": "Detailed description of `Box`'s implementation and how it differs from Go / Javascript" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /concepts/char/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "The `char` data type stores a single unicode codepoint.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/char/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | TODO 4 | -------------------------------------------------------------------------------- /concepts/char/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/collect/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "The `collect` method produces a collection from an iterator.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/collect/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | TODO 4 | -------------------------------------------------------------------------------- /concepts/collect/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/destructuring/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Breaking tuples and structs into distinct named components", 3 | "authors": [ 4 | "efx" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/destructuring/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Destructuring is a way to break apart compound values in Rust. It is often used to extract fields from tuples or structs. 4 | 5 | For example, the below snippet extracts two values from a tuple: 6 | 7 | ```rust 8 | let (first, second) = (1, 2); 9 | ``` 10 | 11 | The value `1` is bound to the variable `first`. 12 | The value `2` is bound to the variable `second`. 13 | -------------------------------------------------------------------------------- /concepts/destructuring/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://doc.rust-lang.org/stable/rust-by-example/flow_control/match/destructuring.html", 4 | "description": "Rust By Example: Destructuring" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /concepts/entry-api/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Entry API for accessing and editing possibly-missing values in maps", 3 | "authors": [ 4 | "seanchen1991" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/entry-api/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Rust's entry API provides a view into a single entry in a map, which may either be a `HashMap` or a `BTreeMap`. The entry may either be occupied or vacant; and the API provides methods to modify the contents of the entry. 4 | -------------------------------------------------------------------------------- /concepts/entry-api/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://doc.rust-lang.org/std/collections/hash_map/enum.Entry.html#method.insert", 4 | "description": "`Entry::insert`" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/std/collections/hash_map/enum.Entry.html#method.key", 8 | "description": "`Entry::key`" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /concepts/enums/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Basic enums: usage and creation with non-data-carrying variants", 3 | "authors": [ 4 | "efx" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/enums/about.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | Rust enums are also called [algebraic data types](https://en.wikipedia.org/wiki/Algebraic_data_type), or [tagged unions](https://en.wikipedia.org/wiki/Tagged_union). Why does this matter? Enumerations are a popular concept and programming languages implement them differently. Functional programming has influenced Rust's design and the `enum` implementation demonstrates that. 4 | 5 | - [introduction to enums in the Rust book](https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html) 6 | -------------------------------------------------------------------------------- /concepts/enums/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Enums, short for enumerations, are a type that limits all possible values of some data. The possible values of an `enum` are called variants. Enums also work well with `match` and other control flow operators to help you express intent in your Rust programs. 4 | -------------------------------------------------------------------------------- /concepts/enums/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://en.wikipedia.org/wiki/Algebraic_data_type", 4 | "description": "algebraic data types" 5 | }, 6 | { 7 | "url": "https://en.wikipedia.org/wiki/Tagged_union", 8 | "description": "tagged unions" 9 | }, 10 | { 11 | "url": "https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html", 12 | "description": "introduction to enums in the Rust book" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /concepts/external-crates/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "External crates: a way to prevent reinventing the wheel", 3 | "authors": [ 4 | "still-flow", 5 | "coriolinus" 6 | ], 7 | "contributors": [] 8 | } 9 | -------------------------------------------------------------------------------- /concepts/external-crates/about.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | A crate is a compilation unit in Rust. A crate can be compiled into a binary or into a library. Most of the time, you will be using `cargo` to manage external dependencies. Adding a dependency can be as simple as adding a line to your `Cargo.toml` file. 4 | 5 | - [introduction to packages and Cargo in the Rust book](https://doc.rust-lang.org/book/ch07-00-managing-growing-projects-with-packages-crates-and-modules.html) 6 | -------------------------------------------------------------------------------- /concepts/external-crates/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Most programs have dependencies on some libraries. Managing those by hand can be a pain. Luckily, the Rust ecosystem comes standard with `cargo`! `cargo` can manage dependencies for a project. 4 | 5 | You will often see external packages being referred to as "crates" in Rust. A crate is a compilation unit in Rust. A crate can be compiled into a binary or into a library. 6 | 7 | Most of the time, adding an external dependency is as simple as adding a line to your `Cargo.toml` file. 8 | -------------------------------------------------------------------------------- /concepts/external-crates/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://doc.rust-lang.org/book/ch07-00-managing-growing-projects-with-packages-crates-and-modules.html", 4 | "description": "intro to package management in the Rust book" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/stable/rust-by-example/cargo.html", 8 | "description": "cargo by example" 9 | }, 10 | { 11 | "url": "https://doc.rust-lang.org/cargo/", 12 | "description": "the cargo book" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /concepts/floating-point-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Non-integral numeric types and usage", 3 | "authors": [ 4 | "LewisClement", 5 | "efx" 6 | ], 7 | "contributors": [] 8 | } 9 | -------------------------------------------------------------------------------- /concepts/floating-point-numbers/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Floating-point numbers are numbers with zero or more digits behind the decimal separator. 4 | 5 | Examples are -2.4, 0.1, 3.14, 16.984025 and 1024.0. 6 | -------------------------------------------------------------------------------- /concepts/floating-point-numbers/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/fold/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "`fold` is a flexible consuming iterator adaptor which produces a single value.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/fold/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | TODO 4 | -------------------------------------------------------------------------------- /concepts/fold/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/functions/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Functions are fundamental units of code abstraction.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/functions/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/hashmap/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Hashmap: collection of keys mapped to values", 3 | "authors": [ 4 | "koushik-ms" 5 | ], 6 | "contributors": [ 7 | "coriolinus" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /concepts/hashmap/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Hashmap is a collection used to store key-value pairs. It allows arbitrary types to be used as keys and values. Hashmap have fast insertion and retrieval functions and are very useful in e.g., making frequency counts, storing relationships etc.,. Hashmap also features the powerful `entry` API that makes it ergonomic to use. 4 | -------------------------------------------------------------------------------- /concepts/hashmap/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://doc.rust-lang.org/book/ch08-03-hash-maps.html", 4 | "description": "introduction to Hashmap in the Rust book" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/rust-by-example/std/hash.html", 8 | "description": "Rust by Example section on Hashmap" 9 | }, 10 | { 11 | "url": "https://www.youtube.com/watch?v=Ovlt82Jz0GQ", 12 | "description": "Easy Rust 051: Collection types (HashMap) video" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /concepts/integers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Integral numeric types and usage", 3 | "authors": [ 4 | "LewisClement", 5 | "efx" 6 | ], 7 | "contributors": [] 8 | } 9 | -------------------------------------------------------------------------------- /concepts/integers/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Integers are whole numbers with no decimal separator. 4 | 5 | Integer types can either store only positive numbers (unsigned) or store either positive and negative numbers (signed). 6 | 7 | Examples are -6, 0, 1, 25 and 976. 8 | 9 | Note that you can use underscores to improve the readability of longer numbers: `1_000_000`. 10 | -------------------------------------------------------------------------------- /concepts/integers/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/iterators/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn how to use iterators.", 3 | "authors": ["nahuakang"], 4 | "contributors": ["coriolinus"] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/loops/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Repeat set of statements with loops", 3 | "authors": [ 4 | "koushik-ms" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/loops/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Loops enable repetition of blocks of code. There are three types of loops in Rust: the `for` loop that enables looping over elements of an iterator or a collection (technically, values of any type that implements the `IntoIterator` trait), the `while` loop that repeates a block of code as long as a condition is satisfied, and the `loop` loop that indefinitely repeats code until a `break` is invoked explicitly. 4 | -------------------------------------------------------------------------------- /concepts/loops/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://doc.rust-lang.org/book/ch03-05-control-flow.html#repetition-with-loops", 4 | "description": "introduction to loops in the Rust book" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/rust-by-example/flow_control/loop.html", 8 | "description": "Rust by Example section on Loops" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /concepts/match-basics/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Basics of pattern matching with the match operator", 3 | "authors": [ 4 | "coriolinus" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/match-basics/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The `match` operator selects cases from an expression by structure and value. It is a good replacement for long if/else chains. 4 | -------------------------------------------------------------------------------- /concepts/match-basics/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://doc.rust-lang.org/rust-by-example/flow_control/match.html", 4 | "description": "match in Rust by Example`" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/book/ch06-02-match.html", 8 | "description": "match in The Rust Book" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /concepts/methods/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn how to implement methods for structs.", 3 | "authors": ["nahuakang"], 4 | "contributors": ["coriolinus"] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/methods/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://doc.rust-lang.org/book/ch05-03-method-syntax.html", 4 | "description": "official rust-lang book's chapter on methods" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/rust-by-example/fn/methods.html", 8 | "description": "examples of methods" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /concepts/mutability/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Mutability of bindings", 3 | "authors": [ 4 | "coriolinus" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/mutability/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Mutability is a property of a particular binding in Rust. A binding is either immutable or mutable. An immutable binding's value may not be changed; a mutable binding's value can be changed. All bindings are immutable by default. 4 | -------------------------------------------------------------------------------- /concepts/mutability/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html", 4 | "description": "Rust book chapter on mutability" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /concepts/option/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Option: a T which may or may not be there", 3 | "authors": [ 4 | "seanchen1991", 5 | "coriolinus" 6 | ], 7 | "contributors": [] 8 | } 9 | -------------------------------------------------------------------------------- /concepts/option/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The standard library provides an enum called `Option` to help you express when a value may or may not exist. 4 | You'll see it referred to as `Option` where `T` is the type of the value you are working with. 5 | -------------------------------------------------------------------------------- /concepts/option/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"description": "Standard library documentation", "url": "https://doc.rust-lang.org/std/option/index.html"}, 3 | {"description": "The RPL Book discussion Option", "url": "https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html#the-option-enum-and-its-advantages-over-null-values"} 4 | ] 5 | -------------------------------------------------------------------------------- /concepts/references/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "References enable borrowing, a core Rust feature.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/references/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | TODO 4 | -------------------------------------------------------------------------------- /concepts/references/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/string-slices/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "String slices are Rust's immutable string type.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/string-slices/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | TODO 4 | -------------------------------------------------------------------------------- /concepts/string-slices/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/string-vs-str/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Rust has two string types: `String` and `&str`.", 3 | "authors": [ 4 | "efx" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/string-vs-str/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | `String` and `&str` are two fundamental ways of working with textual data in Rust. 4 | Knowing when and how to use each type comes in handy. 5 | -------------------------------------------------------------------------------- /concepts/strings/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "String is a sequence of Unicode characters", 3 | "authors": [ 4 | "koushik-ms" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/strings/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | A string is a sequence of characters and commonly represents text. Rust strings are UTF-8 encoded, meaning they support a wide variety of languages and character sets including emojis. Strings can be joined, split and mixed in various ways; they are a very frequently used data type. 4 | -------------------------------------------------------------------------------- /concepts/strings/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://doc.rust-lang.org/book/ch08-02-strings.html", 4 | "description": "introduction to String in the Rust book" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/rust-by-example/std/str.html", 8 | "description": "Rust by Example section on String" 9 | }, 10 | { 11 | "url": "https://doc.rust-lang.org/std/string/struct.String.html", 12 | "description": "Standard library documentation on String" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /concepts/structs/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Structs: fixed-size collections of heterogenous data", 3 | "authors": [ 4 | "seanchen1991" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/structs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | It is often useful to group a collection of items together, and handle those groups as units. 4 | 5 | In Rust, we call such a group a struct, and each item one of the struct's fields. A struct defines the general set of fields available, but a particular example of a struct is called an instance. 6 | -------------------------------------------------------------------------------- /concepts/structs/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://learning-rust.github.io/docs/b2.structs.html#Tuple-structs", 4 | "description": "more information about tuple structs" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/stable/rust-by-example/custom_types/structs.html", 8 | "description": "examples of tuple and unit structs" 9 | }, 10 | { 11 | "url": "https://learning-rust.github.io/docs/b2.structs.html#C-like-structs", 12 | "description": "good overview of the different types of structs and their syntax" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /concepts/tuples/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Tuples are a lightweight way to group a fixed set of arbitrary types of data together.", 3 | "authors": [ 4 | "efx" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/tuples/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Tuples are a lightweight way to group a fixed set of arbitrary types of data together. Tuples can have an arbitrary number of elements. 4 | You can access the elements by destructuring or numeric positional index. 5 | -------------------------------------------------------------------------------- /concepts/tuples/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://learning-rust.github.io/docs/b2.structs.html#Tuple-structs", 4 | "description": "more information about tuple structs" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/stable/rust-by-example/custom_types/structs.html", 8 | "description": "examples of tuple and unit structs" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /concepts/vec-macro/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Create vectors using vec! macro.", 3 | "authors": [ 4 | "efx" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/vec-macro/about.md: -------------------------------------------------------------------------------- 1 | # `vec![]` 2 | 3 | You can use Rust macros to generate vectors. 4 | 5 | ## Syntax 6 | 7 | - `vec![]` uses a std Rust macro to initialize an empty `Vec` 8 | - `vec![1; 3]` initializes a vector with three ones 9 | - `vec![1, 2, 3]` initializes a vector with the literal values 1, 2, 3 10 | -------------------------------------------------------------------------------- /concepts/vec-macro/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Rust provides a macro `vec![]` to help you create Vectors. 4 | This comes in quite handy when you need to initialize lists. 5 | -------------------------------------------------------------------------------- /concepts/vec-macro/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://doc.rust-lang.org/book/ch08-01-vectors.html#creating-a-new-vector", 4 | "description": "Creating a new Vector" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/stable/rust-by-example/std/vec.html", 8 | "description": "Examples of vectors" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /concepts/vec-stack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Vectors in Rust can be used as a stack", 3 | "authors": [ 4 | "coriolinus" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/vec-stack/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | A stack is a linear data structure optimized for access from one end. Vectors in Rust are appropriate for use as a stack. 4 | -------------------------------------------------------------------------------- /concepts/vec-stack/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://en.wikipedia.org/wiki/Stack_(abstract_data_type)", 4 | "description": "description of the stack abstract data type" 5 | }, 6 | { 7 | "url": "https://doc.rust-lang.org/std/vec/struct.Vec.html", 8 | "description": "vector documentation" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /docs/LEARNING.md: -------------------------------------------------------------------------------- 1 | # Learning 2 | 3 | * [The Rust Programming Language](https://doc.rust-lang.org/book/) is a great resource for getting started with Rust as well as diving deeper into specific features of Rust. 4 | * [Rust by Example](https://doc.rust-lang.org/stable/rust-by-example/) shows you examples of the most common things you will be writing in Rust. 5 | * [Into_rust()](http://intorust.com/) "Screencasts for learning Rust." 6 | * [Rustlings](https://github.com/carols10cents/rustlings) "Small exercises to get you used to reading and writing Rust code." 7 | * The [Rust User Forum](http://users.rust-lang.org) answers questions of all levels 8 | -------------------------------------------------------------------------------- /docs/SNIPPET.txt: -------------------------------------------------------------------------------- 1 | pub fn hello() -> &'static str { 2 | "Hello, World!" 3 | } 4 | -------------------------------------------------------------------------------- /exercises/concept/assembly-line/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn about numbers while working on an assembly line for cars.", 3 | "authors": [ 4 | "LewisClement", 5 | "efx" 6 | ], 7 | "files": { 8 | "solution": [ 9 | "src/lib.rs", 10 | "Cargo.toml" 11 | ], 12 | "test": [ 13 | "tests/assembly-line.rs" 14 | ], 15 | "exemplar": [ 16 | ".meta/exemplar.rs" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /exercises/concept/assembly-line/.meta/exemplar.rs: -------------------------------------------------------------------------------- 1 | const PRODUCTION_RATE_DEFAULT: f64 = 221.; 2 | 3 | pub fn production_rate_per_hour(speed: u8) -> f64 { 4 | match speed { 5 | 0 => 0.0, 6 | s @ 1..=4 => PRODUCTION_RATE_DEFAULT * s as f64, 7 | s @ 5..=8 => PRODUCTION_RATE_DEFAULT * s as f64 * 0.9, 8 | s @ 9..=10 => PRODUCTION_RATE_DEFAULT * s as f64 * 0.77, 9 | _ => panic!("Speed should be a value from 0 to 10"), 10 | } 11 | } 12 | 13 | pub fn working_items_per_minute(speed: u8) -> u32 { 14 | (production_rate_per_hour(speed) / 60.0) as u32 15 | } 16 | -------------------------------------------------------------------------------- /exercises/concept/assembly-line/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "assembly-line" 3 | version = "0.1.0" 4 | edition = "2021" 5 | -------------------------------------------------------------------------------- /exercises/concept/assembly-line/src/lib.rs: -------------------------------------------------------------------------------- 1 | // This stub file contains items that aren't used yet; feel free to remove this module attribute 2 | // to enable stricter warnings. 3 | #![allow(unused)] 4 | 5 | pub fn production_rate_per_hour(speed: u8) -> f64 { 6 | unimplemented!("calculate hourly production rate at speed: {}", speed) 7 | } 8 | 9 | pub fn working_items_per_minute(speed: u8) -> u32 { 10 | unimplemented!("calculate the amount of working items at speed: {}", speed) 11 | } 12 | -------------------------------------------------------------------------------- /exercises/concept/csv-builder/.docs/hints.md: -------------------------------------------------------------------------------- 1 | ## General 2 | 3 | - [TRPL book discusses string slices and how to use them](https://doc.rust-lang.org/book/ch04-03-slices.html#string-slices) 4 | 5 | ## 1. Create a new builder 6 | 7 | - The [standard library documentation](https://doc.rust-lang.org/std/string/struct.String.html) has examples on creating `String`s. 8 | 9 | ## 2. Add individual fields to the record 10 | 11 | - The [`push_str`](https://doc.rust-lang.org/std/string/struct.String.html#method.push_str) comes in quite handy for adding string slices to a `String`. 12 | -------------------------------------------------------------------------------- /exercises/concept/csv-builder/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | `String` and `&str` are two fundamental ways of working with textual data in Rust. 2 | 3 | `String` is an owned, vector of `u8` bytes and mutable. 4 | `&str` is a borrowed reference to a String slice and thus immutable. 5 | 6 | You can also create and modify `String`'s using one of their many methods, such as `push`. 7 | ```rust 8 | let mut a_string = String::from("hello"); 9 | a_string.push('!'); 10 | ``` 11 | 12 | You can also create a `String` by converting a `&str`: 13 | ```rust 14 | let a_string = "hello".to_string(); 15 | ``` 16 | -------------------------------------------------------------------------------- /exercises/concept/csv-builder/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn about strings and string slices while working on a CSV builder", 3 | "authors": [ 4 | "gilescope", 5 | "coriolinus", 6 | "efx" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "src/lib.rs", 11 | "Cargo.toml" 12 | ], 13 | "test": [ 14 | "tests/csv-builder.rs" 15 | ], 16 | "exemplar": [ 17 | ".meta/exemplar.rs" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /exercises/concept/csv-builder/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "csv_builder" 3 | version = "0.1.0" 4 | edition = "2021" 5 | -------------------------------------------------------------------------------- /exercises/concept/health-statistics/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn structs to store statistics for a health-monitoring system.", 3 | "authors": [ 4 | "seanchen1991" 5 | ], 6 | "files": { 7 | "solution": [ 8 | "src/lib.rs", 9 | "Cargo.toml" 10 | ], 11 | "test": [ 12 | "tests/health-statistics.rs" 13 | ], 14 | "exemplar": [ 15 | ".meta/exemplar.rs" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /exercises/concept/health-statistics/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "health_statistics" 3 | version = "0.1.0" 4 | edition = "2021" 5 | -------------------------------------------------------------------------------- /exercises/concept/low-power-embedded-game/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn tuples while writing convenience functions for a low-power embedded game", 3 | "authors": [ 4 | "coriolinus" 5 | ], 6 | "files": { 7 | "solution": [ 8 | "src/lib.rs", 9 | "Cargo.toml" 10 | ], 11 | "test": [ 12 | "tests/low-power-embedded-game.rs" 13 | ], 14 | "exemplar": [ 15 | ".meta/exemplar.rs" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /exercises/concept/low-power-embedded-game/.meta/exemplar.rs: -------------------------------------------------------------------------------- 1 | pub fn divmod(dividend: i16, divisor: i16) -> (i16, i16) { 2 | (dividend / divisor, dividend % divisor) 3 | } 4 | 5 | pub fn evens(iter: impl Iterator) -> impl Iterator { 6 | iter.enumerate() 7 | .filter(|&(idx, _)| idx % 2 == 0) 8 | .map(|(_, t)| t) 9 | } 10 | 11 | pub struct Position(pub i16, pub i16); 12 | impl Position { 13 | pub fn manhattan(&self) -> i16 { 14 | self.0.abs() + self.1.abs() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /exercises/concept/low-power-embedded-game/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "low_power_embedded_game" 3 | version = "0.1.0" 4 | edition = "2021" 5 | -------------------------------------------------------------------------------- /exercises/concept/lucians-luscious-lasagna/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn about the basics of Rust by following a lasagna recipe.", 3 | "icon": "lasagna", 4 | "authors": [ 5 | "coriolinus", 6 | "ErikSchierboom" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "src/lib.rs", 11 | "Cargo.toml" 12 | ], 13 | "test": [ 14 | "tests/lucians-luscious-lasagna.rs" 15 | ], 16 | "exemplar": [ 17 | ".meta/exemplar.rs" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /exercises/concept/lucians-luscious-lasagna/.meta/exemplar.rs: -------------------------------------------------------------------------------- 1 | pub fn expected_minutes_in_oven() -> i32 { 2 | 40 3 | } 4 | 5 | pub fn remaining_minutes_in_oven(actual_minutes_in_oven: i32) -> i32 { 6 | expected_minutes_in_oven() - actual_minutes_in_oven 7 | } 8 | 9 | pub fn preparation_time_in_minutes(number_of_layers: i32) -> i32 { 10 | number_of_layers * 2 11 | } 12 | 13 | pub fn elapsed_time_in_minutes(number_of_layers: i32, actual_minutes_in_oven: i32) -> i32 { 14 | preparation_time_in_minutes(number_of_layers) + actual_minutes_in_oven 15 | } 16 | -------------------------------------------------------------------------------- /exercises/concept/lucians-luscious-lasagna/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lucians-luscious-lasagna" 3 | version = "0.1.0" 4 | edition = "2021" 5 | -------------------------------------------------------------------------------- /exercises/concept/magazine-cutout/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Rust's entry API provides a view into a single entry in map, which may be either a `HashMap` or a `BTreeMap`. The entry may be either occupied and vacant, and the API provides methods to modify the contents of the entry. 4 | -------------------------------------------------------------------------------- /exercises/concept/magazine-cutout/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Use `HashMap` and the entry API methods to write an anonymous letter.", 3 | "authors": [ 4 | "seanchen1991" 5 | ], 6 | "files": { 7 | "solution": [ 8 | "src/lib.rs", 9 | "Cargo.toml" 10 | ], 11 | "test": [ 12 | "tests/magazine-cutout.rs" 13 | ], 14 | "exemplar": [ 15 | ".meta/exemplar.rs" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /exercises/concept/magazine-cutout/.meta/exemplar.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | pub fn can_construct_note(magazine: &[&str], note: &[&str]) -> bool { 4 | let mut counts: HashMap<&str, i32> = HashMap::with_capacity(magazine.len()); 5 | 6 | for m in magazine { 7 | *counts.entry(*m).or_default() += 1; 8 | } 9 | 10 | for n in note { 11 | *counts.entry(*n).or_default() -= 1; 12 | 13 | if counts[n] < 0 { 14 | return false; 15 | } 16 | } 17 | 18 | true 19 | } 20 | -------------------------------------------------------------------------------- /exercises/concept/magazine-cutout/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "magazine_cutout" 3 | version = "0.1.0" 4 | edition = "2021" 5 | -------------------------------------------------------------------------------- /exercises/concept/magazine-cutout/src/lib.rs: -------------------------------------------------------------------------------- 1 | // This stub file contains items that aren't used yet; feel free to remove this module attribute 2 | // to enable stricter warnings. 3 | #![allow(unused)] 4 | 5 | use std::collections::HashMap; 6 | 7 | pub fn can_construct_note(magazine: &[&str], note: &[&str]) -> bool { 8 | unimplemented!() 9 | } 10 | -------------------------------------------------------------------------------- /exercises/concept/resistor-color/.docs/hints.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | 3 | ## General 4 | 5 | - Use the `enum-iterator` crate to be able to iterate over enums. Check out [docs](https://docs.rs/enum-iterator/1.1.1/enum_iterator/) to find out how. 6 | 7 | - Use the `int-enum` crate to be able to convert from int to enum. See the [docs](https://docs.rs/int-enum/0.4.0/int_enum/) for details. 8 | 9 | - The `Debug` trait is there because you'll likely need it. 10 | 11 | - You'll need to extend the list of `derive`d traits on your colors enum. 12 | -------------------------------------------------------------------------------- /exercises/concept/resistor-color/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/concept/resistor-color/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "resistor-color" 4 | version = "1.0.0" 5 | 6 | [dependencies] 7 | int-enum = "0.4.0" 8 | enum-iterator = "1.1.1" 9 | -------------------------------------------------------------------------------- /exercises/concept/role-playing-game/.docs/hints.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | 3 | -------------------------------------------------------------------------------- /exercises/concept/role-playing-game/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn about the `Option` enum by creating a minimal role-playing game", 3 | "authors": [ 4 | "seanchen1991", 5 | "coriolinus" 6 | ], 7 | "contributors": [ 8 | "PaulT89" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "src/lib.rs", 13 | "Cargo.toml" 14 | ], 15 | "test": [ 16 | "tests/role-playing-game.rs" 17 | ], 18 | "exemplar": [ 19 | ".meta/exemplar.rs" 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /exercises/concept/role-playing-game/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "role_playing_game" 3 | version = "0.1.0" 4 | edition = "2021" 5 | -------------------------------------------------------------------------------- /exercises/concept/role-playing-game/src/lib.rs: -------------------------------------------------------------------------------- 1 | // This stub file contains items that aren't used yet; feel free to remove this module attribute 2 | // to enable stricter warnings. 3 | #![allow(unused)] 4 | 5 | pub struct Player { 6 | pub health: u32, 7 | pub mana: Option, 8 | pub level: u32, 9 | } 10 | 11 | impl Player { 12 | pub fn revive(&self) -> Option { 13 | unimplemented!("Revive this player") 14 | } 15 | 16 | pub fn cast_spell(&mut self, mana_cost: u32) -> u32 { 17 | unimplemented!("Cast a spell of cost {}", mana_cost) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /exercises/concept/rpn-calculator/.docs/hints.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | 3 | ## General 4 | 5 | - Look at the documentation for `std::vec::Vec`'s [`push()`](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.push) and [`pop()`](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.pop) methods. 6 | -------------------------------------------------------------------------------- /exercises/concept/rpn-calculator/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Use some of `Vec`'s methods to evaluate Reverse Polish notation", 3 | "authors": [ 4 | "cwhakes" 5 | ], 6 | "files": { 7 | "solution": [ 8 | "src/lib.rs", 9 | "Cargo.toml" 10 | ], 11 | "test": [ 12 | "tests/rpn-calculator.rs" 13 | ], 14 | "exemplar": [ 15 | ".meta/exemplar.rs" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /exercises/concept/rpn-calculator/.meta/design.md: -------------------------------------------------------------------------------- 1 | # Design 2 | 3 | ## Goal 4 | 5 | Introduce the design idiom of using `Vec` as a stack. 6 | 7 | ## Learning objectives 8 | 9 | - Know what `push()` and `pop()` do. 10 | - Know how to use the values returned by `pop()`. 11 | - Know how to create and use a stack. 12 | 13 | ## Out of scope 14 | 15 | - Mathematical edge cases, like division by zero 16 | 17 | ## Prerequisites 18 | 19 | - intro-fn 20 | - numbers 21 | - option 22 | - enums 23 | - match-basics 24 | - loops 25 | - mutability 26 | -------------------------------------------------------------------------------- /exercises/concept/rpn-calculator/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rpn_calculator" 3 | version = "0.1.0" 4 | edition = "2021" 5 | -------------------------------------------------------------------------------- /exercises/concept/rpn-calculator/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | pub enum CalculatorInput { 3 | Add, 4 | Subtract, 5 | Multiply, 6 | Divide, 7 | Value(i32), 8 | } 9 | 10 | pub fn evaluate(inputs: &[CalculatorInput]) -> Option { 11 | unimplemented!( 12 | "Given the inputs: {:?}, evaluate them as though they were a Reverse Polish notation expression", 13 | inputs, 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /exercises/concept/semi-structured-logs/.docs/hints.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | 3 | ## General 4 | 5 | - [Rust By Example - Enums][rbe-enums] 6 | - [cheats.rs - Basic Types][cheats-types] 7 | 8 | ## 1. Emit semi-structured messages 9 | 10 | - `match` comes in handy when working with enums. In this case, see how you might use it when figuring how what kind of log message to generate. 11 | 12 | [rbe-enums]: https://doc.rust-lang.org/stable/rust-by-example/custom_types/enum.html#enums 13 | [cheats-types]: https://cheats.rs/#basic-types 14 | -------------------------------------------------------------------------------- /exercises/concept/semi-structured-logs/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Enums, short for enumerations, are a type that limits all possible values of some data. The possible values of an `enum` are called variants. Enums also work well with `match` and other control flow operators to help you express intent in your Rust programs. 4 | -------------------------------------------------------------------------------- /exercises/concept/semi-structured-logs/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn enums while building a logging utility.", 3 | "authors": [ 4 | "efx" 5 | ], 6 | "files": { 7 | "solution": [ 8 | "src/lib.rs", 9 | "Cargo.toml" 10 | ], 11 | "test": [ 12 | "tests/semi-structured-logs.rs" 13 | ], 14 | "exemplar": [ 15 | ".meta/exemplar.rs" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /exercises/concept/semi-structured-logs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "semi_structured_logs" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [features] 7 | add-a-variant = [] 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /exercises/concept/short-fibonacci/.docs/hints.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | 3 | ## General 4 | 5 | - Check out the Rust documentation on [the `vec!` macro](https://doc.rust-lang.org/std/macro.vec.html). 6 | -------------------------------------------------------------------------------- /exercises/concept/short-fibonacci/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Rust provides a macro `vec![]` to help you create Vectors. 4 | This comes in quite handy when you need to initialize lists. 5 | -------------------------------------------------------------------------------- /exercises/concept/short-fibonacci/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/concept/short-fibonacci/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn the `vec!` macro to build a short Fibonacci Sequence.", 3 | "authors": [ 4 | "efx", 5 | "coriolinus" 6 | ], 7 | "files": { 8 | "solution": [ 9 | "src/lib.rs", 10 | "Cargo.toml" 11 | ], 12 | "test": [ 13 | "tests/short-fibonacci.rs" 14 | ], 15 | "exemplar": [ 16 | ".meta/exemplar.rs" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /exercises/concept/short-fibonacci/.meta/design.md: -------------------------------------------------------------------------------- 1 | # Design 2 | 3 | ## Goal 4 | 5 | The goal of this exercise is to teach the student the usage of the `vec!` macro. 6 | 7 | ## Learning objectives 8 | 9 | - Know what `vec!` does 10 | - Know how to populate a `Vec` in one line 11 | 12 | ## Out of scope 13 | 14 | - how macros work 15 | - other ways to instantiate `Vec` 16 | 17 | ## Concepts 18 | 19 | The Concepts this exercise unlocks are: 20 | 21 | - `vec-stack`: for using vectors as an O(1) stack (push and pop methods) 22 | 23 | ## Prerequisites 24 | 25 | - intro-fn 26 | - numbers 27 | -------------------------------------------------------------------------------- /exercises/concept/short-fibonacci/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "short_fibonacci" 3 | version = "0.1.0" 4 | edition = "2021" 5 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn map(values: Vec, mut f: F) -> Vec 2 | where 3 | F: FnMut(T) -> U, 4 | { 5 | let mut v = Vec::with_capacity(values.len()); 6 | for val in values { 7 | v.push(f(val)); 8 | } 9 | v 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "accumulate" 4 | version = "0.0.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/src/lib.rs: -------------------------------------------------------------------------------- 1 | /// What should the type of _function be? 2 | pub fn map(input: Vec, _function: ???) -> Vec { 3 | unimplemented!("Transform input vector {:?} using passed function", input); 4 | } 5 | -------------------------------------------------------------------------------- /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 8 | like Portable Network Graphics to its acronym (PNG). 9 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/acronym/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "acronym" 4 | version = "1.7.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/acronym/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn abbreviate(phrase: &str) -> String { 2 | unimplemented!("Given the phrase '{}', return its acronym", phrase); 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/affine-cipher/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by exercism rust track exercise tool 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/affine-cipher/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "affine-cipher" 4 | version = "2.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "allyourbase" 4 | version = "1.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/allergies/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "allergies" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/.meta/Cargo-example.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "alphametics" 4 | version = "0.0.0" 5 | 6 | [dependencies] 7 | itertools = "0.5" 8 | permutohedron = "0.2" 9 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [8a3e3168-d1ee-4df7-94c7-b9c54845ac3a] 6 | description = "puzzle with two digits final carry" 7 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "alphametics" 4 | version = "1.3.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | pub fn solve(input: &str) -> Option> { 4 | unimplemented!("Solve the alphametic {:?}", input) 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | An anagram is a rearrangement of letters to form a new word. 4 | Given a word and a list of candidates, select the sublist of anagrams of the given word. 5 | 6 | Given `"listen"` and a list of candidates like `"enlists" "google" 7 | "inlets" "banana"` the program should return a list containing 8 | `"inlets"`. 9 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/anagram/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "anagram" 4 | version = "0.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/anagram/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashSet; 2 | 3 | pub fn anagrams_for<'a>(word: &str, possible_anagrams: &[&str]) -> HashSet<&'a str> { 4 | unimplemented!( 5 | "For the '{}' word find anagrams among the following words: {:?}", 6 | word, 7 | possible_anagrams 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn is_armstrong_number(num: u32) -> bool { 2 | let s = format!("{}", num); 3 | let l = s.len(); 4 | s.chars() 5 | .map(|c| c.to_digit(10).unwrap().pow(l as u32)) 6 | .sum::() 7 | == num 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "armstrong_numbers" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn is_armstrong_number(num: u32) -> bool { 2 | unimplemented!("true if {} is an armstrong number", num) 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "atbash-cipher" 4 | version = "1.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/src/lib.rs: -------------------------------------------------------------------------------- 1 | /// "Encipher" with the Atbash cipher. 2 | pub fn encode(plain: &str) -> String { 3 | unimplemented!("Encoding of {:?} in Atbash cipher.", plain); 4 | } 5 | 6 | /// "Decipher" with the Atbash cipher. 7 | pub fn decode(cipher: &str) -> String { 8 | unimplemented!("Decoding of {:?} in Atbash cipher.", cipher); 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "beer-song" 4 | version = "0.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn verse(n: u32) -> String { 2 | unimplemented!("emit verse {}", n) 3 | } 4 | 5 | pub fn sing(start: u32, end: u32) -> String { 6 | unimplemented!("sing verses {} to {}, inclusive", start, end) 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "binary-search" 4 | version = "1.3.0" 5 | 6 | [dependencies] 7 | 8 | [features] 9 | generic = [] 10 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn find(array: &[i32], key: i32) -> Option { 2 | unimplemented!( 3 | "Using the binary search algorithm, find the element '{}' in the array '{:?}' and return its index.", 4 | key, 5 | array 6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/bob/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/bob/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [73a966dc-8017-47d6-bb32-cf07d1a5fcd9] 6 | description = "shouting" 7 | 8 | [bc39f7c6-f543-41be-9a43-fd1c2f753fc0] 9 | description = "silence" 10 | -------------------------------------------------------------------------------- /exercises/practice/bob/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "bob" 4 | version = "1.6.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/bob/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn reply(message: &str) -> &str { 2 | unimplemented!("have Bob reply to the incoming message: {}", message) 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/book-store/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/book-store/.meta/Cargo-example.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "book_store" 4 | version = "1.3.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/book-store/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/book-store/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "book_store" 4 | version = "1.3.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/book-store/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn lowest_price(books: &[u32]) -> u32 { 2 | unimplemented!( 3 | "Find the lowest price of the bookbasket with books {:?}", 4 | books 5 | ) 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/bowling/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/bowling/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "bowling" 4 | version = "1.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/bowling/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, PartialEq, Eq)] 2 | pub enum Error { 3 | NotEnoughPinsLeft, 4 | GameComplete, 5 | } 6 | 7 | pub struct BowlingGame {} 8 | 9 | impl BowlingGame { 10 | pub fn new() -> Self { 11 | unimplemented!(); 12 | } 13 | 14 | pub fn roll(&mut self, pins: u16) -> Result<(), Error> { 15 | unimplemented!("Record that {} pins have been scored", pins); 16 | } 17 | 18 | pub fn score(&self) -> Option { 19 | unimplemented!("Return the score if the game is complete, or None if not."); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "circular-buffer" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /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 | 9 | You will also need to implement `.to_string()` for the `Clock` struct. We will be using this to display the Clock's state. You can either do it via implementing it directly or using the [Display trait](https://doc.rust-lang.org/std/fmt/trait.Display.html). 10 | -------------------------------------------------------------------------------- /exercises/practice/clock/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/clock/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/clock/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "clock" 4 | version = "2.4.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/clock/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub struct Clock; 2 | 3 | impl Clock { 4 | pub fn new(hours: i32, minutes: i32) -> Self { 5 | unimplemented!( 6 | "Construct a new Clock from {} hours and {} minutes", 7 | hours, 8 | minutes 9 | ); 10 | } 11 | 12 | pub fn add_minutes(&self, minutes: i32) -> Self { 13 | unimplemented!("Add {} minutes to existing Clock time", minutes); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/example.rs: -------------------------------------------------------------------------------- 1 | // return Some(x) where x is the number of steps required to reach 1 2 | pub fn collatz(n: u64) -> Option { 3 | match n { 4 | 0 => None, 5 | 1 => Some(0), 6 | n if n % 2 == 0 => collatz(n / 2).map(|c| c + 1), 7 | n => collatz(n.checked_mul(3)?.checked_add(1)?).map(|c| c + 1), 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "collatz_conjecture" 4 | version = "1.2.1" 5 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn collatz(n: u64) -> Option { 2 | unimplemented!( 3 | "return Some(x) where x is the number of steps required to reach 1 starting with {}", 4 | n, 5 | ) 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/.meta/Cargo-example.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "crypto-square" 4 | version = "0.1.0" 5 | 6 | [dependencies] 7 | itertools = "0.6.1" 8 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "crypto-square" 4 | version = "0.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn encrypt(input: &str) -> String { 2 | unimplemented!("Encrypt {:?} using a square code", input) 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Create a custom set type. 4 | 5 | Sometimes it is necessary to define a custom data structure of some 6 | type, like a set. In this exercise you will define your own set. How it 7 | works internally doesn't matter, as long as it behaves like a set of 8 | unique elements. 9 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "custom-set" 4 | version = "1.0.1" 5 | -------------------------------------------------------------------------------- /exercises/practice/decimal/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/decimal/.meta/Cargo-example.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "decimal" 4 | version = "0.1.0" 5 | 6 | [dependencies] 7 | num-bigint = "0.1.40" 8 | num-traits = "0.1.40" 9 | -------------------------------------------------------------------------------- /exercises/practice/decimal/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "decimal" 4 | version = "0.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/decimal/src/lib.rs: -------------------------------------------------------------------------------- 1 | /// Type implementing arbitrary-precision decimal arithmetic 2 | pub struct Decimal { 3 | // implement your type here 4 | } 5 | 6 | impl Decimal { 7 | pub fn try_from(input: &str) -> Option { 8 | unimplemented!("Create a new decimal with a value of {}", input) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/diamond/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/diamond/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/diamond/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "diamond" 4 | version = "1.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/diamond/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn get_diamond(c: char) -> Vec { 2 | unimplemented!( 3 | "Return the vector of strings which represent the diamond with particular char {}", 4 | c 5 | ); 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn square_of_sum(n: u32) -> u32 { 2 | let sum = n * (n + 1) / 2; 3 | sum * sum 4 | } 5 | 6 | pub fn sum_of_squares(n: u32) -> u32 { 7 | (0..=n).map(|x| x * x).sum() 8 | } 9 | 10 | pub fn difference(n: u32) -> u32 { 11 | square_of_sum(n) - sum_of_squares(n) 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "difference-of-squares" 4 | version = "1.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn square_of_sum(n: u32) -> u32 { 2 | unimplemented!("square of sum of 1...{}", n) 3 | } 4 | 5 | pub fn sum_of_squares(n: u32) -> u32 { 6 | unimplemented!("sum of squares of 1...{}", n) 7 | } 8 | 9 | pub fn difference(n: u32) -> u32 { 10 | unimplemented!( 11 | "difference between square of sum of 1...{n} and sum of squares of 1...{n}", 12 | n = n, 13 | ) 14 | } 15 | -------------------------------------------------------------------------------- /exercises/practice/diffie-hellman/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/diffie-hellman/.meta/Cargo-example.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "diffie-hellman" 4 | version = "0.1.0" 5 | 6 | [dependencies] 7 | rand = "0.3.18" 8 | 9 | [features] 10 | big-primes = [] 11 | -------------------------------------------------------------------------------- /exercises/practice/diffie-hellman/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/diffie-hellman/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "diffie-hellman" 4 | version = "0.1.0" 5 | 6 | [dependencies] 7 | 8 | [features] 9 | big-primes = [] 10 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "dominoes" 4 | version = "2.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn chain(input: &[(u8, u8)]) -> Option> { 2 | unimplemented!("From the given input '{:?}' construct a proper dominoes chain or return None if it is not possible.", input); 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/dot-dsl/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Builder pattern 2 | 3 | This exercise expects you to build several structs using `builder pattern`. 4 | In short, this pattern allows you to split the construction function of your struct, that contains a lot of arguments, into 5 | several separate functions. This approach gives you the means to make compact but highly-flexible struct construction and 6 | configuration. 7 | You can read more about it on the [following page](https://doc.rust-lang.org/1.0.0/style/ownership/builders.html). 8 | -------------------------------------------------------------------------------- /exercises/practice/dot-dsl/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/dot-dsl/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "dot-dsl" 4 | version = "0.1.0" 5 | 6 | [dependencies] 7 | maplit = "1.0.1" 8 | -------------------------------------------------------------------------------- /exercises/practice/dot-dsl/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod graph { 2 | pub struct Graph; 3 | 4 | impl Graph { 5 | pub fn new() -> Self { 6 | unimplemented!("Construct a new Graph struct."); 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/doubly-linked-list/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | 3 | * A doubly linked does not have a clear ownership hierarchy, which is why it requires either the use 4 | of unsafe or abstractions for shared ownership like `Rc`. The latter has some overhead that is unnecessary 5 | for this case. 6 | 7 | * Refer to the [Rustonomicon](https://doc.rust-lang.org/nomicon/) for details on how to use `unsafe {}` correctly. 8 | 9 | * Several functions require similar behaviour in different directions (towards front or back). Try not to duplicate 10 | shared code paths. 11 | -------------------------------------------------------------------------------- /exercises/practice/doubly-linked-list/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/doubly-linked-list/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "doubly-linked-list" 3 | version = "0.0.0" 4 | edition = "2021" 5 | 6 | [features] 7 | # check correct covariance and Send, Sync 8 | advanced = [] 9 | -------------------------------------------------------------------------------- /exercises/practice/etl/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/example.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeMap; 2 | 3 | pub fn transform(input: &BTreeMap>) -> BTreeMap { 4 | input 5 | .iter() 6 | .flat_map(|(&n, vec)| vec.iter().map(move |c| (c.to_ascii_lowercase(), n))) 7 | .collect() 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/etl/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "etl" 4 | version = "1.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/etl/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeMap; 2 | 3 | pub fn transform(h: &BTreeMap>) -> BTreeMap { 4 | unimplemented!("How will you transform the tree {:?}?", h) 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/fizzy/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/fizzy/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fizzy" 3 | version = "0.0.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/forth/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/forth/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "forth" 4 | version = "1.7.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/forth/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub type Value = i32; 2 | pub type Result = std::result::Result<(), Error>; 3 | 4 | pub struct Forth; 5 | 6 | #[derive(Debug, PartialEq, Eq)] 7 | pub enum Error { 8 | DivisionByZero, 9 | StackUnderflow, 10 | UnknownWord, 11 | InvalidWord, 12 | } 13 | 14 | impl Forth { 15 | pub fn new() -> Forth { 16 | unimplemented!() 17 | } 18 | 19 | pub fn stack(&self) -> &[Value] { 20 | unimplemented!() 21 | } 22 | 23 | pub fn eval(&mut self, input: &str) -> Result { 24 | unimplemented!("result of evaluating '{}'", input) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | If you're unsure what operations you can perform on `PrimitiveDateTime` take a look at the [time crate](https://docs.rs/time) which is listed as a dependency in the `Cargo.toml` file for this exercise. 4 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a moment, determine the moment that would be after a gigasecond 4 | has passed. 5 | 6 | A gigasecond is 10^9 (1,000,000,000) seconds. 7 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/example.rs: -------------------------------------------------------------------------------- 1 | use time::{Duration, PrimitiveDateTime as DateTime}; 2 | 3 | pub fn after(start: DateTime) -> DateTime { 4 | start + Duration::seconds(1_000_000_000) 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "gigasecond" 4 | version = "2.0.0" 5 | 6 | [dependencies] 7 | time = "0.3" 8 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/src/lib.rs: -------------------------------------------------------------------------------- 1 | use time::PrimitiveDateTime as DateTime; 2 | 3 | // Returns a DateTime one billion seconds after start. 4 | pub fn after(start: DateTime) -> DateTime { 5 | unimplemented!("What time is a gigasecond later than {}", start); 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "grade-school" 4 | version = "0.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/grains/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/grains/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn square(s: u32) -> u64 { 2 | if s == 0 || s > 64 { 3 | panic!("Square must be between 1 and 64"); 4 | } 5 | 6 | 2u64.pow(s - 1) 7 | } 8 | 9 | pub fn total() -> u64 { 10 | (1..65).fold(0, |acc, s| acc + square(s)) 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/grains/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "grains" 4 | version = "1.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/grains/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn square(s: u32) -> u64 { 2 | unimplemented!("grains of rice on square {}", s); 3 | } 4 | 5 | pub fn total() -> u64 { 6 | unimplemented!(); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/grep/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | 10 | # Exercise generates some text files, and while it is meant to clean up after itself, 11 | # it might not in the event of panics 12 | *.txt 13 | -------------------------------------------------------------------------------- /exercises/practice/grep/.meta/Cargo-example.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | anyhow = "1.0" 3 | thiserror = "1.0" 4 | 5 | [package] 6 | edition = "2018" 7 | name = "grep" 8 | version = "1.3.0" 9 | -------------------------------------------------------------------------------- /exercises/practice/grep/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/grep/Cargo.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | anyhow = "1.0" 3 | 4 | [package] 5 | edition = "2021" 6 | name = "grep" 7 | version = "1.3.0" 8 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn hamming_distance(a: &str, b: &str) -> Option { 2 | if a.len() != b.len() { 3 | return None; 4 | } 5 | 6 | Some(a.chars().zip(b.chars()).filter(|&(a, b)| a != b).count()) 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/hamming/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "hamming" 4 | version = "2.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/hamming/src/lib.rs: -------------------------------------------------------------------------------- 1 | /// Return the Hamming distance between the strings, 2 | /// or None if the lengths are mismatched. 3 | pub fn hamming_distance(s1: &str, s2: &str) -> Option { 4 | unimplemented!("What is the Hamming Distance between {} and {}", s1, s2); 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | The classical introductory exercise. Just say "Hello, World!". 4 | 5 | ["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is 6 | the traditional first program for beginning programming in a new language 7 | or environment. 8 | 9 | The objectives are simple: 10 | 11 | - Write a function that returns the string "Hello, World!". 12 | - Run the test suite and make sure that it succeeds. 13 | - Submit your solution and check it at the website. 14 | 15 | If everything goes well, you will be ready to fetch your first real exercise. 16 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn hello() -> &'static str { 2 | "Hello, World!" 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "hello-world" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/src/lib.rs: -------------------------------------------------------------------------------- 1 | // &'static is a "lifetime specifier", something you'll learn more about later 2 | pub fn hello() -> &'static str { 3 | "Goodbye, Mars!" 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/tests/hello-world.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_hello_world() { 3 | assert_eq!("Hello, World!", hello_world::hello()); 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Convert a hexadecimal number, represented as a string (e.g. "10af8c"), to its decimal equivalent using first principles (i.e. no, you may not use built-in or external libraries to accomplish the conversion). 4 | 5 | On the web we use hexadecimal to represent colors, e.g. green: 008000, 6 | teal: 008080, navy: 000080). 7 | 8 | The program should handle invalid hexadecimal strings. 9 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hexadecimal" 3 | version = "0.0.0" 4 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | 3 | Consider retaining a reference to `scores` in the struct - copying is not 4 | necessary. You will require some lifetime annotations, though. 5 | -------------------------------------------------------------------------------- /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 addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score and the three highest scores. 6 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by exercism rust track exercise tool 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Manage a player's High Score list", 3 | "authors": [ 4 | "Br1ght0ne" 5 | ], 6 | "contributors": [ 7 | "coriolinus", 8 | "cwhakes", 9 | "efx", 10 | "ErikSchierboom" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "src/lib.rs", 15 | "Cargo.toml" 16 | ], 17 | "test": [ 18 | "tests/high-scores.rs" 19 | ], 20 | "example": [ 21 | ".meta/example.rs" 22 | ] 23 | }, 24 | "source": "Tribute to the eighties' arcade game Frogger" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/Cargo.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | 3 | [package] 4 | edition = "2021" 5 | name = "high-scores" 6 | version = "4.0.0" 7 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [737f4e91-cbba-4175-95bf-ae630b41fb60] 6 | description = "too short isbn" 7 | 8 | [94610459-55ab-4c35-9b93-ff6ea1a8e562] 9 | description = "empty isbn" 10 | 11 | [7bff28d4-d770-48cc-80d6-b20b3a0fb46c] 12 | description = "input is 9 characters" 13 | 14 | [ed6e8d1b-382c-4081-8326-8b772c581fec] 15 | description = "invalid characters are not ignored" 16 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "isbn-verifier" 4 | version = "2.7.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/src/lib.rs: -------------------------------------------------------------------------------- 1 | /// Determines whether the supplied string is a valid ISBN number 2 | pub fn is_valid_isbn(isbn: &str) -> bool { 3 | unimplemented!("Is {:?} a valid ISBN number?", isbn); 4 | } 5 | -------------------------------------------------------------------------------- /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 "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. 6 | 7 | Examples of isograms: 8 | 9 | - lumberjacks 10 | - background 11 | - downstream 12 | - six-year-old 13 | 14 | The word *isograms*, however, is not an isogram, because the s repeats. 15 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/isogram/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "isogram" 4 | version = "1.3.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/isogram/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn check(candidate: &str) -> bool { 2 | unimplemented!("Is {} an isogram?", candidate); 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Largest Series Product in Rust 2 | 3 | These iterators may be useful, depending on your approach 4 | 5 | - [Windows](https://doc.rust-lang.org/std/primitive.slice.html#method.windows) 6 | - [Product](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.product) 7 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "largest-series-product" 4 | version = "1.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, PartialEq, Eq)] 2 | pub enum Error { 3 | SpanTooLong, 4 | InvalidDigit(char), 5 | } 6 | 7 | pub fn lsp(string_digits: &str, span: usize) -> Result { 8 | unimplemented!( 9 | "largest series product of a span of {} digits in {}", 10 | span, 11 | string_digits 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/leap/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | You may use the [`arithmetic remainder` operator](https://doc.rust-lang.org/book/appendix-02-operators.html) to test for divisibility. 4 | -------------------------------------------------------------------------------- /exercises/practice/leap/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn is_leap_year(year: u64) -> bool { 2 | let has_factor = |n| year % n == 0; 3 | has_factor(4) && (!has_factor(100) || has_factor(400)) 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/leap/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "leap" 4 | version = "1.6.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/leap/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn is_leap_year(year: u64) -> bool { 2 | unimplemented!("true if {} is a leap year", year) 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/luhn-from/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/luhn-from/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "luhn-from" 4 | version = "0.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/luhn-trait/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/luhn-trait/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "luhn-trait" 4 | version = "0.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/luhn-trait/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub trait Luhn { 2 | fn valid_luhn(&self) -> bool; 3 | } 4 | 5 | /// Here is the example of how to implement custom Luhn trait 6 | /// for the &str type. Naturally, you can implement this trait 7 | /// by hand for the every other type presented in the test suite, 8 | /// but your solution will fail if a new type is presented. 9 | /// Perhaps there exists a better solution for this problem? 10 | impl<'a> Luhn for &'a str { 11 | fn valid_luhn(&self) -> bool { 12 | unimplemented!("Determine if '{}' is a valid credit card number.", self); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn is_valid(candidate: &str) -> bool { 2 | if candidate.chars().filter(|c| c.is_digit(10)).take(2).count() <= 1 3 | || candidate.chars().any(|c| !c.is_digit(10) && c != ' ') 4 | { 5 | return false; 6 | } 7 | 8 | candidate 9 | .chars() 10 | .filter_map(|c| c.to_digit(10)) 11 | .rev() 12 | .enumerate() 13 | .map(|(index, digit)| if index % 2 == 0 { digit } else { digit * 2 }) 14 | .map(|digit| if digit > 9 { digit - 9 } else { digit }) 15 | .sum::() 16 | % 10 17 | == 0 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/luhn/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "luhn" 4 | version = "1.6.1" 5 | -------------------------------------------------------------------------------- /exercises/practice/luhn/src/lib.rs: -------------------------------------------------------------------------------- 1 | /// Check a Luhn checksum. 2 | pub fn is_valid(code: &str) -> bool { 3 | unimplemented!("Is the Luhn checksum for {} valid?", code); 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/macros/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Compatibility 2 | 3 | Note that this exercise requires Rust 1.36 or later. 4 | -------------------------------------------------------------------------------- /exercises/practice/macros/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/macros/.meta/example.rs: -------------------------------------------------------------------------------- 1 | // Ignoring the README's injunction, this is heavily based on the implementation from maplit. 2 | // Original source is at https://github.com/bluss/maplit/blob/master/src/lib.rs#L27-L60 3 | 4 | #[macro_export] 5 | macro_rules! hashmap { 6 | ($($key:expr => $value:expr,)+) => { $crate::hashmap!($($key => $value),+) }; 7 | ($($key:expr => $value:expr),*) => { 8 | { 9 | let mut _map = ::std::collections::HashMap::new(); 10 | $( 11 | _map.insert($key, $value); 12 | )* 13 | _map 14 | } 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /exercises/practice/macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "macros" 4 | version = "0.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/macros/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! hashmap { 3 | () => { 4 | unimplemented!() 5 | }; 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/macros/tests/invalid/comma-sep.rs: -------------------------------------------------------------------------------- 1 | use macros::hashmap; 2 | use std::collections::HashMap; 3 | 4 | fn main() { 5 | // using only commas is invalid 6 | let _hm: HashMap<_, _> = hashmap!('a', 1); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/macros/tests/invalid/double-commas.rs: -------------------------------------------------------------------------------- 1 | use macros::hashmap; 2 | use std::collections::HashMap; 3 | 4 | fn main() { 5 | // a single trailing comma is okay, but two is not 6 | let _hm: HashMap<_, _> = hashmap!('a' => 2, ,); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/macros/tests/invalid/leading-comma.rs: -------------------------------------------------------------------------------- 1 | use macros::hashmap; 2 | use std::collections::HashMap; 3 | 4 | fn main() { 5 | // leading commas are not valid 6 | let _hm: HashMap<_, _> = hashmap!(, 'a' => 2); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/macros/tests/invalid/missing-argument.rs: -------------------------------------------------------------------------------- 1 | use macros::hashmap; 2 | use std::collections::HashMap; 3 | 4 | fn main() { 5 | // an argument should come between each pair of commas 6 | let _hm: HashMap<_, _> = hashmap!('a' => 1, , 'b' => 2); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/macros/tests/invalid/no-comma.rs: -------------------------------------------------------------------------------- 1 | use macros::hashmap; 2 | use std::collections::HashMap; 3 | 4 | fn main() { 5 | // Key value pairs must be separated by commas 6 | let _hm: HashMap<_, _> = hashmap!('a' => 1 'b' => 2); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/macros/tests/invalid/only-arrow.rs: -------------------------------------------------------------------------------- 1 | use macros::hashmap; 2 | use std::collections::HashMap; 3 | 4 | fn main() { 5 | // a single random arrow is not valid 6 | let _hm: HashMap<(), ()> = hashmap!(=>); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/macros/tests/invalid/only-comma.rs: -------------------------------------------------------------------------------- 1 | use macros::hashmap; 2 | use std::collections::HashMap; 3 | 4 | fn main() { 5 | // a single random comma is not valid 6 | let _hm: HashMap<(), ()> = hashmap!(,); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/macros/tests/invalid/single-argument.rs: -------------------------------------------------------------------------------- 1 | use macros::hashmap; 2 | use std::collections::HashMap; 3 | 4 | fn main() { 5 | // a single argument is invalid 6 | let _hm: HashMap<_, _> = hashmap!('a'); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/macros/tests/invalid/triple-arguments.rs: -------------------------------------------------------------------------------- 1 | use macros::hashmap; 2 | use std::collections::HashMap; 3 | 4 | fn main() { 5 | // three arguments are invalid 6 | hashmap!('a' => 1, 'b'); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/macros/tests/invalid/two-arrows.rs: -------------------------------------------------------------------------------- 1 | use macros::hashmap; 2 | use std::collections::HashMap; 3 | 4 | fn main() { 5 | // a trailing => isn't valid either 6 | hashmap!('a' => 2, =>); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a string containing brackets `[]`, braces `{}`, parentheses `()`, 4 | or any combination thereof, verify that any and all pairs are matched 5 | and nested correctly. 6 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "matching-brackets" 4 | version = "2.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn brackets_are_balanced(string: &str) -> bool { 2 | unimplemented!( 3 | "Check if the string \"{}\" contains balanced brackets", 4 | string 5 | ); 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "minesweeper" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn annotate(minefield: &[&str]) -> Vec { 2 | unimplemented!("\nAnnotate each square of the given minefield with the number of mines that surround said square (blank if there are no surrounding mines):\n{:#?}\n", minefield); 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | Remember that while people commonly count with 1-based indexing (i.e. "the 6th prime is 13"), many programming languages, including Rust, use 0-based indexing (i.e. `primes[5] == 13`). Use 0-based indexing for your implementation. 4 | -------------------------------------------------------------------------------- /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 6 | the 6th prime is 13. 7 | 8 | If your language provides methods in the standard library to deal with prime 9 | numbers, pretend they don't exist and implement them yourself. 10 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/example.rs: -------------------------------------------------------------------------------- 1 | fn is_prime(n: u32) -> bool { 2 | let mut i = 3; 3 | while (i * i) < (n + 1) { 4 | if n % i == 0 { 5 | return false; 6 | } 7 | i += 1; 8 | } 9 | true 10 | } 11 | 12 | pub fn nth(n: u32) -> u32 { 13 | if n == 0 { 14 | 2 15 | } else { 16 | let mut count = 0; 17 | let mut candidate = 1; 18 | while count < n { 19 | candidate += 2; 20 | if is_prime(candidate) { 21 | count += 1; 22 | } 23 | } 24 | candidate 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "nth_prime" 4 | version = "2.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn nth(n: u32) -> u32 { 2 | unimplemented!("What is the 0-indexed {}th prime number?", n) 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/tests/nth-prime.rs: -------------------------------------------------------------------------------- 1 | use nth_prime as np; 2 | 3 | #[test] 4 | fn test_first_prime() { 5 | assert_eq!(np::nth(0), 2); 6 | } 7 | 8 | #[test] 9 | #[ignore] 10 | fn test_second_prime() { 11 | assert_eq!(np::nth(1), 3); 12 | } 13 | 14 | #[test] 15 | #[ignore] 16 | fn test_sixth_prime() { 17 | assert_eq!(np::nth(5), 13); 18 | } 19 | 20 | #[test] 21 | #[ignore] 22 | fn test_big_prime() { 23 | assert_eq!(np::nth(10_000), 104_743); 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-codons/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-codons/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nucleotide_codons" 3 | version = "0.1.0" 4 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "nucleotide-count" 4 | version = "1.3.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | pub fn count(nucleotide: char, dna: &str) -> Result { 4 | unimplemented!( 5 | "How much of nucleotide type '{}' is contained inside DNA string '{}'?", 6 | nucleotide, 7 | dna 8 | ); 9 | } 10 | 11 | pub fn nucleotide_counts(dna: &str) -> Result, char> { 12 | unimplemented!( 13 | "How much of every nucleotide type is contained inside DNA string '{}'?", 14 | dna 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "ocr-numbers" 4 | version = "0.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/src/lib.rs: -------------------------------------------------------------------------------- 1 | // The code below is a stub. Just enough to satisfy the compiler. 2 | // In order to pass the tests you can add-to or change any of this code. 3 | 4 | #[derive(Debug, PartialEq, Eq)] 5 | pub enum Error { 6 | InvalidRowCount(usize), 7 | InvalidColumnCount(usize), 8 | } 9 | 10 | pub fn convert(input: &str) -> Result { 11 | unimplemented!("Convert the input '{}' to a string", input); 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/paasio/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Abstraction over Networks and Files 2 | 3 | Network and file operations are implemented in terms of the [`io::Read`][read] and [`io::Write`][write] traits. It will therefore be necessary to implement those traits for your types. 4 | 5 | [read]: https://doc.rust-lang.org/std/io/trait.Read.html 6 | [write]: https://doc.rust-lang.org/std/io/trait.Write.html 7 | -------------------------------------------------------------------------------- /exercises/practice/paasio/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Report network IO statistics. 4 | 5 | You are writing a [PaaS][], and you need a way to bill customers based 6 | on network and filesystem usage. 7 | 8 | Create a wrapper for network connections and files that can report IO 9 | statistics. The wrapper must report: 10 | 11 | - The total number of bytes read/written. 12 | - The total number of read/write operations. 13 | 14 | [PaaS]: http://en.wikipedia.org/wiki/Platform_as_a_service 15 | -------------------------------------------------------------------------------- /exercises/practice/paasio/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/paasio/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "paasio" 4 | version = "0.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "palindrome-products" 4 | version = "1.2.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Determine if a sentence is a pangram. A pangram (Greek: παν γράμμα, pan gramma, 4 | "every letter") is a sentence using every letter of the alphabet at least once. 5 | The best known English pangram is: 6 | > The quick brown fox jumps over the lazy dog. 7 | 8 | The alphabet used consists of ASCII letters `a` to `z`, inclusive, and is case 9 | insensitive. Any characters which are not an ASCII letter should be ignored. 10 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/example.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeSet; 2 | 3 | pub fn is_pangram(sentence: &str) -> bool { 4 | sentence 5 | .to_lowercase() 6 | .chars() 7 | .filter(|c| c.is_alphabetic()) 8 | .filter(|c| c.is_ascii()) 9 | .collect::>() 10 | == english_letter_set() 11 | } 12 | 13 | fn english_letter_set() -> BTreeSet { 14 | ENGLISH_ALPHABET.chars().collect() 15 | } 16 | 17 | const ENGLISH_ALPHABET: &str = "abcdefghijklmnopqrstuvwxyz"; 18 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/pangram/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "pangram" 4 | version = "0.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/pangram/src/lib.rs: -------------------------------------------------------------------------------- 1 | /// Determine whether a sentence is a pangram. 2 | pub fn is_pangram(sentence: &str) -> bool { 3 | unimplemented!("Is {} a pangram?", sentence); 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Count the frequency of letters in texts using parallel computation. 4 | 5 | Parallelism is about doing things in parallel that can also be done 6 | sequentially. A common example is counting the frequency of letters. 7 | Create a function that returns the total frequency of each letter in a 8 | list of texts and that employs parallelism. 9 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "parallel-letter-frequency" 4 | version = "0.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | pub fn frequency(input: &[&str], worker_count: usize) -> HashMap { 4 | unimplemented!( 5 | "Count the frequency of letters in the given input '{:?}'. Ensure that you are using {} to process the input.", 6 | input, 7 | match worker_count { 8 | 1 => "1 worker".to_string(), 9 | _ => format!("{} workers", worker_count), 10 | } 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Compute Pascal's triangle up to a given number of rows. 4 | 5 | In Pascal's Triangle each number is computed by adding the numbers to 6 | the right and left of the current position in the previous row. 7 | 8 | ```text 9 | 1 10 | 1 1 11 | 1 2 1 12 | 1 3 3 1 13 | 1 4 6 4 1 14 | # ... etc 15 | ``` 16 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "pascals-triangle" 4 | version = "1.5.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub struct PascalsTriangle; 2 | 3 | impl PascalsTriangle { 4 | pub fn new(row_count: u32) -> Self { 5 | unimplemented!("create Pascal's triangle with {} rows", row_count); 6 | } 7 | 8 | pub fn rows(&self) -> Vec> { 9 | unimplemented!(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn classify(num: u64) -> Option { 2 | if num == 0 { 3 | return None; 4 | } 5 | let sum: u64 = (1..num).filter(|i| num % i == 0).sum(); 6 | Some(match sum.cmp(&num) { 7 | std::cmp::Ordering::Equal => Classification::Perfect, 8 | std::cmp::Ordering::Less => Classification::Deficient, 9 | std::cmp::Ordering::Greater => Classification::Abundant, 10 | }) 11 | } 12 | 13 | #[derive(Debug, PartialEq, Eq)] 14 | pub enum Classification { 15 | Abundant, 16 | Perfect, 17 | Deficient, 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "perfect_numbers" 4 | version = "1.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, PartialEq, Eq)] 2 | pub enum Classification { 3 | Abundant, 4 | Perfect, 5 | Deficient, 6 | } 7 | 8 | pub fn classify(num: u64) -> Option { 9 | unimplemented!("classify {}", num); 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "phone-number" 4 | version = "1.6.1" 5 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn number(user_number: &str) -> Option { 2 | unimplemented!( 3 | "Given the number entered by user '{}', convert it into SMS-friendly format. If the entered number is not a valid NANP number, return None.", 4 | user_number 5 | ); 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.meta/Cargo-example.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "pig-latin" 4 | version = "1.0.0" 5 | 6 | [dependencies] 7 | regex = "0.2" 8 | lazy_static = "1.4.0" 9 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "pig-latin" 4 | version = "1.0.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn translate(input: &str) -> String { 2 | unimplemented!( 3 | "Using the Pig Latin text transformation rules, convert the given input '{}'", 4 | input 5 | ); 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/poker/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Pick the best hand(s) from a list of poker hands. 4 | 5 | See [wikipedia](https://en.wikipedia.org/wiki/List_of_poker_hands) for an 6 | overview of poker hands. 7 | -------------------------------------------------------------------------------- /exercises/practice/poker/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/poker/.meta/Cargo-example.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "poker" 4 | version = "1.0.0" 5 | 6 | [dependencies] 7 | counter = "0.5.2" 8 | -------------------------------------------------------------------------------- /exercises/practice/poker/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/poker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "poker" 4 | version = "1.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/poker/src/lib.rs: -------------------------------------------------------------------------------- 1 | /// Given a list of poker hands, return a list of those hands which win. 2 | /// 3 | /// Note the type signature: this function should return _the same_ reference to 4 | /// the winning hand(s) as were passed in, not reconstructed strings which happen to be equal. 5 | pub fn winning_hands<'a>(hands: &[&'a str]) -> Vec<&'a str> { 6 | unimplemented!("Out of {:?}, which hand wins?", hands) 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn factors(n: u64) -> Vec { 2 | let mut val = n; 3 | let mut out: Vec = vec![]; 4 | let mut possible: u64 = 2; 5 | while val > 1 { 6 | while val % possible == 0 { 7 | out.push(possible); 8 | val /= possible; 9 | } 10 | possible += 1; 11 | } 12 | out 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "prime_factors" 4 | version = "1.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn factors(n: u64) -> Vec { 2 | unimplemented!("This should calculate the prime factors of {}", n) 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "protein-translation" 4 | version = "0.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn build_proverb(items: &[&str]) -> String { 2 | let mut stanzas = Vec::with_capacity(items.len()); 3 | for index in 0..items.len() { 4 | if index == items.len() - 1 { 5 | stanzas.push(format!("And all for the want of a {}.", items[0])); 6 | } else { 7 | stanzas.push(format!( 8 | "For want of a {} the {} was lost.", 9 | items[index], 10 | items[index + 1] 11 | )); 12 | } 13 | } 14 | stanzas.join("\n") 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/proverb/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "proverb" 4 | version = "1.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/proverb/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn build_proverb(list: &[&str]) -> String { 2 | unimplemented!("build a proverb from this list of items: {:?}", list) 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | A Pythagorean triplet is a set of three natural numbers, {a, b, c}, for 4 | which, 5 | 6 | ```text 7 | a**2 + b**2 = c**2 8 | ``` 9 | 10 | and such that, 11 | 12 | ```text 13 | a < b < c 14 | ``` 15 | 16 | For example, 17 | 18 | ```text 19 | 3**2 + 4**2 = 9 + 16 = 25 = 5**2. 20 | ``` 21 | 22 | Given an input integer N, find all Pythagorean triplets for which `a + b + c = N`. 23 | 24 | For example, with N = 1000, there is exactly one Pythagorean triplet for which `a + b + c = 1000`: `{200, 375, 425}`. 25 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/Cargo.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | 3 | [package] 4 | edition = "2021" 5 | name = "pythagorean_triplet" 6 | version = "1.0.0" 7 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashSet; 2 | 3 | pub fn find(sum: u32) -> HashSet<[u32; 3]> { 4 | unimplemented!("Given the sum {}, return all possible Pythagorean triplets, which produce the said sum, or an empty HashSet if there are no such triplets. Note that you are expected to return triplets in [a, b, c] order, where a < b < c", sum); 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "queen-attack" 4 | version = "2.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "rail_fence_cipher" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub struct RailFence; 2 | 3 | impl RailFence { 4 | pub fn new(rails: u32) -> RailFence { 5 | unimplemented!("Construct a new fence with {} rails", rails) 6 | } 7 | 8 | pub fn encode(&self, text: &str) -> String { 9 | unimplemented!("Encode this text: {}", text) 10 | } 11 | 12 | pub fn decode(&self, cipher: &str) -> String { 13 | unimplemented!("Decode this ciphertext: {}", cipher) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn raindrops(n: u32) -> String { 2 | let is_pling = |n| n % 3 == 0; 3 | let is_plang = |n| n % 5 == 0; 4 | let is_plong = |n| n % 7 == 0; 5 | let mut drops = String::new(); 6 | if is_pling(n) { 7 | drops.push_str("Pling"); 8 | } 9 | if is_plang(n) { 10 | drops.push_str("Plang"); 11 | } 12 | if is_plong(n) { 13 | drops.push_str("Plong"); 14 | } 15 | if drops.is_empty() { 16 | let s = format!("{}", n); 17 | drops.push_str(&s); 18 | } 19 | drops 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "raindrops" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn raindrops(n: u32) -> String { 2 | unimplemented!("what sound does Raindrop #{} make?", n) 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/react/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/react/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "react" 4 | version = "2.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/rectangles/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/rectangles/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/rectangles/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "rectangles" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/rectangles/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn count(lines: &[&str]) -> u32 { 2 | unimplemented!("\nDetermine the count of rectangles in the ASCII diagram represented by the following lines:\n{:#?}\n.", lines); 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Reverse a string 4 | 5 | For example: 6 | input: "cool" 7 | output: "looc" 8 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn reverse(input: &str) -> String { 2 | input.chars().rev().collect() 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/Cargo.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | 3 | [features] 4 | grapheme = [] 5 | 6 | [package] 7 | edition = "2021" 8 | name = "reverse_string" 9 | version = "1.2.0" 10 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn reverse(input: &str) -> String { 2 | unimplemented!("Write a function to reverse {}", input); 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Notes on Rust implementation 2 | 3 | By using private fields in structs with public `new` functions returning 4 | `Option` or `Result` (as here with `DNA::new` & `RNA::new`), we can guarantee 5 | that the internal representation of `DNA` is correct. Because every valid DNA 6 | string has a valid RNA string, we don't need to return a `Result`/`Option` from 7 | `into_rna`. 8 | 9 | This explains the type signatures you will see in the tests. 10 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "rna-transcription" 4 | version = "1.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.meta/Cargo-example.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "robot-name" 4 | version = "0.0.0" 5 | 6 | [dependencies] 7 | lazy_static = "1.4.0" 8 | rand = "0.3.12" 9 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "robot-name" 4 | version = "0.0.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub struct Robot; 2 | 3 | impl Robot { 4 | pub fn new() -> Self { 5 | unimplemented!("Construct a new Robot struct."); 6 | } 7 | 8 | pub fn name(&self) -> &str { 9 | unimplemented!("Return the reference to the robot's name."); 10 | } 11 | 12 | pub fn reset_name(&mut self) { 13 | unimplemented!("Assign a new unique name to the robot."); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "robot-simulator" 4 | version = "2.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "roman-numerals" 4 | version = "1.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::fmt::{Display, Formatter, Result}; 2 | 3 | pub struct Roman; 4 | 5 | impl Display for Roman { 6 | fn fmt(&self, _f: &mut Formatter<'_>) -> Result { 7 | unimplemented!("Return a roman-numeral string representation of the Roman object"); 8 | } 9 | } 10 | 11 | impl From for Roman { 12 | fn from(num: u32) -> Self { 13 | unimplemented!("Construct a Roman object from the '{}' number", num); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn rotate(text: &str, key: i8) -> String { 2 | let key = if key < 0 { (26 + key) as u8 } else { key as u8 }; 3 | 4 | text.chars() 5 | .map(|c| { 6 | if c.is_alphabetic() { 7 | let case = if c.is_uppercase() { 'A' } else { 'a' } as u8; 8 | 9 | (((c as u8 - case + key) % 26) + case) as char 10 | } else { 11 | c 12 | } 13 | }) 14 | .collect() 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [71b541bb-819c-4dc6-a9c3-132ef9bb737b] 6 | description = "rotate spaces" 7 | 8 | [ef32601d-e9ef-4b29-b2b5-8971392282e6] 9 | description = "rotate numbers" 10 | 11 | [32dd74f6-db2b-41a6-b02c-82eb4f93e549] 12 | description = "rotate punctuation" 13 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "rotational-cipher" 4 | version = "1.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn rotate(input: &str, key: i8) -> String { 2 | unimplemented!( 3 | "How would input text '{}' transform when every letter is shifted using key '{}'?", 4 | input, 5 | key 6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "run-length-encoding" 4 | version = "1.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn encode(source: &str) -> String { 2 | unimplemented!("Return the run-length encoding of {}.", source); 3 | } 4 | 5 | pub fn decode(source: &str) -> String { 6 | unimplemented!("Return the run-length decoding of {}.", source); 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "saddle-points" 4 | version = "1.3.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn find_saddle_points(input: &[Vec]) -> Vec<(usize, usize)> { 2 | unimplemented!( 3 | "find the saddle points of the following matrix: {:?}", 4 | input 5 | ) 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/say/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/say/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [5d22a120-ba0c-428c-bd25-8682235d83e8] 6 | description = "zero" 7 | 8 | [9b5eed77-dbf6-439d-b920-3f7eb58928f6] 9 | description = "one" 10 | 11 | [7c499be1-612e-4096-a5e1-43b2f719406d] 12 | description = "fourteen" 13 | 14 | [f541dd8e-f070-4329-92b4-b7ce2fcf06b4] 15 | description = "twenty" 16 | -------------------------------------------------------------------------------- /exercises/practice/say/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "say" 4 | version = "1.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/say/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn encode(n: u64) -> String { 2 | unimplemented!("Say {} in English.", n); 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/scale-generator/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/scale-generator/.meta/Cargo-example.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "scale_generator" 4 | version = "1.0.0" 5 | 6 | [dependencies] 7 | enum-primitive-derive = "^0.1" 8 | failure = "0.1" 9 | failure_derive = "0.1" 10 | itertools = "0.7" 11 | num-traits = "^0.1" 12 | -------------------------------------------------------------------------------- /exercises/practice/scale-generator/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [37114c0b-c54d-45da-9f4b-3848201470b0] 6 | description = "Octatonic" 7 | 8 | [496466e7-aa45-4bbd-a64d-f41030feed9c] 9 | description = "Hexatonic" 10 | 11 | [bee5d9ec-e226-47b6-b62b-847a9241f3cc] 12 | description = "Pentatonic" 13 | 14 | [dbee06a6-7535-4ab7-98e8-d8a36c8402d1] 15 | description = "Enigmatic" 16 | -------------------------------------------------------------------------------- /exercises/practice/scale-generator/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "scale_generator" 4 | version = "2.0.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [d3088ad9-570c-4b51-8764-c75d5a430e99] 6 | description = "medium word" 7 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "scrabble-score" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/src/lib.rs: -------------------------------------------------------------------------------- 1 | /// Compute the Scrabble score for a word. 2 | pub fn score(word: &str) -> u64 { 3 | unimplemented!("Score {} in Scrabble.", word); 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/series/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/series/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn series(digits: &str, len: usize) -> Vec { 2 | match len { 3 | 0 => vec!["".to_string(); digits.len() + 1], 4 | _ => digits 5 | .chars() 6 | .collect::>() 7 | .windows(len) 8 | .map(|window| window.iter().collect::()) 9 | .collect::>(), 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/series/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/series/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "series" 4 | version = "0.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/series/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn series(digits: &str, len: usize) -> Vec { 2 | unimplemented!( 3 | "What are the series of length {} in string {:?}", 4 | len, 5 | digits 6 | ) 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn primes_up_to(limit: i32) -> Vec { 2 | let mut integers = (1..limit).map(|x| x + 1).collect::>(); 3 | let mut p = Some(2); 4 | 5 | while let Some(y) = p { 6 | integers.retain(|&x| (x == y) || (x % y != 0)); 7 | p = integers.clone().into_iter().find(|x| *x > y); 8 | } 9 | integers 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [2e2417b7-3f3a-452a-8594-b9af08af6d82] 6 | description = "limit is prime" 7 | -------------------------------------------------------------------------------- /exercises/practice/sieve/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "sieve" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/sieve/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn primes_up_to(upper_bound: u64) -> Vec { 2 | unimplemented!("Construct a vector of all primes up to {}", upper_bound); 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "simple-cipher" 4 | version = "0.0.0" 5 | 6 | [dependencies] 7 | rand = "0.8" 8 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn encode(key: &str, s: &str) -> Option { 2 | unimplemented!("Use {} to encode {} using shift cipher", key, s) 3 | } 4 | 5 | pub fn decode(key: &str, s: &str) -> Option { 6 | unimplemented!("Use {} to decode {} using shift cipher", key, s) 7 | } 8 | 9 | pub fn encode_random(s: &str) -> (String, String) { 10 | unimplemented!( 11 | "Generate random key with only a-z chars and encode {}. Return tuple (key, encoded s)", 12 | s 13 | ) 14 | } 15 | -------------------------------------------------------------------------------- /exercises/practice/simple-linked-list/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/simple-linked-list/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "simple_linked_list" 4 | version = "0.1.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/space-age/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "space-age" 4 | version = "1.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given the size, return a square matrix of numbers in spiral order. 4 | 5 | The matrix should be filled with natural numbers, starting from 1 6 | in the top-left corner, increasing in an inward, clockwise spiral order, 7 | like these examples: 8 | 9 | ## Examples 10 | ### Spiral matrix of size 3 11 | 12 | ```text 13 | 1 2 3 14 | 8 9 4 15 | 7 6 5 16 | ``` 17 | 18 | ### Spiral matrix of size 4 19 | 20 | ```text 21 | 1 2 3 4 22 | 12 13 14 5 23 | 11 16 15 6 24 | 10 9 8 7 25 | ``` 26 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [8f584201-b446-4bc9-b132-811c8edd9040] 6 | description = "empty spiral" 7 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "spiral-matrix" 4 | version = "1.1.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn spiral_matrix(size: u32) -> Vec> { 2 | unimplemented!( 3 | "Function that returns the spiral matrix of square size {}", 4 | size 5 | ); 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/sublist/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/sublist/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [81f3d3f7-4f25-4ada-bcdc-897c403de1b6] 6 | description = "sublist in middle" 7 | 8 | [43bcae1e-a9cf-470e-923e-0946e04d8fdd] 9 | description = "sublist at end" 10 | -------------------------------------------------------------------------------- /exercises/practice/sublist/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "sublist" 4 | version = "0.0.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/sublist/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, PartialEq, Eq)] 2 | pub enum Comparison { 3 | Equal, 4 | Sublist, 5 | Superlist, 6 | Unequal, 7 | } 8 | 9 | pub fn sublist(_first_list: &[T], _second_list: &[T]) -> Comparison { 10 | unimplemented!("Determine if the first list is equal to, sublist of, superlist of or unequal to the second list."); 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a number, find the sum of all the unique multiples of particular numbers up to 4 | but not including that number. 5 | 6 | If we list all the natural numbers below 20 that are multiples of 3 or 5, 7 | we get 3, 5, 6, 9, 10, 12, 15, and 18. 8 | 9 | The sum of these multiples is 78. 10 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.meta/example.rs: -------------------------------------------------------------------------------- 1 | use std::collections::BTreeSet; 2 | 3 | pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 { 4 | let mut multiples: BTreeSet = BTreeSet::new(); 5 | 6 | for &f in factors.iter().filter(|&&c| c > 0) { 7 | let mut multiplier = 2; 8 | let mut x = f; 9 | while x < limit { 10 | multiples.insert(x); 11 | x = f * multiplier; 12 | multiplier += 1; 13 | } 14 | } 15 | 16 | multiples.iter().sum() 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "sum-of-multiples" 4 | version = "1.5.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 { 2 | unimplemented!( 3 | "Sum the multiples of all of {:?} which are less than {}", 4 | factors, 5 | limit 6 | ) 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/tournament/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/tournament/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "tournament" 4 | version = "1.4.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/tournament/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn tally(match_results: &str) -> String { 2 | unimplemented!( 3 | "Given the result of the played matches '{}' return a properly formatted tally table string.", 4 | match_results 5 | ); 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/triangle/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "triangle" 4 | version = "0.0.0" 5 | 6 | [features] 7 | generic = [] 8 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "two-bucket" 4 | version = "1.4.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/example.rs: -------------------------------------------------------------------------------- 1 | pub fn twofer(name: &str) -> String { 2 | match name { 3 | "" => "One for you, one for me.".to_string(), 4 | _ => format!("One for {}, one for me.", name), 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "twofer" 4 | version = "1.2.0" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn twofer(name: &str) -> String { 2 | unimplemented!("how many for {}", name) 3 | } 4 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/tests/two-fer.rs: -------------------------------------------------------------------------------- 1 | use twofer::twofer; 2 | 3 | #[test] 4 | fn empty_string() { 5 | assert_eq!(twofer(""), "One for you, one for me."); 6 | } 7 | 8 | #[test] 9 | #[ignore] 10 | fn alice() { 11 | assert_eq!(twofer("Alice"), "One for Alice, one for me."); 12 | } 13 | 14 | #[test] 15 | #[ignore] 16 | fn bob() { 17 | assert_eq!(twofer("Bob"), "One for Bob, one for me."); 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "variable-length-quantity" 4 | version = "1.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, PartialEq, Eq)] 2 | pub enum Error { 3 | IncompleteNumber, 4 | Overflow, 5 | } 6 | 7 | /// Convert a list of numbers to a stream of bytes encoded with variable length encoding. 8 | pub fn to_bytes(values: &[u32]) -> Vec { 9 | unimplemented!("Convert the values {:?} to a list of bytes", values) 10 | } 11 | 12 | /// Given a stream of bytes, extract all numbers which are encoded in there. 13 | pub fn from_bytes(bytes: &[u8]) -> Result, Error> { 14 | unimplemented!("Convert the list of bytes {:?} to a list of numbers", bytes) 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.meta/example.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | pub fn word_count(input: &str) -> HashMap { 4 | let mut map: HashMap = HashMap::new(); 5 | let lower = input.to_lowercase(); 6 | let slice: &str = lower.as_ref(); 7 | for word in slice 8 | .split(|c: char| !c.is_alphanumeric() && c != '\'') 9 | .filter(|s| !s.is_empty()) 10 | .map(|s| s.trim_matches('\'')) 11 | { 12 | *map.entry(word.to_string()).or_insert(0) += 1; 13 | } 14 | map 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [4185a902-bdb0-4074-864c-f416e42a0f19] 6 | description = "with apostrophes" 7 | 8 | [be72af2b-8afe-4337-b151-b297202e4a7b] 9 | description = "with quotations" 10 | 11 | [c5f4ef26-f3f7-4725-b314-855c04fb4c13] 12 | description = "multiple spaces not detected as a word" 13 | -------------------------------------------------------------------------------- /exercises/practice/word-count/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "word-count" 4 | version = "1.2.0" 5 | -------------------------------------------------------------------------------- /exercises/practice/word-count/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | /// Count occurrences of words. 4 | pub fn word_count(words: &str) -> HashMap { 5 | unimplemented!("Count of occurrences of words in {:?}", words); 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/wordy/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | To get the bonus tests to run, execute the tests with: 4 | 5 | ```bash 6 | $ cargo test --features exponentials 7 | ``` -------------------------------------------------------------------------------- /exercises/practice/wordy/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /exercises/practice/wordy/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "wordy" 4 | version = "1.5.0" 5 | 6 | [features] 7 | exponentials = [] 8 | -------------------------------------------------------------------------------- /exercises/practice/wordy/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub struct WordProblem; 2 | 3 | pub fn answer(command: &str) -> Option { 4 | unimplemented!( 5 | "Return the result of the command '{}' or None, if the command is invalid.", 6 | command 7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/xorcism/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Lifetime of `munge` return value 2 | 3 | Due to the usage of the `impl Trait` feature, lifetime management may be a bit 4 | tricky when implementing the `munge` method. You may find it easier to write 5 | your own `struct` with an `Iterator` implementation and return that concrete 6 | type, at least to get started. Ultimately, it's a good idea to try and implement 7 | the solution using `Iterator` combinators directly. 8 | -------------------------------------------------------------------------------- /exercises/practice/xorcism/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "xorcism" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dependencies] 8 | 9 | [features] 10 | io = [] 11 | 12 | [dev-dependencies] 13 | hexlit = "0.5.0" 14 | rstest = "0.12.0" 15 | rstest_reuse = "0.1.0" 16 | -------------------------------------------------------------------------------- /util/exercise/src/cmd/defaults/README.md: -------------------------------------------------------------------------------- 1 | # Defaults 2 | 3 | The files in this directory are used in appropriate places for defaults. They 4 | are included at build-time in the compiled executable: if you change one, you 5 | will need to recompile to see those changes reflected in the output. 6 | 7 | Using external files makes it easier to ensure that formatting etc is correct, 8 | without needing to worry about proper escaping within a Rust source file. 9 | -------------------------------------------------------------------------------- /util/exercise/src/cmd/defaults/description.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Describe your exercise here. 4 | 5 | Don't forget that `README.md` is automatically generated; update this within 6 | `.meta/description.md`. 7 | -------------------------------------------------------------------------------- /util/exercise/src/cmd/defaults/example.rs: -------------------------------------------------------------------------------- 1 | //! Example implementation 2 | //! 3 | //! - Implement the solution to your exercise here. 4 | //! - Put the stubs for any tested functions in `src/lib.rs`, 5 | //! whose variable names are `_` and 6 | //! whose contents are `unimplemented!()`. 7 | //! - If your example implementation has dependencies, copy 8 | //! `Cargo.toml` into `Cargo-example.toml` and then make 9 | //! any modifications necessary to the latter so your example will run. 10 | //! - Test your example by running `../../bin/test-exercise` 11 | -------------------------------------------------------------------------------- /util/exercise/src/cmd/defaults/gitignore: -------------------------------------------------------------------------------- 1 | # Generated by exercism rust track exercise tool 2 | # will have compiled files and executables 3 | /target/ 4 | **/*.rs.bk 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /util/exercise/src/cmd/defaults/metadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | blurb: "" 3 | source: "" 4 | source_url: "" 5 | -------------------------------------------------------------------------------- /util/exercise/src/cmd/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod configure; 2 | pub mod fetch_configlet; 3 | pub mod generate; 4 | pub mod update; 5 | -------------------------------------------------------------------------------- /util/exercise/src/cmd/templates/test_fn.rs: -------------------------------------------------------------------------------- 1 | {% import "macros.rs" as macros -%} 2 | 3 | #[test] 4 | {% if not first_test_case -%} 5 | #[ignore] 6 | {% endif -%} 7 | /// {{ description }} 8 | {% if comments -%} 9 | /// 10 | {% for comment in comments %} 11 | /// {{ comment }} 12 | {% endfor %} 13 | {% endif -%} 14 | fn test_{{ format_description(description=description) }}() { 15 | process_{{ format_property(property=property) }}_case( 16 | {{ macros::to_literal(value=input, use_maplit=use_maplit) }}, 17 | {{ macros::to_literal(value=expected, use_maplit=use_maplit) }} 18 | ); 19 | } 20 | --------------------------------------------------------------------------------