목록분류 전체보기 (317)
지나가던 개발자

def hab(n): return str(sum(list(map(int, list(n))))) while True: n = input() if n == "0": break while True: if len(n) == 1: print(n) break n = hab(n)

for i in range(int(input())): ox = input() continuity = 1 grade = 0 for j in range(len(ox)): if ox[j] == "O": grade += continuity continuity += 1 else: continuity = 1 print(grade) 맨날 글 쓰기 귀찮아서 임시저장 해두는데 임시저장 글이 90일까지밖에 저장이 안 된다는 사실을 깨닫고 부랴부랴 글 쓴다..

from itertools import combinations while True: s = input().split(" ")[1:] if s == []: break for i in combinations(s, 6): print(" ".join(i)) print("") itertools 진짜 너무 편한 것 같다.. PS할때 모듈 쓰면 안되는게 스탠다드긴 한데, 나는 이미 잘 만들어진 기본 모듈 놓고 왜 직접 이걸 구현하는지 모르겠다. 특히 파이썬에서는. 나도 C할때는 알고리즘 가지고 다 한다! 이 글을 쓰는 데 도움이 되었던 자료: https://juhee-maeng.tistory.com/91 (Python) 순열, 조합, 중복순열, 중복조합 쉽게 구현하기 (Python) 순열, 조합, 중복순열, 중복조합..

def jinsu(n, m): s = 0 while True: if n // m == 0: s += n break s += n%m n = n // m return s for i in [2992, 2993, 2994, 2995, 2996, 2997, 2998, 2999]: print(i) for i in range(3000, 10000): if sum(list(map(int, list(str(i))))) == jinsu(i, 12) == jinsu(i, 16): print(i) 시간초과가 뜨지 않을까? 생각했지만 괜한 걱정이었다. 잘 된다. jinsu 함수는 저번에 만든 진수 변환기 코드를 조금 응용해서배껴서 만들었다. https://developer-next-to-you.tistory.com/11?cat..

s = input() angle_bracket = False to_print = "" for i in s: if i == "": angle_bracket = False print(i, end='') continue if angle_bracket: print(i, end='') continue if i == " ": print("".join(list(reversed(to_print))), end=' ') to_print = "" continue to_print += i print("".join(list(reversed(to_print)))) 꺽쇠의 안쪽인지 아닌지를 True or False 형태로 판별한 뒤, 뒤집은 문자열 혹은 뒤집지 않은 문자열을 출력한다. 16번라인~19번라인... [틀렸습니다]가 떠..

s1 = input() s2 = input() lcs = [[0 for col in range(len(s1)+1)] for row in range(len(s2)+1)] for i in range(1, len(s2)+1): for j in range(1, len(s1)+1): if s1[j-1] == s2[i-1]: lcs[i][j] = lcs[i-1][j-1]+1 continue lcs[i][j] = max(lcs[i-1][j], lcs[i][j-1]) print(max(sum(lcs, []))) 이 문제를 풀고 솔브닥 골드가 되었다...! LCS를 구하는 알고리즘을 설명한 글은 밑에다가 첨부해 놓겠다. 내가 글을 하나 쓸까 하는 생각도 했지만 밑의 블로그가 너무 잘 써서 그걸 보는 편이 나을 듯 하다...

while True: try: print(input()) except: break 11718번 문제와 정답 코드가 정확히 일치한다. 11718번은 브론즈V였는데 이건 왜 브론즈II인지 알 수가 없다.

group_word = 0 for i in range(int(input())): is_group_word = True word = input() wordAlphabet = [] for j in word: if j not in wordAlphabet: wordAlphabet.append(j) if len(wordAlphabet) == len(word) or len(wordAlphabet) == 1: group_word += 1 continue for j in range(len(wordAlphabet)): if j == 0 or j == len(wordAlphabet)-1: if len([x for x in word.split(wordAlphabet[j]) if x != '']) == 1: continue ..