1997 Woburn Computer Programming Challenge

4. Typing

With the introduction of computers in today's life, typing skills are essential for all. As a result, one of the typing teahcers has a booming business. Yesterday, however, she made the mistake of specifying the following test for her students: "Type lines of 26 characters each, such that each letter of the alphabet occurs only once."

Now that she sits at home and wants to mark the tests, she discovered that instead of typing the alphabet in order, most took the liberty to type a permutation (re-ordering) of the alphabet.

What she would like you to do is write a program which marks the tests for her, meaning that you have to check for each line of characters whether it is correct, i.e. whether it is really a permutation of the 26 lowercase letters of the alphabet.

Input

The first line of input contains an integer N specifying the number of test cases.
Each test case is one line of test, no longer than 80 characters.

Output

For each test case, you should create a single line of output. The output should read "OK." if the input is exactly a permutation of the 26 lowercase letters of the alphabet, and "Nope." if it is not.

Sample Input

4
abcdefghijklmnopqrstuvwxyz
zyxwvutsrqponm and so on
thequickbrownfxjmpsvlazydg
And now, for something completely different.

Sample Output

OK.
Nope.
OK.
Nope.

All Submissions
Best Solutions


Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Sep 28, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

It's pretty amusing that this problem statement about typing contains a typo. In the interest of historical accuracy I think I'll leave it :)

Wait jargon stated earlier that "abcdefghijklmnopqrstuvwxyz" is not a permutation, but the sample output doesn't say that.

There's an extra z at the end. ;)

Could someone tell me why my code isn't working? I cannot seem to find the error(s) in this...

Your program does not even work for the sample case.

They seem to work on all the sample cases. I am getting 4/6 when I submit

When I run your code, I get:

OK.
Nope.
Nope.
Nope.


Three things.

First - indent your code! That makes it easier to spot mistakes.

Second - Try this input:
1
ABCDEFGHIJKLMNOPQRSTUVWXYZ


Thirdly: The following section of code has two major errors that cause your program to be incorrect. Can you spot them?
  for i:=1 to num  do 
begin
n:=0;
for j:=1 to 26 do
begin
sample[i]:=0;
end;
readln(a);
wide:=length(a);
for i:=1 to wide do
begin


(Hint: here's how it looks indented:
  for i := 1 to num do 
begin
n := 0;
for j := 1 to 26 do
begin
sample[i] := 0;
end;
readln(a);
wide := length(a);
for i := 1 to wide do
begin

now
why me getting wrong?

Double-post is unnecessary.

You found one of the errors, but not the other one. If you don't even read what I write (i.e. 2 errors, only one of which you attempted to solve), why would you expect more help?



In fixing that bug, you caused another one.

Lemme quote your code again, focusing on incorrect parts:
  for j:=1 to 26 do 
begin
sample[i]:=0;
end;
readln(a);
wide:=length(a);
for g:=1 to wide do
begin
if (a[i]='a') then
sample[1]:=sample[1]+1
else if (a[i]='b') then
sample[2]:=sample[2]+1
else if (a[i]='c') then
sample[3]:=sample[3]+1 // etc


And once again, indent your code.

i am sorry i fixed those errors and i got 4/6

sigh...

There's one mistake that I've quoted in both the previous snippets that you haven't yet addressed.

I won't quote it again; look hard.

for this problem should each character appear only once? like only 1 'a' 1'b' and so on...and the output will be OK.

or
should the output be ok even if there are 2 'a', 2 'b', in the program?

... a permutation (re-ordering) of the alphabet


I think this makes it clear that it's one letter each, e.g.
abcdefghijklmnopqrstuvwxyzz is not correct, and should receive a "Nope."

i tried inputting that in my program...it outputs nope but it still doesn't accept...can some1 check what's wrong and give me some hint?

"Type lines of 26 characters each, such that each letter of the alphabet occurs only once."
Did you check to make sure that each line is EXACTLY 26 characters?

thats impossible because there is only supposed to be 26 characters and there are 26 characters in the alphabet so how can there be two 'a's or two 'b's and still output an 'OK.'?

Note: It is usually ill-advised to reply to a comment posted more than two years ago

Wut up wut up. I output ok and nope, but the Pegjudge is not recieving.