Implementation of dynamic programming for chaos control in discrete systems