MapleStory Finger Point

๐Ÿƒ‍โ™‚๏ธBaekjoon/Python

#5622 ๋‹ค์ด์–ผ - python

HYEJU01 2024. 4. 16. 18:41

 

alp = ['ABC','EDF','GHI','JKL','MNO','PQRS','TUV','WXYZ']
A = input()
sec = 0

for i in range (len(A)):
    for j in alp: #abc ~ wxyz ๊นŒ์ง€ ๋Œ๋ฆฌ๊ธฐ 
        if A[i] in j: # a[i] ๋ž‘ ์ ‘์  ์ฐพ๊ธฐ 
            sec += alp.index(j) + 3 #ํ•ด๋‹น ์ธ๋ฑ์Šค ๊ฐ’์— + 3์„ ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.
print(sec)

๊ทœ์น™ ! 

 

1๋ฒˆ -> 2์ดˆ

2๋ฒˆ (index = 0 )  => 3์ดˆ 

3๋ฒˆ (index = 1)  => 4์ดˆ 

9๋ฒˆ (index = 7) => 10์ดˆ 

+ 3์˜ ๊ทœ์น™์ด ์žˆ๋‹ค.  ์ด ์ ์„ ์‚ฌ์šฉํ•ด์„œ ์ฝ”๋”ฉํ•œ ๊ฒƒ

 

๐Ÿ’ฌ index()  : ํ•ด๋‹น ์š”์†Œ๊ฐ€ ์ฒ˜์Œ์œผ๋กœ ๋“ฑ์žฅํ•˜๋Š” ์œ„์น˜์˜ ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜

 

 

 

<< ๐Ÿคฎ ๋ง‰ํžŒ ์ด์œ  & ํ•ด๊ฒฐ  >>

A = input()
sec = 0 #1๋ฒˆ = 2์ดˆ
print (A)
for i in range(len(A)): #W0 #A2
    print(A[i])
    if 'A'or'B'or'C' ==  A[i]:
        sec += 3
    elif 'D'or'E'or'F' ==  A[i]:
        sec += 4
    elif 'G'or'H'or'I' ==  A[i]:
        sec += 5
    elif 'J'or'K'or'L' ==  A[i]:
        sec += 6
    elif 'M'or'I'or'N' or 'O' ==  A[i]:
        sec += 7
    elif 'P'or'Q'or'R' or 'S' ==  A[i]:
        sec += 8
    elif 'T'or'U'or'V' ==  A[i]:
        sec += 9
    elif 'W'or'X'or'Y' or 'Z' ==  A[i]:
        sec += 10
    else:
        sec += 11

print(sec)

๋ฌธ์ž ํ•˜๋‚˜ํ•˜๋‚˜ ๋น„๊ตํ•ด์„œ ์ดˆ๋ฅผ ๋”ํ•ด์ฃผ๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ ์ด์ƒํ•˜๊ฒŒ ๋น„๊ต๊ฐ€ ์•ˆ๋œ๋‹ค ใ…œใ…œ

์ž๊พธ 3์—์„œ ๊ฑธ๋ฆผ.. ๊ทธ๋ž˜์„œ ์‹คํŒจํ•ด์„œ ์ƒˆ๋กœ์šด ์ฝ”๋“œ๋ฅผ ์ฐพ์•„๋ดค๋‹ค.