재밌는 문자열 처리들
This commit is contained in:
13
zeta_python/completed/1032.py
Normal file
13
zeta_python/completed/1032.py
Normal file
@@ -0,0 +1,13 @@
|
||||
N = int(input())
|
||||
K = [input() for i in range(N)]
|
||||
shared = K[0]
|
||||
|
||||
for k in K:
|
||||
for i, c in enumerate(k):
|
||||
if c == "?":
|
||||
pass
|
||||
elif shared[i] == c:
|
||||
pass
|
||||
else:
|
||||
shared = shared[:i] + "?" + shared[i + 1:]
|
||||
print(shared)
|
||||
1
zeta_python/completed/10988.py
Normal file
1
zeta_python/completed/10988.py
Normal file
@@ -0,0 +1 @@
|
||||
I=input();print(1 if I == I[::-1] else 0)
|
||||
12
zeta_python/completed/1120.py
Normal file
12
zeta_python/completed/1120.py
Normal file
@@ -0,0 +1,12 @@
|
||||
A, B = input().split()
|
||||
|
||||
|
||||
def get(a, b):
|
||||
cnt = 0
|
||||
for f, s in zip(a, b):
|
||||
if f != s:
|
||||
cnt += 1
|
||||
return cnt
|
||||
|
||||
|
||||
print(min(get(A, B[i:i+len(A)+1]) for i in range(len(B) - len(A)+1)))
|
||||
6
zeta_python/completed/11656.py
Normal file
6
zeta_python/completed/11656.py
Normal file
@@ -0,0 +1,6 @@
|
||||
I = input()
|
||||
T = set()
|
||||
for i in range(len(I)):
|
||||
T.add(I[i:])
|
||||
for t in sorted(T):
|
||||
print(t)
|
||||
8
zeta_python/completed/1475.py
Normal file
8
zeta_python/completed/1475.py
Normal file
@@ -0,0 +1,8 @@
|
||||
T = [0 for i in range(9)]
|
||||
for n in input():
|
||||
n = int(n)
|
||||
if n == 9:
|
||||
n = 6
|
||||
T[n] += 1
|
||||
T[6] = (T[6] + 1) // 2
|
||||
print(max(T))
|
||||
14
zeta_python/completed/1764.py
Normal file
14
zeta_python/completed/1764.py
Normal file
@@ -0,0 +1,14 @@
|
||||
noHear = set()
|
||||
noSeer = set()
|
||||
|
||||
N, M = map(int, input().split())
|
||||
|
||||
for i in range(N):
|
||||
noHear.add(input())
|
||||
for i in range(M):
|
||||
noSeer.add(input())
|
||||
|
||||
new = noHear & noSeer
|
||||
print(len(new))
|
||||
for name in sorted(new):
|
||||
print(name)
|
||||
52
zeta_python/completed/2580.py
Normal file
52
zeta_python/completed/2580.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from collections import deque
|
||||
import sys
|
||||
|
||||
Map = list()
|
||||
K = [] # pos list
|
||||
|
||||
for i in range(9):
|
||||
t = list(map(int, sys.stdin.readline().split()))
|
||||
for j in range(9):
|
||||
if t[j] == 0:
|
||||
K.append((i, j)) # pos
|
||||
Map.append(t)
|
||||
|
||||
kl = len(K)
|
||||
|
||||
|
||||
def check_possibility(l):
|
||||
wbr = []
|
||||
for num in range(9, 0, -1):
|
||||
if num in Map[K[l][0]]:
|
||||
continue
|
||||
elif num in (Map[i][K[l][1]] for i in range(9)):
|
||||
continue
|
||||
tx = K[l][0] // 3 * 3
|
||||
ty = K[l][1] // 3 * 3
|
||||
if any(num in s[ty:ty + 3] for s in Map[tx:tx + 3]):
|
||||
continue
|
||||
wbr.append(num)
|
||||
return wbr
|
||||
|
||||
|
||||
T = deque()
|
||||
for i in check_possibility(0):
|
||||
T.append((i, 0))
|
||||
|
||||
beforeDepth = 0
|
||||
|
||||
while T:
|
||||
now, d = T.pop()
|
||||
if d >= beforeDepth:
|
||||
Map[K[d][0]][K[d][1]] = now
|
||||
else:
|
||||
for i in range(d + 1, beforeDepth + 1):
|
||||
Map[K[i][0]][K[i][1]] = 0
|
||||
Map[K[d][0]][K[d][1]] = now
|
||||
if d == kl - 1:
|
||||
break
|
||||
for i in check_possibility(d + 1):
|
||||
T.append((i, d + 1))
|
||||
beforeDepth = d
|
||||
for row in Map:
|
||||
print(" ".join(map(str, row)))
|
||||
27
zeta_python/completed/4949.py
Normal file
27
zeta_python/completed/4949.py
Normal file
@@ -0,0 +1,27 @@
|
||||
I = input()
|
||||
stack = []
|
||||
while I != ".":
|
||||
stack = []
|
||||
for i in I:
|
||||
if i in "()[]":
|
||||
if i == ")" and stack:
|
||||
if not stack:
|
||||
stack.append(0)
|
||||
break
|
||||
elif stack[-1] == "(":
|
||||
stack.pop()
|
||||
else:
|
||||
break
|
||||
elif i == "]":
|
||||
if not stack:
|
||||
stack.append(0)
|
||||
break
|
||||
elif stack[-1] == "[":
|
||||
stack.pop()
|
||||
else:
|
||||
break
|
||||
else:
|
||||
stack.append(i)
|
||||
print("no" if stack else "yes")
|
||||
|
||||
I = input()
|
||||
Reference in New Issue
Block a user