Programmers
-
Level.1 Summer/Winter Coding > 소수 만들기Programmers/Python 2021. 5. 10. 16:13
123456789101112131415161718192021222324import itertools as it;import math as math; def solution(nums): answer = 0; com = it.combinations(nums,3); def isPrime(isP): if isP == 1 or isP == 2: return True; elif isP % 2 == 0: return False; else: for div in range(2,int(math.sqrt(isP))+ 1 ): if isP % div == 0: return False; return True; for i in list(com): isP = sum([e for e in i]) if isPrime(isP): ans..
-
Level.1 연습문제 > 시저 암호Programmers/Python 2021. 5. 10. 15:32
12345678910111213141516171819def solution(s, n): answer = '' for i in s: if i == ' ': answer += i; continue; elif ord(i) >= 97 and ord(i) 122: answer += chr(((ord(i) + n) % 123) + 97); else: answer += chr(ord(i) + n); else: if ord(i) + n > 90: answer += chr(((ord(i) + n) % 91) + 65); else: answer += chr(ord(i) + n); return answer;Colored by Color Scriptercs
-
Level.1 연습문제 > 이상한 문자 만들기Programmers/Python 2021. 5. 10. 13:39
123456789101112131415def solution(s): index = 0; answer = ""; for spell in s: if spell == ' ': index = 0; answer += spell; continue; if index % 2 == 0: answer += spell.upper(); else: answer += spell.lower(); index += 1; return answer;cs