Dynamic distributed programming and applications to swap edge problem