2026-05-21 23:15:22 +09:00

21 lines
401 B
Swift

import Foundation
func solution(_ word:String) -> Int {
let dict: [Character: Int] = ["A": 0, "E": 1, "I": 2, "O": 3, "U": 4]
var idx: Int = 5
var ans: Int = 0
for c in word {
let w: Int = (Int(pow(Double(5), Double(idx))) - 1) / 4
ans += w * dict[c, default: 0] + 1
idx -= 1
}
return ans
}
let word: String = "AAAE"
print(solution(word))