λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
Algorithm/λ°±μ€€(BOJ)

[ 파이썬(python) ] λ°±μ€€ 2490 - μœ·λ†€μ΄

by YWTechIT 2021. 5. 30.
728x90

πŸ“ λ°±μ€€ 2490 - μœ·λ†€μ΄

λ°±μ€€ 2490 - μœ·λ†€μ΄


⚑️ λ‚˜μ˜ 풀이

μœ·μ§λ“€μ˜ μƒνƒœλ₯Ό 보고 도(A), 개(B), κ±Έ(C), 윷(D), λͺ¨(E)λ₯Ό νŒλ³„ν•˜λŠ” λ¬Έμ œλ‹€. μœ·μ§λ“€μ„ κ΅¬μ„±ν•˜λŠ” 값은 0 λ˜λŠ” 1 μž„μ„ μ•Œ 수 μžˆλ‹€. ν•˜μ§€λ§Œ μœ·μ§λ“€μ΄ μ£Όμ–΄μ§ˆ λ•Œ 0κ³Ό 1의 μˆœμ„œκ°€ λ’€λ°”λ€” 수 μžˆμŒμ„ μΈμ§€ν•˜μž. λ‚˜λŠ” 총 2가지 λ°©λ²•μœΌλ‘œ ν’€μ—ˆλŠ”λ°

 

  1. μ£Όμ–΄μ§€λŠ” 각각의 μ€„λ§ˆλ‹€ ν•©(sum)을 ꡬ해 좜λ ₯을 κ΅¬λΆ„ν–ˆλ‹€.
  2. 0κ³Ό 1의 개수λ₯Ό νŒŒμ•…ν•˜λ„λ‘ countν•¨μˆ˜λ₯Ό μ‚¬μš©ν–ˆλ‹€.

 

μ •λ‹΅νŒμ •μ„ λ°›κ³  λ‹€λ₯Έ μ‚¬λžŒμ˜ μ½”λ“œλ₯Ό λ΄€λŠ”λ° 1번의 sum은 μž…λ ₯을 받을 λ•Œ ν•œ λ²ˆμ— μ„ μ–Έν•΄μ€˜λ„ 됐고, 2번의 countλŠ” 0κ³Ό 1 λ‘˜ λ‹€ ν•  ν•„μš”μ—†μ΄ λ‘˜ 쀑에 ν•˜λ‚˜λ§Œ ν•΄μ€˜λ„ ꡬ뢄이 κ°€λŠ₯ν–ˆλ‹€.

 

# sum
yut = [list(map(int, input().split())) for _ in range(3)]

for i in yut:
    if sum(i) == 3:
        print('A')
    elif sum(i) == 2:
        print('B')
    elif sum(i) == 1:
        print('C')
    elif not sum(i):
        print('D')
    elif sum(i) == 4:
        print('E')
# count
yut = [list(map(int, input().split())) for _ in range(3)]

for i in yut:
    if i.count(0) == 1 and i.count(1) == 3:
        print('A')
    elif i.count(0) == 2 and i.count(1) == 2:
        print('B')
    elif i.count(0) == 3 and i.count(1) == 1:
        print('C')
    elif i.count(0) == 4:
        print('D')
    elif i.count(1) == 4:
        print('E')
# λ‹€λ₯Έ μ‚¬λžŒμ˜ μ½”λ“œ
# sum
yut = [sum(map(int, input().split())) for _ in range(3)]

for i in yut:
    if i == 3:
        print('A')
    elif i == 2:
        print('B')
    elif i == 1:
        print('C')
    elif not i:
        print('D')
    elif i == 4:
        print('E')

# count
yut = [list(map(int, input().split())) for _ in range(3)]

for i in yut:
    if i.count(0) == 1:
        print('A')
    elif i.count(0) == 2:
        print('B')
    elif i.count(0) == 3:
        print('C')
    elif i.count(0) == 4:
        print('D')
    elif i.count(1) == 4:
        print('E')
λ°˜μ‘ν˜•

λŒ“κΈ€