Created
September 4, 2017 07:31
-
-
Save ksdme/7f9a5385bb0c2aeff3f8787dc558e911 to your computer and use it in GitHub Desktop.
A compact one line implementation of merge sort!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def merge_em(slice): | |
return slice if len(slice) == 1 else (lambda first, secon, buffed: (buffed + secon) if map(lambda _: ([buffed.append(secon.pop(_[0])) if two < _[1] else None for two in secon], buffed.append(_[1])), enumerate(first)) or True else None)(*(map(merge_em, (slice[:int(len(slice)/2)], slice[int(len(slice)/2):])) + [[]])) | |
print merge_em(map(int, raw_input("Enter Subjects: ").strip().split())), raw_input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment