π μ²μμλ
n = int(input())
for _ in range(n):
a, b = input().split()
cnt = 0
for i in a:
if i in b:
cnt += 1
if cnt == len(a) and len(a) == len(b):
print('{} & {} are anagrams.'.format(a,b))
else:
print('{} & {} are NOT anagrams.'.format(a,b))
λ°λ‘: aaaa aaab.
μ΄μ : if i n b μ½λμμ λ³μ aμ λ³μ bκ° κ°μ§ aμ κ°μμ μκ΄μμ΄, ν¬ν¨λμ΄μλμ§ μλμ§λ§ νλ¨νκΈ° λλ¬Έμ, μ€λ₯ λ°μ..
κ·Έλμ a,b μλ‘μλ‘ κ²μ¬ν΄μ£Όλ μ½λλ‘ λ°κΏ¨λλ° λ .. νλ¦°κ±°λ€...
νλ¦° μ΄μ λ λκ°μ.. κ°μ μ΄λ―Έκ° μμ λ κ°μλ λκ°μμΌ νλλ° ν¬ν¨μΈμ§ μλμ§λ§;; κ³μ 체ν¬νλ€.
κ°μ μ΄λ―Έ + κ°μ κ°μλ₯Ό νμΈν λ°©λ²μΌλ‘ λμ λλ¦¬κ° λ μ¬λΌμ μ½λλ₯Ό μμ νλλ μ λ΅μ²λ¦¬
π» λλ²μ§Έ μλ_ μ΅μ’ μ½λ
n = int(input())
ad = {}
bd = {}
for _ in range(n):
a, b = input().split()
flag = True
if len(a) == len(b):
for i in a:
if ad.get(i):
ad[i] += 1
else:
ad[i] = 1
for j in b:
if bd.get(j):
bd[j] += 1
else:
bd[j] = 1
if ad == bd:
print('{} & {} are anagrams.'.format(a,b))
else:
print('{} & {} are NOT anagrams.'.format(a,b))
else:
print('{} & {} are NOT anagrams.'.format(a,b))
νμκ° λκ² κ³ λ―Όν΄μ μΌλλ°
μκ³ λ³΄λ κ·Έλ₯ μ λ ¬νλ©΄ 8μ€λ μλκ² λλλ λ¬Έμ μλ€..νννν
'PS > BOJ&Programmers' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[λ°±μ€/11179] 2μ§μ λ€μ§κΈ° (0) | 2023.01.12 |
---|---|
[λ°±μ€/2947] λ무 μ‘°κ°/μ λ ¬/λκ°μ§ νμ΄ (1) | 2023.01.11 |
[λ°±μ€/1159] λꡬ경기 (4) | 2023.01.10 |
[λ°±μ€/5704] ν¬κ·Έλ¨/ μΉ΄μ΄νΈ, λμ λ리 (1) | 2023.01.04 |
[λ°±μ€/1551] μμ΄μ λ³ν (0) | 2023.01.04 |