from itertools import combinations
def solution(line):
lines = list(combinations(line, 2))
dots = []
for i in lines:
a, b, e = i[0][0], i[0][1], i[0][2]
c, d, f = i[1][0], i[1][1], i[1][2]
if (a*d) - (b*c) == 0:
continue
x = ((b*f)-(e*d))/((a*d)-(b*c))
y = ((e*c)-(a*f))/((a*d)-(b*c))
dots.append([x,y])
dots = [[int(x[0]), int(x[1])] for x in dots if float(x[0]).is_integer() if float(x[1]).is_integer()]
if len(dots) == 0:
return
dots.sort(key = lambda x : x[0])
max_x = int(dots[len(dots)-1][0])
min_x = int(dots[0][0])
len_x = abs(max_x - min_x)
dots.sort(key = lambda x : x[1])
max_y = int(dots[len(dots) - 1][1])
min_y = int(dots[0][1])
len_y = abs(max_y - min_y)
answer = []
for y in range(max_y, min_y - 1, -1):
row = ""
for x in range(min_x, max_x + 1):
if [x, y] in dots:
row += "*"
else:
row += "."
answer.append(row)
return answer
시간 복잡도나 공간 복잡도는 신경 쓰지 않았다.
구현에 더 집중한 문제이다.