๋ฌธ์ ์ค๋ช
์ฌ์ ์ ์ํ๋ฒณ ๋ชจ์ 'A', 'E', 'I', 'O', 'U'๋ง์ ์ฌ์ฉํ์ฌ ๋ง๋ค ์ ์๋, ๊ธธ์ด 5 ์ดํ์ ๋ชจ๋ ๋จ์ด๊ฐ ์๋ก๋์ด ์์ต๋๋ค. ์ฌ์ ์์ ์ฒซ ๋ฒ์งธ ๋จ์ด๋ "A"์ด๊ณ , ๊ทธ๋ค์์ "AA"์ด๋ฉฐ, ๋ง์ง๋ง ๋จ์ด๋ "UUUUU"์
๋๋ค.
๋จ์ด ํ๋ word๊ฐ ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง ๋, ์ด ๋จ์ด๊ฐ ์ฌ์ ์์ ๋ช ๋ฒ์งธ ๋จ์ด์ธ์ง return ํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์.
์ ํ์ฌํญ
word์ ๊ธธ์ด๋ 1 ์ด์ 5 ์ดํ์
๋๋ค.
word๋ ์ํ๋ฒณ ๋๋ฌธ์ 'A', 'E', 'I', 'O', 'U'๋ก๋ง ์ด๋ฃจ์ด์ ธ ์์ต๋๋ค.
์ ์ถ๋ ฅ ์
word | result |
"AAAAE" | 6 |
"AAAE" | 10 |
"I" | 1563 |
"EIO" | 1189 |
์ ์ถ๋ ฅ ์ ์ค๋ช
์
์ถ๋ ฅ ์ #1
์ฌ์ ์์ ์ฒซ ๋ฒ์งธ ๋จ์ด๋ "A"์ด๊ณ , ๊ทธ๋ค์์ "AA", "AAA", "AAAA", "AAAAA", "AAAAE", ... ์ ๊ฐ์ต๋๋ค. "AAAAE"๋ ์ฌ์ ์์ 6๋ฒ์งธ ๋จ์ด์
๋๋ค.
์
์ถ๋ ฅ ์ #2
"AAAE"๋ "A", "AA", "AAA", "AAAA", "AAAAA", "AAAAE", "AAAAI", "AAAAO", "AAAAU"์ ๋ค์์ธ 10๋ฒ์งธ ๋จ์ด์
๋๋ค.
์
์ถ๋ ฅ ์ #3
"I"๋ 1563๋ฒ์งธ ๋จ์ด์
๋๋ค.
์
์ถ๋ ฅ ์ #4
"EIO"๋ 1189๋ฒ์งธ ๋จ์ด์
๋๋ค.
ํ์ด
- ์ด๊ฒ ๋ญ๊ฐ? ๋ฌด์จ ์ผ์ธ๊ฐ?
- ํผ๋ฎคํ ์ด์ ํ ๋ค์์ ๋ฌธ์์ ์ํธํด์ ์ธ๋ฑ์ค ๋ฝ๋ ๋ฌธ์ ์ธ๊ฐ?
- ์๋๊ฑฐ ๊ฐ์๋ฐ...
- ํ์ฐธ ์ณ๋ค๋ณด๋ค๊ฐ ๋ชจ๋ฅด๊ฒ ์ด์ ๋ ธํธ์ ์ ์ด๊ฐ๋ฉด์ ๊ท์น์ ์ฐพ์๋ณด์๋ค.
- ์ฐพ์ ๊ฑฐ ๊ฐ์๋ฐ...?
- A, E, I, O, U = 1,2,3,4,5
- ๊ทธ ๋ค์ ๋ถ์ ์ซ์๋ 5์ ์ ๊ณฑ : 5, 25, 125, 625, 3125.... ์ 5**5๋ ํ์์๋?
- AAAAE = 4 + 2 = 6
- AAAE = 3 + 2 + 5 = 10
- I = 1563 = 3 + 2 * (5 + 25 + 125 + 625) = 1563
- EIO = 2 + 1*(5+25+125+625) + 3 + 2*(5+25+125) + 4 + 3*(5+25) = 1189
def solution(word):
answer = 0
word_list = [int(ord(s)/4.5)-13 for s in word]
for i in range(len(word_list)):
answer += word_list[i] + (word_list[i]-1) * sum(5**x for x in range(1, 5-i))
return answer
์ ํ์ฑ ํ
์คํธ
ํ
์คํธ 1 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 2 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 3 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 4 ใ ํต๊ณผ (0.01ms, 10MB)
ํ
์คํธ 5 ใ ํต๊ณผ (0.02ms, 10.1MB)
ํ
์คํธ 6 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 7 ใ ํต๊ณผ (0.02ms, 10MB)
ํ
์คํธ 8 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 9 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 10 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 11 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 12 ใ ํต๊ณผ (0.01ms, 10MB)
ํ
์คํธ 13 ใ ํต๊ณผ (0.01ms, 9.97MB)
ํ
์คํธ 14 ใ ํต๊ณผ (0.01ms, 9.95MB)
ํ
์คํธ 15 ใ ํต๊ณผ (0.02ms, 10.2MB)
ํ
์คํธ 16 ใ ํต๊ณผ (0.01ms, 10.3MB)
ํ
์คํธ 17 ใ ํต๊ณผ (0.02ms, 10.1MB)
ํ
์คํธ 18 ใ ํต๊ณผ (0.02ms, 10MB)
ํ
์คํธ 19 ใ ํต๊ณผ (0.02ms, 10.1MB)
ํ
์คํธ 20 ใ ํต๊ณผ (0.01ms, 10.3MB)
ํ
์คํธ 21 ใ ํต๊ณผ (0.01ms, 9.97MB)
ํ
์คํธ 22 ใ ํต๊ณผ (0.02ms, 10MB)
ํ
์คํธ 23 ใ ํต๊ณผ (0.02ms, 10MB)
ํ
์คํธ 24 ใ ํต๊ณผ (0.01ms, 10MB)
ํ
์คํธ 25 ใ ํต๊ณผ (0.01ms, 9.99MB)
ํ
์คํธ 26 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 27 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 28 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 29 ใ ํต๊ณผ (0.02ms, 10.2MB)
ํ
์คํธ 30 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 31 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 32 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 33 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 34 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 35 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 36 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 37 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 38 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 39 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 40 ใ ํต๊ณผ (0.01ms, 10.3MB)
- ํ๋ก๊ทธ๋๋จธ์ค ์ฝ๋ฉํ ์คํธ ์ฐ์ต์ ๋๋ฌ ์งธ ํ๊ณ ์๋๋ฐ ์ด์ ์ฌ์ด ๋ฌธ์ ๋ ํ๋ฒ ๋ง์ถ๊ธฐ๋ ํ๋๊ตฌ๋...?
- ๊ณ ์์ ํ์ด๋... ใ ใ ใ
- ์ฑ๋ฅ์ด ๋น ๋ฅด์ง๋ ์๋ค. ๊ฒฐ๊ตญ ์ฐพ์์ผ ํ๋๊น... ์ด๋ฐ ๊ฒฝ์ฐ์๋ ํด์, ๋์ ๋๋ฆฌ๊ฐ ๋ ๋นจ๋์์ง๋...
์ ํ์ฑ ํ
์คํธ
ํ
์คํธ 1 ใ ํต๊ณผ (0.02ms, 13.7MB)
ํ
์คํธ 2 ใ ํต๊ณผ (0.03ms, 13.7MB)
ํ
์คํธ 3 ใ ํต๊ณผ (0.07ms, 13.6MB)
ํ
์คํธ 4 ใ ํต๊ณผ (0.10ms, 13.8MB)
ํ
์คํธ 5 ใ ํต๊ณผ (0.07ms, 13.6MB)
ํ
์คํธ 6 ใ ํต๊ณผ (0.05ms, 13.8MB)
ํ
์คํธ 7 ใ ํต๊ณผ (0.10ms, 13.8MB)
ํ
์คํธ 8 ใ ํต๊ณผ (0.04ms, 13.7MB)
ํ
์คํธ 9 ใ ํต๊ณผ (0.06ms, 13.8MB)
ํ
์คํธ 10 ใ ํต๊ณผ (0.05ms, 13.7MB)
ํ
์คํธ 11 ใ ํต๊ณผ (0.09ms, 13.7MB)
ํ
์คํธ 12 ใ ํต๊ณผ (0.04ms, 13.7MB)
ํ
์คํธ 13 ใ ํต๊ณผ (0.08ms, 13.6MB)
ํ
์คํธ 14 ใ ํต๊ณผ (0.05ms, 13.7MB)
ํ
์คํธ 15 ใ ํต๊ณผ (0.06ms, 13.7MB)
ํ
์คํธ 16 ใ ํต๊ณผ (0.08ms, 13.8MB)
ํ
์คํธ 17 ใ ํต๊ณผ (0.07ms, 13.8MB)
ํ
์คํธ 18 ใ ํต๊ณผ (0.04ms, 13.8MB)
ํ
์คํธ 19 ใ ํต๊ณผ (0.07ms, 13.6MB)
ํ
์คํธ 20 ใ ํต๊ณผ (0.05ms, 13.9MB)
ํ
์คํธ 21 ใ ํต๊ณผ (0.03ms, 13.7MB)
ํ
์คํธ 22 ใ ํต๊ณผ (0.03ms, 13.8MB)
ํ
์คํธ 23 ใ ํต๊ณผ (0.03ms, 13.7MB)
ํ
์คํธ 24 ใ ํต๊ณผ (0.03ms, 13.7MB)
ํ
์คํธ 25 ใ ํต๊ณผ (0.02ms, 13.8MB)
ํ
์คํธ 26 ใ ํต๊ณผ (0.04ms, 13.7MB)
ํ
์คํธ 27 ใ ํต๊ณผ (0.06ms, 13.7MB)
ํ
์คํธ 28 ใ ํต๊ณผ (0.09ms, 13.8MB)
ํ
์คํธ 29 ใ ํต๊ณผ (0.02ms, 13.8MB)
ํ
์คํธ 30 ใ ํต๊ณผ (0.03ms, 13.9MB)
ํ
์คํธ 31 ใ ํต๊ณผ (0.04ms, 13.8MB)
ํ
์คํธ 32 ใ ํต๊ณผ (0.05ms, 13.6MB)
ํ
์คํธ 33 ใ ํต๊ณผ (0.09ms, 13.8MB)
ํ
์คํธ 34 ใ ํต๊ณผ (0.05ms, 13.7MB)
ํ
์คํธ 35 ใ ํต๊ณผ (0.06ms, 13.6MB)
ํ
์คํธ 36 ใ ํต๊ณผ (0.06ms, 13.7MB)
ํ
์คํธ 37 ใ ํต๊ณผ (0.04ms, 13.8MB)
ํ
์คํธ 38 ใ ํต๊ณผ (0.05ms, 13.8MB)
ํ
์คํธ 39 ใ ํต๊ณผ (0.04ms, 13.6MB)
ํ
์คํธ 40 ใ ํต๊ณผ (0.04ms, 13.7MB)
- product ์จ์ ๋ฌธ์์ด์ ๋ค ๋ง๋ค๊ณ , ์ ๋ ฌํด์, ์ธ๋ฑ์ค๋ฅผ ๋ฆฌํดํ๋ ๋ฐฉ์
- ์ด๊ฒ ์๋ง ์ ์์ด์ง ์์์๊น?
from itertools import product
solution = lambda word: sorted(["".join(c) for i in range(5) for c in product("AEIOU", repeat=i+1)]).index(word) + 1
์ ํ์ฑ ํ
์คํธ
ํ
์คํธ 1 ใ ํต๊ณผ (1.27ms, 10.3MB)
ํ
์คํธ 2 ใ ํต๊ณผ (0.71ms, 10.3MB)
ํ
์คํธ 3 ใ ํต๊ณผ (1.19ms, 10.3MB)
ํ
์คํธ 4 ใ ํต๊ณผ (1.40ms, 10.3MB)
ํ
์คํธ 5 ใ ํต๊ณผ (0.74ms, 10.2MB)
ํ
์คํธ 6 ใ ํต๊ณผ (0.72ms, 10.2MB)
ํ
์คํธ 7 ใ ํต๊ณผ (0.73ms, 10.5MB)
ํ
์คํธ 8 ใ ํต๊ณผ (1.23ms, 10.3MB)
ํ
์คํธ 9 ใ ํต๊ณผ (0.72ms, 10.5MB)
ํ
์คํธ 10 ใ ํต๊ณผ (1.23ms, 10.3MB)
ํ
์คํธ 11 ใ ํต๊ณผ (0.83ms, 10.3MB)
ํ
์คํธ 12 ใ ํต๊ณผ (0.70ms, 10.5MB)
ํ
์คํธ 13 ใ ํต๊ณผ (0.72ms, 10.3MB)
ํ
์คํธ 14 ใ ํต๊ณผ (0.73ms, 10.1MB)
ํ
์คํธ 15 ใ ํต๊ณผ (0.82ms, 10.2MB)
ํ
์คํธ 16 ใ ํต๊ณผ (1.34ms, 10.5MB)
ํ
์คํธ 17 ใ ํต๊ณผ (0.76ms, 10.3MB)
ํ
์คํธ 18 ใ ํต๊ณผ (0.70ms, 10.3MB)
ํ
์คํธ 19 ใ ํต๊ณผ (1.31ms, 10.3MB)
ํ
์คํธ 20 ใ ํต๊ณผ (0.70ms, 10.3MB)
ํ
์คํธ 21 ใ ํต๊ณผ (0.72ms, 10.1MB)
ํ
์คํธ 22 ใ ํต๊ณผ (0.70ms, 10.2MB)
ํ
์คํธ 23 ใ ํต๊ณผ (0.72ms, 10.1MB)
ํ
์คํธ 24 ใ ํต๊ณผ (0.72ms, 10.3MB)
ํ
์คํธ 25 ใ ํต๊ณผ (1.12ms, 10.3MB)
ํ
์คํธ 26 ใ ํต๊ณผ (1.20ms, 10.3MB)
ํ
์คํธ 27 ใ ํต๊ณผ (0.70ms, 10.4MB)
ํ
์คํธ 28 ใ ํต๊ณผ (0.77ms, 10.2MB)
ํ
์คํธ 29 ใ ํต๊ณผ (1.04ms, 10.2MB)
ํ
์คํธ 30 ใ ํต๊ณผ (1.07ms, 10.2MB)
ํ
์คํธ 31 ใ ํต๊ณผ (1.27ms, 10.1MB)
ํ
์คํธ 32 ใ ํต๊ณผ (1.31ms, 10.3MB)
ํ
์คํธ 33 ใ ํต๊ณผ (0.95ms, 10.2MB)
ํ
์คํธ 34 ใ ํต๊ณผ (1.34ms, 10.1MB)
ํ
์คํธ 35 ใ ํต๊ณผ (1.01ms, 10.1MB)
ํ
์คํธ 36 ใ ํต๊ณผ (0.74ms, 10.4MB)
ํ
์คํธ 37 ใ ํต๊ณผ (0.70ms, 10.3MB)
ํ
์คํธ 38 ใ ํต๊ณผ (0.75ms, 10.3MB)
ํ
์คํธ 39 ใ ํต๊ณผ (0.98ms, 10.5MB)
ํ
์คํธ 40 ใ ํต๊ณผ (0.70ms, 10.3MB)
- ์ ์ด๋ ๊ฒ ํ๋ ๋ฐฉ๋ฒ๋ ์๊ตฌ๋.
- ์์ ์ด๋ ๊ฒ ๋ง๋ค ์๋ ์์๊ฒ ๋ค.
- ์ด๊ฒ ์ ์ผ ๋น ๋ฅด๋ค!
def solution(word):
answer = 0
for i, n in enumerate(word):
answer += (5 ** (5 - i) - 1) / (5 - 1) * "AEIOU".index(n) + 1
return answer
์ ํ์ฑ ํ
์คํธ
ํ
์คํธ 1 ใ ํต๊ณผ (0.01ms, 10MB)
ํ
์คํธ 2 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 3 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 4 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 5 ใ ํต๊ณผ (0.01ms, 9.93MB)
ํ
์คํธ 6 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 7 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 8 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 9 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 10 ใ ํต๊ณผ (0.01ms, 9.99MB)
ํ
์คํธ 11 ใ ํต๊ณผ (0.01ms, 10.3MB)
ํ
์คํธ 12 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 13 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 14 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 15 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 16 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 17 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 18 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 19 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 20 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 21 ใ ํต๊ณผ (0.01ms, 10MB)
ํ
์คํธ 22 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 23 ใ ํต๊ณผ (0.01ms, 9.98MB)
ํ
์คํธ 24 ใ ํต๊ณผ (0.01ms, 9.97MB)
ํ
์คํธ 25 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 26 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 27 ใ ํต๊ณผ (0.01ms, 9.98MB)
ํ
์คํธ 28 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 29 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 30 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 31 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 32 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 33 ใ ํต๊ณผ (0.01ms, 10MB)
ํ
์คํธ 34 ใ ํต๊ณผ (0.01ms, 10MB)
ํ
์คํธ 35 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 36 ใ ํต๊ณผ (0.01ms, 10MB)
ํ
์คํธ 37 ใ ํต๊ณผ (0.01ms, 10.2MB)
ํ
์คํธ 38 ใ ํต๊ณผ (0.01ms, 10.1MB)
ํ
์คํธ 39 ใ ํต๊ณผ (0.01ms, 10MB)
ํ
์คํธ 40 ใ ํต๊ณผ (0.01ms, 9.98MB)
'๊ฒ์ ํ๋ก๊ทธ๋๋ฐ > Python ํ๋ก๊ทธ๋๋ฐ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํ๋ก๊ทธ๋๋จธ์ค ํ๋ฐฐ์์ (1) | 2023.02.19 |
---|---|
ํ๋ก๊ทธ๋๋จธ์ค ๋กค์ผ์ดํฌ ์๋ฅด๊ธฐ (0) | 2023.02.18 |
ํ๋ก๊ทธ๋๋จธ์ค ๋ฐฐ๋ฌ (0) | 2023.02.18 |
ํ๋ก๊ทธ๋๋จธ์ค ์ซ์ ๋ธ๋ก (1) | 2023.02.18 |
ํ๋ก๊ทธ๋๋จธ์ค ๋ ๋ฐ๋จน๊ธฐ (0) | 2023.02.17 |