From 94bee56e3df1aba5b33e4671489d40d795ece72c Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Sep 2025 04:29:56 -0600 Subject: [PATCH] adding algo --- .../palindrome_number.py | 9 +++++++++ .../test_palindrome_number_round_19.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/my_project/interviews/top_150_questions_round_19/palindrome_number.py create mode 100644 tests/test_150_questions_round_19/test_palindrome_number_round_19.py diff --git a/src/my_project/interviews/top_150_questions_round_19/palindrome_number.py b/src/my_project/interviews/top_150_questions_round_19/palindrome_number.py new file mode 100644 index 00000000..80952ebd --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_19/palindrome_number.py @@ -0,0 +1,9 @@ +from typing import List, Union, Collection, Mapping, Optional +from abc import ABC, abstractmethod + +class Solution: + def isPalindrome(self, x: int) -> bool: + + str_x = str(x) + + return str_x == str_x[::-1] \ No newline at end of file diff --git a/tests/test_150_questions_round_19/test_palindrome_number_round_19.py b/tests/test_150_questions_round_19/test_palindrome_number_round_19.py new file mode 100644 index 00000000..da7931a8 --- /dev/null +++ b/tests/test_150_questions_round_19/test_palindrome_number_round_19.py @@ -0,0 +1,15 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_19\ +.palindrome_number import Solution + +class PalindromeNumberTestCase(unittest.TestCase): + + def test_is_palindrome_number(self): + solution = Solution() + output = solution.isPalindrome(x=121) + self.assertTrue(output) + + def test_is_no_palindrome_number(self): + solution = Solution() + output = solution.isPalindrome(x=123) + self.assertFalse(output) \ No newline at end of file