본문 바로가기
코딩/프로그래머스 레벨0

프로그래머스 lv0 평행

by 큰고양2 2023. 9. 24.

https://school.programmers.co.kr/learn/courses/30/lessons/120875

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

def solution(dots):
    
    for a in range(1,4):   #1번 점 고정, 2,3,4 연결
        ran = list(range(1,4)) #2,3,4 리스트
        ran.pop(ran.index(a)) #선택 숫자 제외
        b = abs(dots[0][0]-dots[a][0]) / abs(dots[0][1]-dots[a][1])   #점 1으로 만든 선의 x길이/y 길이
        c = abs(dots[ran[0]][0]-dots[ran[1]][0]) / abs(dots[ran[0]][1]-dots[ran[1]][1]) #다른의 x길이/y 길이 
        if b == c :
            return 1
    return 0