πŸ“Œ κ΅¬ν˜„ (이것이 취업을 μœ„ν•œ μ½”λ”© ν…ŒμŠ€νŠΈλ‹€ with python)

λͺ¨κΉ…Β·2023λ…„ 3μ›” 5일
0

πŸ“– 01. κ΅¬ν˜„ μ•Œκ³ λ¦¬μ¦˜ κ°œμš”


✏️ 문제

✍️ μž…λ ₯

# 1. κ³΅κ°„μ˜ 크기 N을 λ°›λŠ”λ‹€.
N = int(input())
# 2. 이동할 κ³„νšμ„ λ°›λŠ”λ‹€.
plans = input().split()
# 3. ν˜„μž¬ μ’Œν‘œ (1,1)을 기본으둜 ν•œλ‹€.
x, y = 1, 1
# μ›€μ§μž„ νƒ€μž…μ„ μ •μ˜ν•˜μž
move_types = ['L', 'R', 'U', 'D']
# λ‹¨μœ„λ²‘ν„°λ₯Ό μ •μ˜ν•˜μž
dx = [0, 0, -1, 1]
dy = [-1, 1, 0, 0]

# 4. κ³„νšμ„ λͺ¨λ‘ λ°˜λ³΅μ‹œν‚¨λ‹€
for plan in plans:
# 5. λ§Œμ•½ κ³„νšκ³Ό L R U D 쀑 ν•˜λ‚˜λΌ 일치 λœλ‹€λ©΄ μ›€μ§μ—¬μ•Όν•˜λŠ” μ’Œν‘œλ₯Ό λ³€μˆ˜μ— λ„£μž
    for i in range(len(move_types)):
        if plan == move_types[i]:
            nx = x + dx[i]
            ny = y + dy[i]
# 6. 움직인 λ†ˆμ΄ 곡간을 λ„˜μ–΄κ°„λ‹€λ©΄ 
    if nx < 1 or ny < 1 or nx > N or ny > N:
# 7. continueν•˜μž
        continue
# 8. κ·Έ λ°©ν–₯으둜 μ›€μ§μ΄μž
    x, y = nx, ny
print(x, y)

πŸ’» 좜λ ₯
>5
>R R R U D D
3 4


πŸ“– 02. κ΅¬ν˜„ μœ ν˜• 문제 풀이

01. μ‹œκ°

✏️ 문제

πŸ•ΆοΈ ν•΄μ„€

-> νŒŒμ΄μ¬μ€ 1μ΄ˆμ— 2000만번 정도 κ³„μ‚°ν•œλ‹€κ³  μƒκ°ν•˜κ³  ν’€λ©΄ μ’‹μŒ!

✍️ μž…λ ₯

N = int(input())

count = 0
for i in range(N+1):
    for j in range(60):
        for k in range(60):
            if '3' in str(i) + str(j) + str(k):
                count += 1

print(count)

πŸ’» 좜λ ₯
>5
11475

02. μ™•μ‹€μ˜ λ‚˜μ΄νŠΈ

✏️ 문제

πŸ•ΆοΈ ν•΄μ„€

✍️ μž…λ ₯

# ν˜„μž¬ μœ„μΉ˜λ₯Ό λ°›λŠ”λ‹€
input_data = input()
row = int(input_data[1])
column = int(ord(input_data[0])) - int(ord('a')) + 1

# λ°©ν–₯ 벑터λ₯Ό μ„€μ •ν•œλ‹€.
dirs = [(1, 2), (1, -2), (-1, 2), (-1, -2), (2, 1), (2, -1), (-2, 1), (-2, -1)]

result = 0
for dir in dirs:
    next_row = row + dir[0]
    next_col = column + dir[1]
    if next_row >= 1 and next_row <= 8 and next_col >= 1 and next_col <= 8:
        result += 1

print(result)

πŸ’» 좜λ ₯
>a1
2

03. λ¬Έμžμ—΄ μž¬μ •λ ¬

✏️ 문제

-> 수 vs 숫자
수 : 100, 700. 98323 λ“± ν•œμžλ¦¬ μ΄μ™Έμ˜ 수
숫자 : 0~9 κΉŒμ§€ ν•œμžλ¦¬μ˜ 숫자

πŸ•ΆοΈ ν•΄μ„€

✍️ μž…λ ₯

datas = input()
result = []
sum = 0

# 데이터λ₯Ό ν•˜λ‚˜μ”© κ²€μ‚¬ν•œλ‹€.
for data in datas:
# λ§Œμ•½ μ•ŒνŒŒλ²³μΈ 경우
    if data.isalpha():
# result에 λ„£μ–΄μ€€λ‹€.
        result.append(data)
# 그렇지 μ•Šλ‹€λ©΄
    else:
# sum 숫자λ₯Ό 더해쀀닀.
        sum += int(data)

# result μ •λ ¬
result.sort()
# sum 을  result에 λ„£μ–΄μ£Όμž
result.append(str(sum))

# result 좜λ ₯ν•˜μž.
print(''.join(result))

πŸ’» 좜λ ₯
>K1KA5CB7
ABCKK13





[좜처] 이것이 취업을 μœ„ν•œ μ½”λ”© ν…ŒμŠ€νŠΈλ‹€ with 파이썬 (λ‚˜λ™λΉˆ μ§€μŒ)

profile
λ©ˆμΆ”μ§€ μ•ŠκΈ°

0개의 λŒ“κΈ€