Update heurisch.py

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