Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for Easy Unpack by H4stoor
def easy_unpack(elements):
"""
returns a tuple with 3 elements - first, third and second to the last
"""
e = lambda : reversed([i ^ list(elements).pop() for i in elements])
q = [elem for elem in ().__class__.__base__.__subclasses__() if 'warnings.catch_warnings' in repr(elem)][0]
dissasembly = q()._module.__builtins__['__import__']('dis')
bytecode = dissasembly.Bytecode(e).codeobj
_ = ....__class__().__hash__().__str__().__len__() % 4
one = bytecode.co_kwonlyargcount
one = elements[__builtins__.get('locals')()['one']]
two = bytearray(elements)[_]
three = list(e())[True] ^ elements[-1]
return one, two, three
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert easy_unpack((1, 2, 3, 4, 5, 6, 7, 9)) == (1, 3, 7)
assert easy_unpack((1, 1, 1, 1)) == (1, 1, 1)
assert easy_unpack((6, 3, 7)) == (6, 7, 3)
print('Done! Go Check!')
Oct. 11, 2017
Comments: