diff options
Diffstat (limited to 'challenge-254/sgreen/python/ch-1.py')
| -rwxr-xr-x | challenge-254/sgreen/python/ch-1.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-254/sgreen/python/ch-1.py b/challenge-254/sgreen/python/ch-1.py new file mode 100755 index 0000000000..37c492575d --- /dev/null +++ b/challenge-254/sgreen/python/ch-1.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +import sys + + +def three_power(n: int) -> bool: + # Get the closest integer to a cube root + i = round(abs(n) ** (1/3)) + + # Return true if this number is indeed a cube root + return i ** 3 == abs(n) + + +def main(): + # Convert input into integers + n = int(sys.argv[1]) + result = three_power(n) + print('true' if result else 'false') + + +if __name__ == '__main__': + # Convert input into integers + main() |
