<jupyter_start><jupyter_text>说明：    以Day Month Year的形式给出日期字符串，其中：        1、Day is in the set {"1st", "2nd", "3rd", "4th", ..., "30th", "31st"}.        2、Month is in the set {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}.        3、Year is in the range [1900, 2100].    将日期字符串转换为格式YYYY-MM-DD，其中：        1、YYYY denotes the 4 digit year.        2、MM denotes the 2 digit month.        3、DD denotes the 2 digit day.Example 1:    Input: date = "20th Oct 2052"    Output: "2052-10-20"Example 2:    Input: date = "6th Jun 1933"    Output: "1933-06-06"Example 3:    Input: date = "26th May 1960"    Output: "1960-05-26"Constraints:    1、The given dates are guaranteed to be valid, so no error handling is necessary.<jupyter_code>class Solution:
    def reformatDate(self, date: str) -> str:
        mons = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
        date = date.split(' ')
        Y, M, D = [], [], []
        for d in date:
            if d.isdigit():
                Y.append(d)
            elif d.isalpha():
                M.append(mons.index(d))
            else:
                D.append(d[:-2])
        res = ''
        for i in range(len(Y)):
            res += Y[i] + '-' + str(M[i]) + '-' + D[i]
        return res
solution = Solution()
solution.reformatDate("20th Oct 2052")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18031609195402298, 'fraction_numerical': 0.05531609195402299, 'mean_word_length': 2.2776470588235296, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '259651', 'license': 'Apache-2.0', 'n_tokens_mistral': 560, 'n_tokens_neox': 505, 'n_words': 148, 'path': 'String/1013/1507. Reformat Date.ipynb', 'repo_name': 'YuHe0108/Leetcode', 'size': '1392'}