Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- kit = list(str(input('Набор чисел: ')))
- len_pal = int(input('Длина будущего паллиндрома: '))
- double, max_one = [], []
- for item in set(kit):
- if kit.count(item) % 2 == 1:
- max_one.extend(item)
- double.extend([item]*((kit.count(item)-1)//2))
- else:
- double.extend([item]*(kit.count(item)//2))
- while len(double)*2 > len_pal-1:
- double.remove(min(double))
- print(f"{''.join(sorted(double, reverse=True))}{max(max_one)}{''.join(sorted(double))}")
Add Comment
Please, Sign In to add comment