swap ' _ ' with the character on it 's right this time
if pp < n - 1 : NEW_LINE INDENT ss = list ( ss ) NEW_LINE ss [ pp ] , ss [ pp + 1 ] = ss [ pp + 1 ] , ss [ pp ] NEW_LINE ss = ' ' . join ( ss ) NEW_LINE if ss not in vis : NEW_LINE INDENT if ss == f : NEW_LINE INDENT return dist + 1 NEW_LINE DEDENT vis [ ss ] = dist + 1 NEW_LINE q . append ( ( ss , pp + 1 ) ) NEW_LINE DEDENT ss = list ( ss ) NEW_LINE ss [ pp ] , ss [ pp + 1 ] = ss [ pp + 1 ] , ss [ pp ] NEW_LINE ss = ' ' . join ( ss ) NEW_LINE DEDENT