Skip to content

Instantly share code, notes, and snippets.

@khrlimam
Last active May 11, 2018 11:48
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 khrlimam/f3ab3a9b526f877d4be95393b7faec7d to your computer and use it in GitHub Desktop.
Save khrlimam/f3ab3a9b526f877d4be95393b7faec7d to your computer and use it in GitHub Desktop.
LombokDev Challenges #2
def valid_n(n):
return 2 < n < 10
def valid_z(z):
return 1 < z < 100000
def F(x, y, z, n):
value = x**n + y**n - z**n
yield abs(value)
def challenge_xy(x, y, z):
return x < y < z
def root(number, to):
r = 1./to
return number**r
def solve_xy(n, z):
power_z = z**n
y = (int)(root(power_z-1, n))
power_y = y**n
diff = power_z-power_y
x = (int)(root(diff, n))
# conditions below only to complete the challenge method
if y == z:
y = y-1
if x == y:
x = x-1
if x <= 0:
x = 1
return (x, y)
if __name__ == '__main__':
t = input("Number of Test Cases (T < 10): ")
for i in range(int(t)):
test = input(
"Input 'n' (2 < n < 10) and 'z' (1 < z < 100000) separated by space: ")
n, z = map(int, test.split(" "))
x, y = solve_xy(n, z)
error = F(x, y, z, n).__next__()
print('%s %s %s' % (x, y, error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment