Skip to content

Instantly share code, notes, and snippets.

@kfstorm
Last active January 26, 2020 09:58
Show Gist options
  • Save kfstorm/0f35d62c68ae4bf9c8272711e8abd99a to your computer and use it in GitHub Desktop.
Save kfstorm/0f35d62c68ae4bf9c8272711e8abd99a to your computer and use it in GitHub Desktop.
import shutil
import os
import re
# This is the directory of https://github.com/kfstorm/leetcode-1/tree/master/solution
dest_dir = "../leetcode-1/solution"
dest = {int(re.match(r'^\d+', d).group(0)): os.path.join(dest_dir, d) for d in os.listdir(dest_dir) if os.path.isdir(os.path.join(dest_dir, d))}
# This is the directory of https://github.com/kfstorm/LeetCode
src_dir = "."
src = {int(re.match(r'^\d+', f).group(0)): os.path.join(src_dir, f) for f in os.listdir(src_dir) if f.endswith(".cs") and not f.endswith(".Test.cs")}
excludes = { 218 }
for number, src_file in src.items():
if number not in excludes:
shutil.copyfile(src_file, os.path.join(dest[number], "Solution.cs"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment