Last active
December 4, 2016 02:58
-
-
Save markostam/341ea500371396e3c430deaf6b788d22 to your computer and use it in GitHub Desktop.
Revisions
-
markostam revised this gist
Dec 4, 2016 . 1 changed file with 20 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,24 +7,23 @@ def read_data(file): input = list(map(lambda sides: list(map(lambda side: int(side),sides)),raw)) return input def check_tri(input, count = 0): for sides in input: count += int(sides[0] + sides[1] > sides[2] and sides[1] + sides[2] > sides[0] and sides[2] + sides[0] > sides[1]) return count def check_tri2(input, count = 0): for sides in input: count += int(max(sides) < sum(sides) - max(sides)) return count def check_tri3(input): return sum(map(lambda sides: int(max(sides) < sum(sides)-max(sides)),input)) def check_tri4(input): #lol return sum([sum(map(lambda sides: int(max(sides) < sum(filter(lambda side: side != max(sides),sides))),input)), sum(map(lambda sides: int(max(sides) < @@ -34,12 +33,21 @@ def transpose_list(input,dim): column_vec = np.array(input).T.reshape(1,np.array(input).size)[0] column_vec = list(zip(*[iter(column_vec)]*3)) return column_vec def algo_test(alg1,alg2,alg3,alg4,input): if (alg1(input) == alg2(input) == alg3(input) == alg4(input) and alg1(transpose_list(input,3)) == alg2(transpose_list(input,3)) == alg3(transpose_list(input,3)) == alg4(transpose_list(input,3))): print("all algorithms match. yay!") else: print("algos don't match you made a boo-boo") def solution(file): input = read_data(file) q1 = check_tri3(input) q2 = check_tri3(transpose_list(input,3)) print("Q1 = {}\nQ2 = {}".format(q1,q2)) algo_test(check_tri, check_tri2, check_tri3, check_tri4, input) if name == "__main__": solution(sys.args[1]) -
markostam revised this gist
Dec 3, 2016 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,10 +3,8 @@ def read_data(file): with open(file) as f: raw = map(lambda x: x.split(),f.readlines()) input = list(map(lambda sides: list(map(lambda side: int(side),sides)),raw)) return input def check_tri(input): -
markostam revised this gist
Dec 3, 2016 . 1 changed file with 22 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,25 +7,41 @@ def read_data(file): input = [] for i in raw: input.append([int(j) for j in i if j != '']) return input def check_tri(input): count = 0 for sides in input: count += int(sides[0] + sides[1] > sides[2] and sides[1] + sides[2] > sides[0] and sides[2] + sides[0] > sides[1]) return count def check_tri2(input): count = 0 for sides in input: big_side = max(sides) small_sides = sides.copy() small_sides.remove(big_side) count += int(big_side < sum(small_sides)) return count def check_tri3(input): return sum([sum(map(lambda sides: int(max(sides) < sum(filter(lambda side: side != max(sides),sides))),input)), sum(map(lambda sides: int(max(sides) < sum(filter(lambda side: side == max(sides),sides))),input))]) def transpose_list(input,dim): column_vec = np.array(input).T.reshape(1,np.array(input).size)[0] column_vec = list(zip(*[iter(column_vec)]*3)) return column_vec def solution(file): input = read_data(file) q1 = check_tri(input) q2 = check_tri(transpose_list(input,3)) print("Q1 = {}\nQ2 = {}".format(q1,q2)) if name == "__main__": solution(sys.args[1]) -
markostam revised this gist
Dec 3, 2016 . 1 changed file with 21 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,31 @@ import numpy as np import sys def read_data(file): with open(file) as f: raw = [i.strip('\n').split(' ') for i in f.readlines()] input = [] for i in raw: input.append([int(j) for j in i if j != '']) def check_tri(input): count = 0 for line in input: count += int(line[0] + line[1] > line[2] and line[1] + line[2] > line[0] and line[2] + line[0] > line[1]) return count def transpose_list(input,dim): column_vec = np.array(input).T.reshape(1,np.array(input).size)[0] column_vec = zip(*[iter(column_vec)]*3) return column_vec def solution(file): input = read_data(file) q1 = check_tri(input) q2 = check_tri(transpose_list(input,3)) print("Q1 = {} \n Q2 = {}".format(q1,q2) if name == "__main__": solution(sys.args[1]) -
markostam revised this gist
Dec 3, 2016 . No changes.There are no files selected for viewing
-
markostam revised this gist
Dec 3, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ import numpy as np with open(file) as f: raw = [i.strip('\n').split(' ') for i in f.readlines()] input = [] -
markostam created this gist
Dec 3, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ with open(file) as f: raw = [i.strip('\n').split(' ') for i in f.readlines()] input = [] for i in raw: input.append([int(j) for j in i if j != '']) def check_tri(input): count = 0 for line in input: count += int(line[0] + line[1] > line[2] and line[1] + line[2] > line[0] and line[2] + line[0] > line[1]) return count check_tri(input) def transpose_list(input,dim): column_vec = np.array(input).T.reshape(1,np.array(input).size)[0] column_vec = zip(*[iter(column_vec)]*3) return column_vec check_tri(transpose_list(input,3))