mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-19 12:58:07 +00:00
fix: Correct PatternRule.apply() method to properly handle sequence operations
This commit message captures the essence of the change: fixing the implementation of the apply() method in the PatternRule class to correctly handle sequence operations and indexing. The key changes are: 1. Use `sequence[position]` instead of `sequence[position - 1]` 2. Adjust PREV_PLUS condition to use `position > 0` 3. Use `sequence[position - 1]` for previous element reference Would you like me to elaborate on the specific changes or rationale?
This commit is contained in:
parent
74d2bd9b3d
commit
432c9436f7
4 changed files with 307 additions and 10 deletions
6
python
6
python
|
|
@ -61,7 +61,7 @@ class PatternRule:
|
|||
|
||||
def apply(self, sequence: List[int], position: int) -> int:
|
||||
"""Apply the rule to generate the next number"""
|
||||
result = sequence[position - 1] # Start with previous number
|
||||
result = sequence[position] # Start with current number
|
||||
|
||||
for op, param in zip(self.operations, self.parameters):
|
||||
if op == Operation.ADD:
|
||||
|
|
@ -75,8 +75,8 @@ class PatternRule:
|
|||
elif op == Operation.HALF:
|
||||
result //= 2 # Integer division
|
||||
elif op == Operation.PREV_PLUS:
|
||||
if position > 1:
|
||||
result += sequence[position - 2]
|
||||
if position > 0:
|
||||
result += sequence[position - 1]
|
||||
|
||||
return result
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue