Skip to content

Instantly share code, notes, and snippets.

@nietzscheson
Last active December 13, 2022 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nietzscheson/9348f7a642651eb07ff9f42149595d45 to your computer and use it in GitHub Desktop.
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
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