Python 精确定位单词位置(类似于战舰)

Python 精确定位单词位置(类似于战舰),python,python-3.x,python-2.7,Python,Python 3.x,Python 2.7,我得到了一个网格,其中有混乱的字母,但它有隐藏的单词。我必须找到单词的位置,根据它是否正确,给用户一些分数 我现在有 def check_guess(puz: str, direct: str, words: str, rc: int, rip: int) -> int: """ """ if words in puz: return [get_points(direct, r

我得到了一个网格,其中有混乱的字母,但它有隐藏的单词。我必须找到单词的位置,根据它是否正确,给用户一些分数

我现在有

def check_guess(puz: str, direct: str, words: str, rc: int, rip: int) -> 
   int:

    """
    """ 
    if words in puz: 
        return [get_points(direct, rip)]
    else:
        return 0
基本上,如果单词(例如:'cat')在puz('catan')中,用户将获得一定数量的分数。然而,只有当他们能够识别单词所在的行/列(我称之为“rc”)时,他们才能得到这些分数,如果这是错误的,他们将得到0分。我不知道如何精确定位这个网格中单词的第一个字母(尺寸是x乘y)

注意:
get_points
是我创建的另一个提供积分的函数。不同的方向给出不同的点(上、下、后、前)

我有两个额外的功能

def get_column(puzzle: str, col_num: int) -> str:
    """Return column col_num of puzzle.

    Precondition: 0 <= col_num < number of columns in puzzle

    >>> get_column('abcd\nefgh\nijkl\n', 1)
    'bfj'
    """

    puzzle_list = puzzle.strip().split('\n')
    column = ''
    for row in puzzle_list:
        column += row[col_num]

    return column
以下是我作业的视频供参考:

def get_row_length(puzzle: str) -> int:
    """Return the length of a row in puzzle.

    >>> get_row_length('abcd\nefgh\nijkl\n')
    4
"""
    return len(puzzle.split('\n')[0])