

"""simple docstring"""

import logging

# standard libraries
import sys

import numpy as np
import pytest  # type: ignore

# Custom/local libraries
from matrix import matrix_operation as matop

_UpperCamelCase		    =						[[1_2, 1_0], [3, 9]]
_UpperCamelCase		    =						[[3, 4], [7, 4]]
_UpperCamelCase		    =						[[3, 0, 2], [2, 0, -2], [0, 1, 1]]
_UpperCamelCase		    =						[[3, 0, -2], [2, 0, 2], [0, 1, 1]]
_UpperCamelCase		    =						[[3, 0, 2], [2, 0, -2], [0, 1, 1], [2, 0, -2]]
_UpperCamelCase		    =						[1]
_UpperCamelCase		    =						[2]

_UpperCamelCase		    =						logging.getLogger()
_UpperCamelCase		    =						logging.DEBUG
_UpperCamelCase		    =						logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)



@pytest.mark.mat_ops
@pytest.mark.parametrize(
    ("mat1", "mat2")				,				[(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]      )
def 			SCREAMING_SNAKE_CASE       (   lowercase__				,				lowercase__      ) ->	Union[str, Any]:
 if (np.array(lowercase__      )).shape < (2, 2) or (np.array(lowercase__      )).shape < (2, 2):
  with pytest.raises(lowercase__      ):
   logger.info(F"""\n\t{test_addition.__name__} returned integer"""      )
   matop.add(lowercase__				,				lowercase__      )
 elif (np.array(lowercase__      )).shape == (np.array(lowercase__      )).shape:
  logger.info(F"""\n\t{test_addition.__name__} with same matrix dims"""      )
  lowerCAmelCase__      :							Optional[Any]    =							(np.array(lowercase__      ) + np.array(lowercase__      )).tolist()
  lowerCAmelCase__      :							int    =							matop.add(lowercase__				,				lowercase__      )
  assert theo == act
 else:
  with pytest.raises(lowercase__      ):
   logger.info(F"""\n\t{test_addition.__name__} with different matrix dims"""      )
   matop.add(lowercase__				,				lowercase__      )



@pytest.mark.mat_ops
@pytest.mark.parametrize(
    ("mat1", "mat2")				,				[(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]      )
def 			SCREAMING_SNAKE_CASE       (   lowercase__				,				lowercase__      ) ->	List[Any]:
 if (np.array(lowercase__      )).shape < (2, 2) or (np.array(lowercase__      )).shape < (2, 2):
  with pytest.raises(lowercase__      ):
   logger.info(F"""\n\t{test_subtraction.__name__} returned integer"""      )
   matop.subtract(lowercase__				,				lowercase__      )
 elif (np.array(lowercase__      )).shape == (np.array(lowercase__      )).shape:
  logger.info(F"""\n\t{test_subtraction.__name__} with same matrix dims"""      )
  lowerCAmelCase__      :							Dict    =							(np.array(lowercase__      ) - np.array(lowercase__      )).tolist()
  lowerCAmelCase__      :							List[Any]    =							matop.subtract(lowercase__				,				lowercase__      )
  assert theo == act
 else:
  with pytest.raises(lowercase__      ):
   logger.info(F"""\n\t{test_subtraction.__name__} with different matrix dims"""      )
   assert matop.subtract(lowercase__				,				lowercase__      )



@pytest.mark.mat_ops
@pytest.mark.parametrize(
    ("mat1", "mat2")				,				[(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]      )
def 			SCREAMING_SNAKE_CASE       (   lowercase__				,				lowercase__      ) ->	Dict:
 if (np.array(lowercase__      )).shape < (2, 2) or (np.array(lowercase__      )).shape < (2, 2):
  logger.info(F"""\n\t{test_multiplication.__name__} returned integer"""      )
  with pytest.raises(lowercase__      ):
   matop.add(lowercase__				,				lowercase__      )
 elif (np.array(lowercase__      )).shape == (np.array(lowercase__      )).shape:
  logger.info(F"""\n\t{test_multiplication.__name__} meets dim requirements"""      )
  lowerCAmelCase__      :							int    =							(np.matmul(lowercase__				,				lowercase__      )).tolist()
  lowerCAmelCase__      :							List[str]    =							matop.multiply(lowercase__				,				lowercase__      )
  assert theo == act
 else:
  with pytest.raises(lowercase__      ):
   logger.info(
       F"""\n\t{test_multiplication.__name__} does not meet dim requirements"""      )
   assert matop.subtract(lowercase__				,				lowercase__      )



@pytest.mark.mat_ops
def 			SCREAMING_SNAKE_CASE       (   ) ->	Optional[Any]:
 lowerCAmelCase__      :							str    =							(3.5 * np.array(lowercase__      )).tolist()
 lowerCAmelCase__      :							List[str]    =							matop.scalar_multiply(lowercase__				,				3.5      )
 assert theo == act



@pytest.mark.mat_ops
def 			SCREAMING_SNAKE_CASE       (   ) ->	str:
 lowerCAmelCase__      :							List[str]    =							(np.identity(5      )).tolist()
 lowerCAmelCase__      :							Any    =							matop.identity(5      )
 assert theo == act






@pytest.mark.mat_ops
@pytest.mark.parametrize("mat"				,				[mat_a, mat_b, mat_c, mat_d, mat_e, mat_f]      )
def 			SCREAMING_SNAKE_CASE       (   lowercase__      ) ->	Tuple:
 if (np.array(lowercase__      )).shape < (2, 2):
  with pytest.raises(lowercase__      ):
   logger.info(F"""\n\t{test_transpose.__name__} returned integer"""      )
   matop.transpose(lowercase__      )
 else:
  lowerCAmelCase__      :							Dict    =							(np.transpose(lowercase__      )).tolist()
  lowerCAmelCase__      :							Optional[Any]    =							matop.transpose(lowercase__				,				return_map=lowercase__      )
  assert theo == act









"""simple docstring"""

from itertools import product



def 			SCREAMING_SNAKE_CASE       (   lowercase__ = 1_5      ) ->	int:
 lowerCAmelCase__      :							float    =							0.0
 lowerCAmelCase__      :							float
 lowerCAmelCase__      :							int
 lowerCAmelCase__      :							int
 lowerCAmelCase__      :							int
 lowerCAmelCase__      :							int
 lowerCAmelCase__      :							tuple[int, ...]

 for series in product(range(2      )				,				repeat=lowercase__      ):
  lowerCAmelCase__      :							Optional[int]    =							series.count(1      )
  lowerCAmelCase__      :							Dict    =							num_turns - num_blue
  if num_red >= num_blue:
   continue
  lowerCAmelCase__      :							Dict    =							1.0
  for ind, col in enumerate(lowercase__				,				2      ):
   if col == 0:
    prob *= (ind - 1) / ind
   else:
    prob *= 1 / ind

  total_prob += prob

 return int(1 / total_prob      )


if __name__ == "__main__":
    print(f"{solution() = }")






