From d1a2b50d56ad9d1de21b682031f7a2281e13fde3 Mon Sep 17 00:00:00 2001 From: Gerald Senarclens de Grancy Date: Tue, 19 Nov 2024 21:04:21 +0100 Subject: [PATCH 1/5] fixed missing closing tag for testcase thanks to Manuel Grobbauer for pointing this out --- exercises/concept/speedywagon/speedywagon_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/concept/speedywagon/speedywagon_test.cpp b/exercises/concept/speedywagon/speedywagon_test.cpp index 6d3f1f34..32c91f0b 100644 --- a/exercises/concept/speedywagon/speedywagon_test.cpp +++ b/exercises/concept/speedywagon/speedywagon_test.cpp @@ -34,7 +34,7 @@ TEST_CASE("activity_counter: sum for a nullptr", "[task_2]") { REQUIRE(speedywagon::activity_counter(nullptr, 0) == 0); } -TEST_CASE("alarm_control: works correctly for pointer", "[task_3") { +TEST_CASE("alarm_control: works correctly for pointer", "[task_3]") { speedywagon::pillar_men_sensor* kars_in_space{nullptr}; REQUIRE_FALSE(speedywagon::alarm_control(kars_in_space)); } From 6dbc8dfe1d084eeef7d4d7422579372408fe9c69 Mon Sep 17 00:00:00 2001 From: Gerald Senarclens de Grancy Date: Wed, 19 Mar 2025 22:55:44 +0100 Subject: [PATCH 2/5] attempted to improve wording started by fixing a typo (exiting -> exciting) but then tried to reduce the length of some sentences; added hints that references are expected where appropriate to allow the reader to focus on the problem at hand --- .../power-of-troy/.docs/instructions.md | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/exercises/concept/power-of-troy/.docs/instructions.md b/exercises/concept/power-of-troy/.docs/instructions.md index 84662691..b4eb3760 100644 --- a/exercises/concept/power-of-troy/.docs/instructions.md +++ b/exercises/concept/power-of-troy/.docs/instructions.md @@ -13,16 +13,18 @@ The first one is related to creating a human, the other five are about handling ## 1. Bring humans to the world of Troy -For your model of Troy humans are the most important feature. +For your model of Troy, humans are the most important feature. Your model human should be able to possess a _unique artifact_. They should also have the ability to manifest a _power_. These powers might affect other humans, so you also want to model if a human is influenced by some other power. You are provided with basic implementations of `artifact` and `power` structs. -Implement a `human` struct (or class) that has a _smart-pointer_ to an `artifact` as `possession` member variable. +Implement a `human` struct (or class) that has a _smart-pointer_ to an `artifact` member variable named `possession`. Each artifact can only be possessed by a single human at any given time. -The `human` should also have variables for their `own_power` and `influenced_by`, which should be _smart-pointers_ to `powers`. +A `human` must have two additional member variables. +One holds their `own_power` and the other is a power they are `influenced_by`. +Both `own_power` and `influenced_by` are _smart-pointers_ to `powers`. Each `power` might be owned by a single human, but also influence other humans at the same time. By default, humans are born without any artifact and neither own any powers nor are they influenced by them. @@ -42,7 +44,7 @@ mindy_mccready.influenced_by; Your model is boring without the interaction of its parts. You want to create unique artifacts and give them to certain humans. -Define the function `give_new_artifact` which returns nothing but takes a `human` and a `string`. +Define the function `give_new_artifact` which returns nothing but takes a reference to a `human` and a `string`. With the `string` it should define a new `artifact` object and set the `possession` pointer of the `human` accordingly. The function should not return anything. @@ -80,10 +82,10 @@ uzumaki.possession->name; ## 4. Give Power to the People -The most exiting feature of Troy are the special powers, that people might wield. +The most exciting feature of Troy are the special powers that people might wield. Some can smelt iron with their thoughts, while others can heal every wound instantly at nighttime. -Define the function `manifest_power` which returns nothing but takes a `human` and a `string`. +Define the function `manifest_power` which returns nothing but takes a reference to a `human` and a `string`. With the `string` it should define a new `power` object and set the `own_power` pointer of the `human` accordingly. The function should not return anything. @@ -100,10 +102,12 @@ eleven.own_power->effect; What use are the greatest powers, if you cannot use them. Your model concentrates on humans, so you want to track the influence of powers. -Write a _void_ function `use_power` that takes two humans, first: a caster and secondly: a target. +Write a _void_ function `use_power` that takes two references to humans. +The first human is the caster and the second represents the target. The target's `influenced_by` pointer should be pointed to the power of the caster. -For simplicity, humans can only be influenced by a single power and this power stays in place even if the caster does not exist any longer. +For simplicity, humans can only be influenced by a single power. +This power stays in place even if the caster does not exist any longer. ```cpp human pamela_isley{}; From 8c45c486ba646b1196a7c80dd0cda07021c9f3ef Mon Sep 17 00:00:00 2001 From: Gerald Senarclens de Grancy Date: Sun, 22 Feb 2026 22:38:20 +0100 Subject: [PATCH 3/5] fixed typo --- exercises/practice/bank-account/bank_account_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/bank-account/bank_account_test.cpp b/exercises/practice/bank-account/bank_account_test.cpp index 32888a3c..ac5ddf43 100644 --- a/exercises/practice/bank-account/bank_account_test.cpp +++ b/exercises/practice/bank-account/bank_account_test.cpp @@ -60,7 +60,7 @@ TEST_CASE("Can do multiple operations sequentially", REQUIRE(account.balance() == 20); } -TEST_CASE("annot check balance of closed account", +TEST_CASE("Cannot check balance of closed account", "[f9facfaa-d824-486e-8381-48832c4bbffd]") { Bankaccount::Bankaccount account{}; account.open(); From 5144ad0de40a5b92b03c3be4748655a04995ef3a Mon Sep 17 00:00:00 2001 From: Gerald Senarclens de Grancy Date: Sun, 22 Feb 2026 22:39:22 +0100 Subject: [PATCH 4/5] reduced false negatives while increasing execution speed test used to pass a lot even if code wasn't thread safe this is still possible now but less likely --- .../practice/bank-account/bank_account_test.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/exercises/practice/bank-account/bank_account_test.cpp b/exercises/practice/bank-account/bank_account_test.cpp index ac5ddf43..1801b085 100644 --- a/exercises/practice/bank-account/bank_account_test.cpp +++ b/exercises/practice/bank-account/bank_account_test.cpp @@ -150,12 +150,16 @@ TEST_CASE("Can handle concurrent transactions", std::vector vec_of_threads; - for (int i = 0; i < 1000; ++i) { + for (int i = 0; i < 10; ++i) { vec_of_threads.push_back(std::thread([&]() { using namespace std::chrono_literals; - account.deposit(1); - std::this_thread::sleep_for(5ms); - account.withdraw(1); + for (int j{0}; j < 100; ++j) { + account.deposit(1); + std::this_thread::sleep_for(1ms); + } + for (int j{0}; j < 100; ++j) { + account.withdraw(1); + } })); } From 10a456a5bac087ecbe0e3b0e4c3b80fd93e098e6 Mon Sep 17 00:00:00 2001 From: Gerald Senarclens de Grancy Date: Sun, 22 Feb 2026 22:44:59 +0100 Subject: [PATCH 5/5] adhered to desired coding style avoid clang-format issue --- exercises/practice/bank-account/bank_account_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/practice/bank-account/bank_account_test.cpp b/exercises/practice/bank-account/bank_account_test.cpp index 1801b085..606ad498 100644 --- a/exercises/practice/bank-account/bank_account_test.cpp +++ b/exercises/practice/bank-account/bank_account_test.cpp @@ -154,11 +154,11 @@ TEST_CASE("Can handle concurrent transactions", vec_of_threads.push_back(std::thread([&]() { using namespace std::chrono_literals; for (int j{0}; j < 100; ++j) { - account.deposit(1); - std::this_thread::sleep_for(1ms); + account.deposit(1); + std::this_thread::sleep_for(1ms); } for (int j{0}; j < 100; ++j) { - account.withdraw(1); + account.withdraw(1); } })); }