Natural systems are a source of inspiration for computer algorithms designed to solve optimisation problems. Yet most 'natureinspired' algorithms take only superficial inspiration from biology, and little is known about how real biological systems solve difficult problems. Moreover, ant algorithms, neural networks and similar methods are usually applied to static problems, whereas most biological systems have evolved to perform under dynamically changing conditions. We used the Towers of Hanoi puzzle to test whether Argentine ants can solve a potentially difficult optimisation problem. We also tested whether the ants can adapt to dynamic changes in the problem. We mapped all possible solutions to the Towers of Hanoi on a single graph and converted this into a maze for the ants to solve. We show that the ants are capable of solving the Towers of Hanoi, and are able to adapt when sections of the maze are blocked off and new sections installed. The presence of exploration pheromone increased the efficiency of the resulting network and increased the ants' ability to adapt to changing conditions. Contrary to previous studies, our study shows that mass-recruiting ant species such as the Argentine ant can forage effectively in a dynamic environment. Our results also suggest that novel optimisation algorithms can benefit from stronger biological mimicry.