From 0c1a9e13ab2a54505be2c01ec012d96ff8b7888a Mon Sep 17 00:00:00 2001 From: Alexander Hans Date: Fri, 30 May 2025 22:36:18 +0200 Subject: [PATCH] build: add standard white-space pre-commit hooks --- .clang-format | 2 +- .github/workflows/ci.yml | 1 - .github/workflows/hello-world.yml | 2 +- .pre-commit-config.yaml | 14 ++++++++++++-- .vscode/settings.json | 2 +- bin/check-hello-world.sh | 2 +- concepts/auto/links.json | 2 +- concepts/basics/about.md | 6 +++--- concepts/basics/introduction.md | 6 +++--- concepts/basics/links.json | 2 +- concepts/booleans/introduction.md | 2 +- concepts/booleans/links.json | 2 +- concepts/classes/about.md | 2 +- concepts/classes/introduction.md | 4 ++-- concepts/classes/links.json | 2 +- concepts/comparisons/about.md | 2 +- concepts/comparisons/introduction.md | 2 +- concepts/comparisons/links.json | 2 +- concepts/enums/about.md | 6 +++--- concepts/enums/introduction.md | 6 +++--- concepts/enums/links.json | 2 +- concepts/functions/links.json | 2 +- concepts/headers/about.md | 8 ++++---- concepts/headers/introduction.md | 4 ++-- concepts/headers/links.json | 2 +- concepts/if-statements/about.md | 2 +- concepts/if-statements/introduction.md | 2 +- concepts/if-statements/links.json | 2 +- concepts/includes/about.md | 2 +- concepts/includes/introduction.md | 2 +- concepts/includes/links.json | 2 +- concepts/literals/links.json | 2 +- concepts/loops/about.md | 2 +- concepts/loops/introduction.md | 2 +- concepts/loops/links.json | 2 +- concepts/namespaces/about.md | 2 +- concepts/namespaces/links.json | 2 +- concepts/numbers/.meta/config.json | 2 +- concepts/numbers/about.md | 8 ++++---- concepts/numbers/introduction.md | 8 ++++---- concepts/numbers/links.json | 2 +- concepts/pointers/about.md | 8 ++++---- concepts/pointers/introduction.md | 6 +++--- concepts/references/about.md | 6 +++--- concepts/references/introduction.md | 6 +++--- concepts/references/links.json | 2 +- concepts/smart-pointers/about.md | 4 ++-- concepts/smart-pointers/introduction.md | 4 ++-- concepts/smart-pointers/links.json | 2 +- concepts/strings/about.md | 4 ++-- concepts/strings/introduction.md | 4 ++-- concepts/strings/links.json | 2 +- concepts/switch/about.md | 2 +- concepts/switch/links.json | 4 ++-- concepts/vector-arrays/about.md | 6 +++--- concepts/vector-arrays/introduction.md | 6 +++--- concepts/vector-arrays/links.json | 2 +- docs/INSTALLATION.md | 2 +- docs/TESTS.md | 6 +++--- .../concept/doctor-data/.docs/instructions.md | 2 +- .../concept/doctor-data/.docs/introduction.md | 4 ++-- .../concept/doctor-data/.docs/introduction.md.tpl | 2 +- exercises/concept/doctor-data/doctor_data.cpp | 2 +- exercises/concept/election-day/.docs/hints.md | 4 ++-- .../concept/election-day/.docs/instructions.md | 8 ++++---- .../concept/election-day/.docs/introduction.md | 4 ++-- .../concept/election-day/.docs/introduction.md.tpl | 2 +- exercises/concept/election-day/.meta/design.md | 2 +- exercises/concept/election-day/election_day.cpp | 2 +- exercises/concept/ellens-alien-game/.docs/hints.md | 2 +- .../ellens-alien-game/.docs/instructions.md | 6 +++--- .../ellens-alien-game/.docs/introduction.md | 2 +- .../ellens-alien-game/.docs/introduction.md.tpl | 2 +- .../concept/ellens-alien-game/.meta/design.md | 2 +- .../concept/ellens-alien-game/.meta/exemplar.cpp | 2 +- .../ellens-alien-game/ellens_alien_game.cpp | 2 +- .../concept/freelancer-rates/.docs/introduction.md | 8 ++++---- .../freelancer-rates/.docs/introduction.md.tpl | 2 +- .../concept/freelancer-rates/.meta/exemplar.cpp | 2 +- .../concept/freelancer-rates/freelancer_rates.cpp | 2 +- .../interest-is-interesting/.meta/exemplar.cpp | 2 +- .../interest_is_interesting.cpp | 2 +- .../lasagna-master/.docs/introduction.md.tpl | 2 +- exercises/concept/lasagna-master/.meta/design.md | 2 +- .../concept/lasagna/.docs/introduction.md.tpl | 2 +- exercises/concept/lasagna/.meta/exemplar.cpp | 2 +- .../concept/last-will/.docs/introduction.md.tpl | 2 +- exercises/concept/last-will/.meta/exemplar.cpp | 2 +- exercises/concept/last-will/last_will.cpp | 2 +- .../concept/log-levels/.docs/introduction.md.tpl | 2 +- .../concept/making-the-grade/.meta/exemplar.cpp | 2 +- exercises/concept/pacman-rules/.meta/exemplar.cpp | 2 +- exercises/concept/pacman-rules/pacman_rules.cpp | 2 +- exercises/concept/power-of-troy/.docs/after.md | 4 ++-- .../concept/power-of-troy/.docs/introduction.md | 2 +- exercises/concept/power-of-troy/.meta/exemplar.cpp | 2 +- exercises/concept/power-of-troy/.meta/exemplar.h | 2 +- .../concept/speedywagon/.docs/introduction.md | 4 ++-- .../concept/speedywagon/.docs/introduction.md.tpl | 2 +- exercises/concept/troll-the-trolls/.docs/hints.md | 2 -- .../concept/troll-the-trolls/.docs/instructions.md | 2 +- .../concept/troll-the-trolls/.docs/introduction.md | 4 ++-- .../troll-the-trolls/.docs/introduction.md.tpl | 2 +- exercises/concept/troll-the-trolls/.meta/design.md | 2 +- .../concept/troll-the-trolls/.meta/exemplar.cpp | 2 +- .../concept/troll-the-trolls/troll_the_trolls.cpp | 2 +- .../concept/vehicle-purchase/.docs/introduction.md | 2 +- .../vehicle-purchase/.docs/introduction.md.tpl | 2 +- .../concept/vehicle-purchase/.meta/exemplar.cpp | 2 +- exercises/concept/vehicle-purchase/CMakeLists.txt | 1 - .../concept/vehicle-purchase/vehicle_purchase.cpp | 2 +- exercises/practice/affine-cipher/.meta/example.cpp | 2 +- exercises/practice/affine-cipher/.meta/example.h | 2 +- exercises/practice/affine-cipher/affine_cipher.cpp | 2 +- exercises/practice/affine-cipher/affine_cipher.h | 2 +- .../practice/affine-cipher/affine_cipher_test.cpp | 2 +- .../.approaches/in-parallel/content.md | 12 ++++++------ .../.approaches/in-parallel/snippet.txt | 2 +- .../.approaches/in-sequence/content.md | 14 +++++++------- .../.approaches/in-sequence/snippet.txt | 2 +- .../all-your-base/.approaches/introduction.md | 6 +++--- .../allergies/.docs/instructions.append.md | 2 +- exercises/practice/alphametics/.meta/example.h | 2 +- exercises/practice/alphametics/alphametics.h | 2 +- .../practice/alphametics/alphametics_test.cpp | 2 +- .../practice/armstrong-numbers/.meta/example.cpp | 2 +- .../armstrong-numbers/armstrong_numbers_test.cpp | 2 +- exercises/practice/bank-account/bank_account.cpp | 2 +- .../practice/bank-account/bank_account_test.cpp | 2 +- .../binary-search/.approaches/introduction.md | 4 ++-- .../while-with-if-statements/content.md | 7 +++---- .../while-with-if-statements/snippet.txt | 2 +- .../practice/collatz-conjecture/.meta/example.cpp | 2 +- .../complex-numbers/complex_numbers_test.cpp | 2 +- exercises/practice/darts/darts.cpp | 2 +- .../high-scores/.docs/instructions.append.md | 2 +- .../practice/high-scores/high_scores_test.cpp | 2 +- exercises/practice/isbn-verifier/isbn_verifier.cpp | 2 +- .../largest_series_product.cpp | 2 +- .../leap/.approaches/boolean-chain/snippet.txt | 2 +- .../practice/leap/.approaches/introduction.md | 2 +- .../leap/.approaches/ternary-operator/snippet.txt | 2 +- .../practice/leap/.articles/performance/.gitignore | 2 +- .../performance/benchmark/leap_benchmark.cpp | 2 +- .../practice/leap/.articles/performance/snippet.md | 2 +- exercises/practice/linked-list/linked_list.cpp | 2 +- .../pangram/.approaches/bitset-all/content.md | 2 +- .../.docs/instructions.append.md | 2 +- .../parallel-letter-frequency/.meta/config.json | 2 +- .../practice/perfect-numbers/.meta/example.cpp | 2 +- .../practice/phone-number/phone_number_test.cpp | 2 +- .../.approaches/direct-construction/content.md | 1 - .../.approaches/divide-and-conquer/content.md | 1 - .../reverse-string/.approaches/introduction.md | 3 +-- .../.approaches/iterative/content.md | 1 - .../.approaches/linear-recursion/content.md | 1 - .../.approaches/over-engineered/content.md | 3 +-- .../.approaches/stack-operations/content.md | 1 - .../.approaches/swapping-characters/content.md | 3 +-- .../.approaches/using-the-standard-lib/content.md | 3 +-- .../rotational-cipher/rotational_cipher_test.cpp | 2 +- .../secret-handshake/.approaches/introduction.md | 4 ++-- .../.approaches/iterate-once/content.md | 4 ++-- .../.approaches/iterate-once/snippet.txt | 2 +- .../practice/sieve/.approaches/introduction.md | 2 +- .../sieve/.approaches/vector-of-bools/content.md | 2 +- exercises/practice/zebra-puzzle/.meta/example.cpp | 2 +- exercises/practice/zebra-puzzle/.meta/tests.toml | 1 - exercises/practice/zebra-puzzle/zebra_puzzle.cpp | 2 +- 169 files changed, 242 insertions(+), 247 deletions(-) diff --git a/.clang-format b/.clang-format index 9a9cbf81..ed916525 100644 --- a/.clang-format +++ b/.clang-format @@ -3,4 +3,4 @@ BasedOnStyle: Google # Customize with larger indents IndentWidth: 4 -ObjCBlockIndentWidth: 4 \ No newline at end of file +ObjCBlockIndentWidth: 4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee4ddf8d..a6b7cfd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,4 +88,3 @@ jobs: cmake . cmake --build . -- test_hello-world cmake --build . - diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index e417c495..0f784cf7 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -25,4 +25,4 @@ jobs: - name: Check Hello World Fails run: bin/check-hello-world.sh env: - CXX: ${{ matrix.compiler }} \ No newline at end of file + CXX: ${{ matrix.compiler }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 25c272ef..074fbe54 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,19 @@ -exclude: 'test/(catch.hpp|tests-main.cpp)' +exclude: | + (?x)^( + (.*/)?test/(catch.hpp|tests-main.cpp)| + .github/CODEOWNERS + )$ repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files - repo: https://github.com/pre-commit/mirrors-clang-format rev: v18.1.2 hooks: - id: clang-format exclude_types: [json] - diff --git a/.vscode/settings.json b/.vscode/settings.json index 216f5a77..8b678e3f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -72,4 +72,4 @@ "cSpell.words": [ "stationprogress" ] -} \ No newline at end of file +} diff --git a/bin/check-hello-world.sh b/bin/check-hello-world.sh index a7e6f75c..ac5edf7e 100755 --- a/bin/check-hello-world.sh +++ b/bin/check-hello-world.sh @@ -25,4 +25,4 @@ if cmake --build .; then exit 1 fi -cd "$repo" \ No newline at end of file +cd "$repo" diff --git a/concepts/auto/links.json b/concepts/auto/links.json index 9c85e363..87f0bf23 100644 --- a/concepts/auto/links.json +++ b/concepts/auto/links.json @@ -7,4 +7,4 @@ "url": "https://www.learncpp.com/cpp-tutorial/type-deduction-for-objects-using-the-auto-keyword/", "description": "Learn C++ overview on the auto keyword and its usage" } -] \ No newline at end of file +] diff --git a/concepts/basics/about.md b/concepts/basics/about.md index 1a3ddc39..764b6b3e 100644 --- a/concepts/basics/about.md +++ b/concepts/basics/about.md @@ -6,7 +6,7 @@ To set off the C++ journey we are starting with variables, function calls, and c Comments come in two flavors: single- and multi-line. Everything that comes after `//` on the same line is ignored by the compiler. -Multi-line comments are also known as C-style comments. +Multi-line comments are also known as C-style comments. They are surrounded by `/*` and `*/`. Anything that comes between these will be ignored as well. @@ -40,7 +40,7 @@ It cannot be stressed enough: avoid undefined behavior at all cost. ## Arithmetic Operations -Arithmetic operators like `*`, `+`, or `-` can be part of an expression like `3 * 2` or `tomatoes + potatoes`. +Arithmetic operators like `*`, `+`, or `-` can be part of an expression like `3 * 2` or `tomatoes + potatoes`. ## Updating Variables @@ -84,7 +84,7 @@ int total_fee(int vips, int adults, int kids) { */ int standard_fee{30}; int kids_discount{15}; - + int kids_total_fee = kids * (standard_fee - kids_discount); int vips_total_fee = vips * vip_fee(standard_fee); int adult_total_fee = adults * standard_fee; diff --git a/concepts/basics/introduction.md b/concepts/basics/introduction.md index 7e6a49ef..c2512452 100644 --- a/concepts/basics/introduction.md +++ b/concepts/basics/introduction.md @@ -6,7 +6,7 @@ To set off the C++ journey we are starting with variables, function calls, and c Comments come in two flavors: single- and multi-line. Everything that comes after `//` on the same line is ignored by the compiler. -Multi-line comments are also known as C-style comments. +Multi-line comments are also known as C-style comments. They are surrounded by `/*` and `*/`. Anything that comes between these will be ignored as well. @@ -40,7 +40,7 @@ It cannot be stressed enough: avoid undefined behavior at all cost. ## Arithmetic Operations -Arithmetic operators like `*`, `+`, or `-` can be part of an expression like `3 * 2` or `tomatoes + potatoes`. +Arithmetic operators like `*`, `+`, or `-` can be part of an expression like `3 * 2` or `tomatoes + potatoes`. ## Updating Variables @@ -84,7 +84,7 @@ int total_fee(int vips, int adults, int kids) { */ int standard_fee{30}; int kids_discount{15}; - + int kids_total_fee = kids * (standard_fee - kids_discount); int vips_total_fee = vips * vip_fee(standard_fee); int adult_total_fee = adults * standard_fee; diff --git a/concepts/basics/links.json b/concepts/basics/links.json index ab2f7aa1..690b9bc3 100644 --- a/concepts/basics/links.json +++ b/concepts/basics/links.json @@ -11,4 +11,4 @@ "url": "https://isocpp.org/faq", "description": "C++ Super-FAQ" } -] \ No newline at end of file +] diff --git a/concepts/booleans/introduction.md b/concepts/booleans/introduction.md index 26706397..ad0ee9e1 100644 --- a/concepts/booleans/introduction.md +++ b/concepts/booleans/introduction.md @@ -35,4 +35,4 @@ If you use a number in a Boolean operation, everything except `0` is treated as !true && 0.0 // => false true + true + false // => 2 ``` -~~~~ \ No newline at end of file +~~~~ diff --git a/concepts/booleans/links.json b/concepts/booleans/links.json index 0df56531..3368e317 100644 --- a/concepts/booleans/links.json +++ b/concepts/booleans/links.json @@ -3,4 +3,4 @@ "url": "https://en.cppreference.com/w/cpp/language/operator_logical", "description": "C++ reference on Logical operators" } -] \ No newline at end of file +] diff --git a/concepts/classes/about.md b/concepts/classes/about.md index d8c64f19..bb94b033 100644 --- a/concepts/classes/about.md +++ b/concepts/classes/about.md @@ -52,7 +52,7 @@ silverhand.cast_spell(); silverhand.name = "Laeral"; // damage is private: -silverhand.damage = 500; +silverhand.damage = 500; // => Compilation error ``` diff --git a/concepts/classes/introduction.md b/concepts/classes/introduction.md index b851e444..e9a957bc 100644 --- a/concepts/classes/introduction.md +++ b/concepts/classes/introduction.md @@ -51,7 +51,7 @@ silverhand.cast_spell(); silverhand.name = "Laeral"; // damage is private: -silverhand.damage = 500; +silverhand.damage = 500; // => Compilation error ``` @@ -102,4 +102,4 @@ Conventionally, the `struct` keyword is often used for **data-only structures**. The `class` keyword is preferred for objects that need to ensure certain properties. Such an invariant could be that the `damage` of your `Wizzard` `class` cannot turn negative. The `damage` variable is private and any function that changes the damage would ensure the invariant is preserved. -~~~~ \ No newline at end of file +~~~~ diff --git a/concepts/classes/links.json b/concepts/classes/links.json index 5afd9955..cd994028 100644 --- a/concepts/classes/links.json +++ b/concepts/classes/links.json @@ -3,4 +3,4 @@ "url": "https://en.cppreference.com/w/cpp/language/classes", "description": "C++ reference on for classes" } -] \ No newline at end of file +] diff --git a/concepts/comparisons/about.md b/concepts/comparisons/about.md index 95803ef9..ec34ac14 100644 --- a/concepts/comparisons/about.md +++ b/concepts/comparisons/about.md @@ -27,7 +27,7 @@ Here are some common examples: ```cpp bool eq3 = 2 == 3; // false, integer comparison -bool eq4 = 2.1 != 2.2; // true, float comparison +bool eq4 = 2.1 != 2.2; // true, float comparison bool eq5 = "hello" == "hello"; // true, string comparison ``` diff --git a/concepts/comparisons/introduction.md b/concepts/comparisons/introduction.md index 103cf6b4..f16a5b0d 100644 --- a/concepts/comparisons/introduction.md +++ b/concepts/comparisons/introduction.md @@ -27,7 +27,7 @@ Here are some common examples: ```cpp bool eq3 = 2 == 3; // false, integer comparison -bool eq4 = 2.1 != 2.2; // true, float comparison +bool eq4 = 2.1 != 2.2; // true, float comparison bool eq5 = "hello" == "hello"; // true, string comparison ``` diff --git a/concepts/comparisons/links.json b/concepts/comparisons/links.json index 8be8cc9a..be11e813 100644 --- a/concepts/comparisons/links.json +++ b/concepts/comparisons/links.json @@ -3,4 +3,4 @@ "url": "https://en.cppreference.com/w/cpp/language/operator_comparison", "description": "C++ reference on comparison operators" } -] \ No newline at end of file +] diff --git a/concepts/enums/about.md b/concepts/enums/about.md index 809f9791..e0f1c462 100644 --- a/concepts/enums/about.md +++ b/concepts/enums/about.md @@ -46,7 +46,7 @@ enum class WheelMaterial { plastic }; ``` -Although the wheels and the deck can both be made of _plastic_, the two cannot be confused. +Although the wheels and the deck can both be made of _plastic_, the two cannot be confused. They are different _types_: `DeckMaterial` plastic and `WheelMaterial` plastic. Each `enumeration` will have its `enumerators` in its own scope - its own `namespace`. This is the reason they are called `scoped enumerations`. @@ -57,7 +57,7 @@ You might be thinking that with a name like `scoped`, there would also be _`uns `Unscoped enumerations` are becoming less popular because they all share the same global namespace. Because of the sharing, you could not have two `unscoped enumerations` with the same `enumerators` like _plastic_ in the example above. -Also, `unscoped enumerations` implicitly convert to integers. +Also, `unscoped enumerations` implicitly convert to integers. Look at the example below for a surprising result: ```cpp @@ -84,4 +84,4 @@ If you want to convert `scoped enumerations` to integers you can use `static_cas -[magic numbers]: https://en.wikipedia.org/wiki/Magic_number_(programming) \ No newline at end of file +[magic numbers]: https://en.wikipedia.org/wiki/Magic_number_(programming) diff --git a/concepts/enums/introduction.md b/concepts/enums/introduction.md index a9b0f41b..ad4e4e4c 100644 --- a/concepts/enums/introduction.md +++ b/concepts/enums/introduction.md @@ -46,7 +46,7 @@ enum class WheelMaterial { plastic }; ``` -Although the wheels and the deck can both be made of _plastic_, the two cannot be confused. +Although the wheels and the deck can both be made of _plastic_, the two cannot be confused. They are different _types_: `DeckMaterial` plastic and `WheelMaterial` plastic. Each `enumeration` will have its `enumerators` in its own scope - its own `namespace`. This is the reason they are called `scoped enumerations`. @@ -57,7 +57,7 @@ You might be thinking that with the name `scoped`, there would also be be `unsco `Unscoped enumerations` are becoming less popular because they all share the same global namespace. Because of the sharing, you could not have two `unscoped enumerations` with the same `enumerators` like _plastic_ in the example above. -Also, `unscoped enumerations` implicitly convert to integers. +Also, `unscoped enumerations` implicitly convert to integers. Look at the example below for a surprising result: ```cpp @@ -84,4 +84,4 @@ If you want to convert `scoped enumerations` to integers you can use `static_cas -[magic numbers]: https://en.wikipedia.org/wiki/Magic_number_(programming) \ No newline at end of file +[magic numbers]: https://en.wikipedia.org/wiki/Magic_number_(programming) diff --git a/concepts/enums/links.json b/concepts/enums/links.json index ca711b76..30bc05dc 100644 --- a/concepts/enums/links.json +++ b/concepts/enums/links.json @@ -3,4 +3,4 @@ "url": "https://en.cppreference.com/w/cpp/language/enum", "description": "C++ reference on enumerations" } -] \ No newline at end of file +] diff --git a/concepts/functions/links.json b/concepts/functions/links.json index c08cc662..6d5b65a7 100644 --- a/concepts/functions/links.json +++ b/concepts/functions/links.json @@ -15,4 +15,4 @@ "url": "https://en.cppreference.com/w/cpp/language/default_arguments", "description": "C++ reference on default arguments" } -] \ No newline at end of file +] diff --git a/concepts/headers/about.md b/concepts/headers/about.md index b6a57a70..8d59dcba 100644 --- a/concepts/headers/about.md +++ b/concepts/headers/about.md @@ -10,7 +10,7 @@ The header file will tell you _what_ a codebase has to offer without going into The most common file extension for header files is `.h`. Some projects use `.hpp` or skip the extension completely. -The definitions are located in a separate `.cpp` file. +The definitions are located in a separate `.cpp` file. To reunite the parts, the source file starts by _including_ the respective header file. If you want to write a library called "quick_math" that offers a function "super_root" that you want to use often, the files would look like this: @@ -81,7 +81,7 @@ int robots::Flower::get_size() {return size;} When the header is used as an API overview, that is where a person would look for information like default values. The `size` parameter's default of the constructor is therefore handled in the header and not in the implementation. The definitions in the source file are prefixed with the namespace `robots` and the class type `Flower`. - + Another layout option is a _header only_ library, that does not have a `.cpp` file at all: ```cpp @@ -164,7 +164,7 @@ int myOtherFunction(int m) { It does not matter if the same file is included multiple times within a project. Header files should not contain definitions. -The complete project cannot have the same definition more than once. +The complete project cannot have the same definition more than once. This is called the "One definition rule". It will be enforced by the compiler. @@ -184,4 +184,4 @@ The syntax can be seen below with `MY_HEADER_FILE_H` as a variable. The problem with `#pragma once` is, that pragmas are not an official part of the C++ language and the implementation differs from compiler to compiler. Many big projects have switched to the simpler pragma method, but a few are still cautious. -~~~~ \ No newline at end of file +~~~~ diff --git a/concepts/headers/introduction.md b/concepts/headers/introduction.md index c8d9c68f..e7db48e1 100644 --- a/concepts/headers/introduction.md +++ b/concepts/headers/introduction.md @@ -10,7 +10,7 @@ The header file will tell you _what_ a codebase has to offer without going into The most common file extension for header files is `.h`. Some projects use `.hpp` or skip the extension completely. -The definitions are located in a separate `.cpp` file. +The definitions are located in a separate `.cpp` file. To reunite the parts, the source file starts by _including_ the respective header file. If you want to write a library called "quick_math" that offers a function "super_root" that you want to use often, the files would look like this: @@ -81,7 +81,7 @@ int robots::Flower::get_size() {return size;} When the header is used as an API overview, that is where a person would look for information like default values. The `size` parameter's default of the constructor is therefore handled in the header and not in the implementation. The definitions in the source file are prefixed with the namespace `robots` and the class type `Flower`. - + Another layout option is a _header only_ library, that does not have a `.cpp` file at all: ```cpp diff --git a/concepts/headers/links.json b/concepts/headers/links.json index 5dcf350b..fa81042f 100644 --- a/concepts/headers/links.json +++ b/concepts/headers/links.json @@ -7,4 +7,4 @@ "url": "https://www.learncpp.com/cpp-tutorial/classes-and-header-files/", "description": "More information about classes in header files" } -] \ No newline at end of file +] diff --git a/concepts/if-statements/about.md b/concepts/if-statements/about.md index 0473b4a8..f2921bd2 100644 --- a/concepts/if-statements/about.md +++ b/concepts/if-statements/about.md @@ -41,4 +41,4 @@ if (int v{2 * num}; v > 10) { // => 14 ``` -> Note: any variables created in the initialization cannot be accesed after the end of the if statement. \ No newline at end of file +> Note: any variables created in the initialization cannot be accesed after the end of the if statement. diff --git a/concepts/if-statements/introduction.md b/concepts/if-statements/introduction.md index 48f930d4..ae4bb934 100644 --- a/concepts/if-statements/introduction.md +++ b/concepts/if-statements/introduction.md @@ -41,4 +41,4 @@ if (int v{2 * num}; v > 10) { // => 14 ``` -> Note: any variables created in the initialization cannot be accesed after the end of the if statement. \ No newline at end of file +> Note: any variables created in the initialization cannot be accesed after the end of the if statement. diff --git a/concepts/if-statements/links.json b/concepts/if-statements/links.json index 0a948465..7f0c14f8 100644 --- a/concepts/if-statements/links.json +++ b/concepts/if-statements/links.json @@ -3,4 +3,4 @@ "url": "https://en.cppreference.com/w/cpp/language/if", "description": "C++ reference on if statements" } -] \ No newline at end of file +] diff --git a/concepts/includes/about.md b/concepts/includes/about.md index 93fc9ed0..d9399b1e 100644 --- a/concepts/includes/about.md +++ b/concepts/includes/about.md @@ -8,7 +8,7 @@ During compilation, the line with the directive is replaced by the content of th Namespaces are kept as they are in the original file after includes. ## The Standard Library - + The standard library offers many common functions, algorithms, and data structures. The standard library uses the `std` namespace. diff --git a/concepts/includes/introduction.md b/concepts/includes/introduction.md index 87cc4f3c..581ef7cd 100644 --- a/concepts/includes/introduction.md +++ b/concepts/includes/introduction.md @@ -11,7 +11,7 @@ During compilation, the line with the directive is replaced by the content of th Namespaces are kept as they are in the original file after includes. ## The Standard Library - + The standard library offers many common functions, algorithms, and data structures. The standard library uses the `std` namespace. diff --git a/concepts/includes/links.json b/concepts/includes/links.json index 2887e953..41b93f13 100644 --- a/concepts/includes/links.json +++ b/concepts/includes/links.json @@ -3,4 +3,4 @@ "url": "https://en.cppreference.com/w/cpp/preprocessor/include", "description": "C++ reference on Source File Inclusion" } -] \ No newline at end of file +] diff --git a/concepts/literals/links.json b/concepts/literals/links.json index 1b9edf60..9f98210d 100644 --- a/concepts/literals/links.json +++ b/concepts/literals/links.json @@ -3,4 +3,4 @@ "url": "https://www.learncpp.com/cpp-tutorial/literals/", "description": "Learn C++ overview on literals" } -] \ No newline at end of file +] diff --git a/concepts/loops/about.md b/concepts/loops/about.md index 10c335d3..b1fcd0f7 100644 --- a/concepts/loops/about.md +++ b/concepts/loops/about.md @@ -63,7 +63,7 @@ for (int i{1}; i < 10; ++i) { } ``` -This loop will sum the numbers from `1` to `9` (including `9`). +This loop will sum the numbers from `1` to `9` (including `9`). ## Break and Continue diff --git a/concepts/loops/introduction.md b/concepts/loops/introduction.md index d6793636..521154ee 100644 --- a/concepts/loops/introduction.md +++ b/concepts/loops/introduction.md @@ -63,7 +63,7 @@ for (int i{1}; i < 10; ++i) { } ``` -This loop will sum the numbers from `1` to `9` (including `9`). +This loop will sum the numbers from `1` to `9` (including `9`). ## Break and Continue diff --git a/concepts/loops/links.json b/concepts/loops/links.json index c814151c..458f3a2d 100644 --- a/concepts/loops/links.json +++ b/concepts/loops/links.json @@ -7,4 +7,4 @@ "url": "https://en.cppreference.com/w/cpp/language/while", "description": "C++ reference on while loops" } -] \ No newline at end of file +] diff --git a/concepts/namespaces/about.md b/concepts/namespaces/about.md index a2220d0c..8c281986 100644 --- a/concepts/namespaces/about.md +++ b/concepts/namespaces/about.md @@ -44,4 +44,4 @@ namespace o = my_other_ns; int also_my_result{m::foo() + o::foo() * m::my_inner_ns::baz()}; ``` -~~~~ \ No newline at end of file +~~~~ diff --git a/concepts/namespaces/links.json b/concepts/namespaces/links.json index 06397a0e..9cb677f9 100644 --- a/concepts/namespaces/links.json +++ b/concepts/namespaces/links.json @@ -3,4 +3,4 @@ "url": "https://en.cppreference.com/w/cpp/language/namespace", "description": "C++ reference on namespaces" } -] \ No newline at end of file +] diff --git a/concepts/numbers/.meta/config.json b/concepts/numbers/.meta/config.json index 6c515a48..afae1027 100644 --- a/concepts/numbers/.meta/config.json +++ b/concepts/numbers/.meta/config.json @@ -6,4 +6,4 @@ "contributors": [ "tesarect" ] -} \ No newline at end of file +} diff --git a/concepts/numbers/about.md b/concepts/numbers/about.md index c0b79e0d..223f35eb 100644 --- a/concepts/numbers/about.md +++ b/concepts/numbers/about.md @@ -4,7 +4,7 @@ Integers are whole numbers like `0`, `691`, or `-2`. Floating point numbers are numbers with a decimal point like `6.02214076`, `0.1`, or `-1.616`. ## Integers -The following example shows the declaration and initialization of four different variables +The following example shows the declaration and initialization of four different variables ```cpp int m_morales{9241}; // base 10: 0-9 @@ -29,7 +29,7 @@ You can use an apostrophe to separate digits for easier readability. ## Floating-Point Numbers -The floating-point literals come in two flavors. +The floating-point literals come in two flavors. In addition to the intuitive `0.0024` it is possible to use its scientific notation `2.4e-3`. The most common floating-point type is `double`. @@ -66,9 +66,9 @@ These operators modify the current value of a variable by performing an operatio // we start with 0 people int people{}; // we need 0 eggs -int eggs{}; +int eggs{}; // two people joined: -people += 2; +people += 2; // people is now 2 // let's add 3 eggs per person eggs += 3 * people; diff --git a/concepts/numbers/introduction.md b/concepts/numbers/introduction.md index be17bde7..30c7fe2e 100644 --- a/concepts/numbers/introduction.md +++ b/concepts/numbers/introduction.md @@ -4,7 +4,7 @@ Integers are whole numbers like `0`, `691`, or `-2`. Floating point numbers are numbers with a decimal point like `6.02214076`, `0.1`, or `-1.616`. ## Integers -The following example shows the declaration and initialization of four different variables +The following example shows the declaration and initialization of four different variables ```cpp int m_morales{9241}; // base 10: 0-9 @@ -29,7 +29,7 @@ You can use an apostrophe to separate digits for easier readability. ## Floating-Point Numbers -The floating-point literals come in two flavors. +The floating-point literals come in two flavors. In addition to the intuitive `0.0024` it is possible to use its scientific notation `2.4e-3`. The most common floating-point type is `double`. @@ -66,9 +66,9 @@ These operators modify the current value of a variable by performing an operatio // we start with 0 people int people{}; // we need 0 eggs -int eggs{}; +int eggs{}; // two people joined: -people += 2; +people += 2; // people is now 2 // let's add 3 eggs per person eggs += 3 * people; diff --git a/concepts/numbers/links.json b/concepts/numbers/links.json index f11210b0..894269e3 100644 --- a/concepts/numbers/links.json +++ b/concepts/numbers/links.json @@ -11,4 +11,4 @@ "url": "https://en.wikipedia.org/wiki/Double-precision_floating-point_format", "description": "Explanation on the floating point format" } - ] \ No newline at end of file + ] diff --git a/concepts/pointers/about.md b/concepts/pointers/about.md index d5230289..b15f9e52 100644 --- a/concepts/pointers/about.md +++ b/concepts/pointers/about.md @@ -36,7 +36,7 @@ Dereferencing a pointer is done using the _indirection operator_ (`*`) operator. ```cpp std::string opponent{"Solomon Lane"}; // 'ethan' points to the address of the string opponent -std::string* ethan{&opponent}; +std::string* ethan{&opponent}; // Instead of ethan's, the opponent's name address is given to the passPort std::string passportName{*ethan}; ``` @@ -54,7 +54,7 @@ int gateCode[] = {462, 753, 218, 611, 977}; // 'ptr' points to the first element of 'gateCode' int* ptr{&gateCode[0]}; // Accesses the third Stargate address through pointer arithmetic -int dialedAddress{*(ptr + 2)}; +int dialedAddress{*(ptr + 2)}; // Chevron encoded! Dialing Stargate address: openStarGate(dialedAddress); ``` @@ -89,7 +89,7 @@ dianaPrince->superpower = "Lasso of Truth"; std::cout << "Wonder Woman, possesses the mighty " << dianaPrince->superpower; // Memory cleanup: -delete dianaPrince; +delete dianaPrince; ``` ## Pointers vs. references @@ -119,7 +119,7 @@ darkMarkBearer = new std::string{"Bellatrix Lestrange"}; // She has been defeated delete darkMarkBearer; // Reset pointer to null, symbolizing there is no more darkMarkBearer at the moment -darkMarkBearer = nullptr; +darkMarkBearer = nullptr; ``` A pointer should either hold the address of a valid object, or be set to `nullptr`. diff --git a/concepts/pointers/introduction.md b/concepts/pointers/introduction.md index 3f64ba0f..bca4fdbf 100644 --- a/concepts/pointers/introduction.md +++ b/concepts/pointers/introduction.md @@ -36,7 +36,7 @@ Dereferencing a pointer is done using the _indirection operator_ (`*`) operator. ```cpp std::string opponent{"Solomon Lane"}; // 'ethan' points to the address of the string opponent -std::string* ethan{&opponent}; +std::string* ethan{&opponent}; // Instead of ethan's, the opponent's name address is given to the passPort std::string passportName{*ethan}; ``` @@ -54,7 +54,7 @@ int gateCode[] = {462, 753, 218, 611, 977}; // 'ptr' points to the first element of 'gateCode' int* ptr{&gateCode[0]}; // Accesses the third Stargate address through pointer arithmetic -int dialedAddress{*(ptr + 2)}; +int dialedAddress{*(ptr + 2)}; // Chevron encoded! Dialing Stargate address: openStarGate(dialedAddress); ``` @@ -86,7 +86,7 @@ dianaPrince->superpower = "Lasso of Truth"; // Using the -> operator to access member variable superpower: std::cout << "Wonder Woman, possesses the mighty " << dianaPrince->superpower; // Memory cleanup: -delete dianaPrince; +delete dianaPrince; ``` ## Pointers vs. references diff --git a/concepts/references/about.md b/concepts/references/about.md index 969025e0..86bafd3d 100644 --- a/concepts/references/about.md +++ b/concepts/references/about.md @@ -52,8 +52,8 @@ int& future_budget; ## `void` -With the power of `references` you might not need to return a value from a function at all. -`void` is used as a return type in this scenario. +With the power of `references` you might not need to return a value from a function at all. +`void` is used as a return type in this scenario. ```cpp void increase_power(int& level) { @@ -65,4 +65,4 @@ increase_power(goku); // It's over 9000! ``` -[Reseating]: https://stackoverflow.com/questions/728233/why-are-references-not-reseatable-in-c \ No newline at end of file +[Reseating]: https://stackoverflow.com/questions/728233/why-are-references-not-reseatable-in-c diff --git a/concepts/references/introduction.md b/concepts/references/introduction.md index 9ab3909a..b769dc5f 100644 --- a/concepts/references/introduction.md +++ b/concepts/references/introduction.md @@ -52,8 +52,8 @@ int& future_budget; ## `void` -With the power of `references` you might not need to return a value from a function at all. -`void` is used as a return type in this scenario. +With the power of `references` you might not need to return a value from a function at all. +`void` is used as a return type in this scenario. ```cpp void increase_power(int& level) { @@ -63,4 +63,4 @@ int goku{8700}; increase_power(goku); // goku's power level? // It's over 9000! -``` \ No newline at end of file +``` diff --git a/concepts/references/links.json b/concepts/references/links.json index b5eca2e1..2d90ebcd 100644 --- a/concepts/references/links.json +++ b/concepts/references/links.json @@ -3,4 +3,4 @@ "url": "https://en.cppreference.com/w/cpp/language/reference", "description": "C++ reference on references" } -] \ No newline at end of file +] diff --git a/concepts/smart-pointers/about.md b/concepts/smart-pointers/about.md index ad66e0a3..c74c0538 100644 --- a/concepts/smart-pointers/about.md +++ b/concepts/smart-pointers/about.md @@ -6,7 +6,7 @@ They act as wrappers around raw pointers, adding additional functionality such a ## General Syntax Smart pointers are typically implemented as class templates in the C++ standard library. -The two most commonly used smart pointers are `std::unique_ptr` and `std::shared_ptr`. +The two most commonly used smart pointers are `std::unique_ptr` and `std::shared_ptr`. ## Unique Pointers @@ -83,7 +83,7 @@ auto your_flatmates_boyfriends_account = your_flatmates_account; ## `std::weak_ptr` and Cyclic Ownership -`std::weak_ptr` was designed to address the issue of cyclic ownership, also known as circular references, that can occur when using `std::shared_ptr`. +`std::weak_ptr` was designed to address the issue of cyclic ownership, also known as circular references, that can occur when using `std::shared_ptr`. In a cyclic ownership scenario, two or more `std::shared_ptr` objects are referencing each other, creating a cycle where none of the objects can be deleted because they have strong references to each other, leading to memory leaks. diff --git a/concepts/smart-pointers/introduction.md b/concepts/smart-pointers/introduction.md index 61c60f69..dd84b788 100644 --- a/concepts/smart-pointers/introduction.md +++ b/concepts/smart-pointers/introduction.md @@ -6,7 +6,7 @@ They act as wrappers around raw pointers, adding additional functionality such a ## General Syntax Smart pointers are typically implemented as class templates in the C++ standard library. -The two most commonly used smart pointers are `std::unique_ptr` and `std::shared_ptr`. +The two most commonly used smart pointers are `std::unique_ptr` and `std::shared_ptr`. ## Unique Pointers @@ -82,7 +82,7 @@ auto your_flatmates_boyfriends_account = your_flatmates_account; ``` Weak pointers are useful in scenarios where cyclic references need to be broken to prevent memory leaks. -`std::weak_ptr` was designed to address the issue of cyclic ownership, also known as circular references, that can occur when using `std::shared_ptr`. +`std::weak_ptr` was designed to address the issue of cyclic ownership, also known as circular references, that can occur when using `std::shared_ptr`. In a cyclic ownership scenario, two or more `std::shared_ptr` objects are referencing each other, creating a cycle where none of the objects can be deleted because they have strong references to each other, leading to memory leaks. `std::weak_ptr` provides a solution to this problem by allowing weak references to shared objects without contributing to their reference count. This means that it can observe and access the shared object but doesn't prevent it from being deleted. diff --git a/concepts/smart-pointers/links.json b/concepts/smart-pointers/links.json index ebcb824f..da71e152 100644 --- a/concepts/smart-pointers/links.json +++ b/concepts/smart-pointers/links.json @@ -11,4 +11,4 @@ "url": "https://en.cppreference.com/w/cpp/memory/weak_ptr", "description": "C++ reference on std::weak_ptr" } -] \ No newline at end of file +] diff --git a/concepts/strings/about.md b/concepts/strings/about.md index c0aabb04..1d5d4842 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -1,6 +1,6 @@ # About -A `string` in C++ is a mutable object that represents text as a sequence of characters (letters, digits, punctuation, etc.). +A `string` in C++ is a mutable object that represents text as a sequence of characters (letters, digits, punctuation, etc.). Strings are manipulated by calling the string's methods. ## Strings Library @@ -32,7 +32,7 @@ Later in the syllabus, you will learn more about member functions and the connec ```cpp std::string qualification{"awesome"}; // 1st argument: from the index to the end of the string: -std::string who_is_awesome = qualification.substr(5); +std::string who_is_awesome = qualification.substr(5); // => "me" // 2nd optional argument for the length: diff --git a/concepts/strings/introduction.md b/concepts/strings/introduction.md index 8d4aa19a..171e651a 100644 --- a/concepts/strings/introduction.md +++ b/concepts/strings/introduction.md @@ -1,6 +1,6 @@ # Introduction -A `string` in C++ is a mutable object that represents text as a sequence of characters (letters, digits, punctuation, etc.). +A `string` in C++ is a mutable object that represents text as a sequence of characters (letters, digits, punctuation, etc.). Strings are manipulated by calling the string's methods. ## Strings Library @@ -33,7 +33,7 @@ Later in the syllabus, you will learn more about member functions and the connec ```cpp std::string qualification{"awesome"}; // 1st argument: from the index to the end of the string: -std::string who_is_awesome = qualification.substr(5); +std::string who_is_awesome = qualification.substr(5); // => "me" // 2nd optional argument for the length: diff --git a/concepts/strings/links.json b/concepts/strings/links.json index 4715085d..5ba25e76 100644 --- a/concepts/strings/links.json +++ b/concepts/strings/links.json @@ -3,4 +3,4 @@ "url": "https://en.cppreference.com/w/cpp/string/basic_string", "description": "C++ reference on strings" } -] \ No newline at end of file +] diff --git a/concepts/switch/about.md b/concepts/switch/about.md index 3a955a5b..500c1017 100644 --- a/concepts/switch/about.md +++ b/concepts/switch/about.md @@ -67,4 +67,4 @@ Many languages can do switches based on boolean expression or even regular expre You can think of the C++ version is an extended goto/switch construct. Only the switch statement can jump to a label. Afterwards all other labels are ignored and you have to use the `break` statement to break out of the code block. -~~~~ \ No newline at end of file +~~~~ diff --git a/concepts/switch/links.json b/concepts/switch/links.json index d9d1a333..47718923 100644 --- a/concepts/switch/links.json +++ b/concepts/switch/links.json @@ -2,9 +2,9 @@ { "url": "https://en.cppreference.com/w/cpp/language/switch", "description": "C++ reference on switch statements" - }, + }, { "url": "https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-break", "description": "CppCoreGuidelines' hints on switch statements" } -] \ No newline at end of file +] diff --git a/concepts/vector-arrays/about.md b/concepts/vector-arrays/about.md index 406ac5f7..dfd42702 100644 --- a/concepts/vector-arrays/about.md +++ b/concepts/vector-arrays/about.md @@ -46,7 +46,7 @@ countdown.at(2); // => 1 countdown[1] = 4; // countdown now contains 3, 4 and 1 -indie_rock.back() = "yeahs"; +indie_rock.back() = "yeahs"; // indie_rock is now "yeah", "yeah", "yeahs" ``` @@ -55,12 +55,12 @@ indie_rock.back() = "yeahs"; ### Vector modifiers -As a `vector` is not fixed in size, it is possible to add or remove elements. +As a `vector` is not fixed in size, it is possible to add or remove elements. Two common functions for that purpose are `emplace_back` and `pop_back`. ```cpp std::vector witches {"Holly", "Alyssa", "Shannen"}; -witches.pop_back(); +witches.pop_back(); // Shannen is no longer with the witches witches.emplace_back("Rose"); // Rose has joined the team diff --git a/concepts/vector-arrays/introduction.md b/concepts/vector-arrays/introduction.md index ca28b607..841839e2 100644 --- a/concepts/vector-arrays/introduction.md +++ b/concepts/vector-arrays/introduction.md @@ -46,7 +46,7 @@ countdown.at(2); // => 1 countdown[1] = 4; // countdown now contains 3, 4 and 1 -indie_rock.back() = "yeahs"; +indie_rock.back() = "yeahs"; // indie_rock is now "yeah", "yeah", "yeahs" ``` @@ -55,12 +55,12 @@ indie_rock.back() = "yeahs"; ### Vector modifiers -As a `vector` is not fixed in size, it is possible to add or remove elements. +As a `vector` is not fixed in size, it is possible to add or remove elements. Two common functions for that purpose are `emplace_back` and `pop_back`. ```cpp std::vector witches {"Holly", "Alyssa", "Shannen"}; -witches.pop_back(); +witches.pop_back(); // Shannen is no longer with the witches witches.emplace_back("Rose"); // Rose has joined the team diff --git a/concepts/vector-arrays/links.json b/concepts/vector-arrays/links.json index 781f2494..2699bfe1 100644 --- a/concepts/vector-arrays/links.json +++ b/concepts/vector-arrays/links.json @@ -7,4 +7,4 @@ "url": "https://en.cppreference.com/w/cpp/container/vector", "description": "C++ reference on vectors" } -] \ No newline at end of file +] diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 58b44668..aea73633 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -103,4 +103,4 @@ MacOS users can install GCC with [Homebrew](http://brew.sh/) via [boost-website]: https://www.boost.org/ -[sourceforge-boost-binaries]: https://sourceforge.net/projects/boost/files/boost-binaries/ \ No newline at end of file +[sourceforge-boost-binaries]: https://sourceforge.net/projects/boost/files/boost-binaries/ diff --git a/docs/TESTS.md b/docs/TESTS.md index 829b516e..5b659c29 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -74,8 +74,8 @@ $ make This example shows creating empty files for the implementation before running CMake. -Simply type `make` in the build directory to compile the tests. This should -generate compile time errors. Once the errors are fixed, `make` will build and +Simply type `make` in the build directory to compile the tests. This should +generate compile time errors. Once the errors are fixed, `make` will build and run the tests. ### Windows with Visual Studio @@ -98,7 +98,7 @@ $ cmake -G Xcode .. ``` This example generates the XCode files so that you can open the project in XCode. -With the project opened in XCode you may need to add another target. +With the project opened in XCode you may need to add another target. For a new target go to File -> New -> Target from the menu, _OS X \ Application \ Command Line Tool_ -> Next _C++_ as the language and provide a target name. Run the code using the target. If your terminal throws an `Xcode x.x not supported` error, it is highly likely that Xcode is not installed on your machine or that your version is out of date. diff --git a/exercises/concept/doctor-data/.docs/instructions.md b/exercises/concept/doctor-data/.docs/instructions.md index 30954627..8fc8b514 100644 --- a/exercises/concept/doctor-data/.docs/instructions.md +++ b/exercises/concept/doctor-data/.docs/instructions.md @@ -105,4 +105,4 @@ You see two functions, that are not members of the `Vessel` class, as they are n Implement the last missing functions from the recovered lines above. -[van-neumann-probes]: https://en.wikipedia.org/wiki/Self-replicating_spacecraft \ No newline at end of file +[van-neumann-probes]: https://en.wikipedia.org/wiki/Self-replicating_spacecraft diff --git a/exercises/concept/doctor-data/.docs/introduction.md b/exercises/concept/doctor-data/.docs/introduction.md index c8d9c68f..e7db48e1 100644 --- a/exercises/concept/doctor-data/.docs/introduction.md +++ b/exercises/concept/doctor-data/.docs/introduction.md @@ -10,7 +10,7 @@ The header file will tell you _what_ a codebase has to offer without going into The most common file extension for header files is `.h`. Some projects use `.hpp` or skip the extension completely. -The definitions are located in a separate `.cpp` file. +The definitions are located in a separate `.cpp` file. To reunite the parts, the source file starts by _including_ the respective header file. If you want to write a library called "quick_math" that offers a function "super_root" that you want to use often, the files would look like this: @@ -81,7 +81,7 @@ int robots::Flower::get_size() {return size;} When the header is used as an API overview, that is where a person would look for information like default values. The `size` parameter's default of the constructor is therefore handled in the header and not in the implementation. The definitions in the source file are prefixed with the namespace `robots` and the class type `Flower`. - + Another layout option is a _header only_ library, that does not have a `.cpp` file at all: ```cpp diff --git a/exercises/concept/doctor-data/.docs/introduction.md.tpl b/exercises/concept/doctor-data/.docs/introduction.md.tpl index 70899ec3..4bc15689 100644 --- a/exercises/concept/doctor-data/.docs/introduction.md.tpl +++ b/exercises/concept/doctor-data/.docs/introduction.md.tpl @@ -1,3 +1,3 @@ # Introduction -%{concept:headers} \ No newline at end of file +%{concept:headers} diff --git a/exercises/concept/doctor-data/doctor_data.cpp b/exercises/concept/doctor-data/doctor_data.cpp index 0771dfcf..7e069e14 100644 --- a/exercises/concept/doctor-data/doctor_data.cpp +++ b/exercises/concept/doctor-data/doctor_data.cpp @@ -1,4 +1,4 @@ // ERROR: FILE CORRUPTED. Please supply valid C++ Code. hp4,ölacöiömthö%Äsmaö%Äsubö(311040ö%Äspaö%Äaddö(311040ö%Ädacöiömthö%Äcountö.hpt,hp4ö%Äxctöhd2ö%Ädacöiöma1 -hp2,öjmpö. \ No newline at end of file +hp2,öjmpö. diff --git a/exercises/concept/election-day/.docs/hints.md b/exercises/concept/election-day/.docs/hints.md index 62dc5315..b21eed65 100644 --- a/exercises/concept/election-day/.docs/hints.md +++ b/exercises/concept/election-day/.docs/hints.md @@ -16,10 +16,10 @@ - You need to create a function with a `reference` to an `ElectionResult`, in other words, a `ElectionResult&`. - - Although you are receiving a `reference` to an `ElectionResult`, you can change its member variables with the dot `.` notation, as if it wasn't a `reference`! -## 3. Vote counting and Presidency +## 3. Vote counting and Presidency - You can iterate a reference to a `vector` like a normal vector with a loop. - You can get the size of a vector with `myvector.size()`. -[learncpp-references]: https://www.learncpp.com/cpp-tutorial/lvalue-references/ \ No newline at end of file +[learncpp-references]: https://www.learncpp.com/cpp-tutorial/lvalue-references/ diff --git a/exercises/concept/election-day/.docs/instructions.md b/exercises/concept/election-day/.docs/instructions.md index 14a71a67..9a4a2994 100644 --- a/exercises/concept/election-day/.docs/instructions.md +++ b/exercises/concept/election-day/.docs/instructions.md @@ -22,7 +22,7 @@ struct ElectionResult { }; ``` -As all members in the `struct` are public, you don't need to write a `constructor` to initialize an `ElectionResult` object. +As all members in the `struct` are public, you don't need to write a `constructor` to initialize an `ElectionResult` object. You can use an `initializer list` instead: ```cpp @@ -53,12 +53,12 @@ vote_count(burr); // => 1804 ``` -## 3. Vote counting and Presidency +## 3. Vote counting and Presidency The school handed in their votes and it is now time to check the results for the winner. Create a function `determine_result` that receives a reference to a final count and returns a reference to the `ElectionResult` of the new president. -It should also change the name of the winner by prefixing it with "President". +It should also change the name of the winner by prefixing it with "President". The final count is given in the form of a `reference` to `std::vector`, a vector with `ElectionResults` of all the participating candidates. ```cpp @@ -74,4 +74,4 @@ winner.name; To keep things simple, you can assume the following: - The `vector` has at least one element. -- There will be no ties for first place. \ No newline at end of file +- There will be no ties for first place. diff --git a/exercises/concept/election-day/.docs/introduction.md b/exercises/concept/election-day/.docs/introduction.md index 2bf28e11..c0c5d2e6 100644 --- a/exercises/concept/election-day/.docs/introduction.md +++ b/exercises/concept/election-day/.docs/introduction.md @@ -54,8 +54,8 @@ int& future_budget; ### `void` -With the power of `references` you might not need to return a value from a function at all. -`void` is used as a return type in this scenario. +With the power of `references` you might not need to return a value from a function at all. +`void` is used as a return type in this scenario. ```cpp void increase_power(int& level) { diff --git a/exercises/concept/election-day/.docs/introduction.md.tpl b/exercises/concept/election-day/.docs/introduction.md.tpl index ee0e6b3d..d67949a9 100644 --- a/exercises/concept/election-day/.docs/introduction.md.tpl +++ b/exercises/concept/election-day/.docs/introduction.md.tpl @@ -1,3 +1,3 @@ # Introduction -%{concept:references} \ No newline at end of file +%{concept:references} diff --git a/exercises/concept/election-day/.meta/design.md b/exercises/concept/election-day/.meta/design.md index 15393c32..a7cc939b 100644 --- a/exercises/concept/election-day/.meta/design.md +++ b/exercises/concept/election-day/.meta/design.md @@ -24,4 +24,4 @@ The Concepts this exercise unlocks are: ## Prerequisites - `classes` -- `strings` \ No newline at end of file +- `strings` diff --git a/exercises/concept/election-day/election_day.cpp b/exercises/concept/election-day/election_day.cpp index 01af9299..f568210b 100644 --- a/exercises/concept/election-day/election_day.cpp +++ b/exercises/concept/election-day/election_day.cpp @@ -28,4 +28,4 @@ struct ElectionResult { // in the form of a `reference` to `std::vector`, a vector with // `ElectionResults` of all the participating candidates. -} // namespace election \ No newline at end of file +} // namespace election diff --git a/exercises/concept/ellens-alien-game/.docs/hints.md b/exercises/concept/ellens-alien-game/.docs/hints.md index 279798ef..0551e83f 100644 --- a/exercises/concept/ellens-alien-game/.docs/hints.md +++ b/exercises/concept/ellens-alien-game/.docs/hints.md @@ -19,4 +19,4 @@ ## 5. The `collision_detection` Function -- All `public` member variables can be accessed from outside the class. \ No newline at end of file +- All `public` member variables can be accessed from outside the class. diff --git a/exercises/concept/ellens-alien-game/.docs/instructions.md b/exercises/concept/ellens-alien-game/.docs/instructions.md index 17184177..0382739a 100644 --- a/exercises/concept/ellens-alien-game/.docs/instructions.md +++ b/exercises/concept/ellens-alien-game/.docs/instructions.md @@ -36,7 +36,7 @@ Ellen wants to introduce shields at a later point, which would then report `fals ```cpp Alien alien {0, 0}; -alien.get_health(); +alien.get_health(); // => 3 (Initial health value) alien.hit(); // Decrements health by 1 point. @@ -80,7 +80,7 @@ alien.y_coordinate; ## 5. The `collision_detection` Function If the aliens can be hit by something, then they need to be able to detect when such a collision might occur. -Ellen needs to know if two aliens occupy the same coordinates. +Ellen needs to know if two aliens occupy the same coordinates. The `collision_detection()` function takes another alien object as an argument and returns a `bool`. ```cpp @@ -91,4 +91,4 @@ lrrr.collision_detection(ndnd); ndnd.teleport(3, 6); ndnd.collision_detection(lrrr); // => true -``` \ No newline at end of file +``` diff --git a/exercises/concept/ellens-alien-game/.docs/introduction.md b/exercises/concept/ellens-alien-game/.docs/introduction.md index f640213a..75c25927 100644 --- a/exercises/concept/ellens-alien-game/.docs/introduction.md +++ b/exercises/concept/ellens-alien-game/.docs/introduction.md @@ -54,7 +54,7 @@ silverhand.cast_spell(); silverhand.name = "Laeral"; // damage is private: -silverhand.damage = 500; +silverhand.damage = 500; // => Compilation error ``` diff --git a/exercises/concept/ellens-alien-game/.docs/introduction.md.tpl b/exercises/concept/ellens-alien-game/.docs/introduction.md.tpl index ccc7c42d..5fd766bb 100644 --- a/exercises/concept/ellens-alien-game/.docs/introduction.md.tpl +++ b/exercises/concept/ellens-alien-game/.docs/introduction.md.tpl @@ -1,3 +1,3 @@ # Introduction -%{concept:classes} \ No newline at end of file +%{concept:classes} diff --git a/exercises/concept/ellens-alien-game/.meta/design.md b/exercises/concept/ellens-alien-game/.meta/design.md index b6c34071..ea87e7ce 100644 --- a/exercises/concept/ellens-alien-game/.meta/design.md +++ b/exercises/concept/ellens-alien-game/.meta/design.md @@ -41,4 +41,4 @@ These are the concepts/concept exercises the student needs to complete/understan ## Resources -- [Class (and struct) tutorial)](https://www.learncpp.com/cpp-tutorial/classes-and-class-members/) \ No newline at end of file +- [Class (and struct) tutorial)](https://www.learncpp.com/cpp-tutorial/classes-and-class-members/) diff --git a/exercises/concept/ellens-alien-game/.meta/exemplar.cpp b/exercises/concept/ellens-alien-game/.meta/exemplar.cpp index e670bc74..85331a31 100644 --- a/exercises/concept/ellens-alien-game/.meta/exemplar.cpp +++ b/exercises/concept/ellens-alien-game/.meta/exemplar.cpp @@ -28,4 +28,4 @@ class Alien { private: int health{3}; }; -} // namespace targets \ No newline at end of file +} // namespace targets diff --git a/exercises/concept/ellens-alien-game/ellens_alien_game.cpp b/exercises/concept/ellens-alien-game/ellens_alien_game.cpp index 98820f04..ccffc725 100644 --- a/exercises/concept/ellens-alien-game/ellens_alien_game.cpp +++ b/exercises/concept/ellens-alien-game/ellens_alien_game.cpp @@ -1,4 +1,4 @@ namespace targets { // TODO: Insert the code for the alien class here -} // namespace targets \ No newline at end of file +} // namespace targets diff --git a/exercises/concept/freelancer-rates/.docs/introduction.md b/exercises/concept/freelancer-rates/.docs/introduction.md index 729d2bce..83c6c141 100644 --- a/exercises/concept/freelancer-rates/.docs/introduction.md +++ b/exercises/concept/freelancer-rates/.docs/introduction.md @@ -4,7 +4,7 @@ Integers are whole numbers like `0`, `691`, or `-2`. Floating point numbers are numbers with a decimal point like `6.02214076`, `0.1`, or `-1.616`. ## Integers -The following example shows the declaration and initialization of four different variables +The following example shows the declaration and initialization of four different variables ```cpp int m_morales{9241}; // base 10: 0-9 @@ -29,7 +29,7 @@ You can use an apostrophe to separate digits for easier readability. ## Floating-Point Numbers -The floating-point literals come in two flavors. +The floating-point literals come in two flavors. In addition to the intuitive `0.0024` it is possible to use its scientific notation `2.4e-3`. The most common floating-point type is `double`. @@ -66,9 +66,9 @@ These operators modify the current value of a variable by performing an operatio // we start with 0 people int people{}; // we need 0 eggs -int eggs{}; +int eggs{}; // two people joined: -people += 2; +people += 2; // people is now 2 // let's add 3 eggs per person eggs += 3 * people; diff --git a/exercises/concept/freelancer-rates/.docs/introduction.md.tpl b/exercises/concept/freelancer-rates/.docs/introduction.md.tpl index 376f97b2..ce74d282 100644 --- a/exercises/concept/freelancer-rates/.docs/introduction.md.tpl +++ b/exercises/concept/freelancer-rates/.docs/introduction.md.tpl @@ -1,3 +1,3 @@ # Introduction -%{concept:numbers} \ No newline at end of file +%{concept:numbers} diff --git a/exercises/concept/freelancer-rates/.meta/exemplar.cpp b/exercises/concept/freelancer-rates/.meta/exemplar.cpp index a1809a36..82035a4b 100644 --- a/exercises/concept/freelancer-rates/.meta/exemplar.cpp +++ b/exercises/concept/freelancer-rates/.meta/exemplar.cpp @@ -31,4 +31,4 @@ int days_in_budget(int budget, double hourly_rate, double discount) { double discounted_daily{daily_rate(discounted_per_hour)}; return static_cast(budget / discounted_daily); -} \ No newline at end of file +} diff --git a/exercises/concept/freelancer-rates/freelancer_rates.cpp b/exercises/concept/freelancer-rates/freelancer_rates.cpp index cdf8897b..3f57eb00 100644 --- a/exercises/concept/freelancer-rates/freelancer_rates.cpp +++ b/exercises/concept/freelancer-rates/freelancer_rates.cpp @@ -29,4 +29,4 @@ int days_in_budget(int budget, double hourly_rate, double discount) { // TODO: Implement a function that takes a budget, an hourly rate, and a // discount, and calculates how many complete days of work that covers. return 0; -} \ No newline at end of file +} diff --git a/exercises/concept/interest-is-interesting/.meta/exemplar.cpp b/exercises/concept/interest-is-interesting/.meta/exemplar.cpp index 00b3e15e..024d0027 100644 --- a/exercises/concept/interest-is-interesting/.meta/exemplar.cpp +++ b/exercises/concept/interest-is-interesting/.meta/exemplar.cpp @@ -31,4 +31,4 @@ int years_until_desired_balance(double balance, double target_balance) { balance = annual_balance_update(balance); } return years; -} \ No newline at end of file +} diff --git a/exercises/concept/interest-is-interesting/interest_is_interesting.cpp b/exercises/concept/interest-is-interesting/interest_is_interesting.cpp index 7fb33b4c..a84f04f0 100644 --- a/exercises/concept/interest-is-interesting/interest_is_interesting.cpp +++ b/exercises/concept/interest-is-interesting/interest_is_interesting.cpp @@ -22,4 +22,4 @@ double annual_balance_update(double balance) { int years_until_desired_balance(double balance, double target_balance) { // TODO: Implement the years_until_desired_balance function return 0; -} \ No newline at end of file +} diff --git a/exercises/concept/lasagna-master/.docs/introduction.md.tpl b/exercises/concept/lasagna-master/.docs/introduction.md.tpl index 5c58bbfd..81f4307d 100644 --- a/exercises/concept/lasagna-master/.docs/introduction.md.tpl +++ b/exercises/concept/lasagna-master/.docs/introduction.md.tpl @@ -1,3 +1,3 @@ # Introduction -%{concept:functions} \ No newline at end of file +%{concept:functions} diff --git a/exercises/concept/lasagna-master/.meta/design.md b/exercises/concept/lasagna-master/.meta/design.md index 5d9fbcb7..8368b845 100644 --- a/exercises/concept/lasagna-master/.meta/design.md +++ b/exercises/concept/lasagna-master/.meta/design.md @@ -41,4 +41,4 @@ The following concepts are needed to solve the exercise: The story was inspired by the [Lasagna Master Exercise in the Javascipt track][javascript-lasagna-master]. Some tasks needed to be changed though to achieve an exercise that fits the C++ learning objectives. -[javascript-lasagna-master]: https://github.com/exercism/javascript/blob/main/exercises/concept/lasagna-master/.docs/instructions.md \ No newline at end of file +[javascript-lasagna-master]: https://github.com/exercism/javascript/blob/main/exercises/concept/lasagna-master/.docs/instructions.md diff --git a/exercises/concept/lasagna/.docs/introduction.md.tpl b/exercises/concept/lasagna/.docs/introduction.md.tpl index 5f0e0140..cd2cef4e 100644 --- a/exercises/concept/lasagna/.docs/introduction.md.tpl +++ b/exercises/concept/lasagna/.docs/introduction.md.tpl @@ -1,3 +1,3 @@ # Introduction -%{concept:basics} \ No newline at end of file +%{concept:basics} diff --git a/exercises/concept/lasagna/.meta/exemplar.cpp b/exercises/concept/lasagna/.meta/exemplar.cpp index 54e61247..ffbfc663 100644 --- a/exercises/concept/lasagna/.meta/exemplar.cpp +++ b/exercises/concept/lasagna/.meta/exemplar.cpp @@ -21,4 +21,4 @@ int preparationTime(int numberOfLayers) { // far. int elapsedTime(int numberOfLayers, int actualMinutesInOven) { return preparationTime(numberOfLayers) + actualMinutesInOven; -} \ No newline at end of file +} diff --git a/exercises/concept/last-will/.docs/introduction.md.tpl b/exercises/concept/last-will/.docs/introduction.md.tpl index 10f577e2..58e43378 100644 --- a/exercises/concept/last-will/.docs/introduction.md.tpl +++ b/exercises/concept/last-will/.docs/introduction.md.tpl @@ -1,3 +1,3 @@ # Introduction -%{concept:namespaces} \ No newline at end of file +%{concept:namespaces} diff --git a/exercises/concept/last-will/.meta/exemplar.cpp b/exercises/concept/last-will/.meta/exemplar.cpp index 8031c008..ef8f15ae 100644 --- a/exercises/concept/last-will/.meta/exemplar.cpp +++ b/exercises/concept/last-will/.meta/exemplar.cpp @@ -57,4 +57,4 @@ int assemble_code() { (zhang::blue::code_fragment() + garcia::blue::code_fragment() + khan::blue::code_fragment()); } -} // namespace estate_executor \ No newline at end of file +} // namespace estate_executor diff --git a/exercises/concept/last-will/last_will.cpp b/exercises/concept/last-will/last_will.cpp index d1321286..3cb9fff8 100644 --- a/exercises/concept/last-will/last_will.cpp +++ b/exercises/concept/last-will/last_will.cpp @@ -42,4 +42,4 @@ int code_fragment() { return 923; } } // namespace blue } // namespace garcia -// Enter your code below \ No newline at end of file +// Enter your code below diff --git a/exercises/concept/log-levels/.docs/introduction.md.tpl b/exercises/concept/log-levels/.docs/introduction.md.tpl index bd4f8dd2..a0da9691 100644 --- a/exercises/concept/log-levels/.docs/introduction.md.tpl +++ b/exercises/concept/log-levels/.docs/introduction.md.tpl @@ -2,4 +2,4 @@ %{concept:includes} -%{concept:strings} \ No newline at end of file +%{concept:strings} diff --git a/exercises/concept/making-the-grade/.meta/exemplar.cpp b/exercises/concept/making-the-grade/.meta/exemplar.cpp index 797dc957..7c5cefee 100644 --- a/exercises/concept/making-the-grade/.meta/exemplar.cpp +++ b/exercises/concept/making-the-grade/.meta/exemplar.cpp @@ -52,4 +52,4 @@ std::string perfect_score(std::vector student_scores, } return ""; -} \ No newline at end of file +} diff --git a/exercises/concept/pacman-rules/.meta/exemplar.cpp b/exercises/concept/pacman-rules/.meta/exemplar.cpp index 734f47af..0ca1c6da 100644 --- a/exercises/concept/pacman-rules/.meta/exemplar.cpp +++ b/exercises/concept/pacman-rules/.meta/exemplar.cpp @@ -25,4 +25,4 @@ bool lost(bool power_pellet_active, bool touching_ghost) { bool won(bool has_eaten_all_dots, bool power_pellet_active, bool touching_ghost) { return has_eaten_all_dots && !lost(power_pellet_active, touching_ghost); -} \ No newline at end of file +} diff --git a/exercises/concept/pacman-rules/pacman_rules.cpp b/exercises/concept/pacman-rules/pacman_rules.cpp index 8160dc75..8625a259 100644 --- a/exercises/concept/pacman-rules/pacman_rules.cpp +++ b/exercises/concept/pacman-rules/pacman_rules.cpp @@ -29,4 +29,4 @@ bool won(bool has_eaten_all_dots, bool power_pellet_active, bool touching_ghost) { // TODO: Please implement the won function return false; -} \ No newline at end of file +} diff --git a/exercises/concept/power-of-troy/.docs/after.md b/exercises/concept/power-of-troy/.docs/after.md index 0c949ba6..df322194 100644 --- a/exercises/concept/power-of-troy/.docs/after.md +++ b/exercises/concept/power-of-troy/.docs/after.md @@ -6,7 +6,7 @@ They act as wrappers around raw pointers, adding additional functionality such a ## General Syntax Smart pointers are typically implemented as class templates in the C++ standard library. -The two most commonly used smart pointers are `std::unique_ptr` and `std::shared_ptr`. +The two most commonly used smart pointers are `std::unique_ptr` and `std::shared_ptr`. ## Unique Pointers @@ -82,7 +82,7 @@ auto your_flatmates_boyfriends_account = your_flatmates_account; ``` Weak pointers are useful in scenarios where cyclic references need to be broken to prevent memory leaks. -`std::weak_ptr` was designed to address the issue of cyclic ownership, also known as circular references, that can occur when using `std::shared_ptr`. +`std::weak_ptr` was designed to address the issue of cyclic ownership, also known as circular references, that can occur when using `std::shared_ptr`. In a cyclic ownership scenario, two or more `std::shared_ptr` objects are referencing each other, creating a cycle where none of the objects can be deleted because they have strong references to each other, leading to memory leaks. `std::weak_ptr` provides a solution to this problem by allowing weak references to shared objects without contributing to their reference count. This means that it can observe and access the shared object but doesn't prevent it from being deleted. diff --git a/exercises/concept/power-of-troy/.docs/introduction.md b/exercises/concept/power-of-troy/.docs/introduction.md index fb84567c..329968d5 100644 --- a/exercises/concept/power-of-troy/.docs/introduction.md +++ b/exercises/concept/power-of-troy/.docs/introduction.md @@ -49,7 +49,7 @@ They act as wrappers around raw pointers, adding additional functionality such a ## General Syntax Smart pointers are typically implemented as class templates in the C++ standard library. -The two most commonly used smart pointers are `std::unique_ptr` and `std::shared_ptr`. +The two most commonly used smart pointers are `std::unique_ptr` and `std::shared_ptr`. ## Unique Pointers diff --git a/exercises/concept/power-of-troy/.meta/exemplar.cpp b/exercises/concept/power-of-troy/.meta/exemplar.cpp index 0f7acea6..1c2ff464 100644 --- a/exercises/concept/power-of-troy/.meta/exemplar.cpp +++ b/exercises/concept/power-of-troy/.meta/exemplar.cpp @@ -24,4 +24,4 @@ int power_intensity(const human& caster) { return caster.own_power.use_count(); } -} // namespace troy \ No newline at end of file +} // namespace troy diff --git a/exercises/concept/power-of-troy/.meta/exemplar.h b/exercises/concept/power-of-troy/.meta/exemplar.h index 5e871faf..b74daa51 100644 --- a/exercises/concept/power-of-troy/.meta/exemplar.h +++ b/exercises/concept/power-of-troy/.meta/exemplar.h @@ -30,4 +30,4 @@ void manifest_power(human& receiver, std::string power_effect); void use_power(const human& caster, human& receiver); int power_intensity(const human& caster); -} // namespace troy \ No newline at end of file +} // namespace troy diff --git a/exercises/concept/speedywagon/.docs/introduction.md b/exercises/concept/speedywagon/.docs/introduction.md index fe708ac3..b11092d5 100644 --- a/exercises/concept/speedywagon/.docs/introduction.md +++ b/exercises/concept/speedywagon/.docs/introduction.md @@ -36,7 +36,7 @@ Dereferencing a pointer is done using the _indirection operator_ (`*`) operator. ```cpp std::string opponent{"Solomon Lane"}; // 'ethan' points to the address of the string opponent -std::string* ethan{&opponent}; +std::string* ethan{&opponent}; // Instead of ethan's, the opponent's name address is given to the passPort std::string passportName{*ethan}; ``` @@ -54,7 +54,7 @@ int gateCode[] = {462, 753, 218, 611, 977}; // 'ptr' points to the first element of 'gateCode' int* ptr{&gateCode[0]}; // Accesses the third Stargate address through pointer arithmetic -int dialedAddress{*(ptr + 2)}; +int dialedAddress{*(ptr + 2)}; // Chevron encoded! Dialing Stargate address: openStarGate(dialedAddress); ``` diff --git a/exercises/concept/speedywagon/.docs/introduction.md.tpl b/exercises/concept/speedywagon/.docs/introduction.md.tpl index 288c8554..8ea64871 100644 --- a/exercises/concept/speedywagon/.docs/introduction.md.tpl +++ b/exercises/concept/speedywagon/.docs/introduction.md.tpl @@ -1,3 +1,3 @@ # Introduction -%{concept:pointers} \ No newline at end of file +%{concept:pointers} diff --git a/exercises/concept/troll-the-trolls/.docs/hints.md b/exercises/concept/troll-the-trolls/.docs/hints.md index a096d4c4..8f2cc9e8 100644 --- a/exercises/concept/troll-the-trolls/.docs/hints.md +++ b/exercises/concept/troll-the-trolls/.docs/hints.md @@ -24,5 +24,3 @@ [switch]: https://www.learncpp.com/cpp-tutorial/switch-statement-basics/ [fallthrough]: https://www.learncpp.com/cpp-tutorial/switch-fallthrough-and-scoping/ - - diff --git a/exercises/concept/troll-the-trolls/.docs/instructions.md b/exercises/concept/troll-the-trolls/.docs/instructions.md index 28898431..2249d8b5 100644 --- a/exercises/concept/troll-the-trolls/.docs/instructions.md +++ b/exercises/concept/troll-the-trolls/.docs/instructions.md @@ -3,7 +3,7 @@ Your friend Helma made a small online game that rapidly gained popularity. It is called _HellMath_. The small community attracted some trolls who make the game and the forums pretty unpleasant. -Helma has asked you to work on a new permission system to separate troublemakers. +Helma has asked you to work on a new permission system to separate troublemakers. The forum supports three different actions: diff --git a/exercises/concept/troll-the-trolls/.docs/introduction.md b/exercises/concept/troll-the-trolls/.docs/introduction.md index 07718a20..ca72911d 100644 --- a/exercises/concept/troll-the-trolls/.docs/introduction.md +++ b/exercises/concept/troll-the-trolls/.docs/introduction.md @@ -46,7 +46,7 @@ enum class WheelMaterial { plastic }; ``` -Although the wheels and the deck can both be made of _plastic_, the two cannot be confused. +Although the wheels and the deck can both be made of _plastic_, the two cannot be confused. They are different _types_: `DeckMaterial` plastic and `WheelMaterial` plastic. Each `enumeration` will have its `enumerators` in its own scope - its own `namespace`. This is the reason they are called `scoped enumerations`. @@ -57,7 +57,7 @@ You might be thinking that with a name like `scoped`, there would also be _`uns `Unscoped enumerations` are becoming less popular because they all share the same global namespace. Because of the sharing, you could not have two `unscoped enumerations` with the same `enumerators` like _plastic_ in the example above. -Also, `unscoped enumerations` implicitly convert to integers. +Also, `unscoped enumerations` implicitly convert to integers. Look at the example below for a surprising result: ```cpp diff --git a/exercises/concept/troll-the-trolls/.docs/introduction.md.tpl b/exercises/concept/troll-the-trolls/.docs/introduction.md.tpl index 18a9e714..3c19d907 100644 --- a/exercises/concept/troll-the-trolls/.docs/introduction.md.tpl +++ b/exercises/concept/troll-the-trolls/.docs/introduction.md.tpl @@ -2,4 +2,4 @@ %{concept:enums} -%{concept:switch} \ No newline at end of file +%{concept:switch} diff --git a/exercises/concept/troll-the-trolls/.meta/design.md b/exercises/concept/troll-the-trolls/.meta/design.md index d68ff7f4..ccc20372 100644 --- a/exercises/concept/troll-the-trolls/.meta/design.md +++ b/exercises/concept/troll-the-trolls/.meta/design.md @@ -16,7 +16,7 @@ As this is an advanced exercise, there are no enum-related things that we should - `enums` - `switch` -- +- ## Prerequisites This exercise's prerequisites Concepts are: diff --git a/exercises/concept/troll-the-trolls/.meta/exemplar.cpp b/exercises/concept/troll-the-trolls/.meta/exemplar.cpp index 0641e605..e8ee0916 100644 --- a/exercises/concept/troll-the-trolls/.meta/exemplar.cpp +++ b/exercises/concept/troll-the-trolls/.meta/exemplar.cpp @@ -41,4 +41,4 @@ bool has_priority(AccountStatus player1, AccountStatus player2) { return static_cast(player1) > static_cast(player2); } -} // namespace hellmath \ No newline at end of file +} // namespace hellmath diff --git a/exercises/concept/troll-the-trolls/troll_the_trolls.cpp b/exercises/concept/troll-the-trolls/troll_the_trolls.cpp index 1ef38f9d..a42c386b 100644 --- a/exercises/concept/troll-the-trolls/troll_the_trolls.cpp +++ b/exercises/concept/troll-the-trolls/troll_the_trolls.cpp @@ -22,4 +22,4 @@ namespace hellmath { // `AccountStatus` arguments and returns `true`, if and only if the first // account has a strictly higher priority than the second. -} // namespace hellmath \ No newline at end of file +} // namespace hellmath diff --git a/exercises/concept/vehicle-purchase/.docs/introduction.md b/exercises/concept/vehicle-purchase/.docs/introduction.md index 42438101..ef98613b 100644 --- a/exercises/concept/vehicle-purchase/.docs/introduction.md +++ b/exercises/concept/vehicle-purchase/.docs/introduction.md @@ -29,7 +29,7 @@ Here are some common examples: ```cpp bool eq3 = 2 == 3; // false, integer comparison -bool eq4 = 2.1 != 2.2; // true, float comparison +bool eq4 = 2.1 != 2.2; // true, float comparison bool eq5 = "hello" == "hello"; // true, string comparison ``` diff --git a/exercises/concept/vehicle-purchase/.docs/introduction.md.tpl b/exercises/concept/vehicle-purchase/.docs/introduction.md.tpl index 058d70af..875c00fa 100644 --- a/exercises/concept/vehicle-purchase/.docs/introduction.md.tpl +++ b/exercises/concept/vehicle-purchase/.docs/introduction.md.tpl @@ -2,4 +2,4 @@ %{concept:comparisons} -%{concept:if-statements} \ No newline at end of file +%{concept:if-statements} diff --git a/exercises/concept/vehicle-purchase/.meta/exemplar.cpp b/exercises/concept/vehicle-purchase/.meta/exemplar.cpp index 64967130..8a734eea 100644 --- a/exercises/concept/vehicle-purchase/.meta/exemplar.cpp +++ b/exercises/concept/vehicle-purchase/.meta/exemplar.cpp @@ -30,4 +30,4 @@ double calculate_resell_price(double original_price, double age) { return original_price * discount; } -} // namespace vehicle_purchase \ No newline at end of file +} // namespace vehicle_purchase diff --git a/exercises/concept/vehicle-purchase/CMakeLists.txt b/exercises/concept/vehicle-purchase/CMakeLists.txt index 24d8a62a..45a584fe 100644 --- a/exercises/concept/vehicle-purchase/CMakeLists.txt +++ b/exercises/concept/vehicle-purchase/CMakeLists.txt @@ -70,4 +70,3 @@ endif() # Run the tests on every build add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise}) - diff --git a/exercises/concept/vehicle-purchase/vehicle_purchase.cpp b/exercises/concept/vehicle-purchase/vehicle_purchase.cpp index b392d9bd..613e11df 100644 --- a/exercises/concept/vehicle-purchase/vehicle_purchase.cpp +++ b/exercises/concept/vehicle-purchase/vehicle_purchase.cpp @@ -23,4 +23,4 @@ double calculate_resell_price(double original_price, double age) { return 0.0; } -} // namespace vehicle_purchase \ No newline at end of file +} // namespace vehicle_purchase diff --git a/exercises/practice/affine-cipher/.meta/example.cpp b/exercises/practice/affine-cipher/.meta/example.cpp index 60c57e5c..886a571d 100644 --- a/exercises/practice/affine-cipher/.meta/example.cpp +++ b/exercises/practice/affine-cipher/.meta/example.cpp @@ -62,4 +62,4 @@ std::string decode(const std::string& text, int a, int b) { return out; } -} // namespace affine_cipher \ No newline at end of file +} // namespace affine_cipher diff --git a/exercises/practice/affine-cipher/.meta/example.h b/exercises/practice/affine-cipher/.meta/example.h index 035300d7..05cf34ce 100644 --- a/exercises/practice/affine-cipher/.meta/example.h +++ b/exercises/practice/affine-cipher/.meta/example.h @@ -7,4 +7,4 @@ namespace affine_cipher { std::string encode(const std::string& input, int a, int b); std::string decode(const std::string& input, int a, int b); -} // namespace affine_cipher \ No newline at end of file +} // namespace affine_cipher diff --git a/exercises/practice/affine-cipher/affine_cipher.cpp b/exercises/practice/affine-cipher/affine_cipher.cpp index 671caf3e..9f8665fc 100644 --- a/exercises/practice/affine-cipher/affine_cipher.cpp +++ b/exercises/practice/affine-cipher/affine_cipher.cpp @@ -4,4 +4,4 @@ namespace affine_cipher { // TODO: add your solution here -} // namespace affine_cipher \ No newline at end of file +} // namespace affine_cipher diff --git a/exercises/practice/affine-cipher/affine_cipher.h b/exercises/practice/affine-cipher/affine_cipher.h index f400dec1..b8d6ddfa 100644 --- a/exercises/practice/affine-cipher/affine_cipher.h +++ b/exercises/practice/affine-cipher/affine_cipher.h @@ -7,4 +7,4 @@ namespace affine_cipher { } // namespace affine_cipher -#endif // AFFINE_CIPHER_H \ No newline at end of file +#endif // AFFINE_CIPHER_H diff --git a/exercises/practice/affine-cipher/affine_cipher_test.cpp b/exercises/practice/affine-cipher/affine_cipher_test.cpp index b36c6b90..8cea17f7 100644 --- a/exercises/practice/affine-cipher/affine_cipher_test.cpp +++ b/exercises/practice/affine-cipher/affine_cipher_test.cpp @@ -88,4 +88,4 @@ TEST_CASE("decode_with_a_not_coprime_to_m", std::invalid_argument); } -#endif \ No newline at end of file +#endif diff --git a/exercises/practice/all-your-base/.approaches/in-parallel/content.md b/exercises/practice/all-your-base/.approaches/in-parallel/content.md index 52869d0b..b72621f6 100644 --- a/exercises/practice/all-your-base/.approaches/in-parallel/content.md +++ b/exercises/practice/all-your-base/.approaches/in-parallel/content.md @@ -13,7 +13,7 @@ A simple serial for-loop can be a lot faster for a small number than a [parallel ## Converting the `input_digits` -### Numeric's `accumulate` +### Numeric's `accumulate` The for-loop with `*` and `+` can be written with the [`accumulate`][acuumulate-function] function from the [`numeric`][numeric-header] header. @@ -94,10 +94,10 @@ unsigned int digit_limit{static_cast(std::log(intermediate) / std: std::vector output_digits(digit_limit); std::iota(output_digits.rbegin(), output_digits.rend(), 1); std::for_each(std::execution::par_unseq, - output_digits.begin(), - output_digits.end(), + output_digits.begin(), + output_digits.end(), [&](unsigned int digit) { - output_digits[digit_limit - digit] = + output_digits[digit_limit - digit] = intermediate / static_cast(std::pow(output_base, digit - 1)) % output_base; @@ -151,7 +151,7 @@ std::vector convert(unsigned int input_base, output_digits.begin(), output_digits.end(), [&](unsigned int digit) { - output_digits[digit_limit - digit] = + output_digits[digit_limit - digit] = intermediate / static_cast(std::pow(output_base, digit - 1)) % output_base; }); @@ -174,5 +174,5 @@ std::vector convert(unsigned int input_base, [execution-policies]: https://en.cppreference.com/w/cpp/algorithm/execution_policy_tag_t [tbb]: https://github.com/oneapi-src/oneTBB [in-sequence]: https://exercism.org/tracks/cpp/exercises/all-your-base/approaches/in-sequence -[for-loop]: https://en.cppreference.com/w/cpp/language/for +[for-loop]: https://en.cppreference.com/w/cpp/language/for [for-each]: https://en.cppreference.com/w/cpp/algorithm/for_each diff --git a/exercises/practice/all-your-base/.approaches/in-parallel/snippet.txt b/exercises/practice/all-your-base/.approaches/in-parallel/snippet.txt index 60e55432..1867dd63 100644 --- a/exercises/practice/all-your-base/.approaches/in-parallel/snippet.txt +++ b/exercises/practice/all-your-base/.approaches/in-parallel/snippet.txt @@ -5,4 +5,4 @@ unsigned int intermediate = std::transform_reduce(std::execution::par_unseq, positions.crbegin(), 0U, std::plus {}, [ & input_base](unsigned int d, unsigned int pos) { return d * std::pow(input_base, pos); - }); \ No newline at end of file + }); diff --git a/exercises/practice/all-your-base/.approaches/in-sequence/content.md b/exercises/practice/all-your-base/.approaches/in-sequence/content.md index 639082cf..a35a900b 100644 --- a/exercises/practice/all-your-base/.approaches/in-sequence/content.md +++ b/exercises/practice/all-your-base/.approaches/in-sequence/content.md @@ -75,7 +75,7 @@ When you need both the remainder and the quotient from a division operation, you ```cpp std::vector output_digits{}; -std::ldiv_t v{intermediate, 0}; +std::ldiv_t v{intermediate, 0}; while (v.quot > 0) { v = std::div(v.quot, output_base); output_digits.emplace_back(v.rem); @@ -107,19 +107,19 @@ std::vector convert(unsigned int input_base, throw std::invalid_argument("Bases must be at least 2"); unsigned int intermediate = 0; for (unsigned int d : input_digits) { - if (d >= input_base) + if (d >= input_base) throw std::invalid_argument("Digits cannot be bigger than the base"); intermediate = intermediate * input_base + d; } std::vector output_digits{}; - std::ldiv_t v{intermediate, 0}; + std::ldiv_t v{intermediate, 0}; while (v.quot > 0) { v = std::div(v.quot, output_base); output_digits.emplace_back(v.rem); } - + std::reverse(output_digits.begin(), output_digits.end()); - + return output_digits; } ``` @@ -129,7 +129,7 @@ std::vector convert(unsigned int input_base, [pow-function]: https://en.cppreference.com/w/cpp/numeric/math/pow [reverse-string]: https://exercism.org/tracks/cpp/exercises/reverse-string/dig_deeper [parallel-computing]: https://en.wikipedia.org/wiki/Parallel_computing -[while-loop]: https://en.cppreference.com/w/cpp/language/while -[for-loop]: https://en.cppreference.com/w/cpp/language/for +[while-loop]: https://en.cppreference.com/w/cpp/language/while +[for-loop]: https://en.cppreference.com/w/cpp/language/for [algorithm-header]: https://en.cppreference.com/w/cpp/algorithm [div-function]: https://en.cppreference.com/w/cpp/numeric/math/div diff --git a/exercises/practice/all-your-base/.approaches/in-sequence/snippet.txt b/exercises/practice/all-your-base/.approaches/in-sequence/snippet.txt index 34297d5d..0918777e 100644 --- a/exercises/practice/all-your-base/.approaches/in-sequence/snippet.txt +++ b/exercises/practice/all-your-base/.approaches/in-sequence/snippet.txt @@ -5,4 +5,4 @@ std::vector output_digits{}; while (intermediate > 0) { output_digits.emplace_back(intermediate % output_base); intermediate /= output_base; -} \ No newline at end of file +} diff --git a/exercises/practice/all-your-base/.approaches/introduction.md b/exercises/practice/all-your-base/.approaches/introduction.md index 78e55c97..89788abb 100644 --- a/exercises/practice/all-your-base/.approaches/introduction.md +++ b/exercises/practice/all-your-base/.approaches/introduction.md @@ -56,10 +56,10 @@ std::vector output_digits(digit_limit); std::iota(output_digits.rbegin(), output_digits.rend(), 1); std::for_each( std::execution::par_unseq, - output_digits.begin(), - output_digits.end(), + output_digits.begin(), + output_digits.end(), [&](unsigned int digit) { - output_digits[digit_limit - digit] = + output_digits[digit_limit - digit] = intermediate / static_cast(std::pow(output_base, digit - 1)) % output_base; diff --git a/exercises/practice/allergies/.docs/instructions.append.md b/exercises/practice/allergies/.docs/instructions.append.md index 72a9cd43..ce6eb03b 100644 --- a/exercises/practice/allergies/.docs/instructions.append.md +++ b/exercises/practice/allergies/.docs/instructions.append.md @@ -1,5 +1,5 @@ # Instructions append - + ## Some Additional Notes for C++ Implementation This exercise uses the [`unordered_set`][set] diff --git a/exercises/practice/alphametics/.meta/example.h b/exercises/practice/alphametics/.meta/example.h index 9fc3bb6e..e5fbdc1b 100644 --- a/exercises/practice/alphametics/.meta/example.h +++ b/exercises/practice/alphametics/.meta/example.h @@ -8,4 +8,4 @@ namespace alphametics { std::optional> solve(const std::string& puzzle); -} // namespace alphametics \ No newline at end of file +} // namespace alphametics diff --git a/exercises/practice/alphametics/alphametics.h b/exercises/practice/alphametics/alphametics.h index bbbdf05d..b3b7f726 100644 --- a/exercises/practice/alphametics/alphametics.h +++ b/exercises/practice/alphametics/alphametics.h @@ -7,4 +7,4 @@ namespace alphametics { } // namespace alphametics -#endif // ALPHAMETICS_H \ No newline at end of file +#endif // ALPHAMETICS_H diff --git a/exercises/practice/alphametics/alphametics_test.cpp b/exercises/practice/alphametics/alphametics_test.cpp index 436ad1ee..7dbdb0a1 100644 --- a/exercises/practice/alphametics/alphametics_test.cpp +++ b/exercises/practice/alphametics/alphametics_test.cpp @@ -160,4 +160,4 @@ TEST_CASE("puzzle_with_ten_letters_and_199_addends", REQUIRE(m.at('T') == 9); } -#endif \ No newline at end of file +#endif diff --git a/exercises/practice/armstrong-numbers/.meta/example.cpp b/exercises/practice/armstrong-numbers/.meta/example.cpp index 662081f6..86b8496b 100644 --- a/exercises/practice/armstrong-numbers/.meta/example.cpp +++ b/exercises/practice/armstrong-numbers/.meta/example.cpp @@ -11,4 +11,4 @@ bool armstrong_numbers::is_armstrong_number(int number) { accumulate += std::pow(current % 10, length); } return accumulate == number; -} \ No newline at end of file +} diff --git a/exercises/practice/armstrong-numbers/armstrong_numbers_test.cpp b/exercises/practice/armstrong-numbers/armstrong_numbers_test.cpp index 8db31c23..20c76b30 100644 --- a/exercises/practice/armstrong-numbers/armstrong_numbers_test.cpp +++ b/exercises/practice/armstrong-numbers/armstrong_numbers_test.cpp @@ -43,4 +43,4 @@ TEST_CASE("seven_digit_number_that_is_an_armstrong_number") { TEST_CASE("seven_digit_number_that_is_not_an_armstrong_number") { REQUIRE_FALSE(armstrong_numbers::is_armstrong_number(9926314)); } -#endif // !EXERCISM_RUN_ALL_TESTS \ No newline at end of file +#endif // !EXERCISM_RUN_ALL_TESTS diff --git a/exercises/practice/bank-account/bank_account.cpp b/exercises/practice/bank-account/bank_account.cpp index ac7a1669..7ee61e27 100644 --- a/exercises/practice/bank-account/bank_account.cpp +++ b/exercises/practice/bank-account/bank_account.cpp @@ -1,3 +1,3 @@ #include "bank_account.h" -namespace Bankaccount {} \ No newline at end of file +namespace Bankaccount {} diff --git a/exercises/practice/bank-account/bank_account_test.cpp b/exercises/practice/bank-account/bank_account_test.cpp index 32f8aed8..32888a3c 100644 --- a/exercises/practice/bank-account/bank_account_test.cpp +++ b/exercises/practice/bank-account/bank_account_test.cpp @@ -165,4 +165,4 @@ TEST_CASE("Can handle concurrent transactions", REQUIRE(account.balance() == 0); } -#endif \ No newline at end of file +#endif diff --git a/exercises/practice/binary-search/.approaches/introduction.md b/exercises/practice/binary-search/.approaches/introduction.md index b1596548..d8cd6c09 100644 --- a/exercises/practice/binary-search/.approaches/introduction.md +++ b/exercises/practice/binary-search/.approaches/introduction.md @@ -29,9 +29,9 @@ namespace binary_search { if (look == value) return mid; if (look < value) left = mid + 1; else right = mid; - } + } throw std::domain_error("Value not found. No soup for you!"); - } + } } // namespace binary_search ``` diff --git a/exercises/practice/binary-search/.approaches/while-with-if-statements/content.md b/exercises/practice/binary-search/.approaches/while-with-if-statements/content.md index 8fe0ef06..cf952d18 100644 --- a/exercises/practice/binary-search/.approaches/while-with-if-statements/content.md +++ b/exercises/practice/binary-search/.approaches/while-with-if-statements/content.md @@ -1,4 +1,4 @@ -# +# ## Approach: `while` loop with `if` statements **binary_search.h** @@ -25,9 +25,9 @@ namespace binary_search { if (look == value) return mid; if (look < value) left = mid + 1; else right = mid; - } + } throw std::domain_error("Value not found. No soup for you!"); - } + } } // namespace binary_search ``` @@ -69,4 +69,3 @@ The loop exits and a [std::domain_error][domain-error] is returned from the func [if]: https://en.cppreference.com/w/cpp/language/if [domain-error]: https://en.cppreference.com/w/cpp/error/domain_error [mid-bug]: https://ai.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html - diff --git a/exercises/practice/binary-search/.approaches/while-with-if-statements/snippet.txt b/exercises/practice/binary-search/.approaches/while-with-if-statements/snippet.txt index 1020f34d..4c520bae 100644 --- a/exercises/practice/binary-search/.approaches/while-with-if-statements/snippet.txt +++ b/exercises/practice/binary-search/.approaches/while-with-if-statements/snippet.txt @@ -4,5 +4,5 @@ while (left < right) { if (look == value) return mid; if (look < value) left = mid + 1; else right = mid; -} +} throw std::domain_error("Value not found."); diff --git a/exercises/practice/collatz-conjecture/.meta/example.cpp b/exercises/practice/collatz-conjecture/.meta/example.cpp index 5f89108a..f0bcacff 100644 --- a/exercises/practice/collatz-conjecture/.meta/example.cpp +++ b/exercises/practice/collatz-conjecture/.meta/example.cpp @@ -11,4 +11,4 @@ int collatz_conjecture::steps(int value) { ++step; } return step; -} \ No newline at end of file +} diff --git a/exercises/practice/complex-numbers/complex_numbers_test.cpp b/exercises/practice/complex-numbers/complex_numbers_test.cpp index 30b23a8c..bbaf6feb 100644 --- a/exercises/practice/complex-numbers/complex_numbers_test.cpp +++ b/exercises/practice/complex-numbers/complex_numbers_test.cpp @@ -353,7 +353,7 @@ TEST_CASE( TEST_CASE( // clang-format off "Operations between real numbers and complex numbers -> Divide complex number by real number", - // clang-format on + // clang-format on "[8a400f75-710e-4d0c-bcb4-5e5a00c78aa0]") { const Complex c{10.0, 100.0}; diff --git a/exercises/practice/darts/darts.cpp b/exercises/practice/darts/darts.cpp index 2d313dd6..f1349a44 100644 --- a/exercises/practice/darts/darts.cpp +++ b/exercises/practice/darts/darts.cpp @@ -4,4 +4,4 @@ namespace darts { // TODO: add your solution here -} // namespace darts \ No newline at end of file +} // namespace darts diff --git a/exercises/practice/high-scores/.docs/instructions.append.md b/exercises/practice/high-scores/.docs/instructions.append.md index 312435fd..8f90adf1 100644 --- a/exercises/practice/high-scores/.docs/instructions.append.md +++ b/exercises/practice/high-scores/.docs/instructions.append.md @@ -1,5 +1,5 @@ # Instructions append - + ## Some Additional Notes for C++ Implementation This exercise uses the [vector container][vector]. diff --git a/exercises/practice/high-scores/high_scores_test.cpp b/exercises/practice/high-scores/high_scores_test.cpp index 9224f5c9..d8854f10 100644 --- a/exercises/practice/high-scores/high_scores_test.cpp +++ b/exercises/practice/high-scores/high_scores_test.cpp @@ -114,4 +114,4 @@ TEST_CASE( REQUIRE(hs.list_scores() == scores); } -#endif \ No newline at end of file +#endif diff --git a/exercises/practice/isbn-verifier/isbn_verifier.cpp b/exercises/practice/isbn-verifier/isbn_verifier.cpp index 70867dcb..84bdc3a9 100644 --- a/exercises/practice/isbn-verifier/isbn_verifier.cpp +++ b/exercises/practice/isbn-verifier/isbn_verifier.cpp @@ -4,4 +4,4 @@ namespace isbn_verifier { // TODO: add your solution here -} // namespace isbn_verifier \ No newline at end of file +} // namespace isbn_verifier diff --git a/exercises/practice/largest-series-product/largest_series_product.cpp b/exercises/practice/largest-series-product/largest_series_product.cpp index 41a95ed0..ad1b5812 100644 --- a/exercises/practice/largest-series-product/largest_series_product.cpp +++ b/exercises/practice/largest-series-product/largest_series_product.cpp @@ -4,4 +4,4 @@ namespace largest_series_product { // TODO: add your solution here -} // namespace largest_series_product \ No newline at end of file +} // namespace largest_series_product diff --git a/exercises/practice/leap/.approaches/boolean-chain/snippet.txt b/exercises/practice/leap/.approaches/boolean-chain/snippet.txt index de02bdc9..8ac824be 100644 --- a/exercises/practice/leap/.approaches/boolean-chain/snippet.txt +++ b/exercises/practice/leap/.approaches/boolean-chain/snippet.txt @@ -1,3 +1,3 @@ bool is_leap_year(int year) { return (year % 4 == 0) && (year % 100 != 0 || year % 400 == 0); -} \ No newline at end of file +} diff --git a/exercises/practice/leap/.approaches/introduction.md b/exercises/practice/leap/.approaches/introduction.md index 7116eb5e..6afcb8d2 100644 --- a/exercises/practice/leap/.approaches/introduction.md +++ b/exercises/practice/leap/.approaches/introduction.md @@ -69,4 +69,4 @@ If you cannot use C++20 features, you might consider falling back on the [boost [ternary-operator]: https://www.learncpp.com/cpp-tutorial/the-conditional-operator/ [approach-boolean-chain]: https://exercism.org/tracks/cpp/exercises/leap/approaches/boolean-chain [approach-ternary-operator]: https://exercism.org/tracks/cpp/exercises/leap/approaches/ternary-operator -[boost-library]: https://www.boost.org/doc/libs/1_31_0/libs/date_time/doc/class_gregorian_calendar.html#functions \ No newline at end of file +[boost-library]: https://www.boost.org/doc/libs/1_31_0/libs/date_time/doc/class_gregorian_calendar.html#functions diff --git a/exercises/practice/leap/.approaches/ternary-operator/snippet.txt b/exercises/practice/leap/.approaches/ternary-operator/snippet.txt index 092b1edf..3f307c07 100644 --- a/exercises/practice/leap/.approaches/ternary-operator/snippet.txt +++ b/exercises/practice/leap/.approaches/ternary-operator/snippet.txt @@ -1,3 +1,3 @@ bool is_leap_year(int year) { return year % 100 == 0 ? year % 400 == 0 : year % 4 == 0; -} \ No newline at end of file +} diff --git a/exercises/practice/leap/.articles/performance/.gitignore b/exercises/practice/leap/.articles/performance/.gitignore index e5174594..3670e3ea 100644 --- a/exercises/practice/leap/.articles/performance/.gitignore +++ b/exercises/practice/leap/.articles/performance/.gitignore @@ -1,2 +1,2 @@ benchmark/* -!benchmark/leap_benchmark.cpp \ No newline at end of file +!benchmark/leap_benchmark.cpp diff --git a/exercises/practice/leap/.articles/performance/benchmark/leap_benchmark.cpp b/exercises/practice/leap/.articles/performance/benchmark/leap_benchmark.cpp index 04e13fe5..81cad193 100644 --- a/exercises/practice/leap/.articles/performance/benchmark/leap_benchmark.cpp +++ b/exercises/practice/leap/.articles/performance/benchmark/leap_benchmark.cpp @@ -84,4 +84,4 @@ static void BM_empty_read(benchmark::State& state) { } BENCHMARK(BM_empty_read); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/exercises/practice/leap/.articles/performance/snippet.md b/exercises/practice/leap/.articles/performance/snippet.md index e360ab3c..df92d509 100644 --- a/exercises/practice/leap/.articles/performance/snippet.md +++ b/exercises/practice/leap/.articles/performance/snippet.md @@ -4,4 +4,4 @@ | Ternary | 15.86 | 127 | | Chrono | 14.816 | 119 | | Boost | 26.691 | 214 | -| Inverse Chain | 27.178 | 218 | \ No newline at end of file +| Inverse Chain | 27.178 | 218 | diff --git a/exercises/practice/linked-list/linked_list.cpp b/exercises/practice/linked-list/linked_list.cpp index e7786eb9..54fe90e8 100644 --- a/exercises/practice/linked-list/linked_list.cpp +++ b/exercises/practice/linked-list/linked_list.cpp @@ -4,4 +4,4 @@ namespace linked_list { // TODO: add your solution here -} // namespace linked_list \ No newline at end of file +} // namespace linked_list diff --git a/exercises/practice/pangram/.approaches/bitset-all/content.md b/exercises/practice/pangram/.approaches/bitset-all/content.md index 1fdf2070..6191d28f 100644 --- a/exercises/practice/pangram/.approaches/bitset-all/content.md +++ b/exercises/practice/pangram/.approaches/bitset-all/content.md @@ -34,7 +34,7 @@ This approach starts be defining a [`bitset`][bitset] to keep track of the used A [range-based `for` loop][ranged-for] iterates over all of the characters in the input phrase [`string_view`][stringview]. Each character is tested by the [`isalpha()`][isalpha] function to see if it is considered an alphabetic character according to the currently installed C locale. -If the currently installed locale is not suitable for the English alphabet, then [`std::locale::classic()`][locale-classic] can be passed to the [`isalpha()`][isalpha-locale] function defined in [<locale>][locale], like so: +If the currently installed locale is not suitable for the English alphabet, then [`std::locale::classic()`][locale-classic] can be passed to the [`isalpha()`][isalpha-locale] function defined in [<locale>][locale], like so: ```cpp #include diff --git a/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md b/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md index d643b8a2..46b095c2 100644 --- a/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md +++ b/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md @@ -1,5 +1,5 @@ # Instructions append - + ## Additional Notes for C++ Implementation There are several ways how to achieve parallelism in C++. diff --git a/exercises/practice/parallel-letter-frequency/.meta/config.json b/exercises/practice/parallel-letter-frequency/.meta/config.json index a6fbf190..fbcd09c9 100644 --- a/exercises/practice/parallel-letter-frequency/.meta/config.json +++ b/exercises/practice/parallel-letter-frequency/.meta/config.json @@ -16,4 +16,4 @@ ] }, "blurb": "Count the frequency of letters in texts using parallel computation." -} \ No newline at end of file +} diff --git a/exercises/practice/perfect-numbers/.meta/example.cpp b/exercises/practice/perfect-numbers/.meta/example.cpp index c6233bb1..6d70ce24 100644 --- a/exercises/practice/perfect-numbers/.meta/example.cpp +++ b/exercises/practice/perfect-numbers/.meta/example.cpp @@ -36,4 +36,4 @@ classification classify(int n) { } return classification::perfect; } -} // namespace perfect_numbers \ No newline at end of file +} // namespace perfect_numbers diff --git a/exercises/practice/phone-number/phone_number_test.cpp b/exercises/practice/phone-number/phone_number_test.cpp index 2757bb22..7f3d6a0c 100644 --- a/exercises/practice/phone-number/phone_number_test.cpp +++ b/exercises/practice/phone-number/phone_number_test.cpp @@ -111,4 +111,4 @@ TEST_CASE("invalid_if_exchange_code_starts_with_1_on_valid_11_digit_number", std::domain_error); } -#endif \ No newline at end of file +#endif diff --git a/exercises/practice/reverse-string/.approaches/direct-construction/content.md b/exercises/practice/reverse-string/.approaches/direct-construction/content.md index 1c930fed..b1ebc8ad 100644 --- a/exercises/practice/reverse-string/.approaches/direct-construction/content.md +++ b/exercises/practice/reverse-string/.approaches/direct-construction/content.md @@ -71,4 +71,3 @@ This is a great approach, it is concise and easy to read (once you know about th [cppref-stringview]: https://en.cppreference.com/w/cpp/string/basic_string_view [cppref-string-ctor]: https://en.cppreference.com/w/cpp/string/basic_string/basic_string - diff --git a/exercises/practice/reverse-string/.approaches/divide-and-conquer/content.md b/exercises/practice/reverse-string/.approaches/divide-and-conquer/content.md index 7c3edbe9..6c45a8b8 100644 --- a/exercises/practice/reverse-string/.approaches/divide-and-conquer/content.md +++ b/exercises/practice/reverse-string/.approaches/divide-and-conquer/content.md @@ -91,4 +91,3 @@ Therefore it is mostly presented as an interesting idea. [wiki-divide-and-conquer]: https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm [wiki-quasilinear-time]: https://en.wikipedia.org/wiki/Time_complexity#Quasilinear_time [approach-linear-recursion]: https://exercism.org/tracks/cpp/exercises/reverse-string/approaches/linear-recursion - diff --git a/exercises/practice/reverse-string/.approaches/introduction.md b/exercises/practice/reverse-string/.approaches/introduction.md index a0afe318..5cfeda24 100644 --- a/exercises/practice/reverse-string/.approaches/introduction.md +++ b/exercises/practice/reverse-string/.approaches/introduction.md @@ -178,7 +178,7 @@ std::string reverse_string(std::string_view original) This approach builds the reversed string by using linear recursion. It creates an empty string and passes that as an "output parameter" to the recursive helper function. -That helper function removes the last character from the input, appends it to the output, and calls itself recursively. +That helper function removes the last character from the input, appends it to the output, and calls itself recursively. Be careful: That is only safe if you know what you are doing. For more information check out the [Linear Recursion][approach-linear-recursion] approach. @@ -248,4 +248,3 @@ For more information check out the [Over-Engineered][approach-over-engineered] a [approach-linear-recursion]: https://exercism.org/tracks/cpp/exercises/reverse-string/approaches/linear-recursion [approach-divide-and-conquer]: https://exercism.org/tracks/cpp/exercises/reverse-string/approaches/divide-and-conquer [approach-over-engineered]: https://exercism.org/tracks/cpp/exercises/reverse-string/approaches/over-engineered - diff --git a/exercises/practice/reverse-string/.approaches/iterative/content.md b/exercises/practice/reverse-string/.approaches/iterative/content.md index b5e2c45d..06fe6f68 100644 --- a/exercises/practice/reverse-string/.approaches/iterative/content.md +++ b/exercises/practice/reverse-string/.approaches/iterative/content.md @@ -127,4 +127,3 @@ Check out the [Direct Construction][approach-direct-construction] approach. [cppref-string-pushback]: https://en.cppreference.com/w/cpp/string/basic_string/push_back [cppref-string-operator-plus-equal]: https://en.cppreference.com/w/cpp/string/basic_string/operator%2B%3D [approach-direct-construction]: https://exercism.org/tracks/cpp/exercises/reverse-string/approaches/direct-construction - diff --git a/exercises/practice/reverse-string/.approaches/linear-recursion/content.md b/exercises/practice/reverse-string/.approaches/linear-recursion/content.md index 1d733111..a3831e83 100644 --- a/exercises/practice/reverse-string/.approaches/linear-recursion/content.md +++ b/exercises/practice/reverse-string/.approaches/linear-recursion/content.md @@ -105,4 +105,3 @@ Therefore it is only presented as an interesting idea and to warn about linear r [cppref-stringview-removesuffix]: https://en.cppreference.com/w/cpp/string/basic_string_view/remove_suffix [wiki-stack-overflow]: https://en.wikipedia.org/wiki/Stack_overflow [wiki-tail-call]: https://en.wikipedia.org/wiki/Tail_call - diff --git a/exercises/practice/reverse-string/.approaches/over-engineered/content.md b/exercises/practice/reverse-string/.approaches/over-engineered/content.md index 3ac5490d..14fac602 100644 --- a/exercises/practice/reverse-string/.approaches/over-engineered/content.md +++ b/exercises/practice/reverse-string/.approaches/over-engineered/content.md @@ -61,7 +61,7 @@ That is helpful in situations where either the result contains some error code t ## Overloading functions In C++ it is possible (and quite common) to define multiple different functions with the same name but different parameter (different number of parameter or different parameter types.) -When an overloaded function is called the compiler collects all candidate with that name, trims the set of candidate to the *viable* ones, and then selects the best fit for the function call (see [cppreference.com][cppref-overload-resolution]). +When an overloaded function is called the compiler collects all candidate with that name, trims the set of candidate to the *viable* ones, and then selects the best fit for the function call (see [cppreference.com][cppref-overload-resolution]). Overloading function is often done if these functions perform the same task *conceptually* but in a slightly different way, depending on the arguments. @@ -144,4 +144,3 @@ Therefore this "over-engineered approach" is not meant as the *best* approach, b [cppref-attributes]: https://en.cppreference.com/w/cpp/language/attributes [cppref-overload-resolution]: https://en.cppreference.com/w/cpp/language/overload_resolution [cppref-noexcept]: https://en.cppreference.com/w/cpp/language/noexcept_spec - diff --git a/exercises/practice/reverse-string/.approaches/stack-operations/content.md b/exercises/practice/reverse-string/.approaches/stack-operations/content.md index a2c35ac4..7b78ccfc 100644 --- a/exercises/practice/reverse-string/.approaches/stack-operations/content.md +++ b/exercises/practice/reverse-string/.approaches/stack-operations/content.md @@ -89,4 +89,3 @@ It is mostly presented as an interesting idea and unique way to think about the [cppref-stringview-back]: https://en.cppreference.com/w/cpp/string/basic_string_view/back [cppref-string-removesuffix]: https://en.cppreference.com/w/cpp/string/basic_string_view/remove_suffix [cppref-string-pushback]: https://en.cppreference.com/w/cpp/string/basic_string/push_back - diff --git a/exercises/practice/reverse-string/.approaches/swapping-characters/content.md b/exercises/practice/reverse-string/.approaches/swapping-characters/content.md index a3e72093..7369dd2b 100644 --- a/exercises/practice/reverse-string/.approaches/swapping-characters/content.md +++ b/exercises/practice/reverse-string/.approaches/swapping-characters/content.md @@ -51,7 +51,7 @@ std::string reverse_string(std::string str) The function takes its argument "by value" (`std::string`). That means the parameter `str` gets constructed from the argument that the caller passes to the function, and it gets destructed at the end of the function. -Any modifications of the parameter will not be visible outside of the function and will not affect the argument of the caller. +Any modifications of the parameter will not be visible outside of the function and will not affect the argument of the caller. We do that because the function needs a "working copy" of the string, it will reverse and return that parameter without creating an additional instance of `std::string`. ## Handling an empty string as a special case @@ -88,4 +88,3 @@ Check out the [Using the standard library][approach-using-the-standard-lib] appr [cppref-swap]: https://en.cppreference.com/w/cpp/algorithm/swap [approach-using-the-standard-lib]: https://exercism.org/tracks/cpp/exercises/reverse-string/approaches/using-the-standard-lib - diff --git a/exercises/practice/reverse-string/.approaches/using-the-standard-lib/content.md b/exercises/practice/reverse-string/.approaches/using-the-standard-lib/content.md index 837350d4..b0c63339 100644 --- a/exercises/practice/reverse-string/.approaches/using-the-standard-lib/content.md +++ b/exercises/practice/reverse-string/.approaches/using-the-standard-lib/content.md @@ -43,7 +43,7 @@ After including this header we can call the function `std::reverse` later in the The function takes its argument "by value" (`std::string`). That means the parameter `str` gets constructed from the argument that the caller passes to the function, and it gets destructed at the end of the function. -Any modifications of the parameter will not be visible outside of the function and will not affect the argument of the caller. +Any modifications of the parameter will not be visible outside of the function and will not affect the argument of the caller. We do that because the function needs a "working copy" of the string, it will reverse and return that parameter without creating an additional instance of `std::string`. ## Calling `std::reverse()`. @@ -59,4 +59,3 @@ This is a great approach; it is concise, easy to read, idiomatic, and very effic [cppref-algorithm]: https://en.cppreference.com/w/cpp/header/algorithm [cppref-reverse]: https://en.cppreference.com/w/cpp/algorithm/reverse - diff --git a/exercises/practice/rotational-cipher/rotational_cipher_test.cpp b/exercises/practice/rotational-cipher/rotational_cipher_test.cpp index 7fdc11ae..144fe464 100644 --- a/exercises/practice/rotational-cipher/rotational_cipher_test.cpp +++ b/exercises/practice/rotational-cipher/rotational_cipher_test.cpp @@ -58,4 +58,4 @@ TEST_CASE("rotate all letters", "[9fb93fe6-42b0-46e6-9ec1-0bf0a062d8c9]") { "Gur dhvpx oebja sbk whzcf bire gur ynml qbt."); } -#endif \ No newline at end of file +#endif diff --git a/exercises/practice/secret-handshake/.approaches/introduction.md b/exercises/practice/secret-handshake/.approaches/introduction.md index 7f124456..d4ff9e13 100644 --- a/exercises/practice/secret-handshake/.approaches/introduction.md +++ b/exercises/practice/secret-handshake/.approaches/introduction.md @@ -70,8 +70,8 @@ namespace secret_handshake { std::vector commands (unsigned int signal) { std::vector output; int action = 0, action_incr = 1, end = actions.size(); - if (signal & REVERSE) {action = actions.size() - 1; action_incr = -1; end = -1;} - + if (signal & REVERSE) {action = actions.size() - 1; action_incr = -1; end = -1;} + for (; action != end; action+=action_incr) if (signal & (1 << action)) output.emplace_back(actions[action]); diff --git a/exercises/practice/secret-handshake/.approaches/iterate-once/content.md b/exercises/practice/secret-handshake/.approaches/iterate-once/content.md index ee1f6b87..33ecbe7d 100644 --- a/exercises/practice/secret-handshake/.approaches/iterate-once/content.md +++ b/exercises/practice/secret-handshake/.approaches/iterate-once/content.md @@ -29,8 +29,8 @@ namespace secret_handshake { std::vector commands (unsigned int signal) { std::vector output; int action = 0, action_incr = 1, end = actions.size(); - if (signal & reverse) {action = actions.size() - 1; action_incr = -1; end = -1;} - + if (signal & reverse) {action = actions.size() - 1; action_incr = -1; end = -1;} + for (; action != end; action += action_incr) if (signal & (1 << action)) output.emplace_back(actions[action]); diff --git a/exercises/practice/secret-handshake/.approaches/iterate-once/snippet.txt b/exercises/practice/secret-handshake/.approaches/iterate-once/snippet.txt index 2bc0e37f..45c27ce4 100644 --- a/exercises/practice/secret-handshake/.approaches/iterate-once/snippet.txt +++ b/exercises/practice/secret-handshake/.approaches/iterate-once/snippet.txt @@ -1,5 +1,5 @@ int action = 0, action_incr = 1, end = signals.size(); -if (signal & REVERSE) {action = actions.size() - 1; action_incr = -1; end = -1;} +if (signal & REVERSE) {action = actions.size() - 1; action_incr = -1; end = -1;} for (; action != end; action+=action_incr) if (signal & (1 << action)) diff --git a/exercises/practice/sieve/.approaches/introduction.md b/exercises/practice/sieve/.approaches/introduction.md index 2b2a6be7..1fcb74b6 100644 --- a/exercises/practice/sieve/.approaches/introduction.md +++ b/exercises/practice/sieve/.approaches/introduction.md @@ -28,7 +28,7 @@ namespace sieve { std::vector composite(limit + 1, false); std::vector primes; primes.reserve(limit / 2); - + for (long long number = 2; number <= limit; number++) { if (!composite[number]) { primes.emplace_back(number); diff --git a/exercises/practice/sieve/.approaches/vector-of-bools/content.md b/exercises/practice/sieve/.approaches/vector-of-bools/content.md index 2af7ccfc..523b092e 100644 --- a/exercises/practice/sieve/.approaches/vector-of-bools/content.md +++ b/exercises/practice/sieve/.approaches/vector-of-bools/content.md @@ -19,7 +19,7 @@ namespace sieve { std::vector composite(limit + 1, false); std::vector primes; primes.reserve(limit / 2); - + for (int number = 2; number <= limit; number++) { if (!composite[number]) { primes.emplace_back(number); diff --git a/exercises/practice/zebra-puzzle/.meta/example.cpp b/exercises/practice/zebra-puzzle/.meta/example.cpp index f6926e9e..a65609bc 100644 --- a/exercises/practice/zebra-puzzle/.meta/example.cpp +++ b/exercises/practice/zebra-puzzle/.meta/example.cpp @@ -263,4 +263,4 @@ Solution solve() { return solution; } -} // namespace zebra_puzzle \ No newline at end of file +} // namespace zebra_puzzle diff --git a/exercises/practice/zebra-puzzle/.meta/tests.toml b/exercises/practice/zebra-puzzle/.meta/tests.toml index 38c82da5..56c21c7a 100644 --- a/exercises/practice/zebra-puzzle/.meta/tests.toml +++ b/exercises/practice/zebra-puzzle/.meta/tests.toml @@ -14,4 +14,3 @@ description = "resident who drinks water" [084d5b8b-24e2-40e6-b008-c800da8cd257] description = "resident who owns zebra" - diff --git a/exercises/practice/zebra-puzzle/zebra_puzzle.cpp b/exercises/practice/zebra-puzzle/zebra_puzzle.cpp index d643a145..3cf69801 100644 --- a/exercises/practice/zebra-puzzle/zebra_puzzle.cpp +++ b/exercises/practice/zebra-puzzle/zebra_puzzle.cpp @@ -1,3 +1,3 @@ #include "zebra_puzzle.h" -namespace zebra_puzzle {} // namespace zebra_puzzle \ No newline at end of file +namespace zebra_puzzle {} // namespace zebra_puzzle