update gray code and rotate_list