분류 전체보기

[7주차_입실 퇴실]-[위클리챌린지] My answer-시간초과 def solution(enter, leave): answer = [0]*len(enter) n=len(enter) for i in range(1,n+1): for j in range(1,n+1): if(i!=j): etmpi, etmpj=enter.index(i),enter.index(j) ltmpi, ltmpj=leave.index(i), leave.index(j) if(etmpi>etmpj and ltmpi
[방문 길이]-[Summer/Winter Coding(~2018)] My answer def solution(dirs): answer = set() posx,posy,tmpx,tmpy=0,0,0,0 for i in dirs: tmpx,tmpy=posx,posy if(i=='U' and posy!=5): posy+=1 elif(i=='D' and posy!=-5): posy-=1 elif(i=='R' and posx!=5): posx+=1 elif(i=='L' and posx!=-5): posx-=1 if((posx,posy)==(tmpx,tmpy)): continue answer.add((posx,posy,tmpx,tmpy)) answer.add((tmpx,tmpy,posx,posy)) return le..
[방금그곡]-[2018 KAKAO BLIND RECRUITMENT] My answer # 총 재생길이를 구해주는 함수 def timecalc(a,b): tmp,tmp2=[],[] tmp=a.split(':') tmp2=b.split(':') tmp=[int(i) for i in tmp] tmp2=[int(i) for i in tmp2] return (tmp2[0]-tmp[0])*60+tmp2[1]-tmp[1] '''#을 치환해주는 함수''' def substitution(a): alt={'C#':'H','D#':'I','F#':'J','G#':'K','A#':'L','E#':'M'} i=0 tmp="" while('#' in a): if(a[i]=='#'): tmp=a[i-1]+a[i] a=a[:i-1]..
[파일명 정렬]-[2018 KAKAO BLIND RECRUITMENT] My answer def solution(s): answer=[] tmp=[[ 0 for i in range(4)] for j in s] for index,i in enumerate(s): for j in range(len(i)): if(i[j].isdigit()==1): tmp[index][0]=i[:j].upper() for k in range(j,len(i)): tmp[index][3]=index if(k==len(i)-1): tmp[index][1]=int(i[j:]) break if(k==j+5 or i[k].isdigit()==0): tmp[index][1]=int(i[j:k]) tmp[index][2]=i[k:] brea..
[올바른 괄호] My answer-효율성 저하 def solution(s): answer = True s=list(s) #우선 갯수가 다르거나 맨앞이 ) 이거나 맨뒤가 ( 이면 바로 끝냄 answer= False if (s.count('(')!=s.count(')') or s[0]==')' or s[-1]=='(') else True if(answer==False): return answer while(len(s)!=0): if(s[0]=='('): for j in range(1,len(s)): if(s[j]==')'): flag=1 break if(flag==0): return False else: del s[0],s[j-1] flag=0 else: return False return True Anot..
[숫자의 표현] My answer def solution(n): answer = 0 for i in range(1,n+1): answer+=sums(i,n) return answer def sums(n,tmp): sumt=0 while(sumt=10): # 11진법 이상부터는 변환해서 넣는다 tmp.append(str(trans[j%n])) else: tmp.append(j%n) j//=n if(j==0): break tmp.reverse() tmp2+=[i for i in tmp] tmp=[] i+=1 for i in range(p-1,p+m*t-1,m): # 이용자가 말해야 되는 순번 인덱스에 저장된 숫자를 말한다. answer+=str(tmp2[i]) return answer Another answ..
창빵맨
'분류 전체보기' 카테고리의 글 목록 (70 Page)