-
-
Save jadar/b154e08487ca00b2da28 to your computer and use it in GitHub Desktop.
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
#!/bin/python | |
import sys, math | |
def usage(): | |
print("Usage: SetDifference.py NUM_1 NUM_2 ...") | |
def formatArrayToStr(factors): | |
string = "" | |
for x in xrange(0,len(factors)): | |
string = string + str(factors[x]) | |
if x != len(factors)-1: | |
string = string + ", " | |
if x == len(factors)-2: | |
string += "and " | |
return string | |
def validateArgs(args): | |
for x in xrange(0, len(args)): | |
if type(args[x]) is not float: | |
return False | |
return True | |
def convertArgs(args): | |
newArgs = [] | |
for arg in args: | |
newArg = float(arg) | |
if math.isnan(newArg): | |
print("error converting args!") | |
raise SystemExit(2) | |
newArgs.append(newArg) | |
return newArgs | |
def main(args): | |
if len(args) <= 1: | |
print("error! not enough args") | |
usage() | |
raise SystemExit(2); | |
return; | |
args.pop(0) | |
newArgs = convertArgs(args) | |
degrees = [] | |
degrees.append(newArgs); | |
for i in range(1, 6): | |
lastDegree = degrees[i - 1] | |
degree = [] | |
for x in xrange(1,len(lastDegree)): | |
degree.append(lastDegree[x] - lastDegree[x-1]) | |
degrees.append(degree) | |
for x in xrange(0, len(degrees)): | |
degree = degrees[x] | |
sys.stdout.write(str(x) + '\t') | |
for space in xrange(0, x): sys.stdout.write('\t') | |
for y in xrange(0,len(degree)): | |
sys.stdout.write(str(degree[y])) | |
sys.stdout.write('\t') | |
sys.stdout.write("\n") | |
sys.stdout.write("\n") | |
if __name__ == "__main__": | |
args = sys.argv | |
# print(args) | |
main(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment