fork(1) download
  1. # https://m...content-available-to-author-only...e.com/questions/3093225/an-efficient-approach-to-combinations-of-pairs-in-groups-without-repetitions
  2. def compute_groupings(n:int):
  3. for i in range(n-1):
  4. print(f'day_{i}: ({n-1},{i})',end='')
  5. for k in range(1, n//2):
  6. print(f', ({(i+k)%(n-1)},{(i-k)%(n-1)})',end='')
  7. print('')
  8.  
  9.  
  10. compute_groupings(8)
Success #stdin #stdout 0.02s 9148KB
stdin
Standard input is empty
stdout
day_0: (7,0), (1,6), (2,5), (3,4)
day_1: (7,1), (2,0), (3,6), (4,5)
day_2: (7,2), (3,1), (4,0), (5,6)
day_3: (7,3), (4,2), (5,1), (6,0)
day_4: (7,4), (5,3), (6,2), (0,1)
day_5: (7,5), (6,4), (0,3), (1,2)
day_6: (7,6), (0,5), (1,4), (2,3)