Skip to content

Commit

Permalink
Remove extra zeros from rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Marven11 committed Dec 19, 2023
1 parent b17b174 commit cfd2f26
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fenjing/payload_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,11 @@ def gen_positive_integer_numbersum1(context: dict, value: int):
return [(UNSATISFIED,)]
alternative = []
for i in range(min(40, value - 1), 3, -1):
inner = "+".join([str(i)] * (value // i) + [str(value % i)])
if value % i != 0:
numbers = [str(i)] * (value // i) + [str(value % i)]
else:
numbers = [str(i)] * (value // i)
inner = "+".join(numbers)
alternative.append([(LITERAL, inner)])
target_list = [(ONEOF, *alternative)]
return [(EXPRESSION, precedence["plus"], target_list)]
Expand All @@ -1295,7 +1299,11 @@ def gen_positive_integer_numbersum2(context: dict, value: int):
return [(UNSATISFIED,)]
alternatives = []
for i in range(min(40, value - 1), 3, -1):
inner = ",".join([str(i)] * (value // i) + [str(value % i)])
if value % i != 0:
numbers = [str(i)] * (value // i) + [str(value % i)]
else:
numbers = [str(i)] * (value // i)
inner = ",".join(numbers)
alternatives.append([(LITERAL, "({})|sum".format(inner))])
target_list = [(ONEOF, *alternatives)]
return [(EXPRESSION, precedence["filter"], target_list)]
Expand Down

0 comments on commit cfd2f26

Please sign in to comment.