<commit_before>import unittest
"""
Given a sequence, find the length of the longest palindromic subsequence in it.
Input: BBABCBCAB
Output: 7
"""


def longest_palindromic_subsequence(string):

    n = len(string)
    #  table[i][j] is longest palindromic subsequence length for string[i...j]
    table = [[0] * n for _ in range(n)]

    for i in range(n):
        table[i][i] = 1

    for L in range(2, n+1):
        for i in range(0, n-L+1):
            j = i+L-1
            if string[i] == string[j] and L == 2:
                table[i][j] = 2
            elif string[i] == string[j]:
                table[i][j] = 2 + table[i+1][j-1]
            else:
                table[i][j] = max(table[i+1][j], table[i][j-1])

    return table[0][n-1]


class TestLPSS(unittest.TestCase):

    def test_lpss(self):
        string = 'GEEKS'
        self.assertEqual(longest_palindromic_subsequence(string), 2)<commit_msg>Some refactoring<commit_after>import unittest
"""
Given a sequence, find the length of the longest palindromic subsequence in it.
Input: BBABCBCAB
Output: 7
"""


def longest_palindromic_subsequence(string):

    n = len(string)
    #  table[i][j] is longest palindromic subsequence length for string[i...j]
    table = [[0] * n for _ in range(n)]

    for L in range(1, n+1):
        for i in range(n-L+1):
            j = i+L-1
            if i == j:
                table[i][j] = 1
            elif string[i] == string[j] and L == 2:
                table[i][j] = 2
            elif string[i] == string[j]:
                table[i][j] = 2 + table[i+1][j-1]
            else:
                table[i][j] = max(table[i+1][j], table[i][j-1])

    return table[0][n-1]


class TestLPSS(unittest.TestCase):

    def test_lpss(self):
        string = 'GEEKS'
        self.assertEqual(longest_palindromic_subsequence(string), 2)
        self.assertEqual(longest_palindromic_subsequence('BBABCBCAB'), 7)
{'fraction_non_alphanumeric': 0.14166231050705697, 'fraction_numerical': 0.01881860951385259, 'mean_word_length': 2.305699481865285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6798769', 'n_tokens_mistral': 706, 'n_tokens_neox': 666, 'n_words': 166}