Skip to content

Instantly share code, notes, and snippets.

Last active July 1, 2021 14:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Соединить числа в одно максимально возможное
# from functools import total_ordering
# @total_ordering
class Int(int):
def __lt__(self, other):
this, that = str(self), str(other)
YES, NO = True, False
if len(this) < len(that): # everything is vice versa
this, that = that, this
# compare EVERY digit of the longer value to the 1st digit of the other
for i in this:
if i < that[0]:
return YES
return NO
l = [10, 7, 76, 415]
x = ''.join(str(j) for j in sorted((Int(i) for i in l), reverse=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment