From caaa6d737b6893fccd38b03e07b6e71f36238b7a Mon Sep 17 00:00:00 2001 From: z4root Date: Fri, 30 Oct 2026 23:44:58 +0000 Subject: [PATCH 1/2] feat(katas): add the solution --- Katas/CP/perfect_sanduches/src/solution.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Katas/CP/perfect_sanduches/src/solution.cpp diff --git a/Katas/CP/perfect_sanduches/src/solution.cpp b/Katas/CP/perfect_sanduches/src/solution.cpp new file mode 100644 index 0000000..ce136a6 --- /dev/null +++ b/Katas/CP/perfect_sanduches/src/solution.cpp @@ -0,0 +1,19 @@ +#include + +int min(int a, int b) { return (a > b) ? b : a; } + +int main() { + int t, a, b; + std::cin >> t; + + for (int i = 0; i < t; i++) { + std::cin >> a >> b; + if (b >= a) { + std::cout << "-1" << std::endl; + } else { + std::cout << min(b, a - b) << std::endl; + } + } + + return 0; +} From 62e28f6afc895cff21b3d2ce22f6e67c76adabd8 Mon Sep 17 00:00:00 2001 From: z4root Date: Fri, 30 Oct 2026 23:51:46 +0000 Subject: [PATCH 2/2] feat(katas): add the test --- Katas/CP/perfect_sanduches/test/expected1.txt | 3 +++ Katas/CP/perfect_sanduches/test/input1.txt | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 Katas/CP/perfect_sanduches/test/expected1.txt create mode 100644 Katas/CP/perfect_sanduches/test/input1.txt diff --git a/Katas/CP/perfect_sanduches/test/expected1.txt b/Katas/CP/perfect_sanduches/test/expected1.txt new file mode 100644 index 0000000..2c62db2 --- /dev/null +++ b/Katas/CP/perfect_sanduches/test/expected1.txt @@ -0,0 +1,3 @@ +2 +1 +-1 diff --git a/Katas/CP/perfect_sanduches/test/input1.txt b/Katas/CP/perfect_sanduches/test/input1.txt new file mode 100644 index 0000000..8598bbd --- /dev/null +++ b/Katas/CP/perfect_sanduches/test/input1.txt @@ -0,0 +1,4 @@ +3 +6 4 +5 1 +4 5