description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | a = input().split()
n = int(a[0])
k = int(a[1])
l = []
t = 0
for i in range(n):
a = input()
l.append(a)
X = set(l)
for i in range(0, n - 1):
for j in range(i + 1, n):
r = ""
for u in range(k):
if l[i][u] == l[j][u]:
r = r + l[i][u]
else:
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP ... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | def binarySearch(words, low, high, key):
if high < low:
return -1
mid = (low + high) // 2
if words[mid] < key:
return binarySearch(words, mid + 1, high, key)
elif words[mid] > key:
return binarySearch(words, low, mid - 1, key)
else:
return mid
a = input().split()
n ... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUM... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | import sys
def main():
s = list()
n, k = (int(e) for e in sys.stdin.readline().strip().split())
q = set()
for i in range(n):
s.append(sys.stdin.readline().strip())
q.add(s[i])
m = ord("S") + ord("E") + ord("T")
r = 0
for i in range(n):
for j in range(i + 1, n):
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | mp = {}
e = [1]
S = ord("S") + ord("T") + ord("E")
n, k = map(int, input().split())
ans = 0
for i in range(1, n + 1):
e.append(input())
if e[i] in mp:
mp[e[i]] += 1
else:
mp[e[i]] = 1
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
if i == j:
continue
... | ASSIGN VAR DICT ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSI... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | n, k = map(int, input().split())
array = [input() for i in range(n)]
set_array = set(array)
for el in array:
new = ""
for x in el:
new += x
set_array.add(new)
count = 0
def is_vzm(x, y):
if x == y:
return x
for el in ["S", "E", "T"]:
if el != x and el != y:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR STRING FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR RETURN VAR FOR VAR LIST STRING STRING STRING IF VAR VAR VAR VAR RETURN VAR A... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | ltr_xor = ord("S") ^ ord("E") ^ ord("T")
def get_matching_card(c1: str, c2: str) -> str:
c3 = []
n = len(c1)
for i in range(n):
if c1[i] == c2[i]:
c3.append(c1[i])
else:
c3.append(chr(ltr_xor ^ ord(c1[i]) ^ ord(c2[i])))
return "".join(c3)
n, k = map(int, input... | ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_DEF VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RET... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | n, k = input().split(" ")
n = int(n)
k = int(k)
cards = dict()
orderLatter = {"S": 1, "E": 2, "T": 3}
for i in range(n):
card = input()
card = tuple(orderLatter[card[i]] for i in range(k))
cards[card] = i
def getThirdNumber(a, b):
if a == b:
return a
return 6 - a - b
def getThird(c1, c2)... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | def calc(a, b):
ans = ""
for i in range(k):
if a[i] == b[i]:
ans += a[i]
elif a[i] != "T" and b[i] != "T":
ans += "T"
elif a[i] != "S" and b[i] != "S":
ans += "S"
else:
ans += "E"
return ans
n, k = map(int, input().split())
d ... | FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR IF VAR VAR STRING VAR VAR STRING VAR STRING IF VAR VAR STRING VAR VAR STRING VAR STRING VAR STRING RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | import sys
input = sys.stdin.readline
n, k = map(int, input().split())
l = []
for i in range(k):
o = []
for j in range(3):
o.append(0)
l.append(o)
d = set()
da = []
for i in range(n):
s = input()
h = []
for i in range(k):
h.append(s[i])
da.append(h)
b = tuple(h)
d.ad... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LI... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | def get_complement(s, t):
k = len(s)
c = list()
for i in range(k):
if s[i] == t[i]:
c.append(s[i])
elif s[i] == "S" and t[i] == "E" or s[i] == "E" and t[i] == "S":
c.append("T")
elif s[i] == "S" and t[i] == "T" or s[i] == "T" and t[i] == "S":
c.app... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR VAR STRING VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR STRING IF VAR VAR STRING VAR VAR STRING VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FU... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | n, m = map(int, input().split())
l = []
s = set()
for i in range(n):
l.append(input())
s.add(l[i])
l1 = set()
s1 = set()
ans = 0
for i in range(n):
for j in range(i + 1, n):
st = ""
for k in range(m):
li = ["S", "E", "T"]
if l[i][k] == l[j][k]:
st += l... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VA... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | def solve(a):
b = "SET"
for i in b:
if i not in a:
return i
n, k = map(int, input().split())
b = []
a = set()
for i in range(n):
b.append(input().rstrip())
a.add(b[-1])
ans = 0
for i in range(n):
for j in range(i + 1, n):
z = []
for l in range(k):
if... | FUNC_DEF ASSIGN VAR STRING FOR VAR VAR IF VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL ... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | n, k = map(int, input().split())
d = {}
d1 = {}
for i in range(n):
d[i] = input()
for i in range(n - 1, -1, -1):
if d1.get(d[i], -1) == -1:
d1[d[i]] = []
d1[d[i]].append(i)
ans = 0
r = k
for i in range(n):
for j in range(i + 1, n):
s = ""
cnt = 0
for k in range(r):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | n, k = map(int, input().split())
deck = []
for _ in range(n):
deck.append(input())
ans = 0
deck.sort()
def thirdChar(a, b):
if a == b:
return a
if a == "S" and b == "T" or a == "T" and b == "S":
return "E"
if a == "S" and b == "E" or a == "E" and b == "S":
return "T"
if a =... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN VAR IF VAR STRING VAR STRING VAR STRING VAR STRING RETURN STRING IF VAR STRING VAR STRING VAR STRING VAR STRING RETURN STRIN... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | n, k = input().split(" ")
n = int(n)
k = int(k)
arr = []
set1 = set()
count = 0
for i in range(n):
arr.append(input())
set1.add(arr[-1])
for i in range(n):
for j in range(i + 1, n):
cons_str = ""
for u in range(k):
if arr[i][u] != arr[j][u]:
if arr[i][u] != "S" an... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VA... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | import itertools
def go():
n, k = map(int, input().split())
s = [input() for _ in range(n)]
dic = {"S": 1, "E": 2, "T": 3}
s2 = [[dic[let] for let in ss] for ss in s]
ts = {s[i]: i for i in range(n)}
dif = {}
alp = "SET"
for aa, bb, cc in itertools.permutations(alp):
dif[dic[aa... | IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VA... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | n, k = map(int, input().split())
l = []
for i in range(n):
l.append(input())
ans = 0
for i in range(n):
s = set()
for jj in range(i + 1, n):
s.add(l[jj])
for j in range(i + 1, n):
to_find = ""
for kk in range(k):
if l[i][kk] == l[j][kk]:
to_find += l[i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSI... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | import sys
input = sys.stdin.readline
def getInt():
return int(input())
def getVars():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getStr():
return input().strip()
n, k = getVars()
res = 0
s = []
for i in range(n):
s.append(getStr())
d = {}
f... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | n, k = map(int, input().split(" "))
cards_set = set()
cards_l = []
for _ in range(n):
card = str(input())
cards_set.add(card)
cards_l.append(card)
dict = {"S": 0, "E": 1, "T": 2}
my_list = ["S", "E", "T"]
ans = 0
for i in range(n):
for j in range(i + 1, n):
s = str()
for c in range(k):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR LIST STRING STRING STRING ASSIGN VA... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | from sys import stdin, stdout
input = stdin.readline
def conv2(l1, l2):
if l1 == l2:
return l1
if l1 == "S":
if l2 == "E":
return "T"
return "E"
if l1 == "E":
if l2 == "S":
return "T"
return "S"
if l1 == "T":
if l2 == "E":
... | ASSIGN VAR VAR FUNC_DEF IF VAR VAR RETURN VAR IF VAR STRING IF VAR STRING RETURN STRING RETURN STRING IF VAR STRING IF VAR STRING RETURN STRING RETURN STRING IF VAR STRING IF VAR STRING RETURN STRING RETURN STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR DICT... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | import sys
ip = lambda: sys.stdin.readline().rstrip()
n, k = map(int, ip().split())
a = []
s = set()
for _ in range(n):
a.append(ip())
s.add(a[-1])
ans = 0
for i in range(n):
for j in range(i + 1, n):
s1, s2 = a[i], a[j]
s3 = ""
for K in range(k):
if s1[K] == s2[K]:
... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASS... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
n, m = len(board), len(board[0])
seen = set()
def helper(i, j, idx):
if idx == len(word):
return True
if (
(i >= n or j >= m or i < 0 or j < 0)
or (i, j) in seen
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR RETURN NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VA... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
n = len(board)
m = len(board[0])
def dfs(i, j, n, m, L, vis, ind):
vis.add((i, j))
if ind == L:
return True
for u, v in [[0, 1], [1, 0], [0, -1], [-1, 0]]:
ro = i + u
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR VAR VAR IF VAR VAR RETURN NUMBER FOR VAR VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER VAR V... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | def visit(board, word, curr, d, done, n, m, i, j):
if curr == len(word):
done[0] = True
return
dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)]
for a, b in dirs:
if (
i + a >= 0
and j + b >= 0
and i + a < n
and j + b < m
and word[c... | FUNC_DEF IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER RETURN ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def DFSBackTracking(self, board, visited, row, col, word, index, n, m):
if index == len(word):
return True
if (
row < 0
or row >= n
or col < 0
or col >= m
or board[row][col] != word[index]
or visited... | CLASS_DEF FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_O... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
def dfs(x, y, i):
if i == len(word):
return True
if (
x < 0
or y < 0
or x == len(board)
or y == len(board[0])
or board[x][y] != word[i... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BI... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
l = len(word)
grid = board
n, m = len(grid), len(grid[0])
def dfs(i, j, l, ind):
nonlocal vis
if ind == l:
return 1
x, y, z, w = 0, 0, 0, 0
vis[i][j] = 1
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUM... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
visited = set()
ROW, COL, N = len(board), len(board[0]), len(word)
for i in range(ROW):
for j in range(COL):
if self.helper(i, j, ROW, COL, 0, board, word, N, visited):
return True
re... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER IF NUMBER VAR VAR NUMBER V... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
l = len(word)
n = len(board)
m = len(board[0])
dic = {}
mat = [[-1, 0], [0, -1], [1, 0], [0, 1]]
for i in range(n):
for j in range(m):
if board[i][j] == word[0]:
dic[s... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUN... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
rw = len(board)
cl = len(board[0])
n = len(word)
vis = {}
res = [0]
def dfs(r, c, i, cur):
if i == n:
if cur == word:
return 1
if (
r < 0
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR LIST NUMBER FUNC_DEF IF VAR VAR IF VAR VAR RETURN NUMBER IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
def dfs(board, i, j, word):
if not word:
return True
if (
i < 0
or j < 0
or i == len(board)
or j == len(board[0])
or board[i][j] != wo... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR NUM... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
m = len(board)
n = len(board[0])
ind = 0
for i in range(m):
for j in range(n):
if board[i][j] == word[ind]:
if self.search(board, word, i, j, ind, m, n):
retur... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMB... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
def find(i, j, pos, board):
if pos >= len(word):
return True
if i < 0 or j < 0 or i >= len(board) or j >= len(board[0]):
return False
if board[i][j] != word[pos]:
return ... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN V... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
n, m = len(board), len(board[0])
x = set()
def dfs(i, j, n, m, ind, s):
if i < 0 or j < 0 or i >= n or j >= m or (i, j) in v:
return
if s[ind] != board[i][j]:
return False
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR VAR RETURN IF VAR VAR VAR VAR VAR RETURN NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER VAR RETURN NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
def calc(r, c, pos):
if pos == len(word):
return True
for nr, nc in [[r - 1, c], [r + 1, c], [r, c - 1], [r, c + 1]]:
if (
nr >= 0
and nr < len(board)
... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER FOR VAR VAR LIST LIST BIN_OP VAR NUMBER VAR LIST BIN_OP VAR NUMBER VAR LIST VAR BIN_OP VAR NUMBER LIST VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VA... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, a, word):
for r in range(len(a)):
for c in range(len(a[0])):
if a[r][c] == word[0] and self.search(a, r, c, word, 0):
return True
return False
def search(self, a, r, c, word, ind):
if ind == len(word)... | CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, l, s):
n, m = len(l), len(l[0])
v = set()
dir = [(-1, 0), (1, 0), (0, -1), (0, 1)]
def dfs(i, j, x):
if x is "":
return True
if i < 0 or j < 0 or i == n or j == m or (i, j) in v or l[i][j] != x[0]:
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF IF VAR STRING RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER E... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def __init__(self):
self.ans = False
def solve(self, word, pos, board, i, j, n, m, vis, ind):
if pos == ind - 1:
self.ans = True
return
vis[i][j] = True
for x1, y1 in self.next:
x, y = i + x1, j + y1
if (
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER FUNC_DEF IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER RETURN ASSIGN VAR VAR VAR NUMBER FOR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF NUMBER VAR VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VA... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def findword(self, board, word, i, j, k, vis):
if k == len(word) - 1 and word[k] == board[i][j]:
vis[i][j] = False
return True
ans = False
if word[k] == board[i][j]:
vis[i][j] = False
li = vis
if i - 1 >= 0 and vis[... | CLASS_DEF FUNC_DEF IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def dfs(self, row, col, idx, board, word, visited, R, C):
if (
row >= 0
and row < R
and col >= 0
and col < C
and board[row][col] == word[idx]
and not visited[row][col]
):
visited[row][col] = True
... | CLASS_DEF FUNC_DEF IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR FUNC_C... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def adjacentSearch(self, board, word, i, j, l):
if l == len(word):
return True
if i < 0 or j < 0 or i >= len(board) or j >= len(board[0]):
return False
if board[i][j] != word[l]:
return False
board[i][j] = "*"
ans = (
... | CLASS_DEF FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUM... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
n = len(board)
m = len(board[0])
starts = []
for i in range(n):
for j in range(m):
if board[i][j] == word[0]:
starts.append((i, j))
output = []
for x, y in starts:
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR FUNC_CALL VAR RETURN FUNC_CALL VAR... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
ans = 0
def dfs(self, board, word, i, j, visited, ch):
if ch == word:
self.ans = 1
return
if len(ch) > len(word):
return
visited[i][j] = 1
if i - 1 >= 0 and visited[i - 1][j] == 0 and word[len(ch)] == board[i - 1][j]:
... | CLASS_DEF ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR ASSIGN VAR NUMBER RETURN IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | def func(pos, board, word, visted, ans):
i, j = pos
if (
i < 0
or j < 0
or i >= len(board)
or j >= len(board[0])
or visted[i][j] == True
or len(word) == 0
or board[i][j] != word[0]
):
return
visted[i][j] = True
if len(word) == 1:
... | FUNC_DEF ASSIGN VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR NUMBER RETURN ASSIGN VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER RETURN EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
def recurs(c, i, j, grid):
if c == "":
return True
elif i < 0 or i == len(board) or j < 0 or j == len(board[0]):
return False
else:
if grid[i][j] == c[0]:
... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR STRING RETURN NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR BIN_OP V... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def is_valid(self, x, y, visited, N, M):
if x < 0 or y < 0 or x >= N or y >= M or visited[x][y] == True:
return False
return True
def DFS(self, node, graph, visited, word, letter):
u, v = node[0], node[1]
if letter >= len(word):
return Tr... | CLASS_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER NUMBER FOR VAR VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NU... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | def wordSearch(board, word):
n, m = len(board), len(board[0])
for i in range(n):
for j in range(m):
if board[i][j] == word[0]:
vis = set()
vis.add((i, j))
text = board[i][j]
ind = 1
res = helper(i, j, n, m, board... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR IF VAR RETURN NUMBER ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
N = len(board)
M = len(board[0])
visited = [[(False) for j in range(M)] for i in range(N)]
for i in range(N):
for j in range(M):
if board[i][j] == word[0] and not visited[i][j]:
if se... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASS... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def explore(self, board, word, i, j, idx):
n = len(board)
m = len(board[0])
if idx == len(word):
return True
if (
i < 0
or i >= n
or j < 0
or j >= m
or board[i][j] == "."
or board[i][... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR STRING VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
for i in range(0, len(board)):
for j in range(0, len(board[0])):
visited = []
for k in range(0, len(board)):
visited.append([0] * len(board[0]))
start = 0
if b... | CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def search(self, board, word, index, board_i, board_j):
if index == len(word):
return True
if (
board_i < 0
or board_i == len(board)
or board_j < 0
or board_j == len(board[0])
):
return False
if ... | CLASS_DEF FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR STRING FOR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR IF VAR RETUR... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
visited = [([0] * len(board[0])) for i in range(len(board))]
delrow = [-1, 0, 1, 0]
delcol = [0, 1, 0, -1]
for i in range(len(board)):
for j in range(len(board[0])):
if board[i][j] == word[0]:
... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER IF FUNC_C... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def __init__(self):
self.flag = False
def dfs(self, board, i, j, n, m, curr_word, word):
if self.flag:
return
if curr_word >= len(word):
self.flag = True
return True
if (
i < 0
or i >= n
or ... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER FUNC_DEF IF VAR RETURN IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR STRING VAR VAR VAR VAR VAR RETURN ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUM... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | def func(pos, board, word, visted, ans, index):
i, j = pos
if (
0 <= i < len(board)
and 0 <= j < len(board[0])
and board[i][j] == word[index]
and (i, j) not in visted
and index < len(word)
):
visted.add((i, j))
if index == len(word) - 1:
an... | FUNC_DEF ASSIGN VAR VAR VAR IF NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR NUMB... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
def search(i, j, m, n, board, word, k):
if k == len(word):
return True
if i < 0 or j < 0 or i == m or j == n or board[i][j] != word[k]:
return False
c = board[i][j]
board[i][... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER V... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | poss = [[0, 1], [0, -1], [1, 0], [-1, 0]]
class Solution:
def isWordExist(self, board, word):
visited = [[(False) for j in range(len(board[0]))] for i in range(len(board))]
for i in range(len(board)):
for j in range(len(board[0])):
if self.dfs(i, j, board, visited, wor... | ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
def isValid(i, j, m, n, visited, board):
if i < 0 or j < 0 or i >= m or j >= n or visited[i][j] == 1:
return 0
return 1
def help(m, n, i, j, idx, word, wlen, board, visited):
if idx == wlen:
... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR VAR... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, M, w):
R, C = len(M), len(M[0])
for r in range(R):
for c in range(C):
if M[r][c] == w[0] and dfs(r, c, w, 0, set(), M, R, C):
return True
return False
def dfs(r, c, w, i, v, M, R, C):
if i == len(w):... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR VAR VAR NUMB... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def helper(self, r, c, rows, cols, board, word):
positionList = [(0, -1), (0, 1), (-1, 0), (1, 0)]
if len(word) == 0:
self.result = 1
return
temp = board[r][c]
board[r][c] = -1
for pos in positionList:
r = r + pos[0]
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER RETURN ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR VAR ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | def dfs(graph, x, y, word, i, visited):
if i >= len(word):
return True
if (
x < 0
or y < 0
or x >= len(graph)
or y >= len(graph[0])
or visited[x][y]
or graph[x][y] != word[i]
):
return False
visited[x][y] = True
ans = (
dfs(grap... | FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR BIN... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
n = len(board)
m = len(board[0])
seen = [[(False) for i in range(m)] for j in range(n)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
def dfs(i, j, k):
if k == len(word):
return True
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VA... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | def isExist(board, r, c, p, q, word, i, n, visit):
if i == n:
return True
if r < 0 or r >= p or c < 0 or c >= q or visit[r][c] or board[r][c] != word[i]:
return False
dr = [0, 0, 1, -1]
dc = [1, -1, 0, 0]
visit[r][c] = True
for k in range(4):
r_, c_ = r + dr[k], c + dc[k]... | FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR IF ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
val = False
def recurs(i, j, target, curr):
nonlocal val
if (
i >= len(board)
or i < 0
or j >= len(board[0])
or j < 0
or (i, j) in curr
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER RETURN NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER RETURN IF VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def find(self, i, j, board, vi, word, c, n, m):
if i >= n or j >= m or i < 0 or j < 0:
return False
if vi[i][j]:
return False
if c == len(word):
return True
vi[i][j] = True
if board[i][j] == word[c]:
if (
... | CLASS_DEF FUNC_DEF IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR VAR VAR RETURN NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def solve(self, i, j, word, board, n1, n2, index):
found = 0
if i < n1 and j < n2 and i >= 0 and j >= 0 and word[index] == board[i][j]:
temp = word[index]
board[i][j] = 0
index += 1
if index == len(word):
found = 1
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR VAR... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def helper(self, board, x, y, row, col, word, pos, len1):
if pos == len1 - 1:
self.res = 1
return
temp, board[x][y] = board[x][y], -1
for x1, y1 in self.next:
x2, y2 = x + x1, y + y1
if -1 < x2 < row and -1 < y2 < col and board... | CLASS_DEF FUNC_DEF IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER RETURN ASSIGN VAR VAR VAR VAR VAR VAR VAR NUMBER FOR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR V... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | def validate(board, i, j, word):
return (
i >= 0
and j >= 0
and i < len(board)
and j < len(board[0])
and board[i][j] == word
)
def sol(board, i, j, k, word):
if k == len(word):
return True
if validate(board, i, j, word[k]):
c = board[i][j]
... | FUNC_DEF RETURN VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VA... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
m = len(board)
n = len(board[0])
N = len(word)
def dfs(i, j, pos, vis):
if (
i < 0
or j < 0
or i >= m
or j >= n
or vis[i][j] == True
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR VAR RETURN NUMBER IF VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CA... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def helper(self, board, word, i, j, n, m, k):
if k > len(word) - 1:
return True
if (
i < 0
or i >= n
or j < 0
or j >= m
or board[i][j] == "."
or word[k] != board[i][j]
):
return F... | CLASS_DEF FUNC_DEF IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR STRING VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR STRING ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
if not board:
return
m = len(board)
n = len(board[0])
dirs = [[1, 0], [-1, 0], [0, 1], [0, -1]]
visited = set()
def dfs(word, k, i, j):
if word[k] == board[i][j]:
visited.add... | CLASS_DEF FUNC_DEF IF VAR RETURN ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN ... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
ar1 = [-1, 0, 1, 0]
ar2 = [0, 1, 0, -1]
n = len(board)
m = len(board[0])
visit = [([0] * m) for _ in range(n)]
def dfs(i, j, visit, board, word, idx):
if idx == len(word):
return True
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR RET... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
path = set()
rows = len(board)
cols = len(board[0])
def solve(r, l, i, rows, cols, path, word, board):
if i == len(word):
return True
if (
r < 0
or l < 0
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR RETURN NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BI... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
def funcall(row, col, rows, cols, temp):
if temp == word:
return True
if (
row < 0
or row >= rows
or col < 0
or col >= cols
or board[r... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR V... |
Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors. The same letter cell can not be used more than once.
Example 1:
Input: board = {{a,g,b,c},{q,e,e,l},{g,b,k,s}},
word = "geeks"
Output: 1
... | class Solution:
def isWordExist(self, board, word):
def findword(board, word, visited, row, col, arr):
visited[row][col] = True
if len(word) == 0:
return True
for i in arr:
if (
row + i[0] >= 0
and ... | CLASS_DEF FUNC_DEF FUNC_DEF ASSIGN VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER VAR BIN_O... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | t = int(input())
li = ["a", "e", "i", "o", "u"]
for z in range(t):
n = int(input())
mi = 1000000
s = input()
p = input()
for j in range(26):
cha = chr(j + 97)
c = 0
s1 = s.replace("?", cha)
p1 = p.replace("?", cha)
for i in range(n):
if s1[i] != p1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN ... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | for _ in range(int(input())):
n = int(input())
s1 = input()
p1 = input()
k = []
vowel = "aeiou"
alpha = "abcdefghijklmnopqrstuvwxyz"
for x in alpha:
s, p = s1, p1
s = s.replace("?", x)
p = p.replace("?", x)
c = 0
for i in range(n):
if s[i] ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING VAR ASSIGN VAR NUMBER FOR ... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | t = int(input())
for i in range(t):
r = int(input())
a = input()
b = input()
ans = 0
up = 0
x = 0
mv = 0
mc = 0
v = ["a", "e", "i", "o", "u"]
hh = [0] * 26
for i in range(r):
if a[i] == "?" or b[i] == "?":
if a[i] == "?" and b[i] == "?":
up... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST STRING STRING STRING STRING STRING ASSIGN VAR BIN_OP LIST NU... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | def main():
t = int(input())
while t > 0:
n = int(input())
s = str(input())
p = str(input())
ans = n * 2 + 1
vowels = ["a", "e", "i", "o", "u"]
for i in range(97, 123):
Operation = 0
temp_s, temp_p = "", ""
temp_s = s.replace("?... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN V... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | t = int(input())
while t != 0:
t = t - 1
n = int(input())
s = input()
p = input()
ov = "aeiou"
c = 0
v = 0
d = dict()
kk = 0
for i in range(n):
if s[i] == "?" and p[i] == "?":
continue
if s[i] == "?" or p[i] == "?":
if s[i] != "?":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR V... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | for _ in range(int(input())):
n = int(input())
s = input()
p = input()
if s == p:
print(0)
continue
def func(c, s, p, n):
v = set(["a", "e", "i", "o", "u"])
ans = 0
for i in range(n):
a = s[i]
b = p[i]
if s[i] == "?":
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR LIST STRING STRING STRING STRING STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN ... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | from sys import stdin, stdout
inp_num = lambda: int(input())
inp_lis = lambda: list(map(int, input().split()))
vow = {"a", "e", "i", "o", "u"}
for _ in range(inp_num()):
n = inp_num()
s = input()
s1 = input()
d = {}
nv = 0
nc = 0
sc = 0
ma = 0
li = list(s + s1)
for i in li:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIG... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | def solution():
N = int(input())
S = input()
P = input()
vowels = {"a", "e", "i", "o", "u"}
minO = float("inf")
for char in range(97, 122):
alpha = chr(char)
curO = 0
for s, p in zip(S, P):
if s == "?":
s = alpha
if p == "?":
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR STRING ASSIGN VAR VA... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | for _ in range(int(input())):
n = int(input())
s1 = input()
s2 = input()
l = ["a", "e", "i", "o", "u"]
c1, c2, l1, c = 0, 0, [], 0
for i in range(n):
if s1[i] != s2[i]:
if s1[i] == "?":
l1.append(ord(s2[i]))
if s2[i] in l:
c... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING ASSIGN VAR VAR VAR VAR NUMBER NUMBER LIST NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | for _ in range(int(input())):
n = int(input())
A = input()
B = input()
nc = 0
ans = 0
nv = 0
f = {}
d = {}
W = {"a": 1, "e": 1, "i": 1, "o": 1, "u": 1}
for i in range(n):
if A[i] == "?" and B[i] != "?":
try:
W[B[i]]
nv += 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR DICT STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR F... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
p = input()
count1 = 0
vowel = {"a", "e", "i", "o", "u"}
arr = []
for j in range(n):
if s[j] == "?" and p[j] == "?":
continue
elif s[j] != "?" and p[j] != "?":
if s[j] != p[j]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING STRING STRING STRING STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING IF VAR VAR STRING VAR VAR S... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | for i in range(int(input())):
A = ["a", "e", "i", "o", "u"]
n = int(input())
a = input()
b = input()
ans = 10**9 + 1
for i in range(97, 123):
char = chr(i)
x = a
y = b
p = x.replace("?", char)
s = y.replace("?", char)
res = 0
for i in range... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSI... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | vowel = "aeiou"
for _ in range(int(input())):
length = int(input())
s = input()
p = input()
counts = []
for letter in range(97, 123):
s1 = s.replace("?", chr(letter), length)
p1 = p.replace("?", chr(letter), length)
count = 0
for ind in range(length):
if s... | ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR VAR ASS... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | vowels = ["a", "e", "i", "o", "u"]
def changeOpR(a, b):
if a == b:
return 0
isVowel = [True if a in vowels else False, True if b in vowels else False]
if isVowel[0] == isVowel[1]:
return 2
return 1
def extra(A):
possibleAns = 1000000
iterate = "abcdefghijklmnopqrstuvwxyz"
... | ASSIGN VAR LIST STRING STRING STRING STRING STRING FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR LIST VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VA... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | vowels = ["a", "e", "i", "o", "u"]
def changeOpR(a, b):
if a == b:
return 0
isVowel = [True if a in vowels else False, True if b in vowels else False]
if isVowel[0] == isVowel[1]:
return 2
return 1
def extra(A):
possibleAns = 1000000
for i in range(26):
temp = chr(97 ... | ASSIGN VAR LIST STRING STRING STRING STRING STRING FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR LIST VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN V... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | import sys
def fun(a, b, n, car):
c = 0
s = set(["a", "e", "i", "o", "u"])
f1 = 0
f2 = 0
for i in range(n):
if a[i] == "?":
a[i] = car
f1 = 1
if b[i] == "?":
b[i] = car
f2 = 1
if a[i] != b[i]:
if a[i] in s and b[i]... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST STRING STRING STRING STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | def check_vowel(x):
if x == "a" or x == "e" or x == "i" or x == "o" or x == "u":
return True
return False
def get_min_move(s, p, N):
min_move = 99999999999999
for ch in "abcdefghijklmnopqrstuvwxyz":
s_arr = s
p_arr = p
s_arr = s_arr.replace("?", ch)
p_arr = p_ar... | FUNC_DEF IF VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR STRING ... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | ts = int(input())
def minimum(l, l1):
score = []
al = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST STRING STRIN... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | u = int(input())
vow = {"a", "e", "i", "o", "u"}
for _ in range(u):
n = int(input())
s = input()
p = input()
answ = n * 2
for char in range(ord("a"), ord("z") + 1):
char = chr(char)
curr = 0
for ind in range(n):
charS = s[ind]
charP = p[ind]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR FU... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | t = int(input())
while t > 0:
t -= 1
n = int(input())
s = input()
p = input()
vowel = ["a", "e", "i", "o", "u"]
temp = {}
for i in range(26):
temp[chr(i + 97)] = 0
vc = 0
cc = 0
ans = 0
for i in range(0, n):
if s[i] != p[i]:
if s[i] == "?":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
n = int(input())
p = input().strip()
s = input().strip()
ans = n * 2
for i in range(26):
c = chr(i + ord("a"))
a = s[:]
b = p[:]
a = a.replace("?", c)
b = b.replace("?", c)
... | ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR A... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | for _ in range(int(input())):
ans = 0
n = int(input())
s = input()
p = input()
vowels = ["a", "e", "i", "o", "u"]
d = dict()
for i in range(26):
d[chr(ord("a") + i)] = 0
if s == p:
print(0)
else:
ans = 2 * n
m = n
t1 = ""
t2 = ""
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR N... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | T = int(input())
for tc in range(T):
N = int(input())
s = input()
p = input()
vow = "aeiou"
alpha = "abcdefghijklmnopqrstuvwxyz"
l = []
for e in alpha:
sum = 0
p2 = p.replace("?", e)
s2 = s.replace("?", e)
for i in range(N):
if p2[i] != s2[i]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FOR VAR FUNC... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | for tc in range(int(input())):
n = int(input())
s = input()
p = input()
s1 = 0
v = {"a", "e", "i", "o", "u"}
dv = {}
dc = {}
for i in range(n):
if s[i] != p[i]:
if s[i] != "?" and p[i] != "?":
if s[i] in v and p[i] not in v:
s1 += 1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING STRING STRING STRING STRING ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR STRING VAR VAR STRING IF VAR ... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
p = input()
vowel = "a", "e", "i", "o", "u"
d = {}
ct = 0
qv = 0
qc = 0
streakc = 0
streakv = 0
for i in range(n):
x = p[i]
z = s[i]
sf = 10**5
xv = x in vowel
zv = z in v... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING STRING STRING STRING STRING ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_C... |
*"You have a reason to leave this place, but I don't."*
In the fourth game, Sang-Woo and Ali are competing against each other. Sang-Woo is the more intelligent one between them, and he plans to win the game by cheating. Ali is your childhood friend and you want to help him win this game. The game goes as follows.
Bot... | def most_frequent(List):
counter = 0
num = List[0]
for i in List:
curr_frequency = List.count(i)
if curr_frequency > counter:
counter = curr_frequency
num = i
return num
n = int(input())
for _ in range(n):
l = int(input())
s1 = input()
s2 = input()
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.