ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/2204
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
for {
var n int
fmt.Fscanln(reader, &n)
if n == 0 {
break
}
var words []string
for i := 0; i < n; i++ {
var word string
fmt.Fscanln(reader, &word)
words = append(words, word)
}
sort.Slice(words, func(i, j int) bool {
return strings.ToLower(words[i]) < strings.ToLower(words[j])
})
fmt.Fprintln(writer, words[0])
}
}
๐จ Python3
# https://www.acmicpc.net/problem/2204
import sys
if __name__ == "__main__":
while True:
n = int(sys.stdin.readline())
if n == 0:
break
words = []
for i in range(n):
words.append(sys.stdin.readline().rstrip())
print(sorted(words, key=lambda x: x.lower())[0])
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 1260๋ฒ / DFS์ BFS [Go][Python3] (0) | 2020.12.05 |
---|---|
BOJ / 7596๋ฒ / MP3 Songs [Go][Python3] (0) | 2020.12.04 |
BOJ / 20291๋ฒ / ํ์ผ ์ ๋ฆฌ [Go][Python3] (0) | 2020.12.02 |
BOJ / 14235๋ฒ / ํฌ๋ฆฌ์ค๋ง์ค ์ ๋ฌผ [Python3] (0) | 2020.12.01 |
BOJ / 11286๋ฒ / ์ ๋๊ฐ ํ [Go][Python3] (0) | 2020.11.30 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ๋ฐฑ์ค
- Algorithm
- ๋งฅ๋ถ
- ๋ธ๋ฃจํธํฌ์ค
- ๋ชฝ๊ณ ๋๋น
- ballet
- ์๊ฐ๊ต์ฒด
- AWS
- java
- baekjoon
- BFS
- ์ด๋ถํ์
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ์๊ณ ๋ฆฌ์ฆ
- ์๋ฐ
- MongoDB
- ํด์๋งต
- ์คํ
- ํ
- Macbook pro 2012 mid 13
- go
- BOJ
- dp
- Golang
- ๋งฅ๋ถํ๋ก
- ํ๋ก์ด๋์์ฌ
- dfs
- python3
- ๋ฐ๋
- ๋ถํ ์ ๋ณต
- Total
- Today
- Yesterday