StephenLujan

perfect cubes

Jun 13th, 2016
90
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import math;
  2.  
  3. MAX = 30
  4. MIN = -30
  5.  
  6. def is_perfect_cube(num):
  7.     num = math.fabs(num)
  8.     if math.pow(num, 1 / 3) == int(math.pow(num, 1 / 3)):
  9.         return True;
  10.     return False;
  11.  
  12.  
  13. def cubes_test(a, b, c, d):
  14.     for num in [a + b, b + c, c + d, a + b + c, b + c + d, a + b + c + d]:
  15.         if not is_perfect_cube(num):
  16.             return False
  17.     if len(set([a, b, c, d])) < 4:
  18.         return False
  19.     #print("found combo:", a, b, c, d)
  20.     print ((a, b, c, d))
  21.     return True
  22.  
  23.  
  24. def main():
  25.     for a in range(MIN, MAX):
  26.         #print(a)
  27.         for b in range(MIN, MAX):
  28.             for c in range(MIN, MAX):
  29.                 for d in range(MIN, MAX):
  30.                     cubes_test(a, b, c, d)
  31.  
  32. main()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×