"""
Script updates `README.md` with respect to files at ./easy and ./medium folders.
"""
import os

curr_dir = os.path.dirname(__file__)
with open(os.path.join(curr_dir, "README.md"), 'w') as readme:
    readme.write("# LeetCode\nDeliberate practice in coding.\n")
    langs = [l for l in os.listdir(curr_dir) if os.path.isdir(os.path.join(curr_dir, l)) and l[0] != '.']
    for lang in langs:
        readme.write("## {}\n".format(lang))
        readme.write("### Easy\n")
        easy = sorted(os.listdir(f"{curr_dir}/{lang}/easy"))
        easy = [x.split("_")[0] for x in easy]
        easy_solved = ""
        for el in easy:
            easy_solved += "{}, ".format(el)
        readme.write(easy_solved[:-2] + "\n")
        readme.write("### Medium\n")
        medium = sorted(os.listdir(f"{curr_dir}/{lang}/medium"))
        medium = [x.split("_")[0] for x in medium]
        medium_solved = ""
        for el in medium:
            medium_solved += "{}, ".format(el)
        readme.write(medium_solved[:-2] + '\n')

[((6, 11, 6, 36), 'os.path.dirname', 'os.path.dirname', ({(6, 27, 6, 35): '__file__'}, {}), '(__file__)', False, 'import os\n'), ((7, 10, 7, 45), 'os.path.join', 'os.path.join', ({(7, 23, 7, 31): 'curr_dir', (7, 33, 7, 44): '"""README.md"""'}, {}), "(curr_dir, 'README.md')", False, 'import os\n'), ((9, 24, 9, 44), 'os.listdir', 'os.listdir', ({(9, 35, 9, 43): 'curr_dir'}, {}), '(curr_dir)', False, 'import os\n'), ((13, 22, 13, 59), 'os.listdir', 'os.listdir', ({(13, 33, 13, 58): 'f"""{curr_dir}/{lang}/easy"""'}, {}), "(f'{curr_dir}/{lang}/easy')", False, 'import os\n'), ((20, 24, 20, 63), 'os.listdir', 'os.listdir', ({(20, 35, 20, 62): 'f"""{curr_dir}/{lang}/medium"""'}, {}), "(f'{curr_dir}/{lang}/medium')", False, 'import os\n'), ((9, 62, 9, 87), 'os.path.join', 'os.path.join', ({(9, 75, 9, 83): 'curr_dir', (9, 85, 9, 86): 'l'}, {}), '(curr_dir, l)', False, 'import os\n')]