Cryptarithm
Task Description
Cryptarithm is a mathematical puzzle where letters represent digits, and different letters represent different digits. Players need to find the correspondence between letters and digits to make the equation true.
Example
Given: SEND + MORE = MONEY Each letter represents a digit (SEND, MORE each represent a four-digit number; MONEY represents a five-digit number), and no two letters represent the same digit. To make the equation true, find the numerical equation.
Answer: 9567 + 1085 = 10652
Code Logic
Generation Logic
- Randomly select
num_letterdigits (between 1-9) - Randomly choose an operator (based on
operator_level: 1=addition/subtraction, 2=addition/subtraction, 3=addition/subtraction/multiplication) - Randomly generate numbers on the left side of the equation, then calculate the result
- Check if the number of different digits in the equation equals
num_letter - Verify that the equation has a unique solution
- Randomly replace digits with letters to create the problem
Verification Logic
Verify whether the numerical equation extracted from the model's answer is correct.
Answer Extraction Logic
Extract the final numerical equation from the model's answer, supporting various formats:
- Chinese format: 答案是:1234 + 5678 = 6912
- English format: The answer is: 1234 + 5678 = 6912
- Direct equation format: 1234 + 5678 = 6912
Parameter Description
num_letter: Number of different letters in the equation (between 1-9)operator_num: Number of calculations in the equationoperator_level: Difficulty level of operators (1=addition/subtraction, 2=addition/subtraction, 3=addition/subtraction/multiplication)num_of_data: Number of samples to generatemax_attempts: Maximum number of attempts for each problem
Usage
# Using default parameters
./run.sh
Generated data will be saved in the data/ directory, organized according to parameter settings.