From 3fc8a805ef5a89a9f67ea2137f1e33259d8577cd Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Tue, 28 Dec 2021 18:15:41 +0100 Subject: [PATCH] 6kyu: add detect pangram Signed-off-by: Matej Focko --- 6kyu/detect_pangram/solution.pas | 29 +++++++++++++++++++++++++++++ README.md | 4 ++++ 2 files changed, 33 insertions(+) create mode 100644 6kyu/detect_pangram/solution.pas diff --git a/6kyu/detect_pangram/solution.pas b/6kyu/detect_pangram/solution.pas new file mode 100644 index 0000000..53ff544 --- /dev/null +++ b/6kyu/detect_pangram/solution.pas @@ -0,0 +1,29 @@ +unit Kata; + +interface + +function IsPangram (s: string): boolean; + +implementation + +function IsPangram (s: string): boolean; +var + i: integer; + stringSize: integer; + letters: integer = 0; +begin + s := LowerCase(s); + stringSize := Length(s); + + for i := 1 to stringSize do + begin + if (s[i] < 'a') or (s[i] > 'z') then + continue; + + letters := letters or (1 << (Ord(s[i]) - Ord('a'))); + end; + + IsPangram := letters = (1 << 26) - 1; +end; + +end. diff --git a/README.md b/README.md index 9c2b017..cebbbfa 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,10 @@ - [Valid Braces](https://www.codewars.com/kata/5277c8a221e209d3f6000b56) - [solution](6kyu/valid_braces) +### Pascal + +- [Detect Pangram](https://www.codewars.com/kata/545cedaa9943f7fe7b000048) - [solution](6kyu/detect_pangram) + ## 7 kyu ### JS