for day in range(1, 26): boilerplate = open(".\\src\\solutions\\dayxx.rs", "r").read() boilerplate = boilerplate.replace("0", str(day)) boilerplate = boilerplate.replace("XX", f"{day:02d}") new_code = open(f".\\src\\solutions\\day{day:02d}.rs", "w") new_code.write(boilerplate) f = open(f".\\input\\day{day:02d}", "x") f = open(f".\\input\\day{day:02d}_test1", "x") f = open(f".\\input\\day{day:02d}_test2", "x")