# UVA Problem 1585 – Score Solution

UVA Problem 1585 – Score Solution:

Solving Technique:

Easy problem.  Run time 0.009 s ( 9 ms ), Rank 439.

We are given a string with only ‘O’ and ‘X’ characters. Also it is specified string length is not bigger than 80 character and there won’t be any space in between characters.

The way to calculate the score is,

```OOXXOXXOOO
1200100123 /* 1+2+0+0+1+0+0+1+2+3 = 10 */
```

We count up until we encounter an ‘X’. Then we reset count to ZERO. Before reset we keep a sum of all previous counts.

Important:  Be sure to add or print a new line after each output unless otherwise specified. The outputs should match exactly because sometimes even a space character causes the answer to be marked as wrong answer.

Input:

```5
OOXXOXXOOO
OOXXOOXXOO
OXOXOXOXOXOXOX
OOOOOOOOOO
OOOOXOOOOXOOOOX```

Output:

```10
9
7
55
30```

Code:

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

#include<stdio.h>
static char s;

int main(){
register unsigned n, i;

scanf("%u", &n);

while (n--){
scanf("%s", s);
unsigned sum = 0, val = 0;

for (i = 0; s[i]; ++i){

/**
* 79 is decimal ASCII 'O', Applying XOR Check to see if they are equal
* If two numbers are same then val is set to 0, otherwise increment val
*/
(s[i] ^ 79) ? val = 0: ++val;

sum += val;
}

printf("%u\n", sum);
}
return 0;
}
```