


"""simple docstring"""





from __future__ import annotations

from collections import Counter


def   _snake_case    (    _snake_case					:      int      ):
      lowerCAmelCase       :						Tuple							= [True] * n
      lowerCAmelCase       :						List[Any]							= False
      lowerCAmelCase       :						List[Any]							= False
      lowerCAmelCase       :						List[str]							= True

      for i in range(3			, int(n**0.5 + 1      )			, 2      ):
            lowerCAmelCase       :						int							= i * 2
            while index < n:
                  lowerCAmelCase       :						List[str]							= False
                  lowerCAmelCase       :						Any							= index + i

      lowerCAmelCase       :						Tuple							= [2]

      for i in range(3			, _snake_case			, 2      ):
            if is_prime[i]:
                  primes.append(_snake_case      )

      return primes


def   _snake_case    (    _snake_case					:      int      ):
      lowerCAmelCase       :						Optional[Any]							= str(_snake_case      )
      lowerCAmelCase       :						List[Any]							= []
      lowerCAmelCase       :						Dict							= ['''0''', '''1''', '''2''', '''3''', '''4''', '''5''', '''6''', '''7''', '''8''', '''9''']

      for duplicate in Counter(_snake_case      ) - Counter(set(_snake_case      )      ):
            lowerCAmelCase       :						Union[str, Any]							= [int(number_str.replace(_snake_case			, _snake_case      )      ) for digit in digits]
            replacements.append(_snake_case      )

      return replacements


def   _snake_case    (    _snake_case					:      int = 8      ):
      lowerCAmelCase       :						List[Any]							= set()

      # Filter primes with less than 3 replaceable digits
      lowerCAmelCase       :						Union[str, Any]							= {
          x for x in set(prime_sieve(1000000      )      ) if len(str(_snake_case      )      ) - len(set(str(_snake_case      )      )      ) >= 3
      }

      for prime in primes:
            if prime in numbers_checked:
                  continue

            lowerCAmelCase       :						List[str]							= digit_replacements(_snake_case      )

            for family in replacements:
                  numbers_checked.update(_snake_case      )
                  lowerCAmelCase       :						Optional[int]							= primes.intersection(_snake_case      )

                  if len(_snake_case      ) != family_length:
                        continue

                  return min(_snake_case      )

      return -1


if __name__ == "__main__":
 print(solution())






"""simple docstring"""





import math as m


def   _snake_case    (    _snake_case					:      List[Any]			, _snake_case					:      Tuple			, _snake_case					:      Tuple=0.001      ):
      return (f(a + h      ) - f(a - h      )) / (2 * h)


def   _snake_case    (    _snake_case					:      int			, _snake_case					:      List[Any]=0			, _snake_case					:      Any=100			, _snake_case					:      Any=0.0001			, _snake_case					:      Optional[Any]=1E-6			, _snake_case					:      Any=False      ):
      lowerCAmelCase       :						Optional[Any]							= xa  # set the initial guess
      lowerCAmelCase       :						str							= [a]
      lowerCAmelCase       :						List[str]							= abs(f(_snake_case      )      )
      lowerCAmelCase       :						Dict							= lambda _snake_case      : calc_derivative(_snake_case			, _snake_case			, h=_snake_case      )  # noqa: E731  Derivative of f(x)
      for _ in range(_snake_case      ):
            if fa(_snake_case      ) == 0:
                  raise ValueError('''No converging solution found'''      )
            lowerCAmelCase       :						Tuple							= a - f(_snake_case      ) / fa(_snake_case      )  # Calculate the next estimate
            if logsteps:
                  steps.append(_snake_case      )
            if error < maxerror:
                  break
      else:
            raise ValueError('''Iteration limit reached, no converging solution found'''      )
      if logsteps:
            # If logstep is true, then log intermediate steps
            return a, error, steps
      return a, error


if __name__ == "__main__":
 from matplotlib import pyplot as plt

 snake_case__		:  Any     					=					lambda x: m.tanh(x) ** 2 - m.exp(3 * x)  # noqa: E731
 snake_case__					,  snake_case__					,  snake_case__		:  List[str]     					=					newton_raphson(
     f, xa=10, maxiter=1_000, step=1e-6, logsteps=True
 )
 plt.plot([abs(f(x)) for x in steps])
 plt.xlabel('''step''')
 plt.ylabel('''error''')
 plt.show()
 print(f"""solution = {{{solution:f}}}, error = {{{error:f}}}""")


