Code Golf: All +-*/ Combinations for 3 integers
Perl 130 chars So long as external libraries are permitted: use Algorithm::Permute”permute”; permute{for$x(@a=qw(+ – / *)){for$y(@a){$_=”@ARGV”;s/ /$x/;s/ /$y/;printf” $_ = %.0f”,eval}}}@ARGV 2nd newline is significant. Without a module, and assuming that all three inputs are distinct, here’s another solution: @n=& ARGV; @o=( q[+], “-“, q{/}, ‘*’ );; for$ {a}(@ n){ for $b(@n){for$c(@ {n}){ for $x( … Read more