Skip to content

Instantly share code, notes, and snippets.

@ashleighbasil
Created March 22, 2021 06:38
Show Gist options
  • Save ashleighbasil/0a72f6f4ec15da12e00c4d8fe6478b32 to your computer and use it in GitHub Desktop.
Save ashleighbasil/0a72f6f4ec15da12e00c4d8fe6478b32 to your computer and use it in GitHub Desktop.
Cassido broken solution!
def digits_list_to_int(digits):
return int("".join([str(i) for i in digits]))
def max_num(n, m, k):
return digits_list_to_int(
sorted(n + m)[::-1][:k]
)
def max_num_uniq(n, m, k):
return digits_list_to_int(
sorted(set(n + m))[::-1][:k]
)
n = [3,4,6,5]
m = [9,0,2,5,8,3]
k = 5
print(max_num(n, m, k)) # 98655
print(max_num_uniq(n, m, k)) # 98654
# The right answer should be 98653??
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment