Pangrams!



A pangram, or holoalphabetic sentence, is a sentence using every letter of the alphabet at least once.

Example: Input  = 'The quick brown fox jumps over the lazy dogs'
 Output =yes

Prerequisite:


ASCII TABLE:



Code:

clc
x=input('Enter the string:');
u=[];
y=double(x);
for i=1:length(y)
    if((y(i)>=97 && y(i)<=122)||(y(i)>=65 && y(i)<=90))
        u=[u y(i)];
    end
end
q=[];
for i=1:length(u)
    if((u(i)>=97 && u(i)<=122))
       u(i)=u(i)-32;
       q=[q u(i)];
    else
        q=[q u(i)];
    end
end
a=sort(q);
cm=1;
for i=1:length(a)-1
    m=a(i);
    n=a(i+1);
    if(m~=n)
    cm=cm+1;
   end
end
if(cm==26)
    disp('yes');
else
    disp('No');
end


Explanation:



Output:





JAVA CODE:

import java.io.*;
class Tumpu
{
public static void main(String args[])throws IOException
{
BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the sentence:");
String q=r.readLine();
int l=q.length();
char m;
int y[]=new int[l];
for(int i=0;i<l;i++)
{
m=q.charAt(i);
y[i]=(int)(m);
}
int ck=0;
for(int i=0;i<l;i++)
{
if((y[i]>=97 && y[i]<=122)||(y[i]>=65 && y[i]<=90))
{
ck=ck+1;
}
}
int kl=0;
int u[]=new int[ck];
for(int i=0;i<l;i++)
{
if((y[i]>=97 && y[i]<=122)||(y[i]>=65 && y[i]<=90))
{
u[kl]=y[i];
kl=kl+1;
}
}
for(int i=0;i<ck;i++)
{
if(u[i]>=97 && u[i]<=122)
{
u[i]=u[i]-32;
}
}
int temp=0;
for(int i=0;i<ck-1;i++)
{
for(int j=0;j<ck-i-1;j++)
{
if(u[j]>u[j+1])
{
temp=u[j];
u[j]=u[j+1];
u[j+1]=temp;
}
}
}
int mv=0;
int nv=0;
int cm=1;
for(int i=0;i<ck-1;i++)
{
mv=u[i];
nv=u[i+1];
if(mv!=nv)
{
cm=cm+1;
}
}
if(cm==26)
{
System.out.println("YES");
}
else if(cm!=26)
{
System.out.println("NO");
}
}
}

Explanation:



Output:


Now if we remove "lazy" from the sentence , as z , l, y is not present in rest of the sentence , so it will not be a pan-gram.




No comments