From bc0a7b86812c4bf81fcd1799363e5309f9e5f02e Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 5 Dec 2024 04:32:24 -0600 Subject: [PATCH] adding palindrome number --- .../palindrome_number.py | 9 +++++++++ .../test_palindrome_number_round_11.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/my_project/interviews/top_150_questions_round_11/palindrome_number.py create mode 100644 tests/test_150_questions_round_11/test_palindrome_number_round_11.py diff --git a/src/my_project/interviews/top_150_questions_round_11/palindrome_number.py b/src/my_project/interviews/top_150_questions_round_11/palindrome_number.py new file mode 100644 index 00000000..80952ebd --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_11/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_11/test_palindrome_number_round_11.py b/tests/test_150_questions_round_11/test_palindrome_number_round_11.py new file mode 100644 index 00000000..5b947247 --- /dev/null +++ b/tests/test_150_questions_round_11/test_palindrome_number_round_11.py @@ -0,0 +1,15 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_11\ +.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