Calculate Hat Trick Wins in a Matrix

Viewed 28

I would like to have a script or formula to calculate the number of three consecutive "W" values on a row of 64 cells from left to right and display the result in a column labeled "Hat Tricks". The formula/script must be able to be copied to multiple other rows.

I have drafted an example sheet here.

The data is a matrix of wrestlers who compete against each other, and the win or loss is recorded in a matrix. The nature of the matrix ignores the cell where the wrestler cannot compete against themselves, thus this will need to be configured into the script/formula. Here is a quick example of what I mean, where x is a competition with the self and the numbers are wrestler IDs:

  1  2  3
1 x  L  L
2 W  x  L
3 W  W  x

I am just a hobbyist without a lot of coding knowledge. I am appreciative of any attention this post generates. Thanks for taking the time.

1 Answers

try:

=ARRAYFORMULA(LEN(REGEXREPLACE(REGEXREPLACE(TRIM(FLATTEN(QUERY(
 TRANSPOSE(B2:G7),,9^9))), "W W W", "1"), "[WL ]", )))

enter image description here

Related