# UVA Problem 12289 ( One Two Three ) Solution

UVA Problem 12289 ( One Two Three ) Solution:

Solving Technique:

Very very easy problem. It requires us to only print 1 or 2 or 3 based on input.

There are only 3 types of string (one, two, three) input and among them only one character is changed for each input. Also Their length is always the same.

So the very basic idea that comes to mind is any input with length of five must be three ( since length doesn’t change ). Now if that is not true it can either be one or two.

Code Explanation:

I took a different approach for my code. Instead of including another header file and calling a function to get the string length, I simply checked if the third position in the array ( array starts from zero ) is not a NULL character. If there is no NULL character in that position then I simply outputted 3. Why? because the string three does not contain a NULL character in position 3.

Now above is not true then I check if the string is one or two. If i only check for sub-strings ( part of strings ) in one and find any two characters of ‘o’, ‘n’, ‘e’ then it is definitely one. Then print 1. Else simply print 2.

Input:

```3
owe
too
theee```

Output:

```1
2
3```

Code:

```/**
* @author  Quickgrid ( Asif Ahmed )
*/

#include<stdio.h>

#define O 111
#define N 110
#define E 101

static char s[8];

int main(){
register unsigned n;
scanf("%u", &n);

while (n--){
scanf("%s", s);
if (s[3]){
printf("3\n");
}else{
unsigned s0 = s[0];
unsigned s1 = s[1];
unsigned s2 = s[2];
if ((s0 == O && s1 == N) || (s1 == N && s2 == E) || (s0 == O && s2 == E))
printf("1\n");
else
printf("2\n");
}
}
return 0;
}
```