Skip to content

Commit

Permalink
Merge pull request #215 from AlgoLeadMe/30-SeongHoonC
Browse files Browse the repository at this point in the history
30-SeongHoonC
  • Loading branch information
SeongHoonC authored Jul 14, 2024
2 parents bafecdf + 91e5984 commit 77123fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SeongHoonC/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
| 27차시 | 2024.05.30 | 그래프 | <a href="https://www.acmicpc.net/problem/16724">피리 부는 사나이</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/201 |
| 28차시 | 2024.06.03 | 투포인터 | <a href="https://www.acmicpc.net/problem/1806">부분합</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/205 |
| 29차시 | 2024.07.01 | 구현, 그래프 | <a href="https://www.acmicpc.net/problem/16166">서울의 지하철</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/213 |

| 30차시 | 2024.07.08 | 브루트포스 | <a href="https://www.acmicpc.net/problem/1759">암호 만들기</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/215 |
---
24 changes: 24 additions & 0 deletions SeongHoonC/브루트포스/암호만들기.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
private lateinit var letters: List<String>

fun main() {
val br = System.`in`.bufferedReader()
val (l, c) = br.readLine().split(" ").map { it.toInt() }
letters = br.readLine().split(" ").sorted()

for (i in 0..c - l) {
dfs(i, letters[i], l)
}
}

private fun dfs(index: Int, word: String, l: Int) {
if (word.length == l) {
val counts = "aeiou".toList().count { word.contains(it) }
if (counts > 0 && l - counts > 1) {
println(word)
}
return
}
for (i in index + 1 until letters.size) {
dfs(i, word + letters[i], l)
}
}

0 comments on commit 77123fe

Please sign in to comment.