Advertisement
simeonshopov

Chairs

Jun 3rd, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #!usr/local/bin/python3.8
  2. # -*- coding: utf-8 -*import
  3.  
  4. names_input = input().split(', ')
  5. chairs_count = int(input())
  6.  
  7.  
  8. def combinations(names, chairs, comb=[]):
  9.     if len(comb) == chairs:
  10.         print(', '.join(comb))
  11.         return
  12.     for i in range(len(names)):
  13.         x = names[i]
  14.         comb.append(x)
  15.         combinations(names[i + 1:], chairs, comb)
  16.         comb.pop()
  17.  
  18.  
  19. combinations(names_input, chairs_count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement