From ec354b6ed3eca1a00dc29d814ae31401b74560d1 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 10 Aug 2025 04:18:29 -0600 Subject: [PATCH] adding updates --- .../palindrome_number.py | 9 +++++++++ .../test_palindrome_number_round_18.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/my_project/interviews/top_150_questions_round_18/palindrome_number.py create mode 100644 tests/test_150_questions_round_18/test_palindrome_number_round_18.py diff --git a/src/my_project/interviews/top_150_questions_round_18/palindrome_number.py b/src/my_project/interviews/top_150_questions_round_18/palindrome_number.py new file mode 100644 index 00000000..410df9ba --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_18/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] diff --git a/tests/test_150_questions_round_18/test_palindrome_number_round_18.py b/tests/test_150_questions_round_18/test_palindrome_number_round_18.py new file mode 100644 index 00000000..7a37a883 --- /dev/null +++ b/tests/test_150_questions_round_18/test_palindrome_number_round_18.py @@ -0,0 +1,15 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_18\ +.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)