[Python] 파이썬 문자열 함수 정리
2021. 3. 16. 13:51
DEVELOP/Python
[Python] 파이썬 문자열 함수 정리 내가 보고 사용하기 위한 파이썬 문자열 함수 정리 지속 업데이트 예정 replace() 문자열 내의 특정 문자열을 다른 문자열로 바꾼 값을 리턴한다. replace("찾을 문자열", "바꿀 문자열") s = "Shoes on, get up in the morn', cup of milk, let's rock and roll" replaced = s.replace("milk", "coffee") print(replaced) # 결과 # Shoes on, get up in the morn', cup of coffee, let's rock and roll [MEMO] 찾을 문자열이 여러개라면? => 모든 문자열을 바꾼다. split() 인자를..
[Algorithm] 2019 카카오 블라인드 테스트 문제풀이 - 오픈채팅방
2021. 3. 3. 21:36
DEVELOP/Algorithm
[Algorithm] 2019 카카오 블라인드 테스트 문제풀이 - 오픈채팅방 문제 카카오톡 오픈채팅방에서는 친구가 아닌 사람들과 대화를 할 수 있는데, 본래 닉네임이 아닌 가상의 닉네임을 사용하여 채팅방에 들어갈 수 있다. 신입사원인 김크루는 카카오톡 오픈 채팅방을 개설한 사람을 위해, 다양한 사람들이 들어오고, 나가는 것을 지켜볼 수 있는 관리자창을 만들기로 했다. 채팅방에 누군가 들어오면 다음 메시지가 출력된다. "[닉네임]님이 들어왔습니다." 채팅방에서 누군가 나가면 다음 메시지가 출력된다. "[닉네임]님이 나갔습니다." 채팅방에서 닉네임을 변경하는 방법은 다음과 같이 두 가지이다. 채팅방을 나간 후, 새로운 닉네임으로 다시 들어간다. 채팅방에서 닉네임을 변경한다. 닉네임을 변경할 때는 기존에 채팅..
[Python] 파이썬 버전 및 가상환경 관리 - pyenv
2020. 11. 27. 10:35
DEVELOP/Python
pyenv 명령어 정리 Brew를 이용한 설치 $ brew install pyenv $ brew install pyenv-virtualenv .zshrc 설정 변경 $ vim ~/.zshrc # 아래 내용 입력 후 저장 export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" 설치된 파이썬 버전 확인 $ pyenv versions 빅서 업데이트 후 오류날 경우 $ brew install zlib $ brew install bzip2 $ export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/bzip2/lib" $ export CPPFLAGS="-..
[Python] LeetCode 문제풀이 :: 344. Reverse String
2020. 1. 16. 00:17
DEVELOP/Algorithm
리트코드 344번 문제풀이 https://leetcode.com/problems/reverse-string/ Reverse String - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must..
[Python] LeetCode 문제풀이 :: 27. Remove Element
2020. 1. 13. 05:16
DEVELOP/Algorithm
LeetCode 27번 문제풀이 https://leetcode.com/problems/remove-element/ Remove Element - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array..
[Python] LeetCode 문제풀이 :: 925. Long Pressed Name
2020. 1. 12. 07:45
DEVELOP/Algorithm
LeetCode 925번 문제풀이 https://leetcode.com/problems/long-pressed-name/ Long Pressed Name - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be ty..
[Python] LeetCode 문제풀이 :: 1. Two Sum
2020. 1. 11. 21:34
DEVELOP/Algorithm
LeetCode 1번 문제풀이 https://leetcode.com/problems/two-sum/ Two Sum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution..
[Python] Flask 프레임워크로 웹앱 만들기 1 :: 플라스크 설치
2019. 9. 7. 23:32
DEVELOP/Python
일에도 어느 정도 적응이 됐다. 그래서 8월말 쯤부터 퇴근하고 개인 프로젝트를 시작했다. 다양한 기술들을 사용해보는 게 목표다. 처음으로 시도한 건 파이썬 웹 프레임워크인 플라스크. 플라스크를 선택한 이유는? 쉽고 간단하니깐. 파이썬 웹 프레임워크의 대세는 두 개다. Django와 Flask. 상대적으로 장고는 기능이 많고 무겁고, 플라스크는 마이크로 프레임워크를 지향하는 만큼 가볍고 단순하다. 어차피 처음 만들어볼 건 개인 블로그니깐 큰 기능은 필요없었다. url에 맞춰 페이지를 뿌려주고, DB에서 데이터를 가져와 뿌려주고, 관리자 페이지를 만들어 화면단에서 DB를 관리하는 정도. 빠르게 간단한 서비스를 만들 수 있는 Flask를 먼저 해보는 것이 재미를 붙이기에 좋다고 생각했다. 우선 프레임워크란 무..
[Python] 백준 알고리즘 문제풀이 :: 9020번
2018. 10. 3. 20:32
DEVELOP/Algorithm
백준 알고리즘 9020번 골드바흐의 추측 문제풀이. 소수 분류에 있는 문제를 풀면서 시간초과가 엄청 많이 났다. 심지어 가장 시간 오래 걸릴 것 같은 경우를 파이참으로 돌렸을 땐 잘 나와도 백준에서 돌리면 시간초과가 나오는 경우가 많았다. 고생 좀 했다. 골드바흐의 추측은 2보다 큰 모든 짝수를 두 소수의 합으로 나타낼 수 있다는 것이다. 10000 이하의 수는 이미 증명이 됐다. 그에 해당하는 소수 조합을 출력하는 문제다. 문제 https://www.acmicpc.net/problem/9020 풀이 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import sys primes = []for i in..
[Python] 백준 알고리즘 문제풀이 :: 9012번
2018. 10. 2. 14:30
DEVELOP/Algorithm
파이썬을 이용한 백준 알고리즘 9012번 괄호 문제풀이. 스택으로 분류되어 있는 걸 생각하면 쉽게 풀린다. 그런데 스택을 생각하지 못한다면 은근 복잡하게 느껴지는 문제. 한 3분 이거 규칙을 어떻게 파악하지 생각했다. 그러다 문득 스택 문제집에 들어있다는 걸 생각하니 바로 해결책이 떠올랐다. 문제 https://www.acmicpc.net/problem/9012 풀이 1234567891011121314151617181920212223242526import sys tc = int(sys.stdin.readline()) for t in range(0, tc): flag = 1 stack = [] ps = sys.stdin.readline().rstrip() for i in range(0, len(ps)): ..