3-Dimensional Connect 4

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types

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 6 parallel 6\times6 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 6 line-separated 6\times6 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


  • 0
    christinakemp  commented on May 15, 2019, 4:35 p.m.

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


    • -11
      magicalsoup  commented on May 15, 2019, 6:41 p.m.

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