Update heurisch.py

Optimized the number of permutations of mapping by not generating cases of the form mapping[-1]!=x