enumerate-expressions
enumerate-expressions copied to clipboard
Enumerate expressions with n variables without repetition
enumerate-expressions
English
This program enumerates expressions involving n variables and the operations +,-,*,/ without repetition.
The program avoids repetitions caused by the following 5 causes:
- Commutative law of addition and multiplication;
- Associative law of addition and multiplication;
- Breaking parentheses in subtraction and division;
- Swapping the two operands of a subtraction;
- Non-unique order of independent operations.
The algorithm is explained in detail in my Zhihu personal column (in Chinese):
The comments in the program are also in Chinese only.
中文
本程序可以不重复地枚举由 n 个变量组成的四则运算式。
本程序可以避免由下列五种原因造成的重复:
- 加法、乘法交换律;
- 加法、乘法结合律;
- 减法、除法去括号;
- 交换被减数与减数;
- 独立运算顺序不唯一。
算法的详细解释,请参阅我的知乎专栏:
程序中的注释均为中文。