Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save inspirit941/0e7cd35e88f97073a3066ba7c6cbd1a0 to your computer and use it in GitHub Desktop.
Save inspirit941/0e7cd35e88f97073a3066ba7c6cbd1a0 to your computer and use it in GitHub Desktop.
def check(result):
for x, y, kind in result:
# 기둥인 경우
if kind == 0:
if y == 0 or (x-1, y, 1) in result or (x, y, 1) in result or (x, y-1, 0) in result:
continue
else:
return False
# 보인 경우
elif kind == 1:
if (x, y-1, 0) in result or (x+1, y-1, 0) in result or \
((x-1,y,1) in result and (x+1,y,1) in result):
continue
else:
return False
return True
def solution(n, build_frame):
result = set()
for a in build_frame:
x, y, what, how = a
# print(x, y, what, how)
if how == 1:
result.add((x, y, what))
is_true = check(result)
if is_true:
continue
else:
result.remove((x,y,what))
elif how == 0:
if (x,y,what) in result:
result.remove((x,y,what))
is_true = check(result)
if is_true:
continue
else:
result.add((x,y,what)
result = [list(i) for i in result]
return sorted(result, key = lambda x: (x[0],x[1],x[2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment