mfgnik

Untitled

May 26th, 2020
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. amount_numbers, exchanges = map(int, input().split())
  2. current = amount_numbers
  3. numbers = []
  4. while exchanges >= current - 1 and exchanges:
  5.     numbers.append(current)
  6.     exchanges -= current - 1
  7.     current -= 1
  8. to_extend = list(range(1, current + 1))
  9. numbers.extend(to_extend[:-exchanges - 1])
  10. numbers.append(to_extend[-1])
  11. numbers.extend(to_extend[-exchanges - 1:-1])
  12. print(*numbers)
Advertisement
Add Comment
Please, Sign In to add comment