Skip to content

Commit

Permalink
2024-10-05
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjunYou committed Oct 5, 2024
1 parent 3cb15d2 commit dc1fffd
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions wonjunYou/백트래킹/BOJ_1759.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import sys

input = sys.stdin.readline

def dfs(idx, password):
if len(password) == l:
vowel_count = 0
consonant_count = 0

for letter in password:
if letter in vowels:
vowel_count += 1

else:
consonant_count += 1

if vowel_count >= 1 and consonant_count >= 2:
print(password)

return

if idx >= len(characters):
return

dfs(idx + 1, password + characters[idx])
dfs(idx + 1, password)

l, c = map(int, input().rstrip('\n').split())
characters = list(input().rstrip('\n').split())

characters.sort()

vowels = ['a', 'e', 'i', 'o', 'u']
vowels = set(vowels)

dfs(0, "")

0 comments on commit dc1fffd

Please sign in to comment.