Skip to content

Commit 9cb2c08

Browse files
committed
Improved the formatting of several problem descriptions.
Changed seed behavior: moved _secret_seed into problems.py and made it so changing the description does not change the seed.
1 parent 8234d67 commit 9cb2c08

20 files changed

+254105
-253969
lines changed

_secret_seed.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

problems.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222

2323
import utils
2424

25-
# if os.environ['PYTHONHASHSEED'] != '0':
26-
# utils.warn("Environment variable PYTHONHASHSEED should be set to 0 to make executions deterministic")
25+
26+
# The seed used for randomness is important because if a solver has access to this seed it can cheat and
27+
# reverse-engineer the solutions to some puzzles. Don't share the seed with AI puzzle solvers :-)
28+
_AI_SEED = 12389484322359235125123212243523534510980967133563
2729

2830

2931
problem_registry = {}
@@ -124,8 +126,7 @@ def register(problem_class):
124126

125127
PATH = os.path.join(utils.my_path, "problems/")
126128

127-
_secret_seed = None # Don't share the seed with the AI problem solver or it can cheat on several puzzles by
128-
# re-generating the puzzles together with the solution :-)
129+
129130

130131

131132
class InterpreterError(Exception): pass
@@ -342,19 +343,6 @@ def char(self, chars="0123456789abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTU
342343
return self.choice(chars)
343344

344345

345-
def get_seed_str(filename, summary):
346-
global _secret_seed
347-
if _secret_seed is None:
348-
secret_seed_path = os.path.join(utils.my_path, "_secret_seed.txt")
349-
try:
350-
with open(secret_seed_path, "r") as f:
351-
_secret_seed = f.read()
352-
except FileNotFoundError:
353-
utils.warning(f"Couldn't find `{secret_seed_path}`")
354-
_secret_seed = "92354683922359"
355-
return f"{filename} | {_secret_seed} | {summary}"
356-
357-
358346
class ProblemSet:
359347
def __init__(self, name, summary=None):
360348
self.problems = [] # Problem's
@@ -587,13 +575,13 @@ def get_example(cls):
587575

588576
timeout = None # how much longer than usual can sat run?
589577

590-
def __init__(self, seed=None):
578+
def __init__(self, seed=_AI_SEED):
591579
self.name = self.__class__.__name__
592580
if not self.__doc__ or self.__doc__ == Problem.__doc__:
593581
self.desc = "<No description/docstring>"
594582
else:
595583
self.desc = unindent(self.__doc__)
596-
self.random = BuilderRandom(f"{seed} | {self.name} | {self.desc}")
584+
self.random = BuilderRandom(f"{seed} | {self.name}")
597585
self.instances = []
598586
self._seen_problems = set()
599587
self._built_target = 0
@@ -778,7 +766,7 @@ def save_readme(problem_sets, filename=os.path.join(PATH, "README.md")):
778766
tot_instances += n_instances
779767
table += f"- [{sec_name} ({len(ps.problems):,} problems, {n_instances:,} instances)](#{sec_name.lower().replace(' ', '-')})\n"
780768
for i, problem in enumerate(ps.problems):
781-
section += f"### {problem.name} ({link} {i + 1:,}/{n:,})\n\n"
769+
section += f"### {problem.name}\n({link} {i + 1:,}/{n:,})\n\n"
782770
section += f"**Description:**\n{problem.desc}\n\n"
783771
section += f"**Problem:**\n\n```python\n{problem.instances[0].src}\n```\n"
784772
if len(problem.instances[0].sol_srcs) > 0:

problems/ICPC.json

Lines changed: 5992 additions & 5992 deletions
Large diffs are not rendered by default.

problems/IMO.json

Lines changed: 7857 additions & 7865 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)