I have a piece of psuedocade here and it is supposed to check if a sentence entered by a user is a pangram or not. Please have a look at it.
string sentence;
bool pangram ßtrue;
ARRAY: characterArray of [26] char ß {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
ARRAY: sCharacterArray of char ß { '.', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '-', '=', '<', '|', '/', '>' };
Input the sentence
for (int i ß0;i <characterArray.Length; i++)
IF (!sentence.ToLower().Contains(characterArray[i]))
pangram ß false
ELSE
{
for(int x = 0; x < sCharArray.Length; x++)
{
if(sentence.Contains(sCharArray[x]))
{
pangram=false;
}
else
{
pangram=true;
}
}
}
ENDIF
ENDFOR
if ( pangram ßtrue)
Display ('pangram');
else
Display ('not a pangram');
ENDIF
//end program
Feedback will be appreciated. Thank you.

VulpesRank #55 · 29.2K reputationPosted Apr 18, 2011, 1:33 AM EDT
This is because it is checking multiple times for 'excluded' characters. It would be better just to check once to see if the sentence includes any excluded characters and, if it does, then it's definitely not a pangram.
Otherwise, you can then check to see whether the sentence contains all 26 letters of the alphabet at least once.
Royalty3 reputationPosted Apr 18, 2011, 1:46 AM EDT
VulpesRank #55 · 29.2K reputationPosted Apr 18, 2011, 1:52 AM EDT
The only situation where the pseudocode as it stands would be superior is if the sentence didn't contain 'a', in which case the code would never check for excluded characters. However, in a sentence of any length this is unlikely as 'a' is of course a common letter.
If it does contain an 'a' then the code will check for excluded characters at least once and probably multiple times in a sentence of any length.
Hiren Joshi6 reputationPosted Oct 13, 2011, 8:33 PM EDT
Hiren Joshi6 reputationPosted Oct 13, 2011, 8:34 PM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 14, 2011, 3:10 AM EDT
Doubtless there will be even faster methods than this.
Hiren Joshi6 reputationPosted Oct 14, 2011, 8:13 AM EDT