Remuda Triangle

What's the Algorithm?