Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 스프링배치 엑셀
- step 값 공유
- 스프링 배치 5
- abstractpagingitemreader
- mybatis
- executioncontext 변수 공유
- 선언적 트랜잭션 관리
- JSON 분리
- step 여러개
- 아이템 리더 커스텀
- 스프링배치 메타테이블
- flatfileitemwriter
- 스프링 트랜잭션 관리
- 마이바티스 트랜잭션
- stepexecutionlistener
- 트랜잭션 분리
- api 아이템 리더
- aop proxy
- JSON 분할
- 아이템 리더 페이징 처리
- step 사이 변수 공유
- spring batch 변수 공유
- JSONObject 분할
- executioncontext
- Spring Batch
- 스프링배치 csv
- 읽기 작업과 쓰기 작업 분리
- JSONArray 분할
- job parameter
- spring batch 5
Archives
- Today
- Total
ebson
boj.kr/1759 암호 만들기 (gold5) 파이썬 풀이 본문
1. 입력받은 후보 문자들 중 모음문자를 vowels에 저장
2. combinations를 사용해 추출한 모든 L개의 문자 조합에 대해 아래를 반복
2.1. 모음문자의 개수를 카운트
2.2. 모음문자가 0개보다 많고 L-2개 이하이면, passwords 배열에 append
3. passwords 배열을 정렬한 후 순회하면서 출력
L, C = map(int, input().split())
words = list(input().split())
vowels = []
for w in words:
if w in ('a', 'e', 'i', 'o', 'u'):
vowels.append(w)
passwords = []
from itertools import combinations
for combi in combinations(words, L):
v_cnt = 0
for c in combi:
if c in vowels:
v_cnt += 1
if 0 < v_cnt <= L-2:
passwords.append(''.join(sorted(list(combi))))
for password in sorted(passwords):
print(password)
itertools에서 combinations를 import 하고 배열로부터 N개의 요소를 추출하는 모든 조합을 구할 수 있다.
'ALGORITHM STUDY WITH PYTHON > BFS | DFS' 카테고리의 다른 글
boj.kr/14502 연구소 (gold4) 파이썬 풀이 (0) | 2023.04.25 |
---|---|
boj.kr/1697 숨바꼭질 (silver1) 파이썬 풀이 (0) | 2023.04.25 |
boj.kr/7576 토마토 (gold5) 파이썬 풀이 (0) | 2023.04.24 |
boj.kr/2667 단지번호붙이기 (silver1) 파이썬 풀이 (0) | 2023.04.24 |
boj.kr/2178 미로 탐색 (silver1) 파이썬 풀이 (0) | 2023.04.24 |
Comments