MaigoAkisame / enumerate-expressions

Enumerate expressions with n variables without repetition

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 个变量组成的四则运算式。

本程序可以避免由下列五种原因造成的重复:

  • 加法、乘法交换律;
  • 加法、乘法结合律;
  • 减法、除法去括号;
  • 交换被减数与减数;
  • 独立运算顺序不唯一。

算法的详细解释,请参阅我的知乎专栏:

程序中的注释均为中文。

About

Enumerate expressions with n variables without repetition


Languages

Language:C++ 50.5%Language:Python 49.5%