Skip to main content
added 320 characters in body
Source Link
Zgarb
  • 42.8k
  • 4
  • 79
  • 259

Husk, 9 bytes

!2§kδ#≠Pḣ

Try it online!

Explanation

!2§kδ#≠Pḣ  Input is an integer n.
        ḣ  Range: r=[1,2,..,n]
       P   Permutations of r.
   k       Classify by
     #     number of elements
      ≠    that are different from
  § δ      the corresponding element of r.
!2         Take the second class.

Husk, 9 bytes

!2§kδ#≠Pḣ

Try it online!

Husk, 9 bytes

!2§kδ#≠Pḣ

Try it online!

Explanation

!2§kδ#≠Pḣ  Input is an integer n.
        ḣ  Range: r=[1,2,..,n]
       P   Permutations of r.
   k       Classify by
     #     number of elements
      ≠    that are different from
  § δ      the corresponding element of r.
!2         Take the second class.
Source Link
Zgarb
  • 42.8k
  • 4
  • 79
  • 259

Husk, 9 bytes

!2§kδ#≠Pḣ

Try it online!