def _rotate ( n , x , y , rx , ry ) : if ry == 0 : if rx == 1 : x = n - 1 - x y = n - 1 - y return y , x return x , y
rot13 algorithim in python 3
Rotate and flip a quadrant appropriately
def _rotate(n, x, y, rx, ry):
    """Rotate and flip a quadrant appropriately

    Based on the implementation here:
        https://en.wikipedia.org/w/index.php?title=Hilbert_curve&oldid=797332503

    """
    if ry == 0:
        if rx == 1:
            x = n - 1 - x
            y = n - 1 - y
        return y, x
    return x, y