"There are five ways to place the parentheses in an expression with four numbers (I'm only using addition here, but obviously you could use any operators):\n",
"* $((a+b)+c)+d$\n",
"* $(a+(b+c))+d$\n",
"* $a+((b+c)+d)$\n",
"* $a+(b+(c+d))$\n",
"* $(a+b)+(c+d)$\n",
"\n",
"(It turns out that the number of ways to place the parentheses around $n$ numbers is $C_{n-1}$, where $C_n$ is the $n$th [Catalan number](https://en.wikipedia.org/wiki/Catalan_number).)\n",
"\n",
"If we iterate through every possible permutation of four digits, along with every possible set of three operators, and evaluate using each of the five possible groupings, we can get every number that can be formed from four digits under the problem's rules.\n",
"\n",
"Here's a function to find the longest streak of positive integers you can form from four digits."
"This work is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International license](https://creativecommons.org/licenses/by-sa/4.0/) and the [BSD Zero Clause license](https://spdx.org/licenses/0BSD.html)."