P を与えた際に,P の並び替えのうち,辞書順で P の次に大きいものに変更して True を返します..存在しない場合,False を返します.破壊的変更を行います.
P を与えた際に,P の並び替えのうち,辞書順で P の次に小さいものに変更して True を返します..存在しない場合,False を返します.破壊的変更を行います.
for Q in all_permutations(P)
とすると,P の並び替えのうち,P + P 寄りも辞書順で後ろのものを全て列挙します.Q に変更を加えると P 側にも変更が加わるので注意してください.回る順番は辞書順です.