Update comprehensive-arithmetic-problems-carries.py
Browse files
comprehensive-arithmetic-problems-carries.py
CHANGED
|
@@ -190,36 +190,39 @@ class ArithmeticProblemsDataset(GeneratorBasedBuilder):
|
|
| 190 |
raise ValueError(f"Invalid operator: {operator}")
|
| 191 |
|
| 192 |
is_float1, is_float2 = operation_type
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
if with_carry:
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
)
|
| 209 |
-
except Exception:
|
| 210 |
-
continue
|
| 211 |
else:
|
|
|
|
| 212 |
operand2 = self._generate_number(
|
| 213 |
min_val=min_value,
|
| 214 |
-
max_val=max_value,
|
| 215 |
is_float=is_float2,
|
| 216 |
max_rounding_precision=max_rounding_precision,
|
| 217 |
)
|
| 218 |
-
break
|
| 219 |
-
|
| 220 |
-
if operator == Operator.SUBTRACT:
|
| 221 |
-
result = operand1 - operand2
|
| 222 |
-
elif operator == Operator.ADD:
|
| 223 |
result = operand1 + operand2
|
| 224 |
elif operator == Operator.MULTIPLY:
|
| 225 |
result = operand1 * operand2
|
|
|
|
| 190 |
raise ValueError(f"Invalid operator: {operator}")
|
| 191 |
|
| 192 |
is_float1, is_float2 = operation_type
|
| 193 |
+
operand1 = self._generate_number(
|
| 194 |
+
min_val=min_value,
|
| 195 |
+
max_val=max_value,
|
| 196 |
+
is_float=is_float1,
|
| 197 |
+
max_rounding_precision=max_rounding_precision,
|
| 198 |
+
)
|
| 199 |
+
# for testing addition
|
| 200 |
+
operand2 = self._generate_number(
|
| 201 |
+
min_val=min_value,
|
| 202 |
+
max_val=max_value,
|
| 203 |
+
is_float=is_float2,
|
| 204 |
+
max_rounding_precision=max_rounding_precision,
|
| 205 |
+
)
|
| 206 |
+
|
| 207 |
+
if operator == Operator.SUBTRACT:
|
| 208 |
+
result = operand1 - operand2
|
| 209 |
+
elif operator == Operator.ADD:
|
| 210 |
if with_carry:
|
| 211 |
+
# for testing addition
|
| 212 |
+
operand2 = self._generate_number(
|
| 213 |
+
min_val=max_value - operand1 ,
|
| 214 |
+
max_val=max_value,
|
| 215 |
+
is_float=is_float2,
|
| 216 |
+
max_rounding_precision=max_rounding_precision,
|
| 217 |
+
)
|
|
|
|
|
|
|
|
|
|
| 218 |
else:
|
| 219 |
+
# for testing addition
|
| 220 |
operand2 = self._generate_number(
|
| 221 |
min_val=min_value,
|
| 222 |
+
max_val=max_value - operand1 - 1,
|
| 223 |
is_float=is_float2,
|
| 224 |
max_rounding_precision=max_rounding_precision,
|
| 225 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
result = operand1 + operand2
|
| 227 |
elif operator == Operator.MULTIPLY:
|
| 228 |
result = operand1 * operand2
|