Raymond is very good at Connect 4. He thinks that regular Connect 4 is boring, so he plays a 3D version instead. The 3D version consists of parallel Connect 4 boards. Two players use red and yellow chips to attempt to connect 4 of their same color horizontally or vertically, across any of the three dimensions. Diagonal lines will not be counted for simplicity. Raymond is too lazy to check the board after a game himself, so he will pay you in points to check for him. Raymond always plays red.

#### Input Specification

The input will consist of line-separated grids, each denoting the chips in one slice of the 3D gameboard, and containing 36 characters that consist of `R`

(for a red chip) and `Y`

(for a yellow chip).

#### Output Specification

Output the number of distinct occurrences where 4 red chips are in a horizontal or vertical line in any of the three dimensions. If there are no such occurrences, output `lost`

(Raymond is very competitive).

*Note: Do not prompt for input, as this will cause the judge to take the prompt as the solution.*

#### Sample Input

```
RYRRRY
RRYYRY
YYRYYR
YRYYRR
YYRRYR
RRYYRY
RYRRRY
RRYYRY
YYRYYR
YRYYRR
YYRRYR
RRYYRY
RYRRRY
RRYYRY
YYRYYR
YRYYRR
YYRRYR
RRYYRY
YRYYYR
YYRRYR
RRYRRY
RYRRYY
RRYYRR
YYRRYY
YRYYYR
YYRRYR
RRYRRY
RYRRYY
RRYYRR
YYRRRY
YRYYYR
YYRRYR
RRYRRY
RYRRYY
RRYYRR
YYRRRY
```

#### Sample Output

`3`

## Comments

I believe my solution is correct. I've rechecked the algorithm multiple times and also tested it with the sample case given. I designed a more general algorithm for solving this problem for an nxnxn cube with determining k connected red chips. I've also tested the algorithm on smaller cube sizes like 3x3x3 and it works fine. Kindly let me know if I'm understanding the problem incorrectly, otherwise, I believe my solution is correct.

You fail a few fairly trivial cases, though it can be easily fixed. Remember that c-style strings require an extra byte of memory for the null character. Failure to allocate this extra byte can result in undefined behaviour and data written to memory addresses where you would least expect, and cause your solution to fail in places you never thought was possible.

Can the 4 in a row overlap? Ie. If you have 6 in a row does that count as 3?

This comment is hidden due to too much negative feedback. Click here to view it.