4 December 2014

Quiz 67: typing namaste

Problem:

Shikhi just learned typing. She still types many unnecessary alphabets.
She wants to type "namaste", but end up typing sting str. Print "YES" if "namaste" can be obtained by deleting  some alphabets from string str, else print "NO". Example, "YES" for "asnamastiie", "NO" for "namteass"

Input Format: 

String str


Output Format: 

YES/NO


Constraints: 

None

Sample Input

aeiounqwsamqwsdaiutstqqwwseqjal

Sample Output:

YES

Explanations:

Red color for namaste- aeiounqwsamqwsdaiutstqqwwseqjal



Solution:

chomp($str=<STDIN>);
if($str=~ /n.*a.*m.*a.*s.*t.*e.*/)
{
print "YES";
}
else
{
print "NO";
}

Tips:

Simple regex use case

No comments:

Post a Comment