From df259acdb2d6ddaa657af3f925210a75b2d6578e Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 20 Oct 2025 03:44:55 -0600 Subject: [PATCH] adding algo --- .../top_150_questions_round_20/palindrome.py | 9 +++++++++ .../test_palindrome_round_20.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/my_project/interviews/top_150_questions_round_20/palindrome.py create mode 100644 tests/test_150_questions_round_20/test_palindrome_round_20.py diff --git a/src/my_project/interviews/top_150_questions_round_20/palindrome.py b/src/my_project/interviews/top_150_questions_round_20/palindrome.py new file mode 100644 index 00000000..80952ebd --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_20/palindrome.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_20/test_palindrome_round_20.py b/tests/test_150_questions_round_20/test_palindrome_round_20.py new file mode 100644 index 00000000..0fe47b58 --- /dev/null +++ b/tests/test_150_questions_round_20/test_palindrome_round_20.py @@ -0,0 +1,15 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_20\ +.palindrome 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