<commit_before>type Cell = {i: number, j: number};

export default function contains(grid: number[][], seq: number[]): boolean {
    if (!seq.length) {
        return true;
    }

    // failed[i][j] contains k if there is no path starting at {i, j} that retraces the sequence
    // suffix starting at index k.
    const failed = grid.map(row =>
        row.map(() => new Set<number>())
    );

    return grid.some((row, i) =>
        row.some((_, j) => containsRec(grid, seq, 0, {i, j}, failed))
    );
}

function containsRec(grid: number[][], seq: number[], seqStart: number, {i, j}: Cell,
    failed: Set<number>[][]): boolean {

    if (failed[i][j].has(seqStart)) {
        return false;
    }

    if (grid[i][j] === seq[seqStart]) {
        // The first element matches, but what about the remaining elements?<commit_msg>[EPI/17.5/typescript] Use explicit length comparison<commit_after>type Cell = {i: number, j: number};

export default function contains(grid: number[][], seq: number[]): boolean {
    if (seq.length === 0) {
        return true;
    }

    // failed[i][j] contains k if there is no path starting at {i, j} that retraces the sequence
    // suffix starting at index k.
    const failed = grid.map(row =>
        row.map(() => new Set<number>())
    );

    return grid.some((row, i) =>
        row.some((_, j) => containsRec(grid, seq, 0, {i, j}, failed))
    );
}

function containsRec(grid: number[][], seq: number[], seqStart: number, {i, j}: Cell,
    failed: Set<number>[][]): boolean {

    if (failed[i][j].has(seqStart)) {
        return false;
    }

    if (grid[i][j] === seq[seqStart]) {
        // The first element matches, but what about the remaining elements?
{'fraction_non_alphanumeric': 0.17174677608440797, 'fraction_numerical': 0.0035169988276670576, 'mean_word_length': 2.9331797235023043, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7191079', 'n_tokens_mistral': 547, 'n_tokens_neox': 541, 'n_words': 176}