├── .appends └── .github │ └── labels.yml ├── .clang-format ├── .github ├── CODEOWNERS ├── dependabot.yml ├── labels.yml ├── stale.yml └── workflows │ ├── checks.yml │ ├── configlet.yml │ ├── format-code.yml │ ├── no-important-files-changed.yml │ ├── ping-cross-track-maintainers-team.yml │ ├── sync-labels.yml │ └── test.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── bin ├── check-include-guards ├── check-unitybegin ├── fetch-configlet ├── run-tests └── verify-unity-version ├── concepts ├── basics │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── bits │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── blocks │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── booleans │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── conditionals │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── dynamic-memory-management │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── function-pointers │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── linkage │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── loops │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── pointers │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── recursion │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── scope │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── static-functions │ ├── .meta │ │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json └── storage-class-specifiers │ ├── .meta │ └── config.json │ ├── about.md │ ├── introduction.md │ └── links.json ├── config.json ├── docs ├── ABOUT.md ├── CONTRIBUTING.md ├── C_STYLE_GUIDE.md ├── INSTALLATION.md ├── LEARNING.md ├── RESOURCES.md ├── SNIPPET.txt ├── TESTS.md ├── VERSIONS.md └── config.json ├── exercises ├── practice │ ├── acronym │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ └── look-for-start-chars │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── acronym.c │ │ ├── acronym.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_acronym.c │ ├── all-your-base │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── all_your_base.c │ │ ├── all_your_base.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_all_your_base.c │ ├── allergies │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── allergies.c │ │ ├── allergies.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_allergies.c │ ├── anagram │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── anagram.c │ │ ├── anagram.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_anagram.c │ ├── armstrong-numbers │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ └── log10-no-pow │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── armstrong_numbers.c │ │ ├── armstrong_numbers.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_armstrong_numbers.c │ ├── atbash-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── atbash_cipher.c │ │ ├── atbash_cipher.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_atbash_cipher.c │ ├── beer-song │ │ ├── .approaches │ │ │ ├── complexity-in-data │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ └── introduction.md │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── beer_song.c │ │ ├── beer_song.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_beer_song.c │ ├── binary-search-tree │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── binary_search_tree.c │ │ ├── binary_search_tree.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_binary_search_tree.c │ ├── binary-search │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ └── while-with-if-statements │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── binary_search.c │ │ ├── binary_search.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_binary_search.c │ ├── binary │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── binary.c │ │ ├── binary.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_binary.c │ ├── bob │ │ ├── .approaches │ │ │ ├── answer-array │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ └── introduction.md │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── bob.c │ │ ├── bob.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_bob.c │ ├── circular-buffer │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── circular_buffer.c │ │ ├── circular_buffer.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_circular_buffer.c │ ├── clock │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ └── minimize-duplicate-code │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── clock.c │ │ ├── clock.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_clock.c │ ├── collatz-conjecture │ │ ├── .approaches │ │ │ ├── bitwise-operations │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ └── introduction.md │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── collatz_conjecture.c │ │ ├── collatz_conjecture.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_collatz_conjecture.c │ ├── complex-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── complex_numbers.c │ │ ├── complex_numbers.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_complex_numbers.c │ ├── crypto-square │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── crypto_square.c │ │ ├── crypto_square.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_crypto_square.c │ ├── darts │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── hypot-for-radius │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── introduction.md │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── darts.c │ │ ├── darts.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_darts.c │ ├── diamond │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── diamond.c │ │ ├── diamond.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_diamond.c │ ├── difference-of-squares │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── formula │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── introduction.md │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── difference_of_squares.c │ │ ├── difference_of_squares.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_difference_of_squares.c │ ├── dnd-character │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── dnd_character.c │ │ ├── dnd_character.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_dnd_character.c │ ├── eliuds-eggs │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── eliuds_eggs.c │ │ ├── eliuds_eggs.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_eliuds_eggs.c │ ├── etl │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── etl.c │ │ ├── etl.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_etl.c │ ├── gigasecond │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── gigasecond.c │ │ ├── gigasecond.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_gigasecond.c │ ├── grade-school │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── grade_school.c │ │ ├── grade_school.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_grade_school.c │ ├── grains │ │ ├── .approaches │ │ │ ├── bit-shifting │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ └── introduction.md │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── grains.c │ │ ├── grains.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_grains.c │ ├── hamming │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── increment-pointers │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── introduction.md │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── hamming.c │ │ ├── hamming.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_hamming.c │ ├── hello-world │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── hello_world.c │ │ ├── hello_world.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_hello_world.c │ ├── high-scores │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── high_scores.c │ │ ├── high_scores.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_high_scores.c │ ├── isogram │ │ ├── .approaches │ │ │ ├── bitfield │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ └── introduction.md │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── isogram.c │ │ ├── isogram.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_isogram.c │ ├── kindergarten-garden │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── kindergarten_garden.c │ │ ├── kindergarten_garden.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_kindergarten_garden.c │ ├── knapsack │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── knapsack.c │ │ ├── knapsack.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_knapsack.c │ ├── largest-series-product │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── largest_series_product.c │ │ ├── largest_series_product.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_largest_series_product.c │ ├── leap │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── leap.c │ │ ├── leap.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_leap.c │ ├── linked-list │ │ ├── .approaches │ │ │ ├── circular-doubly-linked-list │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ └── introduction.md │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── linked_list.c │ │ ├── linked_list.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_linked_list.c │ ├── list-ops │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── list_ops.c │ │ ├── list_ops.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_list_ops.c │ ├── luhn │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── luhn.c │ │ ├── luhn.h │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_luhn.c │ ├── matching-brackets │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── matching_brackets.c │ │ ├── matching_brackets.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_matching_brackets.c │ ├── meetup │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── meetup.c │ │ ├── meetup.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_meetup.c │ ├── minesweeper │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── minesweeper.c │ │ ├── minesweeper.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_minesweeper.c │ ├── nth-prime │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── nth_prime.c │ │ ├── nth_prime.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_nth_prime.c │ ├── nucleotide-count │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── nucleotide_count.c │ │ ├── nucleotide_count.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_nucleotide_count.c │ ├── palindrome-products │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── palindrome_products.c │ │ ├── palindrome_products.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_palindrome_products.c │ ├── pangram │ │ ├── .approaches │ │ │ ├── bitfield │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ └── introduction.md │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── pangram.c │ │ ├── pangram.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_pangram.c │ ├── pascals-triangle │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── pascals_triangle.c │ │ ├── pascals_triangle.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_pascals_triangle.c │ ├── perfect-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── perfect_numbers.c │ │ ├── perfect_numbers.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_perfect_numbers.c │ ├── phone-number │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── phone_number.c │ │ ├── phone_number.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_phone_number.c │ ├── pig-latin │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ └── strchr-strstr-strtok │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── pig_latin.c │ │ ├── pig_latin.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_pig_latin.c │ ├── prime-factors │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── prime_factors.c │ │ ├── prime_factors.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_prime_factors.c │ ├── protein-translation │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── protein_translation.c │ │ ├── protein_translation.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_protein_translation.c │ ├── pythagorean-triplet │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── pythagorean_triplet.c │ │ ├── pythagorean_triplet.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_pythagorean_triplet.c │ ├── queen-attack │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── helper-functions │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── introduction.md │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── queen_attack.c │ │ ├── queen_attack.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_queen_attack.c │ ├── rail-fence-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── rail_fence_cipher.c │ │ ├── rail_fence_cipher.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_rail_fence_cipher.c │ ├── raindrops │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── data-driven │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── if-statements │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── introduction.md │ │ │ └── sprintf │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── raindrops.c │ │ ├── raindrops.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_raindrops.c │ ├── rational-numbers │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── rational_numbers.c │ │ ├── rational_numbers.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_rational_numbers.c │ ├── react │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── react.c │ │ ├── react.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_react.c │ ├── resistor-color-duo │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── resistor_color_duo.c │ │ ├── resistor_color_duo.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_resistor_color_duo.c │ ├── resistor-color-trio │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── resistor_color_trio.c │ │ ├── resistor_color_trio.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_resistor_color_trio.c │ ├── resistor-color │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── define-consecutive-values │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ └── introduction.md │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── resistor_color.c │ │ ├── resistor_color.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_resistor_color.c │ ├── reverse-string │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── reverse_string.c │ │ ├── reverse_string.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_reverse_string.c │ ├── rna-transcription │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── rna_transcription.c │ │ ├── rna_transcription.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_rna_transcription.c │ ├── robot-simulator │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── robot_simulator.c │ │ ├── robot_simulator.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_robot_simulator.c │ ├── roman-numerals │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── roman_numerals.c │ │ ├── roman_numerals.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_roman_numerals.c │ ├── rotational-cipher │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── rotational_cipher.c │ │ ├── rotational_cipher.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_rotational_cipher.c │ ├── run-length-encoding │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── run_length_encoding.c │ │ ├── run_length_encoding.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_run_length_encoding.c │ ├── saddle-points │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── saddle_points.c │ │ ├── saddle_points.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_saddle_points.c │ ├── say │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── say.c │ │ ├── say.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_say.c │ ├── scrabble-score │ │ ├── .approaches │ │ │ ├── array-lookup │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ └── switch-statement │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── scrabble_score.c │ │ ├── scrabble_score.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_scrabble_score.c │ ├── secret-handshake │ │ ├── .approaches │ │ │ ├── config.json │ │ │ ├── introduction.md │ │ │ └── iterate-once │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── secret_handshake.c │ │ ├── secret_handshake.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_secret_handshake.c │ ├── series │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── series.c │ │ ├── series.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_series.c │ ├── sieve │ │ ├── .approaches │ │ │ ├── array-of-ones-and-zeros │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ └── introduction.md │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── sieve.c │ │ ├── sieve.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_sieve.c │ ├── space-age │ │ ├── .approaches │ │ │ ├── array-index │ │ │ │ ├── content.md │ │ │ │ └── snippet.txt │ │ │ ├── config.json │ │ │ └── introduction.md │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── space_age.c │ │ ├── space_age.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_space_age.c │ ├── spiral-matrix │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── spiral_matrix.c │ │ ├── spiral_matrix.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_spiral_matrix.c │ ├── square-root │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── description.md │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── square_root.c │ │ ├── square_root.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_square_root.c │ ├── sublist │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── sublist.c │ │ ├── sublist.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_sublist.c │ ├── sum-of-multiples │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── sum_of_multiples.c │ │ ├── sum_of_multiples.h │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ └── test_sum_of_multiples.c │ ├── triangle │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ ├── test_triangle.c │ │ ├── triangle.c │ │ └── triangle.h │ ├── two-bucket │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ ├── test_two_bucket.c │ │ ├── two_bucket.c │ │ └── two_bucket.h │ ├── two-fer │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ ├── test_two_fer.c │ │ ├── two_fer.c │ │ └── two_fer.h │ ├── variable-length-quantity │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ ├── test_variable_length_quantity.c │ │ ├── variable_length_quantity.c │ │ └── variable_length_quantity.h │ ├── word-count │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ ├── test_word_count.c │ │ ├── word_count.c │ │ └── word_count.h │ ├── wordy │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ ├── test_wordy.c │ │ ├── wordy.c │ │ └── wordy.h │ ├── yacht │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── config.json │ │ │ ├── example.c │ │ │ ├── example.h │ │ │ └── tests.toml │ │ ├── makefile │ │ ├── test-framework │ │ │ ├── unity.c │ │ │ ├── unity.h │ │ │ └── unity_internals.h │ │ ├── test_yacht.c │ │ ├── yacht.c │ │ └── yacht.h │ └── zebra-puzzle │ │ ├── .docs │ │ ├── instructions.md │ │ └── introduction.md │ │ ├── .meta │ │ ├── config.json │ │ ├── example.c │ │ ├── example.h │ │ └── tests.toml │ │ ├── makefile │ │ ├── test-framework │ │ ├── unity.c │ │ ├── unity.h │ │ └── unity_internals.h │ │ ├── test_zebra_puzzle.c │ │ ├── zebra_puzzle.c │ │ └── zebra_puzzle.h └── shared │ └── .docs │ ├── help.md │ └── tests.md ├── format.sh └── reference ├── README.md ├── exercise-concepts ├── binary-search.md ├── difference-of-squares.md ├── hamming.md ├── isogram.md ├── resistor-color.md ├── square-root.md └── two-fer.md └── implementing-a-concept-exercise.md /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners 2 | .github/CODEOWNERS @exercism/maintainers-admin 3 | 4 | # Changes to `fetch-configlet` should be made in the `exercism/configlet` repo 5 | bin/fetch-configlet @exercism/maintainers-admin 6 | 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | 5 | # Keep dependencies for GitHub Actions up-to-date 6 | - package-ecosystem: 'github-actions' 7 | directory: '/' 8 | schedule: 9 | interval: 'monthly' 10 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/workflows/configlet.yml: -------------------------------------------------------------------------------- 1 | name: Configlet 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | workflow_dispatch: 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | configlet: 15 | uses: exercism/github-actions/.github/workflows/configlet.yml@main 16 | -------------------------------------------------------------------------------- /.github/workflows/no-important-files-changed.yml: -------------------------------------------------------------------------------- 1 | name: No important files changed 2 | 3 | on: 4 | pull_request_target: 5 | types: [opened] 6 | branches: [main] 7 | paths: 8 | - "exercises/concept/**" 9 | - "exercises/practice/**" 10 | - "!exercises/*/*/.approaches/**" 11 | - "!exercises/*/*/.articles/**" 12 | - "!exercises/*/*/.docs/**" 13 | - "!exercises/*/*/.meta/**" 14 | 15 | permissions: 16 | pull-requests: write 17 | 18 | jobs: 19 | check: 20 | uses: exercism/github-actions/.github/workflows/check-no-important-files-changed.yml@main 21 | with: 22 | repository: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }} 23 | ref: ${{ github.head_ref }} 24 | -------------------------------------------------------------------------------- /.github/workflows/ping-cross-track-maintainers-team.yml: -------------------------------------------------------------------------------- 1 | name: Ping cross-track maintainers team 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | 8 | permissions: 9 | pull-requests: write 10 | 11 | jobs: 12 | ping: 13 | if: github.repository_owner == 'exercism' # Stops this job from running on forks 14 | uses: exercism/github-actions/.github/workflows/ping-cross-track-maintainers-team.yml@main 15 | secrets: 16 | github_membership_token: ${{ secrets.COMMUNITY_CONTRIBUTIONS_WORKFLOW_TOKEN }} 17 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yml: -------------------------------------------------------------------------------- 1 | name: Tools 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - .github/labels.yml 9 | - .github/workflows/sync-labels.yml 10 | workflow_dispatch: 11 | schedule: 12 | - cron: 0 0 1 * * # First day of each month 13 | 14 | permissions: 15 | issues: write 16 | 17 | jobs: 18 | sync-labels: 19 | uses: exercism/github-actions/.github/workflows/labels.yml@main 20 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test Exercises 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-24.04 12 | 13 | strategy: 14 | matrix: 15 | compiler: [gcc, clang] 16 | 17 | steps: 18 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 19 | - name: Test Exercises 20 | env: 21 | CC: ${{ matrix.compiler }} 22 | run: ./bin/run-tests -a 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/configlet 2 | bin/configlet.exe 3 | build/ 4 | **/*.out 5 | **/*.o 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Exercism C Track 2 | 3 | [![Test Actions Status](https://github.com/exercism/c/actions/workflows/test.yml/badge.svg)](https://github.com/exercism/c/actions) 4 | 5 | Exercism problems in C 6 | 7 | ## Contributing 8 | 9 | Contributions are very welcome! Please see the [contributing guide](https://github.com/exercism/c/blob/master/docs/CONTRIBUTING.md) to get started. The guide contains general contribution tips, information on the code style, information on the continuous integration used and the anatomy of an exercise on this language track. 10 | 11 | ## License 12 | 13 | The MIT License (MIT) 14 | 15 | Copyright (c) 2014 Katrina Owen, _@kytrinyx.com 16 | -------------------------------------------------------------------------------- /concepts/basics/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "C is a statically-typed language, which means that everything has a type at compile-time. C allows one to use an imperative procedural coding style.", 3 | "authors": [ 4 | "wolf99" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/bits/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "A bit is the most granular value. A bit is either 1 or 0. All other data types are derived from bits.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/bits/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/blocks/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "A block is a set of statements and declarations grouped into one syntactic unit.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/blocks/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /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/conditionals/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "A conditional statement can be used to change something.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/conditionals/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/dynamic-memory-management/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Dynamic memory is implemented by library functions which the programmer uses to allocate/deallocate memory at runtime.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/dynamic-memory-management/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/function-pointers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Pointers can be used to pass functions to be called by other functions.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/function-pointers/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/linkage/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Linkage describes from where in the code an identifier may be accessed.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/linkage/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/loops/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Loops repeat one or more statements.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/loops/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/pointers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Pointers are variables or constants whose value is the memory address of another variable or constant.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/pointers/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/recursion/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Recursion repeats code in a function by the function calling itself.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/recursion/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/scope/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Scope relates to where in the program an identifier can be accessed.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/scope/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/static-functions/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "A static function is callable only in the file where it is defined ", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/static-functions/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Functions have external linkage by default and can be called from any other file in the project. 4 | For more on linkage please see the [linkage concept](../linkage/introduction.md#Introduction). 5 | A `static` function can only be called within the source file where it is defined. 6 | 7 | For example 8 | 9 | ```c 10 | // file scope, internal linkage 11 | // can only be called from within this file 12 | static void some_function() 13 | { 14 | // code snipped 15 | } 16 | 17 | // file scope, external linkage by default 18 | // can be called from any other file in the project 19 | int main() 20 | { 21 | // code snipped 22 | } 23 | ``` 24 | -------------------------------------------------------------------------------- /concepts/static-functions/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /concepts/storage-class-specifiers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Storage-class specifiers relate to how variables are stored in memory.", 3 | "authors": [ 4 | "bobahop" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/storage-class-specifiers/links.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /docs/ABOUT.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | C is a general purpose language, used for a wide range of applications, from embedded computers to high-performance computing clusters. 4 | 5 | C is commonly found in low level applications as it's a good alternative to harder-to-read assembly languages. 6 | It can be compiled to assembly to keep the same level of performance, while increasing readability, and providing a small level of safety with static types! 7 | 8 | C was created by Dennis Ritchie at Bell Labs, and used to re-implement the Unix operating system. 9 | Now, it's one of the most used programming languages, with many compilers providing support for most available hardware and platforms - there are plenty of resources and support available to help you get started! 10 | -------------------------------------------------------------------------------- /docs/RESOURCES.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | 3 | - [C++ Reference](https://en.cppreference.com/w/c): An online reference for C and C++ programming languages. 4 | If you are not sure what a stdlib function does, this site has you covered. 5 | - [`C` tag on StackOverflow](https://stackoverflow.com/questions/tagged/c) 6 | -------------------------------------------------------------------------------- /docs/SNIPPET.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char* argv[]) { 4 | printf("Hello, World!\n"); 5 | } 6 | -------------------------------------------------------------------------------- /docs/VERSIONS.md: -------------------------------------------------------------------------------- 1 | # Versions 2 | 3 | * Unity = v2.5.2 (version now specified in `unity.h`) 4 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "64106118-5265-4d81-8088-aa0cf8bc3c38", 9 | "slug": "look-for-start-chars", 10 | "title": "Look for start chars", 11 | "blurb": "Look for start characters.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.approaches/look-for-start-chars/snippet.txt: -------------------------------------------------------------------------------- 1 | const char start_trigger[] = " -"; 2 | for (int start = 1; *phrase; phrase++) { 3 | if (start && isalpha(*phrase)) { 4 | *acronyms++ = toupper(*phrase); 5 | start = 0; 6 | } else if (strchr(start_trigger, *phrase)) 7 | start = 1; 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Convert a phrase to its acronym. 4 | 5 | Techies love their TLA (Three Letter Acronyms)! 6 | 7 | Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG). 8 | 9 | Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input. 10 | 11 | For example: 12 | 13 | | Input | Output | 14 | | ------------------------- | ------ | 15 | | As Soon As Possible | ASAP | 16 | | Liquid-crystal display | LCD | 17 | | Thank George It's Friday! | TGIF | 18 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "h-3-0", 9 | "kgashok", 10 | "patricksjackson", 11 | "QLaille", 12 | "ryanplusplus", 13 | "sesamemucho" 14 | ], 15 | "files": { 16 | "solution": [ 17 | "acronym.c", 18 | "acronym.h" 19 | ], 20 | "test": [ 21 | "test_acronym.c" 22 | ], 23 | "example": [ 24 | ".meta/example.c" 25 | ] 26 | }, 27 | "blurb": "Convert a long phrase to its acronym.", 28 | "source": "Julien Vanier", 29 | "source_url": "https://github.com/monkbroc" 30 | } 31 | -------------------------------------------------------------------------------- /exercises/practice/acronym/acronym.c: -------------------------------------------------------------------------------- 1 | #include "acronym.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/acronym/acronym.h: -------------------------------------------------------------------------------- 1 | #ifndef ACRONYM_H 2 | #define ACRONYM_H 3 | 4 | char *abbreviate(const char *phrase); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You've just been hired as professor of mathematics. 4 | Your first week went well, but something is off in your second week. 5 | The problem is that every answer given by your students is wrong! 6 | Luckily, your math skills have allowed you to identify the problem: the student answers _are_ correct, but they're all in base 2 (binary)! 7 | Amazingly, it turns out that each week, the students use a different base. 8 | To help you quickly verify the student answers, you'll be building a tool to translate between bases. 9 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "h-3-0", 9 | "patricksjackson", 10 | "QLaille", 11 | "ryanplusplus" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "all_your_base.c", 16 | "all_your_base.h" 17 | ], 18 | "test": [ 19 | "test_all_your_base.c" 20 | ], 21 | "example": [ 22 | ".meta/example.c", 23 | ".meta/example.h" 24 | ] 25 | }, 26 | "blurb": "Convert a number, represented as a sequence of digits in one base, to any other base." 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef ALL_YOUR_BASE_H 2 | #define ALL_YOUR_BASE_H 3 | 4 | #include 5 | #include 6 | 7 | #define DIGITS_ARRAY_SIZE 64 8 | 9 | size_t rebase(int8_t digits[DIGITS_ARRAY_SIZE], int16_t from_base, 10 | int16_t to_base, size_t num_digits); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/all_your_base.c: -------------------------------------------------------------------------------- 1 | #include "all_your_base.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/all_your_base.h: -------------------------------------------------------------------------------- 1 | #ifndef ALL_YOUR_BASE_H 2 | #define ALL_YOUR_BASE_H 3 | 4 | #define DIGITS_ARRAY_SIZE 64 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "allergies.h" 2 | #include 3 | 4 | bool is_allergic_to(allergen_t allergen, unsigned int score) 5 | { 6 | return ((score & (1 << allergen)) != 0); 7 | } 8 | 9 | allergen_list_t get_allergens(unsigned int score) 10 | { 11 | allergen_list_t list = { 12 | .count = 0, 13 | .allergens = { 0 }, 14 | }; 15 | 16 | for (allergen_t allergen = 0; allergen < ALLERGEN_COUNT; ++allergen) { 17 | if (is_allergic_to(allergen, score)) { 18 | list.allergens[allergen] = true; 19 | ++list.count; 20 | } 21 | } 22 | return list; 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/allergies/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef ALLERGIES_H 2 | #define ALLERGIES_H 3 | 4 | #include 5 | 6 | typedef enum { 7 | ALLERGEN_EGGS = 0, 8 | ALLERGEN_PEANUTS, 9 | ALLERGEN_SHELLFISH, 10 | ALLERGEN_STRAWBERRIES, 11 | ALLERGEN_TOMATOES, 12 | ALLERGEN_CHOCOLATE, 13 | ALLERGEN_POLLEN, 14 | ALLERGEN_CATS, 15 | ALLERGEN_COUNT, 16 | } allergen_t; 17 | 18 | typedef struct { 19 | int count; 20 | bool allergens[ALLERGEN_COUNT]; 21 | } allergen_list_t; 22 | 23 | bool is_allergic_to(allergen_t allergen, unsigned int score); 24 | allergen_list_t get_allergens(unsigned int score); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /exercises/practice/allergies/allergies.c: -------------------------------------------------------------------------------- 1 | #include "allergies.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/allergies/allergies.h: -------------------------------------------------------------------------------- 1 | #ifndef ALLERGIES_H 2 | #define ALLERGIES_H 3 | 4 | #include 5 | 6 | typedef enum { 7 | ALLERGEN_EGGS = 0, 8 | ALLERGEN_PEANUTS, 9 | ALLERGEN_SHELLFISH, 10 | ALLERGEN_STRAWBERRIES, 11 | ALLERGEN_TOMATOES, 12 | ALLERGEN_CHOCOLATE, 13 | ALLERGEN_POLLEN, 14 | ALLERGEN_CATS, 15 | ALLERGEN_COUNT, 16 | } allergen_t; 17 | 18 | typedef struct { 19 | int count; 20 | bool allergens[ALLERGEN_COUNT]; 21 | } allergen_list_t; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /exercises/practice/anagram/anagram.c: -------------------------------------------------------------------------------- 1 | #include "anagram.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/anagram/anagram.h: -------------------------------------------------------------------------------- 1 | #ifndef ANAGRAM_H 2 | #define ANAGRAM_H 3 | 4 | #include 5 | 6 | #define MAX_STR_LEN 20 7 | 8 | enum anagram_status { UNCHECKED = -1, NOT_ANAGRAM, IS_ANAGRAM }; 9 | 10 | struct candidate { 11 | enum anagram_status is_anagram; 12 | const char *word; 13 | }; 14 | 15 | struct candidates { 16 | struct candidate *candidate; 17 | size_t count; 18 | }; 19 | 20 | /** 21 | * @description - determines if any of the words in candidate are anagrams 22 | * for subject. Contents of candidate structures may be modified. 23 | */ 24 | void find_anagrams(const char *subject, struct candidates *candidates); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "256eab9e-7148-4392-a305-9209ac20eee8", 9 | "slug": "log10-no-pow", 10 | "title": "log10 with no pow", 11 | "blurb": "Use log10 for digit count and avoid pow to return the answer.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.approaches/log10-no-pow/snippet.txt: -------------------------------------------------------------------------------- 1 | while (num > 0) 2 | { 3 | int pow_temp = num % 10; 4 | int pow_temp_total = 1; 5 | for (int i = 0; i < digit_count; i++) 6 | pow_temp_total *= pow_temp; 7 | pow_total += pow_temp_total; 8 | num /= 10; 9 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | An [Armstrong number][armstrong-number] is a number that is the sum of its own digits each raised to the power of the number of digits. 4 | 5 | For example: 6 | 7 | - 9 is an Armstrong number, because `9 = 9^1 = 9` 8 | - 10 is _not_ an Armstrong number, because `10 != 1^2 + 0^2 = 1` 9 | - 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153` 10 | - 154 is _not_ an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190` 11 | 12 | Write some code to determine whether a number is an Armstrong number. 13 | 14 | [armstrong-number]: https://en.wikipedia.org/wiki/Narcissistic_number 15 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "computermouth", 7 | "elyashiv", 8 | "ryanplusplus" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "armstrong_numbers.c", 13 | "armstrong_numbers.h" 14 | ], 15 | "test": [ 16 | "test_armstrong_numbers.c" 17 | ], 18 | "example": [ 19 | ".meta/example.c", 20 | ".meta/example.h" 21 | ] 22 | }, 23 | "blurb": "Determine if a number is an Armstrong number.", 24 | "source": "Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Narcissistic_number" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef ARMSTRONG_NUMBERS_H 2 | #define ARMSTRONG_NUMBERS_H 3 | 4 | #include 5 | 6 | bool is_armstrong_number(int candidate); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/armstrong_numbers.c: -------------------------------------------------------------------------------- 1 | #include "armstrong_numbers.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/armstrong_numbers.h: -------------------------------------------------------------------------------- 1 | #ifndef ARMSTRONG_NUMBERS_H 2 | #define ARMSTRONG_NUMBERS_H 3 | 4 | #include 5 | 6 | bool is_armstrong_number(int candidate); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "RealBarrettBrown" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "gea-migration", 9 | "h-3-0", 10 | "patricksjackson", 11 | "QLaille", 12 | "ryanplusplus", 13 | "wolf99" 14 | ], 15 | "files": { 16 | "solution": [ 17 | "atbash_cipher.c", 18 | "atbash_cipher.h" 19 | ], 20 | "test": [ 21 | "test_atbash_cipher.c" 22 | ], 23 | "example": [ 24 | ".meta/example.c", 25 | ".meta/example.h" 26 | ] 27 | }, 28 | "blurb": "Create an implementation of the Atbash cipher, an ancient encryption system created in the Middle East.", 29 | "source": "Wikipedia", 30 | "source_url": "https://en.wikipedia.org/wiki/Atbash" 31 | } 32 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef ATBASH_CIPHER_H 2 | #define ATBASH_CIPHER_H 3 | 4 | char *atbash_encode(const char *input); 5 | char *atbash_decode(const char *input); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/atbash_cipher.c: -------------------------------------------------------------------------------- 1 | #include "atbash_cipher.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/atbash_cipher.h: -------------------------------------------------------------------------------- 1 | #ifndef ATBASH_CIPHER_H 2 | #define ATBASH_CIPHER_H 3 | 4 | char *atbash_encode(const char *input); 5 | char *atbash_decode(const char *input); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/.approaches/complexity-in-data/snippet.txt: -------------------------------------------------------------------------------- 1 | uint8_t end_bottle = start_bottles - (take_down - 1); 2 | for (int8_t bottle = start_bottles; bottle >= end_bottle; bottle--) { 3 | snprintf(*song++, MAX_LINE_LENGTH, FIRST_LINE[bottle > 1 ? 2 : bottle], 4 | bottle, bottle); 5 | snprintf(*song++, MAX_LINE_LENGTH, 6 | SECOND_LINE[bottle - 1 > 1 ? 3 : bottle], bottle - 1); 7 | song++; 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "7012cfe4-eb04-46c7-9934-491f480f71f1", 9 | "slug": "complexity-in-data", 10 | "title": "Complexity in data", 11 | "blurb": "Put the complexity in data to return the answer.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef BEER_SONG_H 2 | #define BEER_SONG_H 3 | 4 | #include 5 | 6 | void recite(uint8_t start_bottles, uint8_t take_down, char **song); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/beer_song.c: -------------------------------------------------------------------------------- 1 | #include "beer_song.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/beer_song.h: -------------------------------------------------------------------------------- 1 | #ifndef BEER_SONG_H 2 | #define BEER_SONG_H 3 | 4 | #include 5 | 6 | void recite(uint8_t start_bottles, uint8_t take_down, char **song); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "elyashiv", 7 | "h-3-0", 8 | "patricksjackson", 9 | "QLaille", 10 | "ryanplusplus", 11 | "wolf99" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "binary_search_tree.c", 16 | "binary_search_tree.h" 17 | ], 18 | "test": [ 19 | "test_binary_search_tree.c" 20 | ], 21 | "example": [ 22 | ".meta/example.c", 23 | ".meta/example.h" 24 | ] 25 | }, 26 | "blurb": "Insert and search for numbers in a binary tree.", 27 | "source": "Josh Cheek" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef BINARY_SEARCH_TREE_H 2 | #define BINARY_SEARCH_TREE_H 3 | #include 4 | 5 | typedef struct node node_t; 6 | 7 | struct node { 8 | node_t *right; 9 | node_t *left; 10 | int data; 11 | }; 12 | 13 | node_t *build_tree(int *tree_data, size_t tree_data_len); 14 | void free_tree(node_t *tree); 15 | int *sorted_data(node_t *tree); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/binary_search_tree.c: -------------------------------------------------------------------------------- 1 | #include "binary_search_tree.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/binary_search_tree.h: -------------------------------------------------------------------------------- 1 | #ifndef BINARY_SEARCH_TREE_H 2 | #define BINARY_SEARCH_TREE_H 3 | #include 4 | 5 | typedef struct node node_t; 6 | 7 | struct node { 8 | node_t *right; 9 | node_t *left; 10 | int data; 11 | }; 12 | 13 | node_t *build_tree(int *tree_data, size_t tree_data_len); 14 | void free_tree(node_t *tree); 15 | int *sorted_data(node_t *tree); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "2bae133b-26be-42eb-b02c-f0afa574b518", 9 | "slug": "while-with-if-statements", 10 | "title": "While with if statements", 11 | "blurb": "Use a while loop with if statements to return the answer.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.approaches/while-with-if-statements/snippet.txt: -------------------------------------------------------------------------------- 1 | while (left < right) { 2 | size_t mid = left + ((right - left) / 2); 3 | int look = arr[mid]; 4 | if (look == value) return (int *) &arr[mid]; 5 | if (look < value) left = mid + 1; 6 | else right = mid; 7 | } 8 | return NULL; 9 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "patricksjackson" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "gea-migration", 9 | "h-3-0", 10 | "QLaille", 11 | "ryanplusplus", 12 | "wolf99" 13 | ], 14 | "files": { 15 | "solution": [ 16 | "binary_search.c", 17 | "binary_search.h" 18 | ], 19 | "test": [ 20 | "test_binary_search.c" 21 | ], 22 | "example": [ 23 | ".meta/example.c", 24 | ".meta/example.h" 25 | ] 26 | }, 27 | "blurb": "Implement a binary search algorithm.", 28 | "source": "Wikipedia", 29 | "source_url": "https://en.wikipedia.org/wiki/Binary_search_algorithm" 30 | } 31 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "binary_search.h" 2 | 3 | const int *binary_search(const int value, const int *arr, const size_t length) 4 | { 5 | if (0 == length || NULL == arr) { 6 | return NULL; 7 | } 8 | const int *low = arr; 9 | const int *high = arr + length - 1; 10 | while (low <= high) { 11 | const int *mid = low + (high - low) / 2; 12 | if (*mid > value) { 13 | high = mid - 1; 14 | } else if (*mid < value) { 15 | low = mid + 1; 16 | } else { 17 | return mid; 18 | } 19 | } 20 | return NULL; 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef BINARY_SEARCH_H 2 | #define BINARY_SEARCH_H 3 | 4 | #include 5 | 6 | const int *binary_search(int value, const int *arr, size_t length); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/binary_search.c: -------------------------------------------------------------------------------- 1 | #include "binary_search.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/binary_search.h: -------------------------------------------------------------------------------- 1 | #ifndef BINARY_SEARCH_H 2 | #define BINARY_SEARCH_H 3 | 4 | #include 5 | 6 | const int *binary_search(int value, const int *arr, size_t length); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/binary/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "binary.h" 2 | #include 3 | 4 | int convert(const char *input) 5 | { 6 | size_t input_len = strlen(input); 7 | int result = 0; 8 | for (size_t i = 0; i < input_len; i++) { 9 | result <<= 1; 10 | if (input[i] == '1') { 11 | result |= 1; 12 | } else if (input[i] != '0') { 13 | return -1; 14 | } 15 | } 16 | return result; 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/binary/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef BINARY_H 2 | #define BINARY_H 3 | #define INVALID -1 4 | 5 | int convert(const char *input); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/binary/binary.c: -------------------------------------------------------------------------------- 1 | #include "binary.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/binary/binary.h: -------------------------------------------------------------------------------- 1 | #ifndef BINARY_H 2 | #define BINARY_H 3 | 4 | #define INVALID -1 5 | 6 | int convert(const char *input); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/bob/.approaches/answer-array/snippet.txt: -------------------------------------------------------------------------------- 1 | int is_shout = shout && has_letter ? 2 : 0; 2 | int is_question = *end_pos == '?' ? 1 : 0; 3 | return answers[is_question + is_shout]; 4 | -------------------------------------------------------------------------------- /exercises/practice/bob/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "ef854355-ba4d-4996-93bd-4d3d4f892a89", 9 | "slug": "answer-array", 10 | "title": "Answer array", 11 | "blurb": "Index into an array to return the answer.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/bob/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Bob is a [lackadaisical][] teenager. 4 | He likes to think that he's very cool. 5 | And he definitely doesn't get excited about things. 6 | That wouldn't be cool. 7 | 8 | When people talk to him, his responses are pretty limited. 9 | 10 | [lackadaisical]: https://www.collinsdictionary.com/dictionary/english/lackadaisical 11 | -------------------------------------------------------------------------------- /exercises/practice/bob/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef BOB_H 2 | #define BOB_H 3 | 4 | char *hey_bob(char *greeting); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/bob/bob.c: -------------------------------------------------------------------------------- 1 | #include "bob.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/bob/bob.h: -------------------------------------------------------------------------------- 1 | #ifndef BOB_H 2 | #define BOB_H 3 | 4 | char *hey_bob(char *greeting); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Set `errno` to a special value 2 | If the buffer is empty during a read attempt, an error is raised to alert the client. 3 | 4 | These error values can be found in the [`errno.h`][errno.h] header file. 5 | 6 | [errno.h]: https://en.wikipedia.org/wiki/Errno.h 7 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "ryanplusplus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "circular_buffer.c", 11 | "circular_buffer.h" 12 | ], 13 | "test": [ 14 | "test_circular_buffer.c" 15 | ], 16 | "example": [ 17 | ".meta/example.c", 18 | ".meta/example.h" 19 | ] 20 | }, 21 | "blurb": "A data structure that uses a single, fixed-size buffer as if it were connected end-to-end.", 22 | "source": "Wikipedia", 23 | "source_url": "https://en.wikipedia.org/wiki/Circular_buffer" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/circular_buffer.c: -------------------------------------------------------------------------------- 1 | #include "circular_buffer.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/circular_buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef CIRCULAR_BUFFER_H 2 | #define CIRCULAR_BUFFER_H 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /exercises/practice/clock/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "b804e2be-3c8d-431a-9b4b-437ba16e0129", 9 | "slug": "minimize-duplicate-code", 10 | "title": "Minimize duplicate code", 11 | "blurb": "Minimize duplicate code for creating, changing or comparing a clock.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/clock/.approaches/minimize-duplicate-code/snippet.txt: -------------------------------------------------------------------------------- 1 | clock_t clock_add(clock_t clock, int minute_add) 2 | { 3 | return clock_create(0, minutes_from_text(clock.text) + minute_add); 4 | } 5 | clock_t clock_subtract(clock_t clock, int minute_subtract) 6 | { 7 | return clock_create(0, minutes_from_text(clock.text) - minute_subtract); 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/clock/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Implement a clock that handles times without dates. 4 | 5 | You should be able to add and subtract minutes to it. 6 | 7 | Two clocks that represent the same time should be equal to each other. 8 | -------------------------------------------------------------------------------- /exercises/practice/clock/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "StevenRoot" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "gea-migration", 9 | "h-3-0", 10 | "patricksjackson", 11 | "QLaille", 12 | "ryanplusplus", 13 | "wolf99" 14 | ], 15 | "files": { 16 | "solution": [ 17 | "clock.c", 18 | "clock.h" 19 | ], 20 | "test": [ 21 | "test_clock.c" 22 | ], 23 | "example": [ 24 | ".meta/example.c" 25 | ] 26 | }, 27 | "blurb": "Implement a clock that handles times without dates.", 28 | "source": "Pairing session with Erin Drummond" 29 | } 30 | -------------------------------------------------------------------------------- /exercises/practice/clock/clock.c: -------------------------------------------------------------------------------- 1 | #include "clock.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/clock/clock.h: -------------------------------------------------------------------------------- 1 | #ifndef CLOCK_H 2 | #define CLOCK_H 3 | 4 | #include 5 | 6 | #define MAX_STR_LEN sizeof("##:##") 7 | 8 | typedef struct { 9 | char text[MAX_STR_LEN]; 10 | } clock_t; 11 | 12 | clock_t clock_create(int hour, int minute); 13 | clock_t clock_add(clock_t clock, int minute_add); 14 | clock_t clock_subtract(clock_t clock, int minute_subtract); 15 | bool clock_is_equal(clock_t a, clock_t b); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.approaches/bitwise-operations/snippet.txt: -------------------------------------------------------------------------------- 1 | while (start != 1) { 2 | if (!(start & 1)) 3 | start = start >> 1; 4 | else 5 | start = (start * 3) + 1; 6 | step_count++; 7 | } 8 | return step_count; 9 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "88f16869-2492-4525-ab6d-f8fe14860b2f", 9 | "slug": "bitwise-operations", 10 | "title": "Bitwise operations", 11 | "blurb": "Use bitwise operations to check for even and divide.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a positive integer, return the number of steps it takes to reach 1 according to the rules of the Collatz Conjecture. 4 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "RealBarrettBrown" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "h-3-0", 8 | "patricksjackson", 9 | "QLaille", 10 | "ryanplusplus", 11 | "wolf99" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "collatz_conjecture.c", 16 | "collatz_conjecture.h" 17 | ], 18 | "test": [ 19 | "test_collatz_conjecture.c" 20 | ], 21 | "example": [ 22 | ".meta/example.c" 23 | ] 24 | }, 25 | "blurb": "Calculate the number of steps to reach 1 using the Collatz conjecture.", 26 | "source": "Wikipedia", 27 | "source_url": "https://en.wikipedia.org/wiki/Collatz_conjecture" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "collatz_conjecture.h" 2 | #include 3 | 4 | int steps(int start) 5 | { 6 | int step = 0; 7 | int number = start; 8 | 9 | if (start <= 0) { 10 | return ERROR_VALUE; 11 | } 12 | 13 | while (number != 1) { 14 | step++; 15 | 16 | if (number % 2 == 0) { 17 | number /= 2; 18 | } else { 19 | number = (number * 3) + 1; 20 | } 21 | } 22 | return step; 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/collatz_conjecture.c: -------------------------------------------------------------------------------- 1 | #include "collatz_conjecture.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/collatz_conjecture.h: -------------------------------------------------------------------------------- 1 | #ifndef COLLATZ_CONJECTURE_H 2 | #define COLLATZ_CONJECTURE_H 3 | 4 | #define ERROR_VALUE -1 5 | 6 | int steps(int start); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [], 3 | "contributors": [ 4 | "h-3-0", 5 | "patricksjackson", 6 | "QLaille", 7 | "ryanplusplus", 8 | "sjwarner", 9 | "wolf99" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "complex_numbers.c", 14 | "complex_numbers.h" 15 | ], 16 | "test": [ 17 | "test_complex_numbers.c" 18 | ], 19 | "example": [ 20 | ".meta/example.c" 21 | ] 22 | }, 23 | "blurb": "Implement complex numbers.", 24 | "source": "Wikipedia", 25 | "source_url": "https://en.wikipedia.org/wiki/Complex_number" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/complex_numbers.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPLEX_NUMBERS_H 2 | #define COMPLEX_NUMBERS_H 3 | 4 | typedef struct { 5 | double real; 6 | double imag; 7 | } complex_t; 8 | 9 | complex_t c_add(complex_t a, complex_t b); 10 | complex_t c_sub(complex_t a, complex_t b); 11 | complex_t c_mul(complex_t a, complex_t b); 12 | complex_t c_div(complex_t a, complex_t b); 13 | double c_abs(complex_t x); 14 | complex_t c_conjugate(complex_t x); 15 | double c_real(complex_t x); 16 | double c_imag(complex_t x); 17 | complex_t c_exp(complex_t x); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTO_SQUARE_H 2 | #define CRYPTO_SQUARE_H 3 | 4 | char *ciphertext(const char *input); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/crypto_square.c: -------------------------------------------------------------------------------- 1 | #include "crypto_square.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/crypto_square.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTO_SQUARE_H 2 | #define CRYPTO_SQUARE_H 3 | 4 | char *ciphertext(const char *input); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/darts/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "ea833bea-ff7a-4a98-98c2-d56b66df6e58", 9 | "slug": "hypot-for-radius", 10 | "title": "hypot for radius", 11 | "blurb": "Use the hypot function to get the radius of the throw.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/darts/.approaches/hypot-for-radius/snippet.txt: -------------------------------------------------------------------------------- 1 | static float radius(coordinate_t throw) 2 | { 3 | return hypot(throw.x, throw.y); 4 | } 5 | static bool throw(float radius, float ring) 6 | { 7 | return radius <= ring; 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "ryanplusplus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "darts.c", 11 | "darts.h" 12 | ], 13 | "test": [ 14 | "test_darts.c" 15 | ], 16 | "example": [ 17 | ".meta/example.c", 18 | ".meta/example.h" 19 | ] 20 | }, 21 | "blurb": "Calculate the points scored in a single toss of a Darts game.", 22 | "source": "Inspired by an exercise created by a professor Della Paolera in Argentina" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef DARTS_H 2 | #define DARTS_H 3 | 4 | #include 5 | 6 | typedef struct { 7 | float x, y; 8 | } coordinate_t; 9 | 10 | uint8_t score(coordinate_t landing_position); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /exercises/practice/darts/darts.c: -------------------------------------------------------------------------------- 1 | #include "darts.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/darts/darts.h: -------------------------------------------------------------------------------- 1 | #ifndef DARTS_H 2 | #define DARTS_H 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /exercises/practice/diamond/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "wolf99" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "diamond.c", 15 | "diamond.h" 16 | ], 17 | "test": [ 18 | "test_diamond.c" 19 | ], 20 | "example": [ 21 | ".meta/example.c", 22 | ".meta/example.h" 23 | ] 24 | }, 25 | "blurb": "Given a letter, print a diamond starting with 'A' with the supplied letter at the widest point.", 26 | "source": "Seb Rose", 27 | "source_url": "https://web.archive.org/web/20220807163751/http://claysnow.co.uk/recycling-tests-in-tdd/" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/diamond/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef DIAMOND_H 2 | #define DIAMOND_H 3 | 4 | char **make_diamond(const char letter); 5 | void free_diamond(char **diamond); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/diamond/diamond.c: -------------------------------------------------------------------------------- 1 | #include "diamond.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/diamond/diamond.h: -------------------------------------------------------------------------------- 1 | #ifndef DIAMOND_H 2 | #define DIAMOND_H 3 | 4 | char **make_diamond(const char letter); 5 | void free_diamond(char **diamond); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "9904f3ea-21c1-48cb-8158-733ad1efde4c", 9 | "slug": "formula", 10 | "title": "Formula", 11 | "blurb": "Use a formula to calculate a solution.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.approaches/formula/snippet.txt: -------------------------------------------------------------------------------- 1 | unsigned int square_of_sum(unsigned int number) { 2 | unsigned int sum = (number * (number + 1)) / 2; 3 | return sum * sum; 4 | } 5 | 6 | unsigned int sum_of_squares(unsigned int number) { 7 | return (number * (number + 1) * ((number * 2) + 1)) / 6; 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Find the difference between the square of the sum and the sum of the squares of the first N natural numbers. 4 | 5 | The square of the sum of the first ten natural numbers is 6 | (1 + 2 + ... + 10)² = 55² = 3025. 7 | 8 | The sum of the squares of the first ten natural numbers is 9 | 1² + 2² + ... + 10² = 385. 10 | 11 | Hence the difference between the square of the sum of the first ten natural numbers and the sum of the squares of the first ten natural numbers is 3025 - 385 = 2640. 12 | 13 | You are not expected to discover an efficient solution to this yourself from first principles; research is allowed, indeed, encouraged. 14 | Finding the best algorithm for the problem is a key skill in software engineering. 15 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "difference_of_squares.h" 2 | 3 | unsigned int sum_of_squares(unsigned int number) 4 | { 5 | unsigned int sum = 0; 6 | 7 | for (unsigned int i = 0; i <= number; i++) { 8 | sum += i * i; 9 | } 10 | 11 | return sum; 12 | } 13 | 14 | unsigned int square_of_sum(unsigned int number) 15 | { 16 | unsigned int sum = 0; 17 | 18 | for (unsigned int i = 0; i <= number; i++) { 19 | sum += i; 20 | } 21 | 22 | return (sum * sum); 23 | } 24 | 25 | unsigned int difference_of_squares(unsigned int number) 26 | { 27 | return (square_of_sum(number) - sum_of_squares(number)); 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef DIFFERENCE_OF_SQUARES_H 2 | #define DIFFERENCE_OF_SQUARES_H 3 | 4 | unsigned int sum_of_squares(unsigned int number); 5 | unsigned int square_of_sum(unsigned int number); 6 | unsigned int difference_of_squares(unsigned int number); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/difference_of_squares.c: -------------------------------------------------------------------------------- 1 | #include "difference_of_squares.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/difference_of_squares.h: -------------------------------------------------------------------------------- 1 | #ifndef DIFFERENCE_OF_SQUARES_H 2 | #define DIFFERENCE_OF_SQUARES_H 3 | 4 | unsigned int sum_of_squares(unsigned int number); 5 | unsigned int square_of_sum(unsigned int number); 6 | unsigned int difference_of_squares(unsigned int number); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | After weeks of anticipation, you and your friends get together for your very first game of [Dungeons & Dragons][dnd] (D&D). 4 | Since this is the first session of the game, each player has to generate a character to play with. 5 | The character's abilities are determined by rolling 6-sided dice, but where _are_ the dice? 6 | With a shock, you realize that your friends are waiting for _you_ to produce the dice; after all it was your idea to play D&D! 7 | Panicking, you realize you forgot to bring the dice, which would mean no D&D game. 8 | As you have some basic coding skills, you quickly come up with a solution: you'll write a program to simulate dice rolls. 9 | 10 | [dnd]: https://en.wikipedia.org/wiki/Dungeons_%26_Dragons 11 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ahans" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "dnd_character.c", 8 | "dnd_character.h" 9 | ], 10 | "test": [ 11 | "test_dnd_character.c" 12 | ], 13 | "example": [ 14 | ".meta/example.c", 15 | ".meta/example.h" 16 | ] 17 | }, 18 | "blurb": "Randomly generate Dungeons & Dragons characters.", 19 | "source": "Simon Shine, Erik Schierboom", 20 | "source_url": "https://github.com/exercism/problem-specifications/issues/616#issuecomment-437358945" 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef DND_CHARACTER_H 2 | #define DND_CHARACTER_H 3 | 4 | typedef struct { 5 | int strength; 6 | int dexterity; 7 | int constitution; 8 | int intelligence; 9 | int wisdom; 10 | int charisma; 11 | int hitpoints; 12 | } dnd_character_t; 13 | 14 | int ability(void); 15 | int modifier(int score); 16 | dnd_character_t make_dnd_character(void); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/dnd_character.c: -------------------------------------------------------------------------------- 1 | #include "dnd_character.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/dnd_character.h: -------------------------------------------------------------------------------- 1 | #ifndef DND_CHARACTER_H 2 | #define DND_CHARACTER_H 3 | 4 | typedef struct { 5 | int strength; 6 | int dexterity; 7 | int constitution; 8 | int intelligence; 9 | int wisdom; 10 | int charisma; 11 | int hitpoints; 12 | } dnd_character_t; 13 | 14 | int ability(void); 15 | int modifier(int score); 16 | dnd_character_t make_dnd_character(void); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to count the number of 1 bits in the binary representation of a number. 4 | 5 | ## Restrictions 6 | 7 | Keep your hands off that bit-count functionality provided by your standard library! 8 | Solve this one yourself using other basic tools instead. 9 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ahans" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "eliuds_eggs.c", 8 | "eliuds_eggs.h" 9 | ], 10 | "test": [ 11 | "test_eliuds_eggs.c" 12 | ], 13 | "example": [ 14 | ".meta/example.c", 15 | ".meta/example.h" 16 | ] 17 | }, 18 | "blurb": "Help Eliud count the number of eggs in her chicken coop by counting the number of 1 bits in a binary representation.", 19 | "source": "Christian Willner, Eric Willigers", 20 | "source_url": "https://forum.exercism.org/t/new-exercise-suggestion-pop-count/7632/5" 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "eliuds_eggs.h" 2 | 3 | unsigned int egg_count(unsigned int value) 4 | { 5 | unsigned int count = 0; 6 | while (value != 0) { 7 | count += value & 1; 8 | value = value >> 1; 9 | } 10 | return count; 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef ELIUDS_EGGS_H 2 | #define ELIUDS_EGGS_H 3 | 4 | unsigned int egg_count(unsigned int value); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/eliuds_eggs.c: -------------------------------------------------------------------------------- 1 | #include "eliuds_eggs.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/eliuds-eggs/eliuds_eggs.h: -------------------------------------------------------------------------------- 1 | #ifndef ELIUDS_EGGS_H 2 | #define ELIUDS_EGGS_H 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "wolf99" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "etl.c", 15 | "etl.h" 16 | ], 17 | "test": [ 18 | "test_etl.c" 19 | ], 20 | "example": [ 21 | ".meta/example.c", 22 | ".meta/example.h" 23 | ] 24 | }, 25 | "blurb": "Change the data format for scoring a game to more easily add other languages.", 26 | "source": "Based on an exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 27 | "source_url": "https://turing.edu" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef ETL_H 2 | #define ETL_H 3 | #include 4 | 5 | typedef struct { 6 | int value; 7 | const char *keys; 8 | } legacy_map; 9 | 10 | typedef struct { 11 | char key; 12 | int value; 13 | } new_map; 14 | 15 | int convert(const legacy_map *input, const size_t input_len, new_map **output); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [78a7a9f9-4490-4a47-8ee9-5a38bb47d28f] 6 | description = "single letter" 7 | 8 | [60dbd000-451d-44c7-bdbb-97c73ac1f497] 9 | description = "single score with multiple letters" 10 | 11 | [f5c5de0c-301f-4fdd-a0e5-df97d4214f54] 12 | description = "multiple scores with multiple letters" 13 | 14 | [5db8ea89-ecb4-4dcd-902f-2b418cc87b9d] 15 | description = "multiple scores with differing numbers of letters" 16 | -------------------------------------------------------------------------------- /exercises/practice/etl/etl.c: -------------------------------------------------------------------------------- 1 | #include "etl.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/etl/etl.h: -------------------------------------------------------------------------------- 1 | #ifndef ETL_H 2 | #define ETL_H 3 | 4 | #include 5 | 6 | typedef struct { 7 | int value; 8 | const char *keys; 9 | } legacy_map; 10 | 11 | typedef struct { 12 | char key; 13 | int value; 14 | } new_map; 15 | 16 | int convert(const legacy_map *input, const size_t input_len, new_map **output); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | ## Use UTC 2 | 3 | To solve this problem, you'll need to convert a `time_t` value into a `struct tm` value. 4 | The [`time.h`][time.h] library gives you two functions to do this. 5 | Make sure you use the one that results in a calendar time expressed in **UTC**. 6 | 7 | [time.h]: https://en.cppreference.com/w/c/chrono 8 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine the date and time one gigasecond after a certain date. 4 | 5 | A gigasecond is one thousand million seconds. 6 | That is a one with nine zeros after it. 7 | 8 | If you were born on _January 24th, 2015 at 22:00 (10:00:00pm)_, then you would be a gigasecond old on _October 2nd, 2046 at 23:46:40 (11:46:40pm)_. 9 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "gigasecond.h" 2 | 3 | #define GIGASECOND 1000000000 4 | 5 | void gigasecond(time_t start, char *buffer, size_t size) 6 | { 7 | time_t after = start + GIGASECOND; 8 | struct tm *t = gmtime(&after); 9 | strftime(buffer, size, "%Y-%m-%d %H:%M:%S", t); 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef GIGASECOND_H 2 | #define GIGASECOND_H 3 | 4 | #include 5 | 6 | void gigasecond(time_t input, char *output, size_t size); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/gigasecond.c: -------------------------------------------------------------------------------- 1 | #include "gigasecond.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/gigasecond.h: -------------------------------------------------------------------------------- 1 | #ifndef GIGASECOND_H 2 | #define GIGASECOND_H 3 | 4 | #include 5 | 6 | void gigasecond(time_t input, char *output, size_t size); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "ryanplusplus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "grade_school.c", 11 | "grade_school.h" 12 | ], 13 | "test": [ 14 | "test_grade_school.c" 15 | ], 16 | "example": [ 17 | ".meta/example.c", 18 | ".meta/example.h" 19 | ] 20 | }, 21 | "blurb": "Given students' names along with the grade that they are in, create a roster for the school.", 22 | "source": "A pairing session with Phil Battos at gSchool" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef GRADE_SCHOOL_H 2 | #define GRADE_SCHOOL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define MAX_NAME_LENGTH 20 9 | #define MAX_STUDENTS 20 10 | 11 | typedef struct { 12 | uint8_t grade; 13 | char name[MAX_NAME_LENGTH]; 14 | } student_t; 15 | 16 | typedef struct { 17 | size_t count; 18 | student_t students[MAX_STUDENTS]; 19 | } roster_t; 20 | 21 | void init_roster(roster_t *roster); 22 | 23 | bool add_student(roster_t *roster, char *name, uint8_t grade); 24 | 25 | roster_t get_grade(roster_t *roster, uint8_t grade); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/grade_school.c: -------------------------------------------------------------------------------- 1 | #include "grade_school.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/grade_school.h: -------------------------------------------------------------------------------- 1 | #ifndef GRADE_SCHOOL_H 2 | #define GRADE_SCHOOL_H 3 | 4 | #include 5 | #include 6 | 7 | #define MAX_NAME_LENGTH 20 8 | #define MAX_STUDENTS 20 9 | 10 | typedef struct { 11 | uint8_t grade; 12 | char name[MAX_NAME_LENGTH]; 13 | } student_t; 14 | 15 | typedef struct { 16 | size_t count; 17 | student_t students[MAX_STUDENTS]; 18 | } roster_t; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /exercises/practice/grains/.approaches/bit-shifting/snippet.txt: -------------------------------------------------------------------------------- 1 | uint64_t square(uint8_t index) 2 | { 3 | return (index > 0 && index < 65) ? 1ul << (index - 1) : 0; 4 | } 5 | uint64_t total(void) 6 | { 7 | return ((((uint64_t)1 << 63) - 1) << 1) + 1; 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/grains/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"] 4 | }, 5 | "approaches": [ 6 | { 7 | "uuid": "54b082d1-f2d2-4bc7-856b-efb72babed8e", 8 | "slug": "bit-shifting", 9 | "title": "Bit-shifting", 10 | "blurb": "Use bit-shifting to set the correct value.", 11 | "authors": ["bobahop"] 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /exercises/practice/grains/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Calculate the number of grains of wheat on a chessboard. 4 | 5 | A chessboard has 64 squares. 6 | Square 1 has one grain, square 2 has two grains, square 3 has four grains, and so on, doubling each time. 7 | 8 | Write code that calculates: 9 | 10 | - the number of grains on a given square 11 | - the total number of grains on the chessboard 12 | -------------------------------------------------------------------------------- /exercises/practice/grains/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | There once was a wise servant who saved the life of a prince. 4 | The king promised to pay whatever the servant could dream up. 5 | Knowing that the king loved chess, the servant told the king he would like to have grains of wheat. 6 | One grain on the first square of a chessboard, with the number of grains doubling on each successive square. 7 | -------------------------------------------------------------------------------- /exercises/practice/grains/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "grains.h" 2 | 3 | #define NUMBER_OF_SQUARES (64) 4 | 5 | uint64_t square(uint8_t index) 6 | { 7 | if ((!index) || (index > NUMBER_OF_SQUARES)) { 8 | return 0; 9 | } 10 | 11 | return (uint64_t)1 << (index - 1); 12 | } 13 | 14 | uint64_t total(void) 15 | { 16 | uint64_t result = 0; 17 | 18 | for (uint8_t i = 1; i <= NUMBER_OF_SQUARES; i++) { 19 | result += square(i); 20 | } 21 | 22 | return result; 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/grains/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAINS_H 2 | #define GRAINS_H 3 | 4 | #include 5 | 6 | uint64_t square(uint8_t index); 7 | uint64_t total(void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /exercises/practice/grains/grains.c: -------------------------------------------------------------------------------- 1 | #include "grains.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/grains/grains.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAINS_H 2 | #define GRAINS_H 3 | 4 | #include 5 | 6 | uint64_t square(uint8_t index); 7 | uint64_t total(void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "37545957-ff24-41be-b38e-16e8373a28fc", 9 | "slug": "increment-pointers", 10 | "title": "Increment pointers", 11 | "blurb": "Increment pointers directly.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.approaches/increment-pointers/snippet.txt: -------------------------------------------------------------------------------- 1 | if (!lhs || !rhs) 2 | return -1; 3 | int distance = 0; 4 | for (; *lhs && *rhs; lhs++, rhs++) { 5 | if (*lhs != *rhs) 6 | distance++; 7 | } 8 | return (*lhs || *rhs) ? -1 : distance; 9 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Calculate the Hamming distance between two DNA strands. 4 | 5 | We read DNA using the letters C, A, G and T. 6 | Two strands might look like this: 7 | 8 | GAGCCTACTAACGGGAT 9 | CATCGTAATGACGGCCT 10 | ^ ^ ^ ^ ^ ^^ 11 | 12 | They have 7 differences, and therefore the Hamming distance is 7. 13 | 14 | ## Implementation notes 15 | 16 | The Hamming distance is only defined for sequences of equal length, so an attempt to calculate it between sequences of different lengths should not work. 17 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your body is made up of cells that contain DNA. 4 | Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. 5 | In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! 6 | 7 | When cells divide, their DNA replicates too. 8 | Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. 9 | If we compare two strands of DNA and count the differences between them, we can see how many mistakes occurred. 10 | This is known as the "Hamming distance". 11 | 12 | The Hamming distance is useful in many areas of science, not just biology, so it's a nice phrase to be familiar with :) 13 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "hamming.h" 4 | 5 | int compute(const char *lhs, const char *rhs) 6 | { 7 | int count = -1; 8 | if (lhs && rhs && (strlen(lhs) == strlen(rhs))) { 9 | count = 0; 10 | int length = (int)strlen(lhs); 11 | for (int i = 0; i < length; ++i) { 12 | if (lhs[i] != rhs[i]) { 13 | ++count; 14 | } 15 | } 16 | } 17 | return count; 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef HAMMING_H 2 | #define HAMMING_H 3 | 4 | int compute(const char *lhs, const char *rhs); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/hamming/hamming.c: -------------------------------------------------------------------------------- 1 | #include "hamming.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/hamming/hamming.h: -------------------------------------------------------------------------------- 1 | #ifndef HAMMING_H 2 | #define HAMMING_H 3 | 4 | int compute(const char *lhs, const char *rhs); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | The classical introductory exercise. 4 | Just say "Hello, World!". 5 | 6 | ["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. 7 | 8 | The objectives are simple: 9 | 10 | - Modify the provided code so that it produces the string "Hello, World!". 11 | - Run the test suite and make sure that it succeeds. 12 | - Submit your solution and check it at the website. 13 | 14 | If everything goes well, you will be ready to fetch your first real exercise. 15 | 16 | [hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program 17 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "hello_world.h" 2 | 3 | const char *hello(void) 4 | { 5 | return "Hello, World!"; 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [af9ffe10-dc13-42d8-a742-e7bdafac449d] 6 | description = "Say Hi!" 7 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/hello_world.c: -------------------------------------------------------------------------------- 1 | #include "hello_world.h" 2 | 3 | // Define the function itself. 4 | const char *hello(void) 5 | { 6 | return "Goodbye, Mars!"; 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/hello_world.h: -------------------------------------------------------------------------------- 1 | // This is called an include guard, which ensures that the header is only 2 | // included once. You could alternatively use '#pragma once'. See 3 | // https://en.wikipedia.org/wiki/Include_guard. 4 | #ifndef HELLO_WORLD_H 5 | #define HELLO_WORLD_H 6 | 7 | // Declare the 'hello()' function, which takes no arguments and returns a 8 | // 'const char *', i.e. a pointer to a character (in this case the first 9 | // character in a string). The function itself is defined in the hello_world.c 10 | // source file. This function is called by the test case(s) in the test source 11 | // file test_hello_world.c. 12 | const char *hello(void); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | The functions in this exercise accept an array containing one or more numbers, each representing one 'game score'. 4 | 5 | The player's game scores can be read from 6 | 7 | | `scores` | 8 | |---| 9 | | `scores[0]` | 10 | | `scores[1]` | 11 | | ... | 12 | | `scores[scores_len - 1]` | 13 | 14 | `personal_top_three()` should write the player's top scores to 15 | 16 | | `output` | 17 | |---| 18 | | `output[0]` | 19 | | ... | 20 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Manage a game player's High Score list. 4 | 5 | Your task is to build a high-score component of the classic Frogger game, one of the highest selling and most addictive games of all time, and a classic of the arcade era. 6 | Your task is to write methods that return the highest score from the list, the last added score and the three highest scores. 7 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "contributors": [ 6 | "ryanplusplus", 7 | "siebenschlaefer" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "high_scores.c", 12 | "high_scores.h" 13 | ], 14 | "test": [ 15 | "test_high_scores.c" 16 | ], 17 | "example": [ 18 | ".meta/example.c", 19 | ".meta/example.h" 20 | ] 21 | }, 22 | "blurb": "Manage a player's High Score list.", 23 | "source": "Tribute to the eighties' arcade game Frogger" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef HIGH_SCORES_H 2 | #define HIGH_SCORES_H 3 | 4 | #include 5 | #include 6 | 7 | /// Return the latest score. 8 | int32_t latest(const int32_t *scores, size_t scores_len); 9 | 10 | /// Return the highest score. 11 | int32_t personal_best(const int32_t *scores, size_t scores_len); 12 | 13 | /// Write the highest scores to `output` (in non-ascending order). 14 | /// Return the number of scores written. 15 | size_t personal_top_three(const int32_t *scores, size_t scores_len, 16 | int32_t *output); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/high_scores.c: -------------------------------------------------------------------------------- 1 | #include "high_scores.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/high-scores/high_scores.h: -------------------------------------------------------------------------------- 1 | #ifndef HIGH_SCORES_H 2 | #define HIGH_SCORES_H 3 | 4 | #include 5 | #include 6 | 7 | /// Return the latest score. 8 | int32_t latest(const int32_t *scores, size_t scores_len); 9 | 10 | /// Return the highest score. 11 | int32_t personal_best(const int32_t *scores, size_t scores_len); 12 | 13 | /// Write the highest scores to `output` (in non-ascending order). 14 | /// Return the number of scores written. 15 | size_t personal_top_three(const int32_t *scores, size_t scores_len, 16 | int32_t *output); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.approaches/bitfield/snippet.txt: -------------------------------------------------------------------------------- 1 | if (sub != 'X') { 2 | if ((letter_flags & (1 << (letter - sub))) != 0) 3 | return false; 4 | else 5 | letter_flags |= (1 << (letter - sub)); 6 | } 7 | phrase++; 8 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"] 4 | }, 5 | "approaches": [ 6 | { 7 | "uuid": "bc4e307b-e68c-4bdb-89f8-0f3db2b18a2e", 8 | "slug": "bitfield", 9 | "title": "Bit field", 10 | "blurb": "Use a bit field to keep track of used letters.", 11 | "authors": ["bobahop"] 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Determine if a word or phrase is an isogram. 4 | 5 | An isogram (also known as a "non-pattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. 6 | 7 | Examples of isograms: 8 | 9 | - lumberjacks 10 | - background 11 | - downstream 12 | - six-year-old 13 | 14 | The word _isograms_, however, is not an isogram, because the s repeats. 15 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "h-3-0", 9 | "PakkuDon", 10 | "patricksjackson", 11 | "QLaille", 12 | "rootbeersoup", 13 | "ryanplusplus", 14 | "sesamemucho" 15 | ], 16 | "files": { 17 | "solution": [ 18 | "isogram.c", 19 | "isogram.h" 20 | ], 21 | "test": [ 22 | "test_isogram.c" 23 | ], 24 | "example": [ 25 | ".meta/example.c" 26 | ] 27 | }, 28 | "blurb": "Determine if a word or phrase is an isogram.", 29 | "source": "Wikipedia", 30 | "source_url": "https://en.wikipedia.org/wiki/Isogram" 31 | } 32 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "isogram.h" 2 | #include 3 | #include 4 | #include 5 | 6 | bool is_isogram(const char phrase[]) 7 | { 8 | uint32_t used_letters = 0; 9 | 10 | if (phrase == NULL) 11 | return false; 12 | 13 | for (int16_t i = 0; phrase[i] != '\0'; ++i) { 14 | if (isalpha(phrase[i])) { 15 | uint8_t bit_number = toupper(phrase[i]) - 'A'; 16 | uint32_t bit_mask = 1 << bit_number; 17 | 18 | if ((used_letters & bit_mask) > 0) 19 | return false; 20 | else 21 | used_letters |= bit_mask; 22 | } 23 | } 24 | 25 | return true; 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/isogram/isogram.c: -------------------------------------------------------------------------------- 1 | #include "isogram.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/isogram/isogram.h: -------------------------------------------------------------------------------- 1 | #ifndef ISOGRAM_H 2 | #define ISOGRAM_H 3 | 4 | #include 5 | 6 | bool is_isogram(const char phrase[]); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The kindergarten class is learning about growing plants. 4 | The teacher thought it would be a good idea to give the class seeds to plant and grow in the dirt. 5 | To this end, the children have put little cups along the window sills and planted one type of plant in each cup. 6 | The children got to pick their favorites from four available types of seeds: grass, clover, radishes, and violets. 7 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ahans" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "kindergarten_garden.c", 8 | "kindergarten_garden.h" 9 | ], 10 | "test": [ 11 | "test_kindergarten_garden.c" 12 | ], 13 | "example": [ 14 | ".meta/example.c", 15 | ".meta/example.h" 16 | ] 17 | }, 18 | "blurb": "Given a diagram, determine which plants each child in the kindergarten class is responsible for.", 19 | "source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", 20 | "source_url": "https://turing.edu" 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef KINDERGARTEN_GARDEN_H 2 | #define KINDERGARTEN_GARDEN_H 3 | 4 | typedef enum { CLOVER = 0, GRASS = 1, RADISHES = 2, VIOLETS = 3 } plant_t; 5 | 6 | typedef struct { 7 | plant_t plants[4]; 8 | } plants_t; 9 | 10 | plants_t plants(const char *diagram, const char *student); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/kindergarten_garden.c: -------------------------------------------------------------------------------- 1 | #include "kindergarten_garden.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/kindergarten_garden.h: -------------------------------------------------------------------------------- 1 | #ifndef KINDERGARTEN_GARDEN_H 2 | #define KINDERGARTEN_GARDEN_H 3 | 4 | typedef enum { CLOVER = 0, GRASS = 1, RADISHES = 2, VIOLETS = 3 } plant_t; 5 | 6 | typedef struct { 7 | plant_t plants[4]; 8 | } plants_t; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Lhakpa is a [Sherpa][sherpa] mountain guide and porter. 4 | After months of careful planning, the expedition Lhakpa works for is about to leave. 5 | She will be paid the value she carried to the base camp. 6 | 7 | In front of her are many items, each with a value and weight. 8 | Lhakpa would gladly take all of the items, but her knapsack can only hold so much weight. 9 | 10 | [sherpa]: https://en.wikipedia.org/wiki/Sherpa_people#Mountaineering 11 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": ["ryanplusplus"], 3 | "files": { 4 | "solution": [ 5 | "knapsack.c", 6 | "knapsack.h" 7 | ], 8 | "test": [ 9 | "test_knapsack.c" 10 | ], 11 | "example": [ 12 | ".meta/example.c", 13 | ".meta/example.h" 14 | ] 15 | }, 16 | "blurb": "Given a knapsack that can only carry a certain weight, determine which items to put in the knapsack in order to maximize their combined value.", 17 | "source": "Wikipedia", 18 | "source_url": "https://en.wikipedia.org/wiki/Knapsack_problem" 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef KNAPSACK_H 2 | #define KNAPSACK_H 3 | 4 | #include 5 | 6 | typedef struct { 7 | unsigned int weight; 8 | unsigned int value; 9 | } item_t; 10 | 11 | unsigned int maximum_value(unsigned int maximum_weight, item_t *items, 12 | size_t item_count); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/knapsack.c: -------------------------------------------------------------------------------- 1 | #include "knapsack.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/knapsack.h: -------------------------------------------------------------------------------- 1 | #ifndef KNAPSACK_H 2 | #define KNAPSACK_H 3 | 4 | typedef struct { 5 | unsigned int weight; 6 | unsigned int value; 7 | } item_t; 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a government agency that has intercepted a series of encrypted communication signals from a group of bank robbers. 4 | The signals contain a long sequence of digits. 5 | Your team needs to use various digital signal processing techniques to analyze the signals and identify any patterns that may indicate the planning of a heist. 6 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef LARGEST_SERIES_PRODUCT_H 2 | #define LARGEST_SERIES_PRODUCT_H 3 | 4 | #include 5 | #include 6 | 7 | int64_t largest_series_product(char *digits, size_t span); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/largest_series_product.c: -------------------------------------------------------------------------------- 1 | #include "largest_series_product.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/largest_series_product.h: -------------------------------------------------------------------------------- 1 | #ifndef LARGEST_SERIES_PRODUCT_H 2 | #define LARGEST_SERIES_PRODUCT_H 3 | 4 | #include 5 | #include 6 | 7 | int64_t largest_series_product(char *digits, size_t span); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /exercises/practice/leap/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine whether a given year is a leap year. 4 | -------------------------------------------------------------------------------- /exercises/practice/leap/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | A leap year (in the Gregorian calendar) occurs: 4 | 5 | - In every year that is evenly divisible by 4. 6 | - Unless the year is evenly divisible by 100, in which case it's only a leap year if the year is also evenly divisible by 400. 7 | 8 | Some examples: 9 | 10 | - 1997 was not a leap year as it's not divisible by 4. 11 | - 1900 was not a leap year as it's not divisible by 400. 12 | - 2000 was a leap year! 13 | 14 | ~~~~exercism/note 15 | For a delightful, four-minute explanation of the whole phenomenon of leap years, check out [this YouTube video](https://www.youtube.com/watch?v=xX96xng7sAE). 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "leap.h" 2 | 3 | bool leap_year(int year) 4 | { 5 | if (year % 4 == 0) { 6 | if (year % 400 == 0) { 7 | return true; 8 | } 9 | if (year % 100 == 0) { 10 | return false; 11 | } 12 | return true; 13 | } 14 | return false; 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef LEAP_H 2 | #define LEAP_H 3 | 4 | #include 5 | 6 | bool leap_year(int year); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/leap/leap.c: -------------------------------------------------------------------------------- 1 | #include "leap.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/leap/leap.h: -------------------------------------------------------------------------------- 1 | #ifndef LEAP_H 2 | #define LEAP_H 3 | 4 | #include 5 | 6 | bool leap_year(int year); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/.approaches/circular-doubly-linked-list/snippet.txt: -------------------------------------------------------------------------------- 1 | while (node) { 2 | if (node->data == data) { 3 | destroy_node(node, list); 4 | break; 5 | } 6 | if (node->next == list->head) 7 | break; 8 | node = node->next; 9 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "8e575515-a5cd-440e-86e1-bad15ba28e2c", 9 | "slug": "circular-doubly-linked-list", 10 | "title": "Circular Doubly-Linked List", 11 | "blurb": "Use a circular doubly-linked list for implementation.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You are working on a project to develop a train scheduling system for a busy railway network. 4 | 5 | You've been asked to develop a prototype for the train routes in the scheduling system. 6 | Each route consists of a sequence of train stations that a given train stops at. 7 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "patricksjackson", 7 | "QLaille", 8 | "ryanplusplus", 9 | "siebenschlaefer" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "linked_list.c", 14 | "linked_list.h" 15 | ], 16 | "test": [ 17 | "test_linked_list.c" 18 | ], 19 | "example": [ 20 | ".meta/example.c", 21 | ".meta/example.h" 22 | ] 23 | }, 24 | "blurb": "Implement a doubly linked list.", 25 | "source": "Classic computer science topic" 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/linked_list.c: -------------------------------------------------------------------------------- 1 | #include "linked_list.h" 2 | 3 | struct list_node { 4 | struct list_node *prev, *next; 5 | ll_data_t data; 6 | }; 7 | 8 | struct list { 9 | struct list_node *first, *last; 10 | }; 11 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "patricksjackson", 7 | "rootbeersoup", 8 | "ryanplusplus", 9 | "xihh87" 10 | ], 11 | "files": { 12 | "solution": [ 13 | "list_ops.c", 14 | "list_ops.h" 15 | ], 16 | "test": [ 17 | "test_list_ops.c" 18 | ], 19 | "example": [ 20 | ".meta/example.c", 21 | ".meta/example.h" 22 | ] 23 | }, 24 | "blurb": "Implement basic list operations." 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/list_ops.c: -------------------------------------------------------------------------------- 1 | #include "list_ops.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "wolf99" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "luhn.c", 15 | "luhn.h" 16 | ], 17 | "test": [ 18 | "test_luhn.c" 19 | ], 20 | "example": [ 21 | ".meta/example.c", 22 | ".meta/example.h" 23 | ] 24 | }, 25 | "blurb": "Given a number determine whether or not it is valid per the Luhn formula.", 26 | "source": "The Luhn Algorithm on Wikipedia", 27 | "source_url": "https://en.wikipedia.org/wiki/Luhn_algorithm" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef LUHN_H 2 | #define LUHN_H 3 | #include 4 | 5 | bool luhn(const char *num); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/luhn/luhn.c: -------------------------------------------------------------------------------- 1 | #include "luhn.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/luhn/luhn.h: -------------------------------------------------------------------------------- 1 | #ifndef LUHN_H 2 | #define LUHN_H 3 | 4 | #include 5 | 6 | bool luhn(const char *num); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a string containing brackets `[]`, braces `{}`, parentheses `()`, or any combination thereof, verify that any and all pairs are matched and nested correctly. 4 | Any other characters should be ignored. 5 | For example, `"{what is (42)}?"` is balanced and `"[text}"` is not. 6 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You're given the opportunity to write software for the Bracketeer™, an ancient but powerful mainframe. 4 | The software that runs on it is written in a proprietary language. 5 | Much of its syntax is familiar, but you notice _lots_ of brackets, braces and parentheses. 6 | Despite the Bracketeer™ being powerful, it lacks flexibility. 7 | If the source code has any unbalanced brackets, braces or parentheses, the Bracketeer™ crashes and must be rebooted. 8 | To avoid such a scenario, you start writing code that can verify that brackets, braces, and parentheses are balanced before attempting to run it on the Bracketeer™. 9 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "sjwarner", 11 | "wolf99" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "matching_brackets.c", 16 | "matching_brackets.h" 17 | ], 18 | "test": [ 19 | "test_matching_brackets.c" 20 | ], 21 | "example": [ 22 | ".meta/example.c", 23 | ".meta/example.h" 24 | ] 25 | }, 26 | "blurb": "Make sure the brackets and braces all match.", 27 | "source": "Ginna Baker" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef MATCHING_BRACKETS_H 2 | #define MATCHING_BRACKETS_H 3 | #include 4 | 5 | bool is_paired(const char *input); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/matching_brackets.c: -------------------------------------------------------------------------------- 1 | #include "matching_brackets.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/matching_brackets.h: -------------------------------------------------------------------------------- 1 | #ifndef MATCHING_BRACKETS_H 2 | #define MATCHING_BRACKETS_H 3 | 4 | #include 5 | 6 | bool is_paired(const char *input); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/meetup/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "StevenRoot" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "h-3-0", 9 | "patricksjackson", 10 | "QLaille", 11 | "ryanplusplus", 12 | "wolf99" 13 | ], 14 | "files": { 15 | "solution": [ 16 | "meetup.c", 17 | "meetup.h" 18 | ], 19 | "test": [ 20 | "test_meetup.c" 21 | ], 22 | "example": [ 23 | ".meta/example.c", 24 | ".meta/example.h" 25 | ] 26 | }, 27 | "blurb": "Calculate the date of meetups.", 28 | "source": "Jeremy Hinegardner mentioned a Boulder meetup that happens on the Wednesteenth of every month" 29 | } 30 | -------------------------------------------------------------------------------- /exercises/practice/meetup/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef MEETUP_H 2 | #define MEETUP_H 3 | 4 | int meetup_day_of_month(unsigned int year, unsigned int month, const char *week, 5 | const char *day_of_week); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/meetup/meetup.c: -------------------------------------------------------------------------------- 1 | #include "meetup.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/meetup/meetup.h: -------------------------------------------------------------------------------- 1 | #ifndef MEETUP_H 2 | #define MEETUP_H 3 | 4 | int meetup_day_of_month(unsigned int year, unsigned int month, const char *week, 5 | const char *day_of_week); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | [Minesweeper][wikipedia] is a popular game where the user has to find the mines using numeric hints that indicate how many mines are directly adjacent (horizontally, vertically, diagonally) to a square. 4 | 5 | [wikipedia]: https://en.wikipedia.org/wiki/Minesweeper_(video_game) 6 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "wolf99" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "minesweeper.c", 15 | "minesweeper.h" 16 | ], 17 | "test": [ 18 | "test_minesweeper.c" 19 | ], 20 | "example": [ 21 | ".meta/example.c", 22 | ".meta/example.h" 23 | ] 24 | }, 25 | "blurb": "Add the numbers to a minesweeper board." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef MINESWEEPER_H 2 | #define MINESWEEPER_H 3 | #include 4 | 5 | char **annotate(const char **minefield, const size_t rows); 6 | void free_annotation(char **annotation); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/minesweeper.c: -------------------------------------------------------------------------------- 1 | #include "minesweeper.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/minesweeper.h: -------------------------------------------------------------------------------- 1 | #ifndef MINESWEEPER_H 2 | #define MINESWEEPER_H 3 | #include 4 | 5 | char **annotate(const char **minefield, const size_t rows); 6 | void free_annotation(char **annotation); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a number n, determine what the nth prime is. 4 | 5 | By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. 6 | 7 | If your language provides methods in the standard library to deal with prime numbers, pretend they don't exist and implement them yourself. 8 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "RealBarrettBrown" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "gea-migration", 9 | "h-3-0", 10 | "patricksjackson", 11 | "QLaille", 12 | "ryanplusplus", 13 | "wolf99" 14 | ], 15 | "files": { 16 | "solution": [ 17 | "nth_prime.c", 18 | "nth_prime.h" 19 | ], 20 | "test": [ 21 | "test_nth_prime.c" 22 | ], 23 | "example": [ 24 | ".meta/example.c", 25 | ".meta/example.h" 26 | ] 27 | }, 28 | "blurb": "Given a number n, determine what the nth prime is.", 29 | "source": "A variation on Problem 7 at Project Euler", 30 | "source_url": "https://projecteuler.net/problem=7" 31 | } 32 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "nth_prime.h" 2 | #include 3 | 4 | static bool is_prime(uint32_t n) 5 | { 6 | for (uint32_t i = 2; (i * i) < (n + 1); ++i) { 7 | if (n % i == 0) { 8 | return false; 9 | } 10 | } 11 | 12 | return true; 13 | } 14 | 15 | uint32_t nth(uint32_t n) 16 | { 17 | uint32_t candidate = 1; 18 | uint32_t count = 0; 19 | 20 | if (n < 1) { 21 | return 0; 22 | } 23 | 24 | while (count < n) { 25 | if (is_prime(++candidate)) { 26 | count++; 27 | } 28 | } 29 | 30 | return candidate; 31 | } 32 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef NTH_PRIME_H 2 | #define NTH_PRIME_H 3 | 4 | #include 5 | 6 | uint32_t nth(uint32_t n); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [75c65189-8aef-471a-81de-0a90c728160c] 6 | description = "first prime" 7 | 8 | [2c38804c-295f-4701-b728-56dea34fd1a0] 9 | description = "second prime" 10 | 11 | [56692534-781e-4e8c-b1f9-3e82c1640259] 12 | description = "sixth prime" 13 | 14 | [fce1e979-0edb-412d-93aa-2c744e8f50ff] 15 | description = "big prime" 16 | 17 | [bd0a9eae-6df7-485b-a144-80e13c7d55b2] 18 | description = "there is no zeroth prime" 19 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/nth_prime.c: -------------------------------------------------------------------------------- 1 | #include "nth_prime.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/nth_prime.h: -------------------------------------------------------------------------------- 1 | #ifndef NTH_PRIME_H 2 | #define NTH_PRIME_H 3 | 4 | #include 5 | 6 | uint32_t nth(uint32_t n); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef NUCLEOTIDE_COUNT_H 2 | #define NUCLEOTIDE_COUNT_H 3 | 4 | char *count(const char *dna_strand); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /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 | 5 | [3e5c30a8-87e2-4845-a815-a49671ade970] 6 | description = "empty strand" 7 | 8 | [a0ea42a6-06d9-4ac6-828c-7ccaccf98fec] 9 | description = "can count one nucleotide in single-character input" 10 | 11 | [eca0d565-ed8c-43e7-9033-6cefbf5115b5] 12 | description = "strand with repeated nucleotide" 13 | 14 | [40a45eac-c83f-4740-901a-20b22d15a39f] 15 | description = "strand with multiple nucleotides" 16 | 17 | [b4c47851-ee9e-4b0a-be70-a86e343bd851] 18 | description = "strand with invalid nucleotides" 19 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/nucleotide_count.c: -------------------------------------------------------------------------------- 1 | #include "nucleotide_count.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/nucleotide_count.h: -------------------------------------------------------------------------------- 1 | #ifndef NUCLEOTIDE_COUNT_H 2 | #define NUCLEOTIDE_COUNT_H 3 | 4 | char *count(const char *dna_strand); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "h-3-0", 9 | "jagdish-15", 10 | "patricksjackson", 11 | "QLaille", 12 | "vlzware", 13 | "wolf99", 14 | "ZapAnton" 15 | ], 16 | "files": { 17 | "solution": [ 18 | "palindrome_products.c", 19 | "palindrome_products.h" 20 | ], 21 | "test": [ 22 | "test_palindrome_products.c" 23 | ], 24 | "example": [ 25 | ".meta/example.c", 26 | ".meta/example.h" 27 | ] 28 | }, 29 | "blurb": "Detect palindrome products in a given range.", 30 | "source": "Problem 4 at Project Euler", 31 | "source_url": "https://projecteuler.net/problem=4" 32 | } 33 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef PALINDROME_PRODUCTS_H 2 | #define PALINDROME_PRODUCTS_H 3 | 4 | #define MAXERR 100 5 | 6 | typedef struct factors { 7 | int factor_a; 8 | int factor_b; 9 | struct factors *next; 10 | } factor_t; 11 | 12 | struct product { 13 | int smallest; 14 | int largest; 15 | factor_t *factors_sm; 16 | factor_t *factors_lg; 17 | char error[MAXERR]; 18 | }; 19 | 20 | typedef struct product product_t; 21 | 22 | product_t *get_palindrome_product(int from, int to); 23 | void free_product(product_t *p); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/palindrome_products.c: -------------------------------------------------------------------------------- 1 | #include "palindrome_products.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/palindrome_products.h: -------------------------------------------------------------------------------- 1 | #ifndef PALINDROME_PRODUCTS_H 2 | #define PALINDROME_PRODUCTS_H 3 | 4 | #define MAXERR 100 5 | 6 | typedef struct factors { 7 | int factor_a; 8 | int factor_b; 9 | struct factors *next; 10 | } factor_t; 11 | 12 | struct product { 13 | int smallest; 14 | int largest; 15 | factor_t *factors_sm; 16 | factor_t *factors_lg; 17 | char error[MAXERR]; 18 | }; 19 | 20 | typedef struct product product_t; 21 | 22 | product_t *get_palindrome_product(int from, int to); 23 | void free_product(product_t *p); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.approaches/bitfield/snippet.txt: -------------------------------------------------------------------------------- 1 | while ((letter = *sentence) != '\0') { 2 | if (letter >= 'a' && letter <= 'z') 3 | phrasemask |= 1 << (letter - 'a'); 4 | else if (letter >= 'A' && letter <= 'Z') 5 | phrasemask |= 1 << (letter - 'A'); 6 | sentence++; 7 | } 8 | return phrasemask == 67108863; 9 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"] 4 | }, 5 | "approaches": [ 6 | { 7 | "uuid": "31f53b6f-013c-40dd-8407-b490db4f7435", 8 | "slug": "bitfield", 9 | "title": "Bit field", 10 | "blurb": "Use a bit field to keep track of used letters.", 11 | "authors": ["bobahop"] 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to figure out if a sentence is a pangram. 4 | 5 | A pangram is a sentence using every letter of the alphabet at least once. 6 | It is case insensitive, so it doesn't matter if a letter is lower-case (e.g. `k`) or upper-case (e.g. `K`). 7 | 8 | For this exercise, a sentence is a pangram if it contains each of the 26 letters in the English alphabet. 9 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a company that sells fonts through their website. 4 | They'd like to show a different sentence each time someone views a font on their website. 5 | To give a comprehensive sense of the font, the random sentences should use **all** the letters in the English alphabet. 6 | 7 | They're running a competition to get suggestions for sentences that they can use. 8 | You're in charge of checking the submissions to see if they are valid. 9 | 10 | ~~~~exercism/note 11 | Pangram comes from Greek, παν γράμμα, pan gramma, which means "every letter". 12 | 13 | The best known English pangram is: 14 | 15 | > The quick brown fox jumps over the lazy dog. 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "RealBarrettBrown" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "gea-migration", 9 | "h-3-0", 10 | "PakkuDon", 11 | "patricksjackson", 12 | "QLaille", 13 | "ryanplusplus", 14 | "Vitorvgc", 15 | "wolf99" 16 | ], 17 | "files": { 18 | "solution": [ 19 | "pangram.c", 20 | "pangram.h" 21 | ], 22 | "test": [ 23 | "test_pangram.c" 24 | ], 25 | "example": [ 26 | ".meta/example.c" 27 | ] 28 | }, 29 | "blurb": "Determine if a sentence is a pangram.", 30 | "source": "Wikipedia", 31 | "source_url": "https://en.wikipedia.org/wiki/Pangram" 32 | } 33 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "pangram.h" 2 | #include 3 | #include 4 | 5 | #define NUMBER_OF_LETTERS (26) 6 | 7 | bool is_pangram(const char *sentence) 8 | { 9 | size_t sentence_length = ((sentence == NULL) ? 0 : strlen(sentence)); 10 | bool found_letters[NUMBER_OF_LETTERS]; 11 | 12 | memset(found_letters, 0, sizeof(found_letters)); 13 | 14 | for (size_t i = 0; i < sentence_length; i++) { 15 | char letter = tolower(sentence[i]); 16 | 17 | if (isalpha(letter)) { 18 | found_letters[letter - 'a'] = true; 19 | } 20 | } 21 | 22 | for (size_t i = 0; i < NUMBER_OF_LETTERS; i++) { 23 | if (!found_letters[i]) { 24 | return false; 25 | } 26 | } 27 | 28 | return true; 29 | } 30 | -------------------------------------------------------------------------------- /exercises/practice/pangram/pangram.c: -------------------------------------------------------------------------------- 1 | #include "pangram.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/pangram/pangram.h: -------------------------------------------------------------------------------- 1 | #ifndef PANGRAM_H 2 | #define PANGRAM_H 3 | 4 | #include 5 | 6 | bool is_pangram(const char *sentence); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef PASCALS_TRIANGLE_H 2 | #define PASCALS_TRIANGLE_H 3 | 4 | #include 5 | #include 6 | 7 | void free_triangle(uint8_t **triangle, size_t rows); 8 | uint8_t **create_triangle(size_t rows); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/pascals_triangle.c: -------------------------------------------------------------------------------- 1 | #include "pascals_triangle.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/pascals_triangle.h: -------------------------------------------------------------------------------- 1 | #ifndef PASCALS_TRIANGLE_H 2 | #define PASCALS_TRIANGLE_H 3 | 4 | #include 5 | #include 6 | 7 | void free_triangle(uint8_t **triangle, size_t rows); 8 | uint8_t **create_triangle(size_t rows); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "perfect_numbers.h" 2 | 3 | static int aliquot_sum(int n) 4 | { 5 | if (n == 1) { 6 | return 0; 7 | } 8 | int result = 1; 9 | int i; 10 | for (i = 2; i * i < n; ++i) { 11 | if ((n % i) == 0) { 12 | result += i + (n / i); 13 | } 14 | } 15 | return result + (i * i == n ? i : 0); 16 | } 17 | 18 | kind classify_number(int n) 19 | { 20 | kind class = ERROR; 21 | if (n > 0) { 22 | int sum = aliquot_sum(n); 23 | if (sum > n) { 24 | class = ABUNDANT_NUMBER; 25 | } else if (sum < n) { 26 | class = DEFICIENT_NUMBER; 27 | } else { 28 | class = PERFECT_NUMBER; 29 | } 30 | } 31 | return class; 32 | } 33 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef PERFECT_NUMBERS_H 2 | #define PERFECT_NUMBERS_H 3 | 4 | typedef enum { 5 | PERFECT_NUMBER = 1, 6 | ABUNDANT_NUMBER = 2, 7 | DEFICIENT_NUMBER = 3, 8 | ERROR = -1 9 | } kind; 10 | 11 | kind classify_number(int); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/perfect_numbers.c: -------------------------------------------------------------------------------- 1 | #include "perfect_numbers.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/perfect_numbers.h: -------------------------------------------------------------------------------- 1 | #ifndef PERFECT_NUMBERS_H 2 | #define PERFECT_NUMBERS_H 3 | 4 | typedef enum { 5 | PERFECT_NUMBER = 1, 6 | ABUNDANT_NUMBER = 2, 7 | DEFICIENT_NUMBER = 3, 8 | ERROR = -1 9 | } kind; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You've joined LinkLine, a leading communications company working to ensure reliable connections for everyone. 4 | The team faces a big challenge: users submit phone numbers in all sorts of formats — dashes, spaces, dots, parentheses, and even prefixes. 5 | Some numbers are valid, while others are impossible to use. 6 | 7 | Your mission is to turn this chaos into order. 8 | You'll clean up valid numbers, formatting them appropriately for use in the system. 9 | At the same time, you'll identify and filter out any invalid entries. 10 | 11 | The success of LinkLine's operations depends on your ability to separate the useful from the unusable. 12 | Are you ready to take on the challenge and keep the connections running smoothly? 13 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef PHONE_NUMBER_H 2 | #define PHONE_NUMBER_H 3 | 4 | char *phone_number_clean(const char *input); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/phone_number.c: -------------------------------------------------------------------------------- 1 | #include "phone_number.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/phone_number.h: -------------------------------------------------------------------------------- 1 | #ifndef PHONE_NUMBER_H 2 | #define PHONE_NUMBER_H 3 | 4 | char *phone_number_clean(const char *input); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "2b474e3a-38eb-4561-b42e-ea74d7f51ad9", 9 | "slug": "strchr-strstr-strtok", 10 | "title": "strchr and strstr with strtok", 11 | "blurb": "Use strchr and strstr with strtok for parsing.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.approaches/strchr-strstr-strtok/snippet.txt: -------------------------------------------------------------------------------- 1 | if (strchr(VOWELS, *word) != NULL || strstr(word, "xr") == word || 2 | strstr(word, "yt") == word) { 3 | strncat(output, word, MAX_PHRASE_LEN - (strlen(output) + 2)); 4 | strcat(output, "ay"); 5 | return true; 6 | } 7 | return false; 8 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your parents have challenged you and your sibling to a game of two-on-two basketball. 4 | Confident they'll win, they let you score the first couple of points, but then start taking over the game. 5 | Needing a little boost, you start speaking in [Pig Latin][pig-latin], which is a made-up children's language that's difficult for non-children to understand. 6 | This will give you the edge to prevail over your parents! 7 | 8 | [pig-latin]: https://en.wikipedia.org/wiki/Pig_latin 9 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef PIG_LATIN_H 2 | #define PIG_LATIN_H 3 | 4 | char *translate(const char *phrase); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/pig_latin.c: -------------------------------------------------------------------------------- 1 | #include "pig_latin.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/pig_latin.h: -------------------------------------------------------------------------------- 1 | #ifndef PIG_LATIN_H 2 | #define PIG_LATIN_H 3 | 4 | char *translate(const char *phrase); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "wolf99" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "prime_factors.c", 15 | "prime_factors.h" 16 | ], 17 | "test": [ 18 | "test_prime_factors.c" 19 | ], 20 | "example": [ 21 | ".meta/example.c", 22 | ".meta/example.h" 23 | ] 24 | }, 25 | "blurb": "Compute the prime factors of a given natural number.", 26 | "source": "The Prime Factors Kata by Uncle Bob", 27 | "source_url": "https://web.archive.org/web/20221026171801/http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "prime_factors.h" 2 | #include 3 | 4 | /** 5 | * find prime factors: brute force version 6 | * https://en.wikipedia.org/wiki/Trial_division 7 | */ 8 | size_t find_factors(uint64_t n, uint64_t factors[static MAXFACTORS]) 9 | { 10 | int count = 0; 11 | while ((n % 2 == 0) && (count < MAXFACTORS)) { 12 | factors[count++] = 2; 13 | n /= 2; 14 | } 15 | 16 | for (uint64_t i = 3; (i <= sqrt(n)) && (count < MAXFACTORS); i += 2) { 17 | while (n % i == 0) { 18 | factors[count++] = i; 19 | n /= i; 20 | } 21 | } 22 | 23 | if (n > 2) { 24 | factors[count++] = n; 25 | } 26 | 27 | return count; 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef PRIME_FACTORS_H 2 | #define PRIME_FACTORS_H 3 | 4 | #include 5 | #include 6 | 7 | #define MAXFACTORS 10 8 | 9 | size_t find_factors(uint64_t n, uint64_t factors[static MAXFACTORS]); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/prime_factors.c: -------------------------------------------------------------------------------- 1 | #include "prime_factors.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/prime_factors.h: -------------------------------------------------------------------------------- 1 | #ifndef PRIME_FACTORS_H 2 | #define PRIME_FACTORS_H 3 | 4 | #include 5 | #include 6 | 7 | #define MAXFACTORS 10 8 | 9 | size_t find_factors(uint64_t n, uint64_t factors[static MAXFACTORS]); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "jagdish-15" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "protein_translation.c", 11 | "protein_translation.h" 12 | ], 13 | "test": [ 14 | "test_protein_translation.c" 15 | ], 16 | "example": [ 17 | ".meta/example.c", 18 | ".meta/example.h" 19 | ] 20 | }, 21 | "blurb": "Translate RNA sequences into proteins.", 22 | "source": "Tyler Long" 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef PROTEIN_TRANSLATION_H 2 | #define PROTEIN_TRANSLATION_H 3 | 4 | #include 5 | #include 6 | 7 | #define MAX_AMINO_ACIDS 10 8 | 9 | typedef enum { 10 | Methionine, 11 | Phenylalanine, 12 | Leucine, 13 | Serine, 14 | Tyrosine, 15 | Cysteine, 16 | Tryptophan, 17 | } amino_acid_t; 18 | 19 | typedef struct { 20 | bool valid; 21 | size_t count; 22 | amino_acid_t amino_acids[MAX_AMINO_ACIDS]; 23 | } protein_t; 24 | 25 | protein_t protein(const char *const rna); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/protein_translation.c: -------------------------------------------------------------------------------- 1 | #include "protein_translation.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/protein_translation.h: -------------------------------------------------------------------------------- 1 | #ifndef PROTEIN_TRANSLATION_H 2 | #define PROTEIN_TRANSLATION_H 3 | 4 | #include 5 | #include 6 | 7 | #define MAX_AMINO_ACIDS 10 8 | 9 | typedef enum { 10 | Methionine, 11 | Phenylalanine, 12 | Leucine, 13 | Serine, 14 | Tyrosine, 15 | Cysteine, 16 | Tryptophan, 17 | } amino_acid_t; 18 | 19 | typedef struct { 20 | bool valid; 21 | size_t count; 22 | amino_acid_t amino_acids[MAX_AMINO_ACIDS]; 23 | } protein_t; 24 | 25 | protein_t protein(const char *const rna); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | A Pythagorean triplet is a set of three natural numbers, {a, b, c}, for which, 4 | 5 | ```text 6 | a² + b² = c² 7 | ``` 8 | 9 | and such that, 10 | 11 | ```text 12 | a < b < c 13 | ``` 14 | 15 | For example, 16 | 17 | ```text 18 | 3² + 4² = 5². 19 | ``` 20 | 21 | Given an input integer N, find all Pythagorean triplets for which `a + b + c = N`. 22 | 23 | For example, with N = 1000, there is exactly one Pythagorean triplet for which `a + b + c = 1000`: `{200, 375, 425}`. 24 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "ryanplusplus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "pythagorean_triplet.c", 11 | "pythagorean_triplet.h" 12 | ], 13 | "test": [ 14 | "test_pythagorean_triplet.c" 15 | ], 16 | "example": [ 17 | ".meta/example.c", 18 | ".meta/example.h" 19 | ] 20 | }, 21 | "blurb": "Given an integer N, find all Pythagorean triplets for which a + b + c = N.", 22 | "source": "A variation of Problem 9 from Project Euler", 23 | "source_url": "https://projecteuler.net/problem=9" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef PYTHAGOREAN_TRIPLET_H 2 | #define PYTHAGOREAN_TRIPLET_H 3 | 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | uint16_t a, b, c; 9 | } triplet_t; 10 | 11 | typedef struct { 12 | size_t count; 13 | triplet_t triplets[]; 14 | } triplets_t; 15 | 16 | triplets_t *triplets_with_sum(uint16_t sum); 17 | 18 | void free_triplets(triplets_t *triplets); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/pythagorean_triplet.c: -------------------------------------------------------------------------------- 1 | #include "pythagorean_triplet.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/pythagorean_triplet.h: -------------------------------------------------------------------------------- 1 | #ifndef PYTHAGOREAN_TRIPLET_H 2 | #define PYTHAGOREAN_TRIPLET_H 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "f06822a4-1d59-4d9d-b682-0c4c78885e7d", 9 | "slug": "helper-functions", 10 | "title": "Helper functions", 11 | "blurb": "Use helper functions to return the answer.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/.approaches/helper-functions/snippet.txt: -------------------------------------------------------------------------------- 1 | attack_status_t can_attack(position_t queen_1, position_t queen_2) 2 | { 3 | return (!has_valid_positions(queen_1, queen_2)) ? INVALID_POSITION 4 | : is_on_straight_or_diagonal(queen_1, queen_2) ? CAN_ATTACK 5 | : CAN_NOT_ATTACK; 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/queen_attack.c: -------------------------------------------------------------------------------- 1 | #include "queen_attack.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/queen_attack.h: -------------------------------------------------------------------------------- 1 | #ifndef QUEEN_ATTACK_H 2 | #define QUEEN_ATTACK_H 3 | 4 | #include 5 | 6 | typedef enum { CAN_NOT_ATTACK, CAN_ATTACK, INVALID_POSITION } attack_status_t; 7 | 8 | typedef struct { 9 | uint8_t row; 10 | uint8_t column; 11 | } position_t; 12 | 13 | attack_status_t can_attack(position_t queen_1, position_t queen_2); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "patricksjackson" 4 | ], 5 | "contributors": [ 6 | "ryanplusplus", 7 | "wolf99" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "rail_fence_cipher.c", 12 | "rail_fence_cipher.h" 13 | ], 14 | "test": [ 15 | "test_rail_fence_cipher.c" 16 | ], 17 | "example": [ 18 | ".meta/example.c" 19 | ] 20 | }, 21 | "blurb": "Implement encoding and decoding for the rail fence cipher.", 22 | "source": "Wikipedia", 23 | "source_url": "https://en.wikipedia.org/wiki/Transposition_cipher#Rail_Fence_cipher" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/rail_fence_cipher.c: -------------------------------------------------------------------------------- 1 | #include "rail_fence_cipher.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/rail_fence_cipher.h: -------------------------------------------------------------------------------- 1 | #ifndef RAIL_FENCE_CIPHER_H 2 | #define RAIL_FENCE_CIPHER_H 3 | 4 | #include 5 | 6 | char *encode(char *text, size_t rails); 7 | 8 | char *decode(char *ciphertext, size_t rails); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.approaches/data-driven/snippet.txt: -------------------------------------------------------------------------------- 1 | for (size_t i = 0; i < ARRAY_SIZE(SOUNDS); i++) { 2 | if (drops % SOUNDS[i].factor == 0) { 3 | strcat(result, SOUNDS[i].sound); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.approaches/if-statements/snippet.txt: -------------------------------------------------------------------------------- 1 | if (drops % 3 == 0) 2 | strcat(result, "Pling"); 3 | if (drops % 5 == 0) 4 | strcat(result, "Plang"); 5 | if (drops % 7 == 0) 6 | strcat(result, "Plong"); 7 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.approaches/sprintf/snippet.txt: -------------------------------------------------------------------------------- 1 | sprintf(result, "%s%s%s", drops % 3 == 0 ? "Pling" : "", 2 | drops % 5 == 0 ? "Plang" : "", drops % 7 == 0 ? "Plong" : ""); 3 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Raindrops is a slightly more complex version of the FizzBuzz challenge, a classic interview question. 4 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "raindrops.h" 2 | 3 | #include 4 | #include 5 | 6 | void convert(char result[], int drops) 7 | { 8 | if (drops % 3 == 0) { 9 | strcat(result, "Pling"); 10 | } 11 | if (drops % 5 == 0) { 12 | strcat(result, "Plang"); 13 | } 14 | if (drops % 7 == 0) { 15 | strcat(result, "Plong"); 16 | } 17 | if (strlen(result) == 0) { 18 | char drops_string[12] = "\0"; 19 | sprintf(drops_string, "%d", drops); 20 | strcat(result, drops_string); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef RAINDROPS_H 2 | #define RAINDROPS_H 3 | 4 | void convert(char result[], int drops); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/raindrops.c: -------------------------------------------------------------------------------- 1 | #include "raindrops.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/raindrops.h: -------------------------------------------------------------------------------- 1 | #ifndef RAINDROPS_H 2 | #define RAINDROPS_H 3 | 4 | void convert(char result[], int drops); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/rational-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "ryanplusplus", 7 | "xihh87" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "rational_numbers.c", 12 | "rational_numbers.h" 13 | ], 14 | "test": [ 15 | "test_rational_numbers.c" 16 | ], 17 | "example": [ 18 | ".meta/example.c", 19 | ".meta/example.h" 20 | ] 21 | }, 22 | "blurb": "Implement rational numbers.", 23 | "source": "Wikipedia", 24 | "source_url": "https://en.wikipedia.org/wiki/Rational_number" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/rational-numbers/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef RATIONAL_NUMBERS_H 2 | #define RATIONAL_NUMBERS_H 3 | 4 | #include 5 | 6 | typedef struct { 7 | int16_t numerator, denominator; 8 | } rational_t; 9 | 10 | rational_t add(rational_t r1, rational_t r2); 11 | 12 | rational_t subtract(rational_t r1, rational_t r2); 13 | 14 | rational_t multiply(rational_t r1, rational_t r2); 15 | 16 | rational_t divide(rational_t r1, rational_t r2); 17 | 18 | rational_t absolute(rational_t r); 19 | 20 | rational_t exp_rational(rational_t r, int16_t n); 21 | 22 | float exp_real(uint16_t n, rational_t r); 23 | 24 | rational_t reduce(rational_t r); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /exercises/practice/rational-numbers/rational_numbers.c: -------------------------------------------------------------------------------- 1 | #include "rational_numbers.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/rational-numbers/rational_numbers.h: -------------------------------------------------------------------------------- 1 | #ifndef RATIONAL_NUMBERS_H 2 | #define RATIONAL_NUMBERS_H 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /exercises/practice/react/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "petertseng" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "h-3-0", 9 | "patricksjackson", 10 | "QLaille", 11 | "ryanplusplus", 12 | "wolf99" 13 | ], 14 | "files": { 15 | "solution": [ 16 | "react.c", 17 | "react.h" 18 | ], 19 | "test": [ 20 | "test_react.c" 21 | ], 22 | "example": [ 23 | ".meta/example.c" 24 | ] 25 | }, 26 | "blurb": "Implement a basic reactive system." 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/react/react.c: -------------------------------------------------------------------------------- 1 | #include "react.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "ryanplusplus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "resistor_color_duo.c", 11 | "resistor_color_duo.h" 12 | ], 13 | "test": [ 14 | "test_resistor_color_duo.c" 15 | ], 16 | "example": [ 17 | ".meta/example.c", 18 | ".meta/example.h" 19 | ] 20 | }, 21 | "blurb": "Convert color codes, as used on resistors, to a numeric value.", 22 | "source": "Maud de Vries, Erik Schierboom", 23 | "source_url": "https://github.com/exercism/problem-specifications/issues/1464" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "resistor_color_duo.h" 2 | 3 | uint16_t color_code(resistor_band_t colors[]) 4 | { 5 | return (uint16_t)(colors[0] * 10 + colors[1]); 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef RESISTOR_COLOR_DUO_H 2 | #define RESISTOR_COLOR_DUO_H 3 | 4 | #include 5 | 6 | typedef enum { 7 | BLACK = 0, 8 | BROWN = 1, 9 | RED = 2, 10 | ORANGE = 3, 11 | YELLOW = 4, 12 | GREEN = 5, 13 | BLUE = 6, 14 | VIOLET = 7, 15 | GREY = 8, 16 | WHITE = 9 17 | } resistor_band_t; 18 | 19 | uint16_t color_code(resistor_band_t colors[]); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/resistor_color_duo.c: -------------------------------------------------------------------------------- 1 | #include "resistor_color_duo.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/resistor_color_duo.h: -------------------------------------------------------------------------------- 1 | #ifndef RESISTOR_COLOR_DUO_H 2 | #define RESISTOR_COLOR_DUO_H 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "ryanplusplus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "resistor_color_trio.c", 11 | "resistor_color_trio.h" 12 | ], 13 | "test": [ 14 | "test_resistor_color_trio.c" 15 | ], 16 | "example": [ 17 | ".meta/example.c", 18 | ".meta/example.h" 19 | ] 20 | }, 21 | "blurb": "Convert color codes, as used on resistors, to a human-readable label.", 22 | "source": "Maud de Vries, Erik Schierboom", 23 | "source_url": "https://github.com/exercism/problem-specifications/issues/1549" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "resistor_color_trio.h" 2 | #include 3 | 4 | resistor_value_t color_code(resistor_band_t colors[]) 5 | { 6 | resistor_value_t resistor = { 0, 0 }; 7 | uint16_t digits = ((uint16_t)colors[0]) * 10 + colors[1]; 8 | uint64_t total = ((uint64_t)pow(10, colors[2])) * digits; 9 | 10 | while (total / 1000 >= 1) { 11 | ++resistor.unit; 12 | total /= 1000; 13 | } 14 | 15 | resistor.value = total; 16 | return resistor; 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef RESISTOR_COLOR_TRIO_H 2 | #define RESISTOR_COLOR_TRIO_H 3 | 4 | #include 5 | 6 | typedef enum { 7 | BLACK = 0, 8 | BROWN = 1, 9 | RED = 2, 10 | ORANGE = 3, 11 | YELLOW = 4, 12 | GREEN = 5, 13 | BLUE = 6, 14 | VIOLET = 7, 15 | GREY = 8, 16 | WHITE = 9 17 | } resistor_band_t; 18 | 19 | typedef enum { 20 | OHMS = 0, 21 | KILOOHMS = 1, 22 | MEGAOHMS = 2, 23 | GIGAOHMS = 3, 24 | TERAOHMS = 4, 25 | PETAOHMS = 5, 26 | EXAOHMS = 6, 27 | } resistor_unit_t; 28 | 29 | typedef struct { 30 | uint16_t value; 31 | resistor_unit_t unit; 32 | } resistor_value_t; 33 | 34 | resistor_value_t color_code(resistor_band_t colors[]); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/resistor_color_trio.c: -------------------------------------------------------------------------------- 1 | #include "resistor_color_trio.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/resistor_color_trio.h: -------------------------------------------------------------------------------- 1 | #ifndef RESISTOR_COLOR_TRIO_H 2 | #define RESISTOR_COLOR_TRIO_H 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "1e004736-9760-4097-bc1f-9e02a289c484", 9 | "slug": "define-consecutive-values", 10 | "title": "Define consecutive values", 11 | "blurb": "Define consecutive values for the enum and array.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.approaches/define-consecutive-values/snippet.txt: -------------------------------------------------------------------------------- 1 | #define COLORS \ 2 | BLACK, BROWN, RED, ORANGE, YELLOW, GREEN, BLUE, VIOLET, GREY, WHITE 3 | 4 | typedef enum RESISTOR_BANDS { COLORS } resistor_band_t; 5 | 6 | int color_code(resistor_band_t color); 7 | resistor_band_t *colors(); 8 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "elyashiv", 7 | "ryanplusplus" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "resistor_color.c", 12 | "resistor_color.h" 13 | ], 14 | "test": [ 15 | "test_resistor_color.c" 16 | ], 17 | "example": [ 18 | ".meta/example.c", 19 | ".meta/example.h" 20 | ] 21 | }, 22 | "blurb": "Convert a resistor band's color to its numeric representation.", 23 | "source": "Maud de Vries, Erik Schierboom", 24 | "source_url": "https://github.com/exercism/problem-specifications/issues/1458" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "resistor_color.h" 2 | 3 | static const resistor_band_t band_colors[] = { BLACK, BROWN, RED, ORANGE, 4 | YELLOW, GREEN, BLUE, VIOLET, 5 | GREY, WHITE }; 6 | 7 | uint16_t color_code(resistor_band_t color) 8 | { 9 | return (uint16_t)color; 10 | } 11 | 12 | const resistor_band_t *colors(void) 13 | { 14 | return band_colors; 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef RESISTOR_COLOR_H 2 | #define RESISTOR_COLOR_H 3 | 4 | #include 5 | 6 | typedef enum { 7 | BLACK = 0, 8 | BROWN = 1, 9 | RED = 2, 10 | ORANGE = 3, 11 | YELLOW = 4, 12 | GREEN = 5, 13 | BLUE = 6, 14 | VIOLET = 7, 15 | GREY = 8, 16 | WHITE = 9 17 | } resistor_band_t; 18 | 19 | uint16_t color_code(resistor_band_t color); 20 | 21 | const resistor_band_t *colors(void); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/.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 | [49eb31c5-10a8-4180-9f7f-fea632ab87ef] 6 | description = "Black" 7 | 8 | [0a4df94b-92da-4579-a907-65040ce0b3fc] 9 | description = "White" 10 | 11 | [5f81608d-f36f-4190-8084-f45116b6f380] 12 | description = "Orange" 13 | 14 | [581d68fa-f968-4be2-9f9d-880f2fb73cf7] 15 | description = "Colors" 16 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/resistor_color.c: -------------------------------------------------------------------------------- 1 | #include "resistor_color.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/resistor_color.h: -------------------------------------------------------------------------------- 1 | #ifndef RESISTOR_COLOR_H 2 | #define RESISTOR_COLOR_H 3 | 4 | typedef enum { 5 | 6 | } resistor_band_t; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to reverse a given string. 4 | 5 | Some examples: 6 | 7 | - Turn `"stressed"` into `"desserts"`. 8 | - Turn `"strops"` into `"sports"`. 9 | - Turn `"racecar"` into `"racecar"`. 10 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Reversing strings (reading them from right to left, rather than from left to right) is a surprisingly common task in programming. 4 | 5 | For example, in bioinformatics, reversing the sequence of DNA or RNA strings is often important for various analyses, such as finding complementary strands or identifying palindromic sequences that have biological significance. 6 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "keiravillekode" 4 | ], 5 | "contributors": [ 6 | "jagdish-15", 7 | "wolf99" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "reverse_string.c", 12 | "reverse_string.h" 13 | ], 14 | "test": [ 15 | "test_reverse_string.c" 16 | ], 17 | "example": [ 18 | ".meta/example.c", 19 | ".meta/example.h" 20 | ] 21 | }, 22 | "blurb": "Reverse a given string.", 23 | "source": "Introductory challenge to reverse an input string", 24 | "source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "reverse_string.h" 2 | #include 3 | #include 4 | 5 | char *reverse(const char *value) 6 | { 7 | size_t value_len = strlen(value); 8 | char *result = malloc(value_len + 1); 9 | char *dest = result + value_len; 10 | 11 | *dest = '\0'; 12 | while (*value) { 13 | --dest; 14 | *dest = *value; 15 | ++value; 16 | } 17 | 18 | return result; 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef REVERSE_STRING_H 2 | #define REVERSE_STRING_H 3 | 4 | char *reverse(const char *value); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/reverse_string.c: -------------------------------------------------------------------------------- 1 | #include "reverse_string.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/reverse_string.h: -------------------------------------------------------------------------------- 1 | #ifndef REVERSE_STRING_H 2 | #define REVERSE_STRING_H 3 | 4 | char *reverse(const char *value); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine the RNA complement of a given DNA sequence. 4 | 5 | Both DNA and RNA strands are a sequence of nucleotides. 6 | 7 | The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**), and thymine (**T**). 8 | 9 | The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**), and uracil (**U**). 10 | 11 | Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement: 12 | 13 | - `G` -> `C` 14 | - `C` -> `G` 15 | - `T` -> `A` 16 | - `A` -> `U` 17 | 18 | ~~~~exercism/note 19 | If you want to look at how the inputs and outputs are structured, take a look at the examples in the test suite. 20 | ~~~~ 21 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a bioengineering company that specializes in developing therapeutic solutions. 4 | 5 | Your team has just been given a new project to develop a targeted therapy for a rare type of cancer. 6 | 7 | ~~~~exercism/note 8 | It's all very complicated, but the basic idea is that sometimes people's bodies produce too much of a given protein. 9 | That can cause all sorts of havoc. 10 | 11 | But if you can create a very specific molecule (called a micro-RNA), it can prevent the protein from being produced. 12 | 13 | This technique is called [RNA Interference][rnai]. 14 | 15 | [rnai]: https://admin.acceleratingscience.com/ask-a-scientist/what-is-rnai/ 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "rna_transcription.h" 4 | 5 | char *to_rna(const char *dna) 6 | { 7 | size_t len = strlen(dna); 8 | char *rna = calloc(len + 1, sizeof(char)); 9 | 10 | for (size_t i = 0; i < len; i++) { 11 | switch (dna[i]) { 12 | case 'G': 13 | rna[i] = 'C'; 14 | break; 15 | case 'C': 16 | rna[i] = 'G'; 17 | break; 18 | case 'T': 19 | rna[i] = 'A'; 20 | break; 21 | case 'A': 22 | rna[i] = 'U'; 23 | break; 24 | default: 25 | free(rna); 26 | return NULL; 27 | } 28 | } 29 | 30 | return rna; 31 | } 32 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef RNA_TRANSCRIPTION_H 2 | #define RNA_TRANSCRIPTION_H 3 | 4 | char *to_rna(const char *dna); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/rna_transcription.c: -------------------------------------------------------------------------------- 1 | #include "rna_transcription.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/rna_transcription.h: -------------------------------------------------------------------------------- 1 | #ifndef RNA_TRANSCRIPTION_H 2 | #define RNA_TRANSCRIPTION_H 3 | 4 | char *to_rna(const char *dna); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "StevenRoot" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "elyashiv", 8 | "Gamecock", 9 | "h-3-0", 10 | "patricksjackson", 11 | "QLaille", 12 | "ryanplusplus", 13 | "wolf99" 14 | ], 15 | "files": { 16 | "solution": [ 17 | "robot_simulator.c", 18 | "robot_simulator.h" 19 | ], 20 | "test": [ 21 | "test_robot_simulator.c" 22 | ], 23 | "example": [ 24 | ".meta/example.c" 25 | ] 26 | }, 27 | "blurb": "Write a robot simulator.", 28 | "source": "Inspired by an interview question at a famous company." 29 | } 30 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/robot_simulator.c: -------------------------------------------------------------------------------- 1 | #include "robot_simulator.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/robot_simulator.h: -------------------------------------------------------------------------------- 1 | #ifndef ROBOT_SIMULATOR_H 2 | #define ROBOT_SIMULATOR_H 3 | 4 | typedef enum { 5 | DIRECTION_NORTH = 0, 6 | DIRECTION_DEFAULT = DIRECTION_NORTH, 7 | DIRECTION_EAST, 8 | DIRECTION_SOUTH, 9 | DIRECTION_WEST, 10 | DIRECTION_MAX 11 | } robot_direction_t; 12 | 13 | typedef struct { 14 | int x; 15 | int y; 16 | } robot_position_t; 17 | 18 | typedef struct { 19 | robot_direction_t direction; 20 | robot_position_t position; 21 | } robot_status_t; 22 | 23 | robot_status_t robot_create(robot_direction_t direction, int x, int y); 24 | void robot_move(robot_status_t *robot, const char *commands); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your task is to convert a number from Arabic numerals to Roman numerals. 4 | 5 | For this exercise, we are only concerned about traditional Roman numerals, in which the largest number is MMMCMXCIX (or 3,999). 6 | 7 | ~~~~exercism/note 8 | There are lots of different ways to convert between Arabic and Roman numerals. 9 | We recommend taking a naive approach first to familiarise yourself with the concept of Roman numerals and then search for more efficient methods. 10 | 11 | Make sure to check out our Deep Dive video at the end to explore the different approaches you can take! 12 | ~~~~ 13 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef ROMAN_NUMERALS_H 2 | #define ROMAN_NUMERALS_H 3 | 4 | char *to_roman_numeral(unsigned int number); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/roman_numerals.c: -------------------------------------------------------------------------------- 1 | #include "roman_numerals.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/roman_numerals.h: -------------------------------------------------------------------------------- 1 | #ifndef ROMAN_NUMERALS_H 2 | #define ROMAN_NUMERALS_H 3 | 4 | char *to_roman_numeral(unsigned int number); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ahans" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "rotational_cipher.c", 8 | "rotational_cipher.h" 9 | ], 10 | "test": [ 11 | "test_rotational_cipher.c" 12 | ], 13 | "example": [ 14 | ".meta/example.c", 15 | ".meta/example.h" 16 | ] 17 | }, 18 | "blurb": "Create an implementation of the rotational cipher, also sometimes called the Caesar cipher.", 19 | "source": "Wikipedia", 20 | "source_url": "https://en.wikipedia.org/wiki/Caesar_cipher" 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "rotational_cipher.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | char *rotate(const char *text, int shift_key) 8 | { 9 | char *rotated = malloc(strlen(text) + 1); 10 | char *out = rotated; 11 | for (const char *in = text; *in != '\0'; ++in, ++out) { 12 | if (isalpha(*in)) { 13 | const char base = isupper(*in) ? 'A' : 'a'; 14 | *out = base + ((*in - base + shift_key) % 26); 15 | } else { 16 | *out = *in; 17 | } 18 | } 19 | *out = '\0'; 20 | return rotated; 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef ROTATIONAL_CIPHER_H 2 | #define ROTATIONAL_CIPHER_H 3 | 4 | char *rotate(const char *text, int shift_key); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/rotational_cipher.c: -------------------------------------------------------------------------------- 1 | #include "rotational_cipher.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/rotational_cipher.h: -------------------------------------------------------------------------------- 1 | #ifndef ROTATIONAL_CIPHER_H 2 | #define ROTATIONAL_CIPHER_H 3 | 4 | char *rotate(const char *text, int shift_key); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "wolf99" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "run_length_encoding.c", 15 | "run_length_encoding.h" 16 | ], 17 | "test": [ 18 | "test_run_length_encoding.c" 19 | ], 20 | "example": [ 21 | ".meta/example.c", 22 | ".meta/example.h" 23 | ] 24 | }, 25 | "blurb": "Implement run-length encoding and decoding.", 26 | "source": "Wikipedia", 27 | "source_url": "https://en.wikipedia.org/wiki/Run-length_encoding" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef RUN_LENGTH_ENCODING_H 2 | #define RUN_LENGTH_ENCODING_H 3 | 4 | char *encode(const char *text); 5 | char *decode(const char *data); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/run_length_encoding.c: -------------------------------------------------------------------------------- 1 | #include "run_length_encoding.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/run_length_encoding.h: -------------------------------------------------------------------------------- 1 | #ifndef RUN_LENGTH_ENCODING_H 2 | #define RUN_LENGTH_ENCODING_H 3 | 4 | char *encode(const char *text); 5 | char *decode(const char *data); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You plan to build a tree house in the woods near your house so that you can watch the sun rise and set. 4 | 5 | You've obtained data from a local survey company that show the height of every tree in each rectangular section of the map. 6 | You need to analyze each grid on the map to find good trees for your tree house. 7 | 8 | A good tree is both: 9 | 10 | - taller than every tree to the east and west, so that you have the best possible view of the sunrises and sunsets. 11 | - shorter than every tree to the north and south, to minimize the amount of tree climbing. 12 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "gabriel376", 7 | "ryanplusplus" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "saddle_points.c", 12 | "saddle_points.h" 13 | ], 14 | "test": [ 15 | "test_saddle_points.c" 16 | ], 17 | "example": [ 18 | ".meta/example.c", 19 | ".meta/example.h" 20 | ] 21 | }, 22 | "blurb": "Detect saddle points in a matrix.", 23 | "source": "J Dalbey's Programming Practice problems", 24 | "source_url": "https://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef SADDLE_POINTS_H 2 | #define SADDLE_POINTS_H 3 | 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | size_t row, column; 9 | } saddle_point_t; 10 | 11 | typedef struct { 12 | size_t count; 13 | saddle_point_t points[]; 14 | } saddle_points_t; 15 | 16 | saddle_points_t *saddle_points(size_t rows, size_t columns, 17 | uint8_t matrix[][columns]); 18 | 19 | void free_saddle_points(saddle_points_t *saddle_points); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/saddle_points.c: -------------------------------------------------------------------------------- 1 | #include "saddle_points.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/saddle_points.h: -------------------------------------------------------------------------------- 1 | #ifndef SADDLE_POINTS_H 2 | #define SADDLE_POINTS_H 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /exercises/practice/say/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "sjwarner", 11 | "wolf99" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "say.c", 16 | "say.h" 17 | ], 18 | "test": [ 19 | "test_say.c" 20 | ], 21 | "example": [ 22 | ".meta/example.c", 23 | ".meta/example.h" 24 | ] 25 | }, 26 | "blurb": "Given a number from 0 to 999,999,999,999, spell out that number in English.", 27 | "source": "A variation on the JavaRanch CattleDrive, Assignment 4", 28 | "source_url": "https://web.archive.org/web/20240907035912/https://coderanch.com/wiki/718804" 29 | } 30 | -------------------------------------------------------------------------------- /exercises/practice/say/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef SAY_H 2 | #define SAY_H 3 | #include 4 | 5 | int say(int64_t input, char **ans); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/say/say.c: -------------------------------------------------------------------------------- 1 | #include "say.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/say/say.h: -------------------------------------------------------------------------------- 1 | #ifndef SAY_H 2 | #define SAY_H 3 | 4 | #include 5 | 6 | int say(int64_t input, char **ans); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.approaches/array-lookup/snippet.txt: -------------------------------------------------------------------------------- 1 | if (word == NULL) 2 | return 0; 3 | initialize_scores(); 4 | unsigned int total_score = 0; 5 | for (; *word; word++) 6 | total_score += scores[tolower(*word) - 'a']; 7 | return total_score; 8 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "9ad3c6de-2a1c-497d-b8d4-f81b149883b2", 9 | "slug": "switch-statement", 10 | "title": "switch statement", 11 | "blurb": "Look up scores in a switch to return the answer.", 12 | "authors": ["bobahop"] 13 | }, 14 | { 15 | "uuid": "4a3004d1-8cf1-4ff8-97e4-541724993e54", 16 | "slug": "array-lookup", 17 | "title": "Array lookup", 18 | "blurb": "Look up scores in an array to return the answer.", 19 | "authors": ["bobahop"] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.approaches/switch-statement/snippet.txt: -------------------------------------------------------------------------------- 1 | case 'd': 2 | case 'g': 3 | return 2; 4 | case 'b': 5 | case 'c': 6 | case 'm': 7 | case 'p': 8 | return 3; 9 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | [Scrabble][wikipedia] is a word game where players place letter tiles on a board to form words. 4 | Each letter has a value. 5 | A word's score is the sum of its letters' values. 6 | 7 | [wikipedia]: https://en.wikipedia.org/wiki/Scrabble 8 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "subpop" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "h-3-0", 9 | "patricksjackson", 10 | "QLaille", 11 | "ryanplusplus", 12 | "wolf99" 13 | ], 14 | "files": { 15 | "solution": [ 16 | "scrabble_score.c", 17 | "scrabble_score.h" 18 | ], 19 | "test": [ 20 | "test_scrabble_score.c" 21 | ], 22 | "example": [ 23 | ".meta/example.c", 24 | ".meta/example.h" 25 | ] 26 | }, 27 | "blurb": "Given a word, compute the Scrabble score for that word.", 28 | "source": "Inspired by the Extreme Startup game", 29 | "source_url": "https://github.com/rchatley/extreme_startup" 30 | } 31 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "scrabble_score.h" 2 | #include 3 | 4 | static unsigned int score_book[] = { 1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 5 | 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10 }; 6 | 7 | unsigned int score(const char *word) 8 | { 9 | char c; 10 | unsigned int word_score = 0; 11 | 12 | while ((c = tolower(*word++)) != '\0') { 13 | word_score += score_book[c - 'a']; 14 | } 15 | 16 | return word_score; 17 | } 18 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef SCRABBLE_SCORE_H 2 | #define SCRABBLE_SCORE_H 3 | 4 | unsigned int score(const char *word); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/scrabble_score.c: -------------------------------------------------------------------------------- 1 | #include "scrabble_score.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/scrabble_score.h: -------------------------------------------------------------------------------- 1 | #ifndef SCRABBLE_SCORE_H 2 | #define SCRABBLE_SCORE_H 3 | 4 | unsigned int score(const char *word); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "38d1b318-7c0f-496f-9b62-9fd0c0ef8002", 9 | "slug": "iterate-once", 10 | "title": "Iterate once", 11 | "blurb": "Iterate once even if reverse is needed.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.approaches/iterate-once/snippet.txt: -------------------------------------------------------------------------------- 1 | const char **output = calloc(4, sizeof(char *)); 2 | int signal = 0, signal_incr = 1, output_idx = 0, end = 4; 3 | if (n & 16) {signal = 3; signal_incr = -1; end = -1;} 4 | 5 | for (; signal != end; signal+=signal_incr) 6 | if (n & 1 << signal) 7 | output[output_idx++] = signals[signal]; 8 | return output; 9 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You are starting a secret coding club with some friends and friends-of-friends. 4 | Not everyone knows each other, so you and your friends have decided to create a secret handshake that you can use to recognize that someone is a member. 5 | You don't want anyone who isn't in the know to be able to crack the code. 6 | 7 | You've designed the code so that one person says a number between 1 and 31, and the other person turns it into a series of actions. 8 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "wolf99" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "secret_handshake.c", 15 | "secret_handshake.h" 16 | ], 17 | "test": [ 18 | "test_secret_handshake.c" 19 | ], 20 | "example": [ 21 | ".meta/example.c", 22 | ".meta/example.h" 23 | ] 24 | }, 25 | "blurb": "Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.", 26 | "source": "Bert, in Mary Poppins", 27 | "source_url": "https://www.imdb.com/title/tt0058331/quotes/?item=qt0437047" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef SECRET_HANDSHAKE_H 2 | #define SECRET_HANDSHAKE_H 3 | #include 4 | 5 | const char **commands(size_t number); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/secret_handshake.c: -------------------------------------------------------------------------------- 1 | #include "secret_handshake.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/secret_handshake.h: -------------------------------------------------------------------------------- 1 | #ifndef SECRET_HANDSHAKE_H 2 | #define SECRET_HANDSHAKE_H 3 | 4 | #include 5 | 6 | const char **commands(size_t number); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/series/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a string of digits, output all the contiguous substrings of length `n` in that string in the order that they appear. 4 | 5 | For example, the string "49142" has the following 3-digit series: 6 | 7 | - "491" 8 | - "914" 9 | - "142" 10 | 11 | And the following 4-digit series: 12 | 13 | - "4914" 14 | - "9142" 15 | 16 | And if you ask for a 6-digit series from a 5-digit string, you deserve whatever you get. 17 | 18 | Note that these series are only required to occupy _adjacent positions_ in the input; 19 | the digits need not be _numerically consecutive_. 20 | -------------------------------------------------------------------------------- /exercises/practice/series/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "StevenRoot" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "chriscool", 8 | "Gamecock", 9 | "h-3-0", 10 | "patricksjackson", 11 | "QLaille", 12 | "ryanplusplus", 13 | "sjwarner", 14 | "wolf99" 15 | ], 16 | "files": { 17 | "solution": [ 18 | "series.c", 19 | "series.h" 20 | ], 21 | "test": [ 22 | "test_series.c" 23 | ], 24 | "example": [ 25 | ".meta/example.c" 26 | ] 27 | }, 28 | "blurb": "Given a string of digits, output all the contiguous substrings of length `n` in that string.", 29 | "source": "A subset of the Problem 8 at Project Euler", 30 | "source_url": "https://projecteuler.net/problem=8" 31 | } 32 | -------------------------------------------------------------------------------- /exercises/practice/series/series.c: -------------------------------------------------------------------------------- 1 | #include "series.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.approaches/array-of-ones-and-zeros/snippet.txt: -------------------------------------------------------------------------------- 1 | for (uint32_t number = 2; number <= limit; number++) { 2 | if (!composite[number]) { 3 | primes[output_pos++] = number; 4 | if (output_pos == max_primes) 5 | break; 6 | for (uint32_t idx = number * number; idx <= limit; idx += number) 7 | composite[idx] = 1; 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "49609966-f2d7-42e6-89f5-3e567cc20713", 9 | "slug": "array-of-ones-and-zeros", 10 | "title": "Array of ones and zeros", 11 | "blurb": "Use an array of ones and zeros to keep track of composite numbers.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You bought a big box of random computer parts at a garage sale. 4 | You've started putting the parts together to build custom computers. 5 | 6 | You want to test the performance of different combinations of parts, and decide to create your own benchmarking program to see how your computers compare. 7 | You choose the famous "Sieve of Eratosthenes" algorithm, an ancient algorithm, but one that should push your computers to the limits. 8 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "StevenRoot" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "bgraf", 8 | "Gamecock", 9 | "h-3-0", 10 | "mikewalker", 11 | "patricksjackson", 12 | "QLaille", 13 | "ryanplusplus", 14 | "sjwarner", 15 | "wolf99" 16 | ], 17 | "files": { 18 | "solution": [ 19 | "sieve.c", 20 | "sieve.h" 21 | ], 22 | "test": [ 23 | "test_sieve.c" 24 | ], 25 | "example": [ 26 | ".meta/example.c" 27 | ] 28 | }, 29 | "blurb": "Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.", 30 | "source": "Sieve of Eratosthenes at Wikipedia", 31 | "source_url": "https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" 32 | } 33 | -------------------------------------------------------------------------------- /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 | [88529125-c4ce-43cc-bb36-1eb4ddd7b44f] 6 | description = "no primes under two" 7 | 8 | [4afe9474-c705-4477-9923-840e1024cc2b] 9 | description = "find first prime" 10 | 11 | [974945d8-8cd9-4f00-9463-7d813c7f17b7] 12 | description = "find primes up to 10" 13 | 14 | [2e2417b7-3f3a-452a-8594-b9af08af6d82] 15 | description = "limit is prime" 16 | 17 | [92102a05-4c7c-47de-9ed0-b7d5fcd00f21] 18 | description = "find primes up to 1000" 19 | -------------------------------------------------------------------------------- /exercises/practice/sieve/sieve.c: -------------------------------------------------------------------------------- 1 | #include "sieve.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/sieve/sieve.h: -------------------------------------------------------------------------------- 1 | #ifndef SIEVE_H 2 | #define SIEVE_H 3 | 4 | #include 5 | #include 6 | 7 | /// Calculate at most `max_primes` prime numbers in the interval [2,limit] 8 | /// using the Sieve of Eratosthenes and store the prime numbers in `primes` 9 | /// in increasing order. 10 | /// The function returns the number of calculated primes. 11 | uint32_t sieve(uint32_t limit, uint32_t *primes, size_t max_primes); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.approaches/array-index/snippet.txt: -------------------------------------------------------------------------------- 1 | static const int EARTH_YEAR_SECONDS = 31557600; 2 | static const double RATIOS [] = { 3 | 0.2408467, 0.61519726, 1.0, 1.8808158, // inner planets 4 | 11.862615, 29.447498, 84.016846, 164.79132 // outer planets 5 | }; 6 | float age(planet_t planet, int64_t seconds) { 7 | return planet >= 0 && planet <= 7 ? seconds / EARTH_YEAR_SECONDS / RATIOS[planet] : -1; 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "aaa252c2-8e3f-44e6-9269-87c687145d94", 9 | "slug": "array-index", 10 | "title": "Array index", 11 | "blurb": "Index into an array to return the answer.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/space-age/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef SPACE_AGE_H 2 | #define SPACE_AGE_H 3 | 4 | #include 5 | 6 | typedef enum planet { 7 | MERCURY, 8 | VENUS, 9 | EARTH, 10 | MARS, 11 | JUPITER, 12 | SATURN, 13 | URANUS, 14 | NEPTUNE, 15 | } planet_t; 16 | 17 | float age(planet_t planet, int64_t seconds); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /exercises/practice/space-age/space_age.c: -------------------------------------------------------------------------------- 1 | #include "space_age.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/space-age/space_age.h: -------------------------------------------------------------------------------- 1 | #ifndef SPACE_AGE_H 2 | #define SPACE_AGE_H 3 | 4 | #include 5 | 6 | typedef enum planet { 7 | MERCURY, 8 | VENUS, 9 | EARTH, 10 | MARS, 11 | JUPITER, 12 | SATURN, 13 | URANUS, 14 | NEPTUNE, 15 | } planet_t; 16 | 17 | float age(planet_t planet, int64_t seconds); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to return a square matrix of a given size. 4 | 5 | The matrix should be filled with natural numbers, starting from 1 in the top-left corner, increasing in an inward, clockwise spiral order, like these examples: 6 | 7 | ## Examples 8 | 9 | ### Spiral matrix of size 3 10 | 11 | ```text 12 | 1 2 3 13 | 8 9 4 14 | 7 6 5 15 | ``` 16 | 17 | ### Spiral matrix of size 4 18 | 19 | ```text 20 | 1 2 3 4 21 | 12 13 14 5 22 | 11 16 15 6 23 | 10 9 8 7 24 | ``` 25 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | In a small village near an ancient forest, there was a legend of a hidden treasure buried deep within the woods. 4 | Despite numerous attempts, no one had ever succeeded in finding it. 5 | This was about to change, however, thanks to a young explorer named Elara. 6 | She had discovered an old document containing instructions on how to locate the treasure. 7 | Using these instructions, Elara was able to draw a map that revealed the path to the treasure. 8 | 9 | To her surprise, the path followed a peculiar clockwise spiral. 10 | It was no wonder no one had been able to find the treasure before! 11 | With the map in hand, Elara embarks on her journey to uncover the hidden treasure. 12 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": ["ryanplusplus"], 3 | "contributors": ["wolf99"], 4 | "files": { 5 | "solution": [ 6 | "spiral_matrix.c", 7 | "spiral_matrix.h" 8 | ], 9 | "test": [ 10 | "test_spiral_matrix.c" 11 | ], 12 | "example": [ 13 | ".meta/example.c", 14 | ".meta/example.h" 15 | ] 16 | }, 17 | "blurb": "Given the size, return a square matrix of numbers in spiral order.", 18 | "source": "Reddit r/dailyprogrammer challenge #320 [Easy] Spiral Ascension.", 19 | "source_url": "https://web.archive.org/web/20230607064729/https://old.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/" 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef SPIRAL_MATRIX_H 2 | #define SPIRAL_MATRIX_H 3 | 4 | typedef struct { 5 | int size; 6 | int **matrix; 7 | } spiral_matrix_t; 8 | 9 | spiral_matrix_t *spiral_matrix_create(int size); 10 | void spiral_matrix_destroy(spiral_matrix_t *spiral_matrix); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/spiral_matrix.c: -------------------------------------------------------------------------------- 1 | #include "spiral_matrix.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/spiral_matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef SPIRAL_MATRIX_H 2 | #define SPIRAL_MATRIX_H 3 | 4 | typedef struct { 5 | int size; 6 | int **matrix; 7 | } spiral_matrix_t; 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | We are launching a deep space exploration rocket and we need a way to make sure the navigation system stays on target. 4 | 5 | As the first step in our calculation, we take a target number and find its square root (that is, the number that when multiplied by itself equals the target number). 6 | 7 | The journey will be very long. 8 | To make the batteries last as long as possible, we had to make our rocket's onboard computer very power efficient. 9 | Unfortunately that means that we can't rely on fancy math libraries and functions, as they use more power. 10 | Instead we want to implement our own square root calculation. 11 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "wolf99" 4 | ], 5 | "contributors": [ 6 | "ryanplusplus" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "square_root.c", 11 | "square_root.h" 12 | ], 13 | "test": [ 14 | "test_square_root.c" 15 | ], 16 | "example": [ 17 | ".meta/example.c", 18 | ".meta/example.h" 19 | ] 20 | }, 21 | "blurb": "Given a natural radicand, return its square root.", 22 | "source": "wolf99", 23 | "source_url": "https://github.com/exercism/problem-specifications/pull/1582" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/description.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Given a natural radicand, return its square root. 4 | 5 | Check out the Wikipedia pages on [square root](https://en.wikipedia.org/wiki/Square_root) and [methods of computing square roots](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots). 6 | 7 | Note that the term "radicand" refers to the number for which the root is to be determined. That is, it is the number under the root symbol. 8 | 9 | Recall also that natural numbers are positive real whole numbers (i.e. 1, 2, 3 and up). 10 | 11 | When implementing this in a language with a built-in square root function, implement your own function. 12 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "square_root.h" 2 | 3 | uint16_t square_root(uint16_t radicand) 4 | { 5 | uint16_t result = 0; 6 | uint16_t bit = 1 << 14; 7 | 8 | while (bit > radicand) 9 | bit >>= 2; 10 | 11 | while (bit != 0) { 12 | if (radicand >= result + bit) { 13 | radicand -= result + bit; 14 | result = (result >> 1) + bit; 15 | } else { 16 | result >>= 1; 17 | } 18 | bit >>= 2; 19 | } 20 | return result; 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef SQUARE_ROOT_H 2 | #define SQUARE_ROOT_H 3 | 4 | #include 5 | 6 | uint16_t square_root(uint16_t radicand); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/square-root/.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 | [9b748478-7b0a-490c-b87a-609dacf631fd] 6 | description = "root of 1" 7 | 8 | [7d3aa9ba-9ac6-4e93-a18b-2e8b477139bb] 9 | description = "root of 4" 10 | 11 | [6624aabf-3659-4ae0-a1c8-25ae7f33c6ef] 12 | description = "root of 25" 13 | 14 | [93beac69-265e-4429-abb1-94506b431f81] 15 | description = "root of 81" 16 | 17 | [fbddfeda-8c4f-4bc4-87ca-6991af35360e] 18 | description = "root of 196" 19 | 20 | [c03d0532-8368-4734-a8e0-f96a9eb7fc1d] 21 | description = "root of 62025" 22 | -------------------------------------------------------------------------------- /exercises/practice/square-root/square_root.c: -------------------------------------------------------------------------------- 1 | #include "square_root.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/square-root/square_root.h: -------------------------------------------------------------------------------- 1 | #ifndef SQUARE_ROOT_H 2 | #define SQUARE_ROOT_H 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /exercises/practice/sublist/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "RealBarrettBrown" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "h-3-0", 8 | "patricksjackson", 9 | "QLaille", 10 | "ryanplusplus", 11 | "wolf99" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "sublist.c", 16 | "sublist.h" 17 | ], 18 | "test": [ 19 | "test_sublist.c" 20 | ], 21 | "example": [ 22 | ".meta/example.c" 23 | ] 24 | }, 25 | "blurb": "Write a function to determine if a list is a sublist of another list." 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/sublist/sublist.c: -------------------------------------------------------------------------------- 1 | #include "sublist.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/sublist/sublist.h: -------------------------------------------------------------------------------- 1 | #ifndef SUBLIST_H 2 | #define SUBLIST_H 3 | 4 | #include 5 | 6 | typedef enum { EQUAL, UNEQUAL, SUBLIST, SUPERLIST } comparison_result_t; 7 | 8 | comparison_result_t check_lists(int *list_to_compare, int *base_list, 9 | size_t list_to_compare_element_count, 10 | size_t base_list_element_count); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a company that makes an online, fantasy-survival game. 4 | 5 | When a player finishes a level, they are awarded energy points. 6 | The amount of energy awarded depends on which magical items the player found while exploring that level. 7 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "sum_of_multiples.h" 2 | #include 3 | 4 | unsigned int sum(const unsigned int *factors, const size_t number_of_factors, 5 | const unsigned int limit) 6 | { 7 | unsigned int sum = 0; 8 | if (NULL == factors) 9 | return sum; 10 | 11 | for (unsigned int current = 1; current < limit; current++) { 12 | for (size_t i = 0; i < number_of_factors; i++) { 13 | if (0 != factors[i] && (current % factors[i]) == 0) { 14 | sum += current; 15 | break; 16 | } 17 | } 18 | } 19 | 20 | return sum; 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef SUM_OF_MULTIPLES_H 2 | #define SUM_OF_MULTIPLES_H 3 | 4 | #include 5 | 6 | unsigned int sum(const unsigned int *factors, const size_t number_of_factors, 7 | const unsigned int limit); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/sum_of_multiples.c: -------------------------------------------------------------------------------- 1 | #include "sum_of_multiples.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/sum_of_multiples.h: -------------------------------------------------------------------------------- 1 | #ifndef SUM_OF_MULTIPLES_H 2 | #define SUM_OF_MULTIPLES_H 3 | 4 | #include 5 | 6 | unsigned int sum(const unsigned int *factors, const size_t number_of_factors, 7 | const unsigned int limit); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "deathsec" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Gamecock", 8 | "h-3-0", 9 | "patricksjackson", 10 | "QLaille", 11 | "ryanplusplus", 12 | "wolf99" 13 | ], 14 | "files": { 15 | "solution": [ 16 | "triangle.c", 17 | "triangle.h" 18 | ], 19 | "test": [ 20 | "test_triangle.c" 21 | ], 22 | "example": [ 23 | ".meta/example.c", 24 | ".meta/example.h" 25 | ] 26 | }, 27 | "blurb": "Determine if a triangle is equilateral, isosceles, or scalene.", 28 | "source": "The Ruby Koans triangle project, parts 1 & 2", 29 | "source_url": "https://web.archive.org/web/20220831105330/http://rubykoans.com" 30 | } 31 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef TRIANGLE_H 2 | #define TRIANGLE_H 3 | 4 | #include 5 | 6 | typedef struct { 7 | double a; 8 | double b; 9 | double c; 10 | } triangle_t; 11 | 12 | bool is_equilateral(triangle_t sides); 13 | bool is_isosceles(triangle_t sides); 14 | bool is_scalene(triangle_t sides); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /exercises/practice/triangle/triangle.c: -------------------------------------------------------------------------------- 1 | #include "triangle.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/triangle/triangle.h: -------------------------------------------------------------------------------- 1 | #ifndef TRIANGLE_H 2 | #define TRIANGLE_H 3 | 4 | typedef struct { 5 | double a; 6 | double b; 7 | double c; 8 | } triangle_t; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ryanplusplus" 4 | ], 5 | "contributors": [ 6 | "wolf99" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "two_bucket.c", 11 | "two_bucket.h" 12 | ], 13 | "test": [ 14 | "test_two_bucket.c" 15 | ], 16 | "example": [ 17 | ".meta/example.c", 18 | ".meta/example.h" 19 | ] 20 | }, 21 | "blurb": "Given two buckets of different size, demonstrate how to measure an exact number of liters.", 22 | "source": "Water Pouring Problem", 23 | "source_url": "https://demonstrations.wolfram.com/WaterPouringProblem/" 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef TWO_BUCKET_H 2 | #define TWO_BUCKET_H 3 | 4 | #include 5 | 6 | typedef enum { BUCKET_ID_1, BUCKET_ID_2 } bucket_id_t; 7 | 8 | typedef unsigned int bucket_liters_t; 9 | 10 | typedef struct { 11 | bool possible; 12 | int move_count; 13 | bucket_id_t goal_bucket; 14 | bucket_liters_t other_bucket_liters; 15 | } bucket_result_t; 16 | 17 | bucket_result_t measure(bucket_liters_t bucket_1_size, 18 | bucket_liters_t bucket_2_size, 19 | bucket_liters_t goal_volume, bucket_id_t start_bucket); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/two_bucket.c: -------------------------------------------------------------------------------- 1 | #include "two_bucket.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/two_bucket.h: -------------------------------------------------------------------------------- 1 | #ifndef TWO_BUCKET_H 2 | #define TWO_BUCKET_H 3 | 4 | #include 5 | 6 | typedef enum { BUCKET_ID_1, BUCKET_ID_2 } bucket_id_t; 7 | 8 | typedef unsigned int bucket_liters_t; 9 | 10 | typedef struct { 11 | bool possible; 12 | int move_count; 13 | bucket_id_t goal_bucket; 14 | bucket_liters_t other_bucket_liters; 15 | } bucket_result_t; 16 | 17 | bucket_result_t measure(bucket_liters_t bucket_1_size, 18 | bucket_liters_t bucket_2_size, 19 | bucket_liters_t goal_volume, bucket_id_t start_bucket); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine what you will say as you give away the extra cookie. 4 | 5 | If you know the person's name (e.g. if they're named Do-yun), then you will say: 6 | 7 | ```text 8 | One for Do-yun, one for me. 9 | ``` 10 | 11 | If you don't know the person's name, you will say _you_ instead. 12 | 13 | ```text 14 | One for you, one for me. 15 | ``` 16 | 17 | Here are some examples: 18 | 19 | | Name | Dialogue | 20 | | :----- | :-------------------------- | 21 | | Alice | One for Alice, one for me. | 22 | | Bohdan | One for Bohdan, one for me. | 23 | | | One for you, one for me. | 24 | | Zaphod | One for Zaphod, one for me. | 25 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | In some English accents, when you say "two for" quickly, it sounds like "two fer". 4 | Two-for-one is a way of saying that if you buy one, you also get one for free. 5 | So the phrase "two-fer" often implies a two-for-one offer. 6 | 7 | Imagine a bakery that has a holiday offer where you can buy two cookies for the price of one ("two-fer one!"). 8 | You take the offer and (very generously) decide to give the extra cookie to someone else in the queue. 9 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "sjwarner", 11 | "wolf99" 12 | ], 13 | "files": { 14 | "solution": [ 15 | "two_fer.c", 16 | "two_fer.h" 17 | ], 18 | "test": [ 19 | "test_two_fer.c" 20 | ], 21 | "example": [ 22 | ".meta/example.c", 23 | ".meta/example.h" 24 | ] 25 | }, 26 | "blurb": "Create a sentence of the form \"One for X, one for me.\".", 27 | "source_url": "https://github.com/exercism/problem-specifications/issues/757" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/example.c: -------------------------------------------------------------------------------- 1 | #include "two_fer.h" 2 | #include 3 | 4 | #define BUFFER_SIZE (100) 5 | #define SEQUENCE "One for %s, one for me." 6 | 7 | void two_fer(char *buffer, const char *name) 8 | { 9 | snprintf(buffer, BUFFER_SIZE, SEQUENCE, 10 | (buffer == NULL || name == NULL) ? "you" : name); 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef TWO_FER_H 2 | #define TWO_FER_H 3 | 4 | void two_fer(char *buffer, const char *name); 5 | 6 | #endif 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 | 5 | [1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce] 6 | description = "no name given" 7 | 8 | [b4c6dbb8-b4fb-42c2-bafd-10785abe7709] 9 | description = "a name given" 10 | 11 | [3549048d-1a6e-4653-9a79-b0bda163e8d5] 12 | description = "another name given" 13 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/two_fer.c: -------------------------------------------------------------------------------- 1 | #include "two_fer.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/two_fer.h: -------------------------------------------------------------------------------- 1 | #ifndef TWO_FER_H 2 | #define TWO_FER_H 3 | 4 | void two_fer(char *buffer, const char *name); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "Wiguwbe" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "variable_length_quantity.c", 8 | "variable_length_quantity.h" 9 | ], 10 | "test": [ 11 | "test_variable_length_quantity.c" 12 | ], 13 | "example": [ 14 | ".meta/example.c", 15 | ".meta/example.h" 16 | ] 17 | }, 18 | "blurb": "Implement variable length quantity encoding and decoding.", 19 | "source": "A poor Splice developer having to implement MIDI encoding/decoding.", 20 | "source_url": "https://splice.com" 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef VARIABLE_LENGTH_QUANTITY_H 2 | #define VARIABLE_LENGTH_QUANTITY_H 3 | 4 | #include 5 | #include 6 | 7 | /// Encode an array of integers into Variable Length Quantity. 8 | /// 9 | /// The function returns the size of the output buffer used. 10 | int encode(const uint32_t *integers, size_t integers_len, uint8_t *output); 11 | 12 | /// Decode a Variable Length Quantity byte array into an array of integers. 13 | /// 14 | /// The function returns the size of the output buffer used or -1 if an error 15 | /// occurred. 16 | int decode(const uint8_t *bytes, size_t buffer_len, uint32_t *output); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/variable_length_quantity.c: -------------------------------------------------------------------------------- 1 | #include "variable_length_quantity.h" 2 | 3 | int encode(const uint32_t *integers, size_t integers_len, uint8_t *output) 4 | { 5 | // write to `output`, return final output's length 6 | // `output` buffer should be enough to hold the full result 7 | } 8 | 9 | int decode(const uint8_t *bytes, size_t buffer_len, uint32_t *output) 10 | { 11 | // write to `output`, return final output's length 12 | // return -1 if error 13 | // `output` buffer should be enough to hold the full result 14 | } 15 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/variable_length_quantity.h: -------------------------------------------------------------------------------- 1 | #ifndef VARIABLE_LENGTH_QUANTITY_H 2 | #define VARIABLE_LENGTH_QUANTITY_H 3 | 4 | #include 5 | #include 6 | 7 | /// Encode an array of integers into Variable Length Quantity. 8 | /// 9 | /// The function returns the size of the output buffer used. 10 | int encode(const uint32_t *integers, size_t integers_len, uint8_t *output); 11 | 12 | /// Decode a Variable Length Quantity byte array into an array of integers. 13 | /// 14 | /// The function returns the size of the output buffer used or -1 if an error 15 | /// occurred. 16 | int decode(const uint8_t *bytes, size_t buffer_len, uint32_t *output); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | - Note that the tests for this exercise expect the output words to be proper C strings. That is, they should be NUL terminated. See https://en.wikipedia.org/wiki/C_string_handling -------------------------------------------------------------------------------- /exercises/practice/word-count/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You teach English as a foreign language to high school students. 4 | 5 | You've decided to base your entire curriculum on TV shows. 6 | You need to analyze which words are used, and how often they're repeated. 7 | 8 | This will let you choose the simplest shows to start with, and to gradually increase the difficulty as time passes. 9 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "StevenRoot" 4 | ], 5 | "contributors": [ 6 | "bcc32", 7 | "Bulagro", 8 | "ethagnawl", 9 | "Gamecock", 10 | "h-3-0", 11 | "patricksjackson", 12 | "QLaille", 13 | "ryanplusplus", 14 | "sesamemucho", 15 | "ShadowWolf387", 16 | "wolf99" 17 | ], 18 | "files": { 19 | "solution": [ 20 | "word_count.c", 21 | "word_count.h" 22 | ], 23 | "test": [ 24 | "test_word_count.c" 25 | ], 26 | "example": [ 27 | ".meta/example.c" 28 | ] 29 | }, 30 | "blurb": "Given a phrase, count the occurrences of each word in that phrase.", 31 | "source": "This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour." 32 | } 33 | -------------------------------------------------------------------------------- /exercises/practice/word-count/word_count.c: -------------------------------------------------------------------------------- 1 | #include "word_count.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/wordy/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "vlzware" 4 | ], 5 | "contributors": [ 6 | "h-3-0", 7 | "patricksjackson", 8 | "QLaille", 9 | "ryanplusplus", 10 | "wolf99" 11 | ], 12 | "files": { 13 | "solution": [ 14 | "wordy.c", 15 | "wordy.h" 16 | ], 17 | "test": [ 18 | "test_wordy.c" 19 | ], 20 | "example": [ 21 | ".meta/example.c", 22 | ".meta/example.h" 23 | ] 24 | }, 25 | "blurb": "Parse and evaluate simple math word problems returning the answer as an integer.", 26 | "source": "Inspired by one of the generated questions in the Extreme Startup game.", 27 | "source_url": "https://github.com/rchatley/extreme_startup" 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/wordy/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef WORDY_H 2 | #define WORDY_H 3 | #include 4 | 5 | bool answer(const char *question, int *result); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /exercises/practice/wordy/wordy.c: -------------------------------------------------------------------------------- 1 | #include "wordy.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/wordy/wordy.h: -------------------------------------------------------------------------------- 1 | #ifndef WORDY_H 2 | #define WORDY_H 3 | 4 | #include 5 | 6 | bool answer(const char *question, int *result); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /exercises/practice/yacht/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Each year, something new is "all the rage" in your high school. 4 | This year it is a dice game: [Yacht][yacht]. 5 | 6 | The game of Yacht is from the same family as Poker Dice, Generala and particularly Yahtzee, of which it is a precursor. 7 | The game consists of twelve rounds. 8 | In each, five dice are rolled and the player chooses one of twelve categories. 9 | The chosen category is then used to score the throw of the dice. 10 | 11 | [yacht]: https://en.wikipedia.org/wiki/Yacht_(dice_game) 12 | -------------------------------------------------------------------------------- /exercises/practice/yacht/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ahans" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "yacht.c", 8 | "yacht.h" 9 | ], 10 | "test": [ 11 | "test_yacht.c" 12 | ], 13 | "example": [ 14 | ".meta/example.c", 15 | ".meta/example.h" 16 | ] 17 | }, 18 | "blurb": "Score a single throw of dice in the game Yacht.", 19 | "source": "James Kilfiger, using Wikipedia", 20 | "source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)" 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/yacht/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef YACHT_H 2 | #define YACHT_H 3 | 4 | typedef enum { 5 | ONES, 6 | TWOS, 7 | THREES, 8 | FOURS, 9 | FIVES, 10 | SIXES, 11 | FULL_HOUSE, 12 | FOUR_OF_A_KIND, 13 | LITTLE_STRAIGHT, 14 | BIG_STRAIGHT, 15 | CHOICE, 16 | YACHT 17 | } category_t; 18 | 19 | typedef struct { 20 | int faces[5]; 21 | } dice_t; 22 | 23 | int score(dice_t dice, category_t category); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /exercises/practice/yacht/yacht.c: -------------------------------------------------------------------------------- 1 | #include "yacht.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/yacht/yacht.h: -------------------------------------------------------------------------------- 1 | #ifndef YACHT_H 2 | #define YACHT_H 3 | 4 | typedef enum { 5 | ONES, 6 | TWOS, 7 | THREES, 8 | FOURS, 9 | FIVES, 10 | SIXES, 11 | FULL_HOUSE, 12 | FOUR_OF_A_KIND, 13 | LITTLE_STRAIGHT, 14 | BIG_STRAIGHT, 15 | CHOICE, 16 | YACHT 17 | } category_t; 18 | 19 | typedef struct { 20 | int faces[5]; 21 | } dice_t; 22 | 23 | int score(dice_t dice, category_t category); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "siebenschlaefer" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "zebra_puzzle.c", 8 | "zebra_puzzle.h" 9 | ], 10 | "test": [ 11 | "test_zebra_puzzle.c" 12 | ], 13 | "example": [ 14 | ".meta/example.c", 15 | ".meta/example.h" 16 | ] 17 | }, 18 | "blurb": "Solve the zebra puzzle.", 19 | "source": "Wikipedia", 20 | "source_url": "https://en.wikipedia.org/wiki/Zebra_Puzzle" 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/.meta/example.h: -------------------------------------------------------------------------------- 1 | #ifndef ZEBRA_PUZZLE_H 2 | #define ZEBRA_PUZZLE_H 3 | 4 | typedef struct { 5 | const char *drinks_water; 6 | const char *owns_zebra; 7 | } solution_t; 8 | 9 | solution_t solve_puzzle(void); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. 2 | # 3 | # Regenerating this file via `configlet sync` will: 4 | # - Recreate every `description` key/value pair 5 | # - Recreate every `reimplements` key/value pair, where they exist in problem-specifications 6 | # - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) 7 | # - Preserve any other key/value pair 8 | # 9 | # As user-added comments (using the # character) will be removed when this file 10 | # is regenerated, comments can be added via a `comment` key. 11 | 12 | [16efb4e4-8ad7-4d5e-ba96-e5537b66fd42] 13 | description = "resident who drinks water" 14 | 15 | [084d5b8b-24e2-40e6-b008-c800da8cd257] 16 | description = "resident who owns zebra" 17 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/test_zebra_puzzle.c: -------------------------------------------------------------------------------- 1 | #include "zebra_puzzle.h" 2 | #include "test-framework/unity.h" 3 | 4 | void setUp(void) 5 | { 6 | } 7 | 8 | void tearDown(void) 9 | { 10 | } 11 | 12 | static void test_who_drinks_water(void) 13 | { 14 | solution_t solution = solve_puzzle(); 15 | TEST_ASSERT_EQUAL_STRING("Norwegian", solution.drinks_water); 16 | } 17 | 18 | static void test_who_owns_the_zebra(void) 19 | { 20 | TEST_IGNORE(); // delete this line to run test 21 | solution_t solution = solve_puzzle(); 22 | TEST_ASSERT_EQUAL_STRING("Japanese", solution.owns_zebra); 23 | } 24 | 25 | int main(void) 26 | { 27 | UNITY_BEGIN(); 28 | 29 | RUN_TEST(test_who_drinks_water); 30 | RUN_TEST(test_who_owns_the_zebra); 31 | 32 | return UNITY_END(); 33 | } 34 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/zebra_puzzle.c: -------------------------------------------------------------------------------- 1 | #include "zebra_puzzle.h" 2 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/zebra_puzzle.h: -------------------------------------------------------------------------------- 1 | #ifndef ZEBRA_PUZZLE_H 2 | #define ZEBRA_PUZZLE_H 3 | 4 | typedef struct { 5 | const char *drinks_water; 6 | const char *owns_zebra; 7 | } solution_t; 8 | 9 | solution_t solve_puzzle(void); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /format.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Formats all .c and .h files in the project that are not vendor code (ie: Unity). 4 | # 5 | 6 | if ! [ -x "$(command -v clang-format)" ]; then 7 | echo "ERROR: Install clang-format version 10.0.0 or greater to run this script." 8 | exit 126 9 | fi 10 | 11 | echo "INFO: clang-format version 10.0.0 or greater is recommended to run this script" 12 | 13 | find exercises/practice/ -path 'exercises/practice/*/test-framework' -prune -o \ 14 | \( -iname '*.h' -o -iname '*.c' \) -print0 |\ 15 | xargs --null clang-format -i 16 | --------------------------------------------------------------------------------