mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-30 17:40:45 +00:00
feat: Implement allow_negation to generate both positive and negative numbers in ChainSum
This commit is contained in:
parent
358829cc60
commit
1ff01627cc
2 changed files with 41 additions and 2 deletions
|
|
@ -83,7 +83,12 @@ class ChainSum:
|
|||
min_value = 10 ** (num_digits - 1) # e.g., 100 for 3 digits
|
||||
max_value = (10 ** num_digits) - 1 # e.g., 999 for 3 digits
|
||||
|
||||
constants = [rng.randint(min_value, max_value) for _ in range(num_terms)]
|
||||
if self.config.allow_negation:
|
||||
# Allow both positive and negative numbers in the range
|
||||
constants = [rng.randint(-max_value, max_value) for _ in range(num_terms)]
|
||||
else:
|
||||
# Only positive numbers
|
||||
constants = [rng.randint(min_value, max_value) for _ in range(num_terms)]
|
||||
operators = [rng.choice(["+", "-"]) for _ in range(num_terms - 1)]
|
||||
|
||||
# Build expression and compute result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue