-2
\$\begingroup\$

This is code golf. Fewest bytes wins, only standard libraries, etc.

Write code, in any language, to output all possible same-length permutations of all items of an array / list / object in the input format and any order, grouped in whatever way you like. The items can be of ANY type, as allowed by the programming language.

Example input and output (inputting array, outputting array of arrays).
Inputs:

[1, 2, 3]

and outputs:

[
    [1, 2, 3],
    [1, 3, 2],
    [2, 1, 3],
    [2, 3, 1],
    [3, 1, 2],
    [3, 2, 1]
]

Code-Golf: Permutations reposts not allowed!

\$\endgroup\$
  • \$\begingroup\$ I don't see how the type of items changes anything. Permuting elements of an array doesn't depend on the type of items it contains \$\endgroup\$ – Fatalize Sep 13 '15 at 18:06
  • \$\begingroup\$ @Fatalize But... That's inactive now. \$\endgroup\$ – wizzwizz4 Sep 13 '15 at 18:07
  • \$\begingroup\$ ...what? I don't understand. \$\endgroup\$ – Fatalize Sep 13 '15 at 18:08
  • \$\begingroup\$ Every answer to that can apply here \$\endgroup\$ – Blue Sep 13 '15 at 18:09
  • \$\begingroup\$ @muddyfish Yes, you're right. But it is an interesting codegolf. \$\endgroup\$ – wizzwizz4 Sep 13 '15 at 18:13
5
\$\begingroup\$

Pyth, 3 bytes

.pQ

:D

Live demo.

\$\endgroup\$
  • \$\begingroup\$ +1 Yup! It works. And it's not a repost. \$\endgroup\$ – wizzwizz4 Sep 13 '15 at 18:12
  • \$\begingroup\$ This might have to be closed. If it is, I recommend you move your answer to the question above. \$\endgroup\$ – wizzwizz4 Sep 13 '15 at 18:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.