-
-
Save icio/6191f2ce019c9c795a30 to your computer and use it in GitHub Desktop.
This file contains 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 a_by_b(a, b): | |
b = {c:p for p, c in enumerate(reversed(b+a))} | |
return "".join(sorted(a, lambda l, r: b[r] - b[l])) | |
a = "adlkfhxaxjxkxhxfwkhkjfhjkahjksedeheflhadslfkhdfjkadhjhdhskghdjdjkhskkhjokhkshakhlhfkjdshjfkshhkskskss" | |
b = "alskdjfhg" | |
assert a_by_b(a, b) == "aaaaaallllssssssssssskkkkkkkkkkkkkkkkkkkkdddddddddjjjjjjjjjjjffffffffhhhhhhhhhhhhhhhhhhhhhgxxxxxweeeo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment