일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 역사 파이썬
- SQL SERVER MIGRATION
- SWEA
- 램프 파이썬
- 백준 11054.가장 긴 바이토닉 부분 수열
- 다리 만들기 파이썬
- 트리의 지름 파이썬
- 백준 2352 반도체 설계 파이썬
- 백준 1034 램프 파이썬
- 프로그래머스 등굣길
- 가장 긴 팰린드롬 파이썬
- 프로그래머스 순위
- 백준 2146 다리 만들기
- 베스트앨범 파이썬
- 백준 1516 게임 개발
- 백준 1043 거짓말 파이썬
- 반도체 설계 파이썬
- 백준 1167 트리의 지름 파이썬
- 프로그래머스 가장 긴 팰린드롬
- 가장 긴 바이토닉 부분 수열 파이썬
- 다중 컬럼 NOT IN
- 프로그래머스 여행경로
- 백준 1613 역사
- SQL SERVER 장비교체
- 백준 1238 파티 파이썬
- 등굣길 파이썬
- 순위 파이썬
- 게임 개발 파이썬
- 프로그래머스 순위 파이썬
- 프로그래머스 베스트앨범
Archives
- Today
- Total
공부, 기록
프로그래머스 방문 길이 파이썬(PYTHON) 본문
문제링크 : programmers.co.kr/learn/courses/30/lessons/49994
코딩테스트 연습 - 방문 길이
programmers.co.kr
import copy
def solution(dirs):
answer = 0
coord=list()
coord.append(0)
coord.append(0)
movehistory=list()
for i in dirs:
newcoord=movearrow(coord,i)
if (coord,newcoord) not in movehistory and coord!=newcoord:
movehistory.append((coord,newcoord))
movehistory.append((newcoord,coord))
coord=newcoord
return (len(movehistory)//2)
def movearrow(position,move):
getcoord = copy.copy(position)
if move == "U":
if position[1]!=5:
getcoord[1]+=1
elif move == "D":
if position[1]!=-5:
getcoord[1]-=1
elif move == "L":
if position[0]!=-5:
getcoord[0]-=1
elif move == "R":
if position[0]!=5:
getcoord[0]+=1
return getcoord
'코딩' 카테고리의 다른 글
프로그래머스 최고의 집합 파이썬(PYTHON) (0) | 2020.11.14 |
---|---|
프로그래머스 야근 지수 파이썬(PYTHON) (0) | 2020.11.14 |
프로그래머스 불량 사용자 파이썬(PYTHON) (0) | 2020.11.14 |
[프로그래머스] 멀리 뛰기 파이썬(PYTHON) (0) | 2020.11.14 |
[프로그래머스] LEVEL 3. 거스름돈 파이썬 (0) | 2020.11.14 |