Advertisement
SY573M_404

B

Jun 3rd, 2023
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. import itertools
  2.  
  3. def main():
  4.     in_file = open("perm.in", "r")
  5.     n = int(in_file.readline())
  6.     in_file.close()
  7.  
  8.     out_file = open("perm.out", "w")
  9.     out_file.writelines(
  10.         map(
  11.             lambda permutation: " ".join(map(str, permutation)) + "\n",
  12.             itertools.permutations(range(1, n + 1), n),
  13.         ),
  14.     )
  15.     out_file.close()
  16.  
  17. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement