
"""simple docstring"""




from __future__ import annotations

from collections import deque





class 			snake_case  :

							def __init__(self							,							SCREAMING_SNAKE_CASE_     ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_    			=			[]
									self.adlist.append(
									    {'''value''': '''''', '''next_states''': [], '''fail_state''': 0, '''output''': []}     )

									for keyword in keywords:
											self.add_keyword(SCREAMING_SNAKE_CASE_     )
									self.set_fail_transitions()

							def _lowercase       (self							,							SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_     ):

									"""simple docstring"""







									for state in self.adlist[current_state]["next_states"]:
											if char == self.adlist[state]["value"]:
													return state
									return None

							def _lowercase       (self							,							SCREAMING_SNAKE_CASE_     ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_    			=			0
									for character in keyword:
											SCREAMING_SNAKE_CASE_    			=			self.find_next_state(SCREAMING_SNAKE_CASE_							,							SCREAMING_SNAKE_CASE_     )
											if next_state is None:
													self.adlist.append(
													    {
													        '''value''': character,
													        '''next_states''': [],
													        '''fail_state''': 0,
													        '''output''': [],
													    }     )
													self.adlist[current_state]["next_states"].append(len(self.adlist     ) - 1     )
													SCREAMING_SNAKE_CASE_    			=			len(self.adlist     ) - 1
											else:
													SCREAMING_SNAKE_CASE_    			=			next_state
									self.adlist[current_state]["output"].append(SCREAMING_SNAKE_CASE_     )

							def _lowercase       (self     ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_    			=			deque()
									for node in self.adlist[0]["next_states"]:
											q.append(SCREAMING_SNAKE_CASE_     )
											SCREAMING_SNAKE_CASE_    			=			0
									while q:
											SCREAMING_SNAKE_CASE_    			=			q.popleft()
											for child in self.adlist[r]["next_states"]:
													q.append(SCREAMING_SNAKE_CASE_     )
													SCREAMING_SNAKE_CASE_    			=			self.adlist[r]['''fail_state''']
													while (
													    self.find_next_state(SCREAMING_SNAKE_CASE_							,							self.adlist[child]['''value''']     ) is None
													    and state != 0
													):
															SCREAMING_SNAKE_CASE_    			=			self.adlist[state]['''fail_state''']
													SCREAMING_SNAKE_CASE_    			=			self.find_next_state(
													    SCREAMING_SNAKE_CASE_							,							self.adlist[child]['''value''']     )
													if self.adlist[child]["fail_state"] is None:
															SCREAMING_SNAKE_CASE_    			=			0
													SCREAMING_SNAKE_CASE_    			=			(
													    self.adlist[child]['''output''']
													    + self.adlist[self.adlist[child]['''fail_state''']]['''output''']
													)







							def _lowercase       (self							,							SCREAMING_SNAKE_CASE_     ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_    			=			{}  # returns a dict with keywords and list of its occurrences
									SCREAMING_SNAKE_CASE_    			=			0
									for i in range(len(SCREAMING_SNAKE_CASE_     )     ):
											while (
											    self.find_next_state(SCREAMING_SNAKE_CASE_							,							string[i]     ) is None
											    and current_state != 0
											):
													SCREAMING_SNAKE_CASE_    			=			self.adlist[current_state]['''fail_state''']
											SCREAMING_SNAKE_CASE_    			=			self.find_next_state(SCREAMING_SNAKE_CASE_							,							string[i]     )
											if next_state is None:
													SCREAMING_SNAKE_CASE_    			=			0
											else:
													SCREAMING_SNAKE_CASE_    			=			next_state
													for key in self.adlist[current_state]["output"]:
															if key not in result:
																	SCREAMING_SNAKE_CASE_    			=			[]
															result[key].append(i - len(SCREAMING_SNAKE_CASE_     ) + 1     )
									return result


if __name__ == "__main__":
						import doctest

						doctest.testmod()

"""simple docstring"""




from __future__ import annotations

from collections.abc import Callable



def 							_lowerCamelCase			(			__a,				__a,				__a,				__a = 100,				):
		SCREAMING_SNAKE_CASE_    			=			x_start
		SCREAMING_SNAKE_CASE_    			=			fnc(__a     )
		SCREAMING_SNAKE_CASE_    			=			0.0
		for _ in range(__a     ):
				# Approximates small segments of curve as linear and solve
				# for trapezoidal area
				SCREAMING_SNAKE_CASE_    			=			(x_end - x_start) / steps + xa
				SCREAMING_SNAKE_CASE_    			=			fnc(__a     )
				area += abs(fxa + fxa     ) * (xa - xa) / 2
				# Increment step
				SCREAMING_SNAKE_CASE_    			=			xa
				SCREAMING_SNAKE_CASE_    			=			fxa
		return area


if __name__ == "__main__":



						def 							_lowerCamelCase			(			__a     ):
								return x**3 + x**2

						print('f(x) = x^3 + x^2')
						print('The area between the curve, x = -5, x = 5 and the x axis is:')
						lowerCAmelCase__				=					10
						while i <= 100000:
												print(f'''with {i} steps: {trapezoidal_area(f, -5, 5, i)}''')
												i *= 10