From 09b03e33e382ed4dbc4540415c0a38218c6c2fe7 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Sat, 20 Jun 2026 20:10:45 +0000 Subject: [PATCH] [Sync Iteration] cpp/pangram/1 --- solutions/cpp/pangram/1/pangram.cpp | 26 ++++++++++++++++++++++++++ solutions/cpp/pangram/1/pangram.h | 6 ++++++ 2 files changed, 32 insertions(+) create mode 100644 solutions/cpp/pangram/1/pangram.cpp create mode 100644 solutions/cpp/pangram/1/pangram.h diff --git a/solutions/cpp/pangram/1/pangram.cpp b/solutions/cpp/pangram/1/pangram.cpp new file mode 100644 index 0000000..a6de4a7 --- /dev/null +++ b/solutions/cpp/pangram/1/pangram.cpp @@ -0,0 +1,26 @@ +#include "pangram.h" + +namespace pangram { + bool is_pangram(std::string_view text) { + int seen_letters = 0; // Aquí guardaremos los 26 bits + + for (char c : text) { + // 1. Convertir a minúscula de forma manual y segura (ASCII) + if (c >= 'A' && c <= 'Z') { + c = c + ('a' - 'A'); + } + + // 2. Si es una letra del alfabeto inglés, encendemos su bit + if (c >= 'a' && c <= 'z') { + int bit_position = c - 'a'; + seen_letters |= (1 << bit_position); + } + } + + // 3. Máscara de control: ¿Están los 26 bits encendidos? + constexpr int all_26_letters_mask = (1 << 26) - 1; + + return seen_letters == all_26_letters_mask; + } + +} \ No newline at end of file diff --git a/solutions/cpp/pangram/1/pangram.h b/solutions/cpp/pangram/1/pangram.h new file mode 100644 index 0000000..562a6e3 --- /dev/null +++ b/solutions/cpp/pangram/1/pangram.h @@ -0,0 +1,6 @@ +#pragma once +#include + +namespace pangram { + bool is_pangram(std::string_view text); +} \ No newline at end of file