일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- ChatGPT
- 캐치카페
- gs25
- leetcode
- 편스토랑 우승상품
- 백준
- 금융문자분석경진대회
- 자연어처리
- hackerrank
- programmers
- 프로그래머스 파이썬
- github
- PYTHON
- 편스토랑
- 우분투
- 파이썬
- 프로그래머스
- Git
- Real or Not? NLP with Disaster Tweets
- ubuntu
- Docker
- 코로나19
- SW Expert Academy
- dacon
- Baekjoon
- AI 경진대회
- 데이콘
- 맥북
- Kaggle
- 더현대서울 맛집
- Today
- Total
목록
반응형
Programming/코딩 1일 1문제 (1013)
솜씨좋은장씨

1일 1문제 78일차 오늘의 문제는 백준의 가장 긴 감소하는 부분 수열 입니다. 11722번: 가장 긴 감소하는 부분 수열 수열 A가 주어졌을 때, 가장 긴 감소하는 부분 수열을 구하는 프로그램을 작성하시오. 예를 들어, 수열 A = {10, 30, 10, 20, 20, 10} 인 경우에 가장 긴 감소하는 부분 수열은 A = {10, 30, 10, 20, 20, 10} 이고, 길이는 3이다. www.acmicpc.net Solution inputNum = int(input()) inputNums = input() inputNums = inputNums.split() inputNums = [int(num) for num in inputNums] nc = [0] * (inputNum) maxNum = 0 f..

1일 1문제 77일차! 오늘의 문제는 프로그래머스의 카펫입니다. 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr Solution def solution(brown, red): answer = [] for red_height in range(1, int(red**0.5) + 1): if red % red_height == 0: red_width = red // red_height if (2*red_width) + (2*red_height) + 4 == brown: answer = [red_width + 2, red_height + 2] break return..

1일 1문제 76일차! 오늘의 문제는 백준의 이친수입니다. 2193번: 이친수 0과 1로만 이루어진 수를 이진수라 한다. 이러한 이진수 중 특별한 성질을 갖는 것들이 있는데, 이들을 이친수(pinary number)라 한다. 이친수는 다음의 성질을 만족한다. 이친수는 0으로 시작하지 않는다. 이친수에서는 1이 두 번 연속으로 나타나지 않는다. 즉, 11을 부분 문자열로 갖지 않는다. 예를 들면 1, 10, 100, 101, 1000, 1001 등이 이친수가 된다. 하지만 0010101이나 101101은 각각 1, 2번 규칙에 위배되 www.acmicpc.net Solution n = int(input()) def answer(n): if n == 1: fiboNum = 1 elif n == 2: fibo..

1일 1문제 75일차! 오늘의 문제는 백준의 암호코드 입니다.

1일 1문제 74일차! 오늘의 문제는 프로그래머스의 쇠막대기입니다. 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr Solution def solution(arrangement): sum_num = 0 left = 0 for i in range(len(arrangement)): if arrangement[i] == '(': left = left + 1 elif arrangement[i] == ')': left = left - 1 if arrangement[i-1] == '(': sum_num = sum_num + left else: sum_num = sum..

1일 1문제 73일차! 오늘의 문제는 프로그래머스의 2018 KAKAO BLIND RECRUITMENT : [1차] 뉴스클러스트링 입니다. 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫번째 제출 import re def getTwolengthString(temp): re_compile = re.compile('[a-z]{2}') re_match = re.fullmatch(re_compile, temp) return re_match def solution(str1, str2): str1_list = list(str1.lower()) str2_list =..

1일 1문제 72일차! 오늘의 문제는 백준의 제로입니다. 10773번: 제로 문제 나코더 기장 재민이는 동아리 회식을 준비하기 위해서 장부를 관리하는 중이다. 재현이는 재민이를 도와서 돈을 관리하는 중인데, 애석하게도 항상 정신없는 재현이는 돈을 실수로 잘못 부르는 사고를 치기 일쑤였다. 재현이는 잘못된 수를 부를 때마다 0을 외쳐서, 가장 최근에 재민이가 쓴 수를 지우게 시킨다. 재민이는 이렇게 모든 수를 받아 적은 후 그 수의 합을 알고 싶어 한다. 재민이를 도와주자! 입력 첫 번째 줄에 정수 K가 주어진다. (1 ≤ K ≤ www.acmicpc.net Solution input_N = int(input()) stack = [] for i in range(input_N): input_num = int..

1일 1문제 71일차! 오늘의 문제는 프로그래머스의 영어 끝말잇기 입니다. 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr Solution def solution(n, words): answer = [0, 0] for i in range(1, len(words)): if words[i-1][-1] != words[i][0] or words[i] in words[0:i]: answer[0] = ( i % n ) + 1 answer[1] = ( i // n ) + 1 break return answer SOMJANG/CODINGTEST_PRACTICE 1일 1..

1일 1문제 70일차! 오늘의 문제는 프로그래머스의 Summer/Winter Coding(~2018)의 소수만들기입니다. 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr Solution from itertools import combinations def getPrimaryNum_Eratos(N): nums = [True] * (N + 1) for i in range(2, len(nums) // 2 + 1): if nums[i] == True: for j in range(i+i, N, i): nums[j] = False return [i for i in r..

1일 1문제 69일차! 오늘의 문제는 2019 카카오 개발자 겨울 인턴십 문제였던 튜플 입니다. 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr Solution from collections import Counter def solution(s): answer = [] delete_special_word_s = s.replace("{", "").replace("}", "").split(',') count_dict = Counter(delete_special_word_s) count_dict_most_common = count_dict.most_common(..

코딩 1일 1문제 68일차! 오늘의 문제는 백준의 JOI와 IOI입니다. 5586번: JOI와 IOI 문제 입력으로 주어지는 문자열에서 연속으로 3개의 문자가 JOI 또는 IOI인 곳이 각각 몇 개 있는지 구하는 프로그램을 작성하시오. 문자열은 알파벳 대문자로만 이루어져 있다. 예를 들어, 아래와 같이 "JOIOIOI"에는 JOI가 1개, IOI가 2개 있다. 입력 첫째 줄에 알파벳 10000자 이내의 문자열이 주어진다. 출력 첫째 줄에 문자열에 포함되어 있는 JOI의 개수, 둘째 줄에 IOI의 개수를 출력한다. 예제 입력 1 복사 JOIOIOIOI 예 www.acmicpc.net Solution input_string = str(input()) JOI = 0 IOI = 0 if len(input_str..

1일 1문제 67일차! 오늘의 문제는 프로그래머스의 다리를 지나는 트럭입니다. 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫번째 시도 from collections import deque def solution(bridge_length, weight, truck_weights): answer = 0 truck_weights_deque = deque(truck_weights) trucks_on_bridge = [] while True: if len(truck_weights_deque) == 0: break if sum(trucks_on_bridge) <..

1일 1문제 66일차! 오늘의 문제는 백준에 있는 모음의 개수입니다. 1264번: 모음의 개수 문제 영문 문장을 입력받아 모음의 개수를 세는 프로그램을 작성하시오. 모음은 'a', 'e', 'i', 'o', 'u'이며 대문자 또는 소문자이다. 입력 입력은 여러 개의 테스트 케이스로 이루어져 있으며, 각 줄마다 영어 대소문자, ',', '.', '!', '?', 공백으로 이루어진 문장이 주어진다. 각 줄은 최대 255글자로 이루어져 있다. 입력의 끝에는 한 줄에 '#' 한 글자만이 주어진다. 출력 각 줄마다 모음의 개수를 세서 출력한다. 예제 입력 www.acmicpc.net Solution vowel_list = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] ..

1일 1문제 65일차! 오늘의 문제는 프로그래머스 해시의 위장입니다. 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr Solution def solution(clothes): answer = 1 spy_clothes_dict = {} for cloth in clothes: if cloth[1] not in spy_clothes_dict.keys(): spy_clothes_dict[cloth[1]] = 1 else: spy_clothes_dict[cloth[1]] = spy_clothes_dict[cloth[1]] + 1 all_values = list(sp..

1일 1문제! 64일차! 오늘의 문제는 백준의 연속합입니다! 1912번: 연속합 첫째 줄에 정수 n(1 ≤ n ≤ 100,000)이 주어지고 둘째 줄에는 n개의 정수로 이루어진 수열이 주어진다. 수는 -1,000보다 크거나 같고, 1,000보다 작거나 같은 정수이다. www.acmicpc.net Solution inputNum = int(input()) inputNums = input() inputNums = inputNums.split() inputNums = [int(num) for num in inputNums] inputNums.insert(0, 0) maxSum = [] maxSum.append(inputNums[0]) for i in range(1, inputNum+1): maxSum.appe..

1일 1문제 63일차! 오늘의 문제는 프로그래머스의 디스크 컨트롤러입니다! 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr Solution def solution(jobs): job_nums = len(jobs) answer = 0 jobs.sort(key=lambda x: (x[0], x[1])) start, time = jobs.pop(0) end = time + start answer = answer + time while jobs: next_index = 0 for index in range(1, len(jobs)): if jobs[index][0]..

1일 1문제 62일차! 오늘의 문제는 백준의 스티커입니다. 9465번: 스티커 문제 상근이의 여동생 상냥이는 문방구에서 스티커 2n개를 구매했다. 스티커는 그림 (a)와 같이 2행 n열로 배치되어 있다. 상냥이는 스티커를 이용해 책상을 꾸미려고 한다. 상냥이가 구매한 스티커의 품질은 매우 좋지 않다. 스티커 한 장을 떼면, 그 스티커와 변을 공유하는 스티커는 모두 찢어져서 사용할 수 없게 된다. 즉, 뗀 스티커의 왼쪽, 오른쪽, 위, 아래에 있는 스티커는 사용할 수 없게 된다. 모든 스티커를 붙일 수 없게된 상냥이는 각 스티커에 점 www.acmicpc.net Solution loopNum = int(input()) for i in range(loopNum): inputNum = int(input()) ..

Consider an array of integers, arr = [ arr [0], arr [1], ... , arr [n - 1]]. We define the absolute difference between two elements, a[i] and a[j] (where i != j), to be the absolute value of a[i] - a[j]. Given an array of integers, find and print the minimum absolute difference between any two elements in the array. For example, given the array arr = [ -2, 2, 4 ] we can create 3 pairs of numbers..

1일 1문제 60일차! 오늘의 문제는 프로그래머스의 더 맵게 입니다. 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 첫번째 시도 def solution(scoville, K): answer = -1 count = 0 check_flag = False while min(scoville) < K: scoville = sorted(scoville, reverse=True) scoville.append(scoville.pop() + (scoville.pop() * 2) ) if len(scoville) == 1 and scoville[0] < K: check_f..

Given a time in 12-hour AM/PM format, convert it to military (24-hour) time. Note: Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock. Noon is 12:00:00PM on a 12-hour clock, and 12:00:00 on a 24-hour clock. Function Description Complete the timeConversion function in the editor below. It should return a new string representing the input time in 24 hour format. timeConvers..

You are in charge of the cake for your niece's birthday and have decided the cake will have one candle for each year of her total age. When she blows out the candles, she’ll only be able to blow out the tallest ones. Your task is to find out how many candles she can successfully blow out. For example, if your niece is turning 4 years old, and the cake will have 4 candles of height 4, 4, 1, 3, sh..

A queue is an abstract data type that maintains the order in which elements were added to it, allowing the oldest elements to be removed from the front and new elements to be added to the rear. This is called a First-In-First-Out (FIFO) data structure because the first element added to the queue (i.e., the one that has been waiting the longest) is always the first one to be removed. A basic queu..

Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. For example, arr = [ 1, 3, 5, 7, 9 ]. Our minimum sum is 1 + 3 + 5 + 7 = 16 and our maximum sum is 3 + 5 + 7 + 9 = 24. We would print 16 24 Function Descri..

Consider a staircase of size : n = 4 # ## ### #### Observe that its base and height are both equal to n, and the image is drawn using # symbols and spaces. The last line is not preceded by any spaces. Write a program that prints a staircase of size n. Function Description Complete the staircase function in the editor below. It should print a staircase as described above. staircase has the follow..

1일 1문제 55일차! 오늘의 문제는 백준의 타일 채우기 문제입니다. 2133번: 타일 채우기 문제 3×N 크기의 벽을 2×1, 1×2 크기의 타일로 채우는 경우의 수를 구해보자. 입력 첫째 줄에 N(1 ≤ N ≤ 30)이 주어진다. 출력 첫째 줄에 경우의 수를 출력한다. 예제 입력 1 복사 2 예제 출력 1 복사 3 힌트 아래 그림은 3×12 벽을 타일로 채운 예시이다.... www.acmicpc.net Solution inputNum = int(input()) nc = [0] * (inputNum+1) for i in range(1, inputNum+1): if i % 2 == 1 : nc[i] = 0 elif i == 2 : nc[i] = 3 else : temp = 0 for j in range(..

1일 1문제 54일차! 오늘의 문제는 백준의 30입니다. 10610번: 30 문제 어느 날, 미르코는 우연히 길거리에서 양수 N을 보았다. 미르코는 30이란 수를 존경하기 때문에, 그는 길거리에서 찾은 수에 포함된 숫자들을 섞어 30의 배수가 되는 가장 큰 수를 만들고 싶어한다. 미르코를 도와 그가 만들고 싶어하는 수를 계산하는 프로그램을 작성하라. 입력 N을 입력받는다. N는 최대 105개의 숫자로 구성되어 있으며, 0으로 시작하지 않는다. 출력 미르코가 만들고 싶어하는 수가 존재한다면 그 수를 출력하라. 그 수가 존재하지 않는 www.acmicpc.net Solution 1 N = input() N = list(N) answer = -1 max_num = sorted(N, reverse=True) m..

1일 1문제 53일차! 오늘의 문제는 동전 0 입니다. 11047번: 동전 0 첫째 줄에 N과 K가 주어진다. (1 ≤ N ≤ 10, 1 ≤ K ≤ 100,000,000) 둘째 줄부터 N개의 줄에 동전의 가치 Ai가 오름차순으로 주어진다. (1 ≤ Ai ≤ 1,000,000, A1 = 1, i ≥ 2인 경우에 Ai는 Ai-1의 배수) www.acmicpc.net 첫번째 시도 N, K = map(int, input().split()) coins = [] for i in range(N): coin = int(input()) coins.append(coin) index = N - 1 count = 0 while K != 0: if coins[index] K: index = index - 1 print(coun..

1일 1문제 52일차! 오늘의 문제는 서로 다른 부분 문자열의 개수 입니다. 11478번: 서로 다른 부분 문자열의 개수 첫째 줄에 문자열 S가 주어진다. S는 알파벳 소문자로만 이루어져 있고, 길이는 1,000 이하이다. www.acmicpc.net Solution 1 string = str(input()) strings = [] for i in range(len(string)): for j in range(len(string) - i): strings.append(string[j:j+i+1]) print(len(set(strings))) SOMJANG/CODINGTEST_PRACTICE 1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTI..

1일 1문제 51일차! 오늘의 문제는 백준의 KMP는 왜 KMP일까? 입니다. 2902번: KMP는 왜 KMP일까? 문제 KMP 알고리즘이 KMP인 이유는 이를 만든 사람의 성이 Knuth, Morris, Prett이기 때문이다. 이렇게 알고리즘에는 발견한 사람의 성을 따서 이름을 붙이는 경우가 많다. 또 다른 예로, 유명한 비대칭 암호화 알고리즘 RSA는 이를 만든 사람의 이름이 Rivest, Shamir, Adleman이다. 사람들은 이렇게 사람 성이 들어간 알고리즘을 두 가지 형태로 부른다. 첫 번째는 성을 모두 쓰고, 이를 하이픈(-)으로 이어 붙인 것이다. 예 www.acmicpc.net Solution input_string = str(input()) split_string = input_st..

Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc" Note: In the string, each word is separated by single space and there will not be any extra space in the string. Solution 1 class Solution: def reverseWords(self, ..