


"""simple docstring"""





from __future__ import annotations

from PIL import Image

# Define glider example
snake_case__						:   str			 = [
    [0, 1, 0, 0, 0, 0, 0, 0],
    [0, 0, 1, 0, 0, 0, 0, 0],
    [1, 1, 1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
]

# Define blinker example
snake_case__						:   Optional[int]			 = [[0, 1, 0], [0, 1, 0], [0, 1, 0]]


def    _snake_case  (  _snake_case :	Any	):
      lowerCAmelCase    :		Optional[int]				=      []
      for i in range(len(__snake_case	)	):
            lowerCAmelCase    :		Optional[Any]				=      []
            for j in range(len(cells[i]	)	):
                  # Get the number of live neighbours
                  lowerCAmelCase    :		int				=      0
                  if i > 0 and j > 0:
                        neighbour_count += cells[i - 1][j - 1]
                  if i > 0:
                        neighbour_count += cells[i - 1][j]
                  if i > 0 and j < len(cells[i]	) - 1:
                        neighbour_count += cells[i - 1][j + 1]
                  if j > 0:
                        neighbour_count += cells[i][j - 1]
                  if j < len(cells[i]	) - 1:
                        neighbour_count += cells[i][j + 1]
                  if i < len(__snake_case	) - 1 and j > 0:
                        neighbour_count += cells[i + 1][j - 1]
                  if i < len(__snake_case	) - 1:
                        neighbour_count += cells[i + 1][j]
                  if i < len(__snake_case	) - 1 and j < len(cells[i]	) - 1:
                        neighbour_count += cells[i + 1][j + 1]

                  # Rules of the game of life (excerpt from Wikipedia):
                  # 1. Any live cell with two or three live neighbours survives.
                  # 2. Any dead cell with three live neighbours becomes a live cell.
                  # 3. All other live cells die in the next generation.
                  #    Similarly, all other dead cells stay dead.
                  lowerCAmelCase    :		Optional[Any]				=      cells[i][j] == 1
                  if (
                      (alive and 2 <= neighbour_count <= 3)
                      or not alive
                      and neighbour_count == 3
                  ):
                        next_generation_row.append(1	)
                  else:
                        next_generation_row.append(0	)

            next_generation.append(__snake_case	)
      return next_generation


def    _snake_case  (  _snake_case :	Dict       ,      _snake_case :	Optional[Any]	):
      lowerCAmelCase    :		Optional[int]				=      []
      for _ in range(__snake_case	):
            # Create output image
            lowerCAmelCase    :		Any				=      Image.new('''RGB'''       ,      (len(cells[0]	), len(__snake_case	))	)
            lowerCAmelCase    :		Optional[int]				=      img.load()

            # Save cells to image
            for x in range(len(__snake_case	)	):
                  for y in range(len(cells[0]	)	):
                        lowerCAmelCase    :		int				=      255 - cells[y][x] * 255
                        lowerCAmelCase    :		int				=      (colour, colour, colour)

        # Save image
            images.append(__snake_case	)
            lowerCAmelCase    :		List[str]				=      new_generation(__snake_case	)
      return images


if __name__ == "__main__":
 snake_case__						:   Union[str, Any]			 = generate_images(GLIDER, 16)
 images[0].save('''out.gif''', save_all=True, append_images=images[1:])




"""simple docstring"""





def       lowerCamelCase__		(			__snake_case	)							->		bool:


					"""simple docstring"""





					return credit_card_number.startswith(('''34''', '''35''', '''37''', '''4''', '''5''', '''6''')	)



def       lowerCamelCase__		(			__snake_case	)							->		bool:


					"""simple docstring"""





					_UpperCamelCase							 =  credit_card_number
					_UpperCamelCase							 =  0
					_UpperCamelCase							 =  len(__snake_case	) - 2
					for i in range(__snake_case,     -1,     -2	):
										#  double the value of every second digit
										_UpperCamelCase							 =  int(cc_number[i]	)
										digit *= 2
										# If doubling of a number results in a two digit number
										# i.e greater than 9(e.g., 6 × 2 = 12),
										# then add the digits of the product (e.g., 12: 1 + 2 = 3, 15: 1 + 5 = 6),
										# to get a single digit number.
										if digit > 9:
															digit %= 10
															digit += 1
										_UpperCamelCase							 =  cc_number[:i] + str(__snake_case	) + cc_number[i + 1 :]
										total += digit

					# Sum up the remaining digits
					for i in range(len(__snake_case	) - 1,     -1,     -2	):
										total += int(cc_number[i]	)

					return total % 10 == 0



def       lowerCamelCase__		(			__snake_case	)							->		bool:


					"""simple docstring"""





					_UpperCamelCase							 =  F'''{credit_card_number} is an invalid credit card number because'''
					if not credit_card_number.isdigit():
										print(F'''{error_message} it has nonnumerical characters.'''	)
										return False

					if not 13 <= len(__snake_case	) <= 16:
										print(F'''{error_message} of its length.'''	)
										return False

					if not validate_initial_digits(__snake_case	):
										print(F'''{error_message} of its first two digits.'''	)
										return False

					if not luhn_validation(__snake_case	):
										print(F'''{error_message} it fails the Luhn check.'''	)
										return False

					print(F'''{credit_card_number} is a valid credit card number.'''	)
					return True


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				validate_credit_card_number("""4111111111111111""")
				validate_credit_card_number("""32323""")






