목록전체 글 (112)
Star_project
3. 카드 역배치 import sys sys.stdin=open("pythonalgorithm/섹션 3/3. 카드 역배치/in2.txt", "rt") a=list(range(21)) for _ in range(10): s, e=map(int, input().split()) for i in range((e-s+1)//2): a[s+i], a[e-i]=a[e-i], a[s+i] a.pop(0) for x in a: print(x, end=' ') 리스트 값 교환하는 방법 a, b = c, d --> a=c b=d 가 됨. a[s+i], a[e-i]=a[e-i], a[s+i] a.pop(0) 0번 인덱스 pop 해라.
2. 숫자만 추출 import sys sys.stdin=open("pythonalgorithm/섹션 3/2. 숫자만 추출/in1.txt","rt") a=input() res=cnt=0 for i in a: if i.isdecimal(): res=res*10+int(i) print(res) for i in range(1,res+1): if res%i==0: cnt+=1 print(cnt) isdecimal() Definition and Usage The isdecimal() method returns True if all the characters are decimals (0-9). This method is used on unicode objects. 출처 : https://www.w3schools.co..
1.회문 문자열 검사 import sys sys.stdin=open("pythonalgorithm/섹션 3/1. 회문 문자열 검사/in1.txt","rt") n=int(input()) for i in range(n): x=input() x=x.upper() for j in range(len(x)//2): if x[j]!=x[-j-1]: print("#%d NO" %(i+1)) break else: print("#%d YES" %(i+1)) x=input() 하면 됨!!
import sys sys.stdin=open("pythonalgorithm/섹션 2/10. 점수 계산/in2.txt","rt") n=int(input()) a=list(map(int,input().split())) score=ch=0 for x in a: if x==1 and ch==0: score+=1 ch+=1 elif x==1 and ch>0: score+=(1+ch) ch+=1 else: ch=0 print(score) 내가 푼 풀이 import sys sys.stdin=open("pythonalgorithm/섹션 2/10. 점수 계산/in2.txt","rt") n=int(input()) a=list(map(int,input().split())) score=ch=0 for x in a: if x..
import sys sys.stdin=open("pythonalgorithm/섹션 2/9. 주사위 게임/in5.txt","rt") n=int(input()) res=0 for _ in range(n): tmp=list(map(int,input().split())) tmp.sort() a,b,c=tmp if a==b and b==c: money=10000+1000*a elif a==b or a==c: money=1000+100*a elif b==c: money=1000+100*b else: money=100*c if money>res: res=money print(res)
UNDO, REDO REDO는 "다시 하다."라는 뜻을 가지고 UNDO는 "원상태로 돌리다" 라는 뜻을 가지고 있습니다. 즉 REDO는 무언가를 다시 하는 것이고 UNDO는 무언가를 되돌리는 것입니다. REDO는 기본적으로 복구의 역할을 합니다. 오라클 서버에 무슨 작업을 하든지 모두 REDO에 기록이 됩니다. (UNDO 포함) UNDO는 작업 롤백과, 읽기 일관성, 복구를 합니다. REDO와UNDO의 공통점은 복구를 한다는 것입니다. 출처 : https://brownbears.tistory.com/181 [DB] 트랜잭션, REDO와 UNDO 개념 트랜잭션이란? 데이터베이스 트랜잭션(Database Transaction)은 데이터베이스 관리 시스템 또는 유사한 시스템에서 상호작용의 단위입니다. 여기서 ..
import sys from sklearn.utils import resample sys.stdin=open("pythonalgorithm/섹션 2/8. 뒤집은 소수/in5.txt","rt") n=int(input()) a=list(map(int, input().split())) def reverse(x): res=0 while x>0: t=x%10 res=res*10+t x=x//10 return res def isPrime(x): if x==1: return False for i in range(2, x//2+1): if x%i==0: return False # false 당하면 if 문 끝남 else: return True # for 문 이 False 안당하고 정상적으로 종료되면 else 문 실행 ..
You are given three tables: Students, Friends and Packages. Students contains two columns: ID and Name. Friends contains two columns: ID and Friend_ID (ID of the ONLY best friend). Packages contains two columns: ID and Salary (offered salary in $ thousands per month). Write a query to output the names of those students whose best friends got offered a higher salary than them. Names must be order..
자릿수 더하기 문제 설명 자연수 N이 주어지면, N의 각 자릿수의 합을 구해서 return 하는 solution 함수를 만들어 주세요. 예를들어 N = 123이면 1 + 2 + 3 = 6을 return 하면 됩니다. 제한사항 N의 범위 : 100,000,000 이하의 자연수 입출력 예Nanswer 123 6 987 24 입출력 예 설명 입출력 예 #1 문제의 예시와 같습니다. 입출력 예 #2 9 + 8 + 7 = 24이므로 24를 return 하면 됩니다. def solution(n): answer = 0 while n>0: answer+=n%10 n=n//10 return answer