





from __future__ import annotations



class       A__     :





      def __init__(				self ,							A_     ):
       '''simple docstring'''




       UpperCamelCase			:      Tuple 			=     order

       # a_{0} ... a_{k}
       UpperCamelCase			:      Dict 			=     [1.0] + [0.0] * order
       # b_{0} ... b_{k}
       UpperCamelCase			:      List[str] 			=     [1.0] + [0.0] * order

       # x[n-1] ... x[n-k]
       UpperCamelCase			:      List[str] 			=     [0.0] * self.order
       # y[n-1] ... y[n-k]
       UpperCamelCase			:      Tuple 			=     [0.0] * self.order





      def  __UpperCamelCase(				self ,							A_ ,							A_     ):
       '''simple docstring'''




       if len(A_     ) < self.order:
        UpperCamelCase			:      Union[str, Any] 			=     [1.0, *a_coeffs]

       if len(A_     ) != self.order + 1:
        UpperCamelCase			:      Optional[int] 			=     (
            F"""Expected a_coeffs to have {self.order + 1} elements """
            F"""for {self.order}-order filter, got {len(A_     )}"""
        )
        raise ValueError(A_     )

       if len(A_     ) != self.order + 1:
        UpperCamelCase			:      List[str] 			=     (
            F"""Expected b_coeffs to have {self.order + 1} elements """
            F"""for {self.order}-order filter, got {len(A_     )}"""
        )
        raise ValueError(A_     )

       UpperCamelCase			:      Dict 			=     a_coeffs
       UpperCamelCase			:      Union[str, Any] 			=     b_coeffs





      def  __UpperCamelCase(				self ,							A_     ):
       '''simple docstring'''




       UpperCamelCase			:      int 			=     0.0

       # Start at index 1 and do index 0 at the end.
       for i in range(1 ,							self.order + 1     ):
        result += (
            self.b_coeffs[i] * self.input_history[i - 1]
            - self.a_coeffs[i] * self.output_history[i - 1]
        )

       UpperCamelCase			:      Dict 			=     (result + self.b_coeffs[0] * sample) / self.a_coeffs[0]

       UpperCamelCase			:      Optional[Any] 			=     self.input_history[:-1]
       UpperCamelCase			:      Dict 			=     self.output_history[:-1]

       UpperCamelCase			:      List[Any] 			=     sample
       UpperCamelCase			:      Any 			=     result

       return result







def 	A_       (  _lowerCAmelCase							,     _lowerCAmelCase  )		->				int:
 return int(input_a == input_a == 0  )



def 	A_       (  )		->				None:
 print("Truth Table of NOR Gate:"  )
 print("|   Input 1   |  Input 2  | Output |"  )
 print(F"""|      0      |    0      |  {nor_gate(0							,     0  )}     |"""  )
 print(F"""|      0      |    1      |  {nor_gate(0							,     1  )}     |"""  )
 print(F"""|      1      |    0      |  {nor_gate(1							,     0  )}     |"""  )
 print(F"""|      1      |    1      |  {nor_gate(1							,     1  )}     |"""  )


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    main()
