How to resolve the algorithm Pangram checker step by step in the Picat programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Pangram checker step by step in the Picat programming language
Table of Contents
Problem Statement
A pangram is a sentence that contains all the letters of the English alphabet at least once. For example: The quick brown fox jumps over the lazy dog.
Write a function or method to check a sentence to see if it is a pangram (or not) and show its use.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Pangram checker step by step in the Picat programming language
Source code in the picat programming language
go =>
S1 = "The quick brown fox jumps over the lazy dog",
S2 = "The slow brown fox jumps over the lazy dog",
println([S1, is_pangram(S1)]),
println([S2, is_pangram(S2)]),
nl,
println("With missing chars:"),
println([S1, is_pangram2(S1)]),
println([S2, is_pangram2(S2)]),
nl.
% Check if S is a pangram and get the missing chars
is_pangram(S) = P =>
Lower = S.to_lowercase,
Alpha = [chr(I+96) : I in 1..26],
foreach(A in Alpha) membchk(A,Lower) end -> P = true ; P = false.
% Check if S is a pangram and get the missing chars (if any)
is_pangram2(S) = [pangram=cond(Missing==[],true,false),missing=Missing] =>
Lower = S.to_lowercase,
Missing = [A : A in [chr(I+96) : I in 1..26], not membchk(A,Lower)].
You may also check:How to resolve the algorithm Scope modifiers step by step in the Lua programming language
You may also check:How to resolve the algorithm Weird numbers step by step in the C# programming language
You may also check:How to resolve the algorithm Unicode strings step by step in the Haskell programming language
You may also check:How to resolve the algorithm Fairshare between two and more step by step in the Lua programming language
You may also check:How to resolve the algorithm Sum of a series step by step in the AppleScript programming language