def count_swaps(source, target):
lookup = {val: idx for idx, val in enumerate(target)}
source = [lookup[v] for v in source]
print(lookup)
print(source)
swaps = 0
for i in range(len(source)):
while source[i] != i:
swap_idx = source[i]
print(swap_idx)
source[i], source[swap_idx] = source[swap_idx], source[i]
swaps += 1
print(source)
return swaps
print(count_swaps([1,2,3], [3,1,2]))
ZGVmIGNvdW50X3N3YXBzKHNvdXJjZSwgdGFyZ2V0KToKICAgIGxvb2t1cCA9IHt2YWw6IGlkeCBmb3IgaWR4LCB2YWwgaW4gZW51bWVyYXRlKHRhcmdldCl9CiAgICBzb3VyY2UgPSBbbG9va3VwW3ZdIGZvciB2IGluIHNvdXJjZV0KICAgIHByaW50KGxvb2t1cCkKICAgIHByaW50KHNvdXJjZSkKICAgIHN3YXBzID0gMAogICAgZm9yIGkgaW4gcmFuZ2UobGVuKHNvdXJjZSkpOgogICAgICAgIHdoaWxlIHNvdXJjZVtpXSAhPSBpOgogICAgICAgICAgICBzd2FwX2lkeCA9IHNvdXJjZVtpXQogICAgICAgICAgICBwcmludChzd2FwX2lkeCkKICAgICAgICAgICAgc291cmNlW2ldLCBzb3VyY2Vbc3dhcF9pZHhdID0gc291cmNlW3N3YXBfaWR4XSwgc291cmNlW2ldCiAgICAgICAgICAgIHN3YXBzICs9IDEKICAgICAgICAgICAgcHJpbnQoc291cmNlKQogICAgcmV0dXJuIHN3YXBzCgpwcmludChjb3VudF9zd2FwcyhbMSwyLDNdLCBbMywxLDJdKSk=