diff --git a/00_Utilities/TODO.md b/00_Utilities/TODO.md new file mode 100644 index 00000000..3f49e4b8 --- /dev/null +++ b/00_Utilities/TODO.md @@ -0,0 +1,98 @@ +# TODO list + game | csharp | java | javascript | pascal | perl | python | ruby | vbnet + --- | --- | --- | --- | --- | --- | --- | --- | --- +01_Acey_Ducey | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +02_Amazing | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +03_Animal | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +04_Awari | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +05_Bagels | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +06_Banner | ✅ | ✅ | ✅ | ⬜️ | ⬜️ | ✅ | ✅ | ✅ +07_Basketball | ⬜️ | ✅ | ✅ | ⬜️ | ⬜️ | ✅ | ⬜️ | ✅ +08_Batnum | ✅ | ✅ | ✅ | ⬜️ | ✅ | ✅ | ⬜️ | ✅ +09_Battle | ✅ | ✅ | ✅ | ⬜️ | ⬜️ | ✅ | ⬜️ | ✅ +10_Blackjack | ✅ | ⬜️ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +11_Bombardment | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +12_Bombs_Away | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +13_Bounce | ⬜️ | ✅ | ✅ | pascal | ⬜️ | ✅ | ✅ | ✅ +14_Bowling | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +15_Boxing | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +16_Bug | ⬜️ | ✅ | ✅ | pascal | ⬜️ | ✅ | ✅ | ✅ +17_Bullfight | ✅ | ⬜️ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +18_Bullseye | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +20_Buzzword | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +21_Calendar | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +22_Change | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +23_Checkers | ✅ | ⬜️ | ✅ | pascal | ⬜️ | ✅ | ✅ | ✅ +24_Chemist | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +25_Chief | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +26_Chomp | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +27_Civil_War | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +28_Combat | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +29_Craps | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +30_Cube | ⬜️ | ✅ | ✅ | pascal | ⬜️ | ✅ | ✅ | ✅ +31_Depth_Charge | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +32_Diamond | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +33_Dice | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +34_Digits | ⬜️ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +35_Even_Wins | ⬜️ | ⬜️ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +36_Flip_Flop | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ✅ | ✅ +37_Football | ⬜️ | ⬜️ | ✅ | pascal | ⬜️ | ⬜️ | ⬜️ | ✅ +38_Fur_Trader | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +39_Golf | ✅ | ⬜️ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +40_Gomoko | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +41_Guess | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +42_Gunner | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +43_Hammurabi | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +44_Hangman | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +45_Hello | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +46_Hexapawn | ✅ | ⬜️ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +47_Hi-Lo | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +48_High_IQ | ⬜️ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +49_Hockey | ⬜️ | ⬜️ | ✅ | pascal | ⬜️ | ⬜️ | ⬜️ | ✅ +50_Horserace | ⬜️ | ⬜️ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +51_Hurkle | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +52_Kinema | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +53_King | ⬜️ | ⬜️ | ✅ | pascal | ⬜️ | ⬜️ | ⬜️ | ✅ +54_Letter | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +55_Life | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +56_Life_for_Two | ⬜️ | ⬜️ | ✅ | pascal | ⬜️ | ⬜️ | ⬜️ | ✅ +57_Literature_Quiz | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +58_Love | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +59_Lunar_LEM_Rocket | ⬜️ | ⬜️ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +60_Mastermind | ✅ | ⬜️ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +61_Math_Dice | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +62_Mugwump | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +63_Name | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +64_Nicomachus | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +65_Nim | ⬜️ | ⬜️ | ✅ | pascal | ⬜️ | ✅ | ✅ | ✅ +66_Number | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +67_One_Check | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +68_Orbit | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +69_Pizza | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +70_Poetry | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +71_Poker | ⬜️ | ✅ | ✅ | pascal | ⬜️ | ⬜️ | ⬜️ | ✅ +72_Queen | ⬜️ | ⬜️ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +73_Reverse | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +74_Rock_Scissors_Paper | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +75_Roulette | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +76_Russian_Roulette | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +77_Salvo | ⬜️ | ⬜️ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +78_Sine_Wave | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +79_Slalom | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +80_Slots | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +81_Splat | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +82_Stars | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +83_Stock_Market | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +84_Super_Star_Trek | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +85_Synonym | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +86_Target | ✅ | ✅ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +87_3-D_Plot | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +88_3-D_Tic-Tac-Toe | ✅ | ⬜️ | ✅ | pascal | ⬜️ | ✅ | ⬜️ | ✅ +89_Tic-Tac-Toe | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +90_Tower | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +91_Train | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +92_Trap | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +93_23_Matches | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +94_War | ⬜️ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ +95_Weekday | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ⬜️ | ✅ +96_Word | ✅ | ✅ | ✅ | pascal | ✅ | ✅ | ✅ | ✅ diff --git a/00_Utilities/markdown_todo.py b/00_Utilities/markdown_todo.py index bdcedb15..da27cab4 100644 --- a/00_Utilities/markdown_todo.py +++ b/00_Utilities/markdown_todo.py @@ -1,73 +1,112 @@ import os - -lang_pos = { - "csharp": 1, - "java": 2, - "javascript": 3, - "pascal": 4, - "perl": 5, - "python": 6, - "ruby": 7, - "vbnet": 8, -} - -write_string = "# TODO list \n game | csharp | java | javascript | pascal | perl | python | ruby | vbnet \n --- | --- | --- | --- | --- | --- | --- | --- | --- \n" -# Set the directory you want to start from -rootDir = ".." - -strings_done = [] - -checklist = [ - "game", - "csharp", - "java", - "javascript", - "pascal", - "perl", - "python", - "ruby", - "vbnet", -] - -prev_game = "" - -for dirName, subdirList, fileList in os.walk(rootDir): - split_dir = dirName.split(os.path.sep) - - if len(split_dir) == 2 and split_dir[1] not in [".git", "00_Utilities"]: - if prev_game == "": - prev_game = split_dir[1] - checklist[0] = split_dir[1] - - if prev_game != split_dir[1]: - # it's a new dir - strings_done.append(checklist) - checklist = [ - split_dir[1], - "csharp", - "java", - "javascript", - "pascal", - "perl", - "python", - "ruby", - "vbnet", - ] - prev_game = split_dir[1] - - elif len(split_dir) == 3 and split_dir[1] != ".git" and split_dir[2] in lang_pos: - if len(fileList) > 1 or len(subdirList) > 0: - # there is more files than the readme - checklist[lang_pos[split_dir[2]]] = "✅" - else: - checklist[lang_pos[split_dir[2]]] = "⬜️" +from typing import Dict, List -sorted_strings = list( - map(lambda l: " | ".join(l) + "\n", sorted(strings_done, key=lambda x: x[0])) -) -write_string += "".join(sorted_strings) +def has_implementation(lang: str, file_list: List[str], subdir_list: List[str]) -> bool: + if lang == "csharp": + return any(file.endswith(".cs") for file in file_list) + else: + return len(file_list) > 1 or len(subdir_list) > 0 -with open("README.md", "w", encoding="utf-8") as f: - f.write(write_string) +def get_data(root_dir: str = "..") -> List[List[str]]: + """ + + Parameters + ---------- + root_dir : str + The root directory you want to start from. + """ + lang_pos: Dict[str, int] = { + "csharp": 1, + "java": 2, + "javascript": 3, + "pascal": 4, + "perl": 5, + "python": 6, + "ruby": 7, + "vbnet": 8, + } + strings_done: List[List[str]] = [] + + checklist = [ + "game", + "csharp", + "java", + "javascript", + "pascal", + "perl", + "python", + "ruby", + "vbnet", + ] + + ignore_folders = [ + ".git", + "00_Utilities", + ".github", + ".mypy_cache", + ".pytest_cache", + "00_Alternate_Languages", + "00_Common", + "buildJvm", + "htmlcov", + ] + + prev_game = "" + + for dir_name, subdir_list, file_list in os.walk(root_dir): + # split_dir[1] is the game + # split_dir[2] is the language + split_dir = dir_name.split(os.path.sep) + + if len(split_dir) == 2 and split_dir[1] not in ignore_folders: + if prev_game == "": + prev_game = split_dir[1] + checklist[0] = split_dir[1] + + if prev_game != split_dir[1]: + # it's a new dir + strings_done.append(checklist) + checklist = [ + split_dir[1], + "csharp", + "java", + "javascript", + "pascal", + "perl", + "python", + "ruby", + "vbnet", + ] + prev_game = split_dir[1] + elif ( + len(split_dir) == 3 and split_dir[1] != ".git" and split_dir[2] in lang_pos + ): + out = ( + "✅" + if has_implementation(split_dir[2], file_list, subdir_list) + else "⬜️" + ) + checklist[lang_pos[split_dir[2]]] = out + return strings_done + + +def write_file(path: str, strings_done: List[List[str]]) -> None: + write_string = ( + "# TODO list\n" + " game | csharp | java | javascript | pascal | perl | python | ruby | vbnet\n" + " --- | --- | --- | --- | --- | --- | --- | --- | ---\n" + ) + sorted_strings = list( + map(lambda l: " | ".join(l) + "\n", sorted(strings_done, key=lambda x: x[0])) + ) + write_string += "".join(sorted_strings) + + with open(path, "w", encoding="utf-8") as f: + f.write(write_string) + + +if __name__ == "__main__": + strings_done = get_data() + write_file("TODO.md", strings_done)