Algorithmic reconstruction of discrete dynamics