A more elegant and concise solution for the permute test