Last active
December 13, 2022 17:55
-
-
Save nietzscheson/9348f7a642651eb07ff9f42149595d45 to your computer and use it in GitHub Desktop.
Show if a exponentiation sum of numbers is False or True with the same input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
def potencial(numbers: str): | |
to_split = int(len(numbers) / 2) | |
to_sum = (int(numbers[0:to_split]) + int(numbers[to_split::])) ** 2 | |
if to_sum == int(numbers): | |
return True | |
return False | |
class PotencialTestCase(unittest.TestCase): | |
def tests_false_potencial(self): | |
self.assertEqual(potencial("123456"), False) | |
def tests_true_potencial(self): | |
self.assertEqual(potencial("998001"), True) | |
if __name__ == "__main__": | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment