Algorithm/goorm 25

goorm 소수 판별, 고장난 컴퓨터, 하노이의 탑

소수 판별 # -*- coding: utf-8 -*- # UTF-8 encoding when using korean n = int(input()) sw = 0 for i in range(2, n): if(n % i == 0): sw += 1 if(sw == 0): print("True") else: print("False") 고장난 컴퓨터 # -*- coding: utf-8 -*- # UTF-8 encoding when using korean n, tick = map(int, input().split(' ')) num = input().split(' ') cnt = 0 for i in range(0, n-1): if((int(num[i+1]) - int(num[i])) > tick): cnt = 0 el..

Algorithm/goorm 2020.09.13

goorm 재원 넘버, 부모 단어, 피자 쿠폰

재원 넘버 # -*- coding: utf-8 -*- # UTF-8 encoding when using korean n = int(input()) cnt = 0 for i in range(1, n+1): cnt += 3 ** i print(cnt) 부모 단어 # -*- coding: utf-8 -*- # UTF-8 encoding when using korean n,m = input().split(' ') parent = [i for i in n] qst = [j for j in m] sw = 0 for k in range(len(qst)): if qst[k] not in parent: sw = 1 if(sw==0): print("YES") else: print("NO") 피자 쿠폰 #include us..

Algorithm/goorm 2020.09.11

goorm 가위바위보, 홀수 놀이, 멀티탭 사용

가위바위보 # -*- coding: utf-8 -*- # UTF-8 encoding when using korean s = input().split(' ') x = 0 #가위 o = 0 #주먹 q = 0 #보 for i in range(5): if(s[i]=='1'): x += 1 elif(s[i]=='2'): o += 1 elif(s[i]=='3'): q += 1 if(x==0 and o!=0 and q!=0): print(q) elif(x!=0 and o==0 and q!=0): print(x) elif(x!=0 and o!=0 and q==0): print(o) else: print(0) 홀수 놀이 #include #include using namespace std; int main() { int ..

Algorithm/goorm 2020.09.07

goorm 문자열 번갈아 출력하기, 벡터의 +, - 연산, 구구단+

문자열 번갈아 출력하기 # -*- coding: utf-8 -*- # UTF-8 encoding when using korean s = input() l = len(s) if(l%2==0): frt = s[0:int(l/2):1] lst = s[l-1:int(l/2)-1:-1] else: frt = s[0:int(l/2)+1:1] lst = s[l-1:int(l/2):-1] i = 0 while(1): if(i+1>len(frt)): break print(frt[i], end='') if(i+1>len(lst)): break print(lst[i], end='') i += 1 벡터의 +, - 연산 # -*- coding: utf-8 -*- # UTF-8 encoding when using korean x..

Algorithm/goorm 2020.09.06

goorm 완전 제곱수, 앵무새 꼬꼬, 은행 예금 이자 구하기

완전 제곱수 # -*- coding: utf-8 -*- # UTF-8 encoding when using korean n = int(input()) a = [] for i in range(n): a.append(int(input())) sum =0 for i in range(0, n): tmp = a[i] ** 0.5 if int(tmp) == tmp: if(tmp ** 2 == a[i]): sum += 1 print(sum) 앵무새 꼬꼬 # -*- coding: utf-8 -*- # UTF-8 encoding when using korean checkWord = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] n = int(input()) slist =[] a..

Algorithm/goorm 2020.08.30