Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions solutions/cpp/pangram/1/pangram.cpp
Original file line number Diff line number Diff line change
@@ -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;
}

}
6 changes: 6 additions & 0 deletions solutions/cpp/pangram/1/pangram.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#include <string_view>

namespace pangram {
bool is_pangram(std::string_view text);
}