



'''simple docstring'''

import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
		import torch

		from transformers.generation import DisjunctiveConstraint



@require_torch
class 		lowerCamelCase__      (						unittest.TestCase     ):




					'''simple docstring'''



					def 						__UpperCAmelCase     (  self				:	int					)  ->       List[str]:



						'''simple docstring'''





						_lowercase					:       Optional[int]       =		[[1, 2, 4], [1, 2, 3, 4]]
						_lowercase					:       Tuple       =		DisjunctiveConstraint(UpperCamelCase_					)
						self.assertTrue(isinstance(dc.token_ids     ,  UpperCamelCase_					)					)

						with self.assertRaises(UpperCamelCase_					):
							DisjunctiveConstraint(torch.LongTensor([[1, 2, 4], [1, 2, 3]]					)					)

						with self.assertRaises(UpperCamelCase_					):
							DisjunctiveConstraint([torch.LongTensor([1, 2, 4]					), torch.LongTensor([1, 2, 3, 4, 5]					)]					)




					def 						__UpperCAmelCase     (  self				:	List[Any]					)  ->       Optional[Any]:



						'''simple docstring'''





						_lowercase					:       Union[str, Any]       =		[[1, 2], [1, 2, 3, 4]]

						with self.assertRaises(UpperCamelCase_					):
							DisjunctiveConstraint(UpperCamelCase_					)  # fails here




					def 						__UpperCAmelCase     (  self				:	List[Any]					)  ->       List[Any]:



						'''simple docstring'''





						_lowercase					:       List[Any]       =		[[1, 2, 3], [1, 2, 4]]

						_lowercase					:       Optional[int]       =		DisjunctiveConstraint(UpperCamelCase_					)

						_lowercase  ,    _lowercase  ,    _lowercase					:       Any       =		dc.update(1					)
						_lowercase					:       Dict       =		stepped is True and completed is False and reset is False
						self.assertTrue(UpperCamelCase_					)
						self.assertTrue(not dc.completed					)
						self.assertTrue(dc.current_seq == [1]					)

						_lowercase  ,    _lowercase  ,    _lowercase					:       Dict       =		dc.update(2					)
						_lowercase					:       int       =		stepped is True and completed is False and reset is False
						self.assertTrue(UpperCamelCase_					)
						self.assertTrue(not dc.completed					)
						self.assertTrue(dc.current_seq == [1, 2]					)

						_lowercase  ,    _lowercase  ,    _lowercase					:       Optional[int]       =		dc.update(3					)
						_lowercase					:       str       =		stepped is True and completed is True and reset is False
						self.assertTrue(UpperCamelCase_					)
						self.assertTrue(dc.completed					)  # Completed!
						self.assertTrue(dc.current_seq == [1, 2, 3]					)




					def 						__UpperCAmelCase     (  self				:	str					)  ->       List[Any]:



						'''simple docstring'''





						_lowercase					:       str       =		[[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

						_lowercase					:       Union[str, Any]       =		DisjunctiveConstraint(UpperCamelCase_					)

						_lowercase  ,    _lowercase  ,    _lowercase					:       Dict       =		dc.update(1					)
						self.assertTrue(not dc.completed					)
						self.assertTrue(dc.current_seq == [1]					)

						_lowercase  ,    _lowercase  ,    _lowercase					:       List[str]       =		dc.update(2					)
						self.assertTrue(not dc.completed					)
						self.assertTrue(dc.current_seq == [1, 2]					)

						_lowercase  ,    _lowercase  ,    _lowercase					:       int       =		dc.update(4					)
						self.assertTrue(not dc.completed					)
						self.assertTrue(dc.current_seq == [1, 2, 4]					)

						_lowercase  ,    _lowercase  ,    _lowercase					:       List[Any]       =		dc.update(5					)
						self.assertTrue(dc.completed					)  # Completed!
						self.assertTrue(dc.current_seq == [1, 2, 4, 5]					)

						dc.reset()

						_lowercase  ,    _lowercase  ,    _lowercase					:       Dict       =		dc.update(1					)
						self.assertTrue(not dc.completed					)
						self.assertTrue(dc.remaining() == 3					)
						self.assertTrue(dc.current_seq == [1]					)

						_lowercase  ,    _lowercase  ,    _lowercase					:       Optional[Any]       =		dc.update(2					)
						self.assertTrue(not dc.completed					)
						self.assertTrue(dc.remaining() == 2					)
						self.assertTrue(dc.current_seq == [1, 2]					)

						_lowercase  ,    _lowercase  ,    _lowercase					:       Any       =		dc.update(5					)
						self.assertTrue(dc.completed					)  # Completed!
						self.assertTrue(dc.remaining() == 0					)
						self.assertTrue(dc.current_seq == [1, 2, 5]					)





'''simple docstring'''

def 						__UpperCamelCase				(							_lowercase					) ->			bool:
	return str(_lowercase					) == str(_lowercase					)[::-1]







def 						__UpperCamelCase				(							_lowercase					) ->			int:
	return int(_lowercase					) + int(str(_lowercase					)[::-1]					)







def 						__UpperCamelCase				(							_lowercase = 1_0000					) ->			int:
	_lowercase					:       List[str]       =		[]
	for num in range(1,				_lowercase					):
		_lowercase					:       Tuple       =		0
		_lowercase					:       Tuple       =		num
		while iterations < 50:
			_lowercase					:       Union[str, Any]       =		sum_reverse(_lowercase					)
			iterations += 1
			if is_palindrome(_lowercase					):
				break
		else:
			lychrel_nums.append(_lowercase					)
	return len(_lowercase					)


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