Skip to content

Commit

Permalink
improved template
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanExtreme002 committed Apr 28, 2024
1 parent 3ea8cc9 commit 00b6da0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fastsnake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
A Python Helper CLI for Competitive Programming
"""

__version__ = "1.4.17"
__version__ = "1.4.18"

__author__ = "Jean Loui Bernard Silva de Jesus"
__github__ = "https://github.com/JeanExtreme002"
Expand Down
21 changes: 15 additions & 6 deletions fastsnake/application/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,25 @@ def start_contest(
with open(os.path.join(config["solutions_namespace"], problem.upper() + ".py"), "w") as file:
file.write("# Solution for problem " + problem + "\n\n")
file.write("# [START STEP COUNTER]\n\n")
file.write("# Python is not recommended for recursive solutions.\n")
file.write("# Python is NOT recommended for recursive solutions.\n")
file.write("import sys\n")
file.write("sys.setrecursionlimit(2 * 10**9)\n\n")
file.write("# IMPORT FASTSNAKE ALGORITHMS OR STRUCTURES OR YOUR EXTERNAL MODULES.\n")
file.write("# from fastsnake.algorithms.something import *\n")
file.write("# from fastsnake.structures.something import *\n")
file.write("# from fastsnake.external.your_external_module import *\n")
file.write("sys.setrecursionlimit(2 * 10**9)\n")
file.write("\n")
file.write("# Time-complexity of Python implementations: https://wiki.python.org/moin/TimeComplexity\n")
file.write("# A deque (double-ended queue) is a doubly linked list. Complexity O(1) for append and pop operations.\n")
file.write("# Add elements with the method append (left to right). Use it as a stack (pop) or as a queue (popLeft).\n\n")
file.write("from collections import deque\n")
file.write("\n")
file.write("# Priority Queue Algorithm [Complexity O(log(n))]: https://docs.python.org/3/library/heapq.html\n")
file.write("# Use the heapq.heapify(x) to transform a list into a heap. All functions will use this transformed list.\n")
file.write("# Hint: heapq.heapreplace(...) is more efficient than a heappop(...) followed by heappush(...)\n\n")
file.write("import heapq\n")
file.write("\n\n")
file.write("# IMPORT FASTSNAKE ALGORITHMS OR STRUCTURES OR YOUR EXTERNAL MODULES.\n")
file.write("# from fastsnake.algorithms.something import *\n")
file.write("# from fastsnake.structures.something import *\n")
file.write("# from fastsnake.external.your_external_module import *\n")
file.write("\n")
file.write("# Just remove the fastsnake code below if you will not use it.\n")
file.write("# " + "=" * 70 + "\n")
file.write("from fastsnake.entries import *\n")
Expand All @@ -60,6 +66,9 @@ def start_contest(
file.write("putm = input_int_matrix # Other: input_{char, float, string}_array\n")
file.write("# " + "=" * 70 + "\n")
file.write("\n")
file.write("# >>> HEY, RIGHT HERE!! Write your code below:\n")
file.write("# Remember, sometimes the solution is much simpler than you think S2\n")
file.write("\n")
file.write("for test_case in range(int(input())):\n")
file.write(" n = int(input())\n")
file.write(" pass\n")
Expand Down
8 changes: 5 additions & 3 deletions fastsnake/util/compiler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime
import os


path = os.path.join(os.path.dirname(__file__), "..")


Expand Down Expand Up @@ -36,7 +36,9 @@ def compile_code(input_filename: str, output_filename: str) -> None:

# Write the compiled code.
with open(output_filename, "w") as file:
ftime = datetime.now().strftime("%m/%d/%Y %H:%M:%S")

file.write(string)
file.write("\n\n# " + "=" * 50 + "\n")
file.write("# COMPILED SOLUTION \n")
file.write("\n# " + "=" * 50 + "\n")
file.write(f"# COMPILED SOLUTION [{ftime}]\n")
file.write("# " + "=" * 50 + "\n\n")

0 comments on commit 00b6da0

Please sign in to comment.