diff --git a/Implementation/4-1_updown.py b/Implementation/4-1_updown.py new file mode 100644 index 0000000..4aaacfb --- /dev/null +++ b/Implementation/4-1_updown.py @@ -0,0 +1,25 @@ +#시간복잡도 O(n),2n이지만,, + +n=int(input()) +gps=[1,1] +lst=list(input()) #이동 위치 입력 +num=len(lst) + +for i in range(num): + if lst[i]=="R": + if gps[1]<5: + gps[1]+=1 + + elif lst[i]=="L": + if gps[1]>1: + gps[1]-=1 + + elif lst[i]=="U": + if gps[0]>1: + gps[0]-=1 + + elif lst[i]=="D": + if gps[0]<5: + gps[0]+=1 + +print(gps[0],gps[1]) \ No newline at end of file diff --git a/Implementation/4-2_how_many_3.py b/Implementation/4-2_how_many_3.py new file mode 100644 index 0000000..df76245 --- /dev/null +++ b/Implementation/4-2_how_many_3.py @@ -0,0 +1,35 @@ + +n=int(input()) +clock=[0 for i in range(6)] +cnt=0 + +for i in range(n+1): + if clock[1]<9: + clock[1]=i + else: + clock[0]=i//10 + clock[1]=0 + clock[3],clock[2]=0,0 + + for j in range(60): + if clock[3]<9: + clock[3]+=1 + else: + clock[2]+=1 + clock[3]=0 + clock[4],clock[5]=0,0 + + for k in range(60): + if clock[5]<9: + clock[5]+=1 + else: + clock[4]+=1 + clock[5]=0 + print(clock) + for l in range(0,6): + if clock[l]==3: + cnt+=1 + break + +print(cnt) + \ No newline at end of file diff --git a/Implementation/4-3_knight.py b/Implementation/4-3_knight.py new file mode 100644 index 0000000..c656398 --- /dev/null +++ b/Implementation/4-3_knight.py @@ -0,0 +1,31 @@ + +gps=list(input()) +print(gps) +cnt=0 + +diff_x=abs(ord(gps[0])-ord('h')) +diff_y=abs(int(gps[1])-8) + +if diff_x==0 or diff_x==7: + if diff_y==0 or diff_y==7: + cnt=2 + elif diff_y==1 or diff_y==6: + cnt=3 + else: + cnt=4 +elif diff_x==1 or diff_x==6: + if diff_y==0 or diff_y==7: + cnt=3 + elif diff_y==1 or diff_y==6: + cnt=4 + else: + cnt=6 +else: + if diff_y==0 or diff_y==7: + cnt=4 + elif diff_y==1 or diff_y==6: + cnt=6 + else: + cnt=8 + +print(cnt) \ No newline at end of file diff --git a/Implementation/4-4_game.py b/Implementation/4-4_game.py new file mode 100644 index 0000000..80aac3b --- /dev/null +++ b/Implementation/4-4_game.py @@ -0,0 +1,59 @@ + +n,m=map(int,input().split()) + +a,b,d=map(int,input().split()) #좌표와 방향 +character_gps=[a,b] +map_structure=[0 for i in range(n)] + +for i in range(n): + map_structure[i]=list(map(int,input().split())) +print(map_structure) + +#입력 끝 탐색 시작 + +cnt=1 +stuck=0 #네 방향 다 탐색했는지 찾는 변수 +while(1): + if d==0: #방향이 위쪽일 때 + if character_gps[0]>0 and map_structure[character_gps[0]-1][character_gps[1]]==0: + character_gps[0]-=1 + map_structure[character_gps[0]][character_gps[1]]=1 #이미 가본곳은 못가게 하는 장치 + cnt+=1 + stuck=0 + else: + d+=1 + stuck+=1 + + + elif d==2: #방향이 아래일 때 + if character_gps[0]0 and map_structure[character_gps[0]][character_gps[1]-1]==0: + character_gps[0]-=1 + map_structure[character_gps[0]][character_gps[1]]=1 + cnt+=1 + stuck=0 + else: + d=0 + stuck+=1 + + if stuck==4: + break + +print(cnt) \ No newline at end of file diff --git a/sort/6_2first.py b/sort/6_2first.py new file mode 100644 index 0000000..6b16ac5 --- /dev/null +++ b/sort/6_2first.py @@ -0,0 +1,9 @@ +N=int(input()) +lst=[] +for i in range(n): + lst[i]=int(input()) + +lst=sorted(lst,reversed=True) + +for i in lst: + print(i,end=" ") diff --git a/sort/6_3first copy.py b/sort/6_3first copy.py new file mode 100644 index 0000000..6b16ac5 --- /dev/null +++ b/sort/6_3first copy.py @@ -0,0 +1,9 @@ +N=int(input()) +lst=[] +for i in range(n): + lst[i]=int(input()) + +lst=sorted(lst,reversed=True) + +for i in lst: + print(i,end=" ") diff --git a/sort/6_4first copy 2.py b/sort/6_4first copy 2.py new file mode 100644 index 0000000..d45a61b --- /dev/null +++ b/sort/6_4first copy 2.py @@ -0,0 +1,14 @@ +n,k=map(int,input().split()) + +a=list(map(int,input().split())) +b=list(map(int,input().split())) + +a.sort() #배열 정렬 +b.sort(reverse=True) + +for i in range(k): + if a[i]