[Haskell-cafe] Arithmetic expressions with random operators
Ingo Blechschmidt
iblech at web.de
Thu Jun 8 16:20:19 UTC 2017
Dear Murad,
On Thu, Jun 08, 2017 at 04:03:55PM +0300, Mahmoud Murad wrote:
> I have the following problem, I want to randomly generate arithmetic
> expressions based on a number, for example:
> if I have n = 3, then the expression must have 3 operators like this
> (4)*(((3+5)-2)).
Mark Dominus, well-known in the Perl community, likes this puzzle so
much that he collected several solutions and nonsolutions on his blog
(which I warmly recommend). He also lists several Haskell solutions:
http://blog.plover.com/math/24-puzzle.html
Ideas for further optimizations of the Haskell solutions (regarding
clarity, elegance, and length of the code) are very much welcome:
https://gist.github.com/iblech/e21b0a2f5a6e0184ba43c3b1e0e70337
Cheers,
Ingo
More information about the Haskell-Cafe
mailing list