1# Towers of Hanoi 2 3## Clingo standard implementation 4 5Known ASP encodings set a bound to the number of moves that can be 6done, proposed in 7([Gebser et al. 2008](https://www.cs.utexas.edu/users/vl/teaching/lbai/clingo_guide.pdf)) 8 for 7 disks and up to 126 movements. 9 10``` 11clingo toh_standard_7.pl 12clingo toh_standard_8.pl 13clingo toh_standard_9.pl 14``` 15 16## Clingo incremental implementation 17 18ASP encoding by incrementing the number n of allowed movements (from 19the [clingo 5.2.0](https://github.com/potassco/clingo) distribution) and proposerd in ([Gebser et al. 2014](https://arxiv.org/pdf/1405.3694.pdf)) 20 21``` 22clingo toh_incremental_7.pl 23clingo toh_incremental_8.pl 24clingo toh_incremental_9.pl 25``` 26 27## s(CASP) implementation 28 29s(CASP)’s top down approach can use a CLP-like control strategy to 30implement the wellknown Towers of Hanoi algorithm. Predicate 31hanoi(N,T) receives in N the number of disks and returns in T the 32number of movements and a partial stable model which contains all the 33movements and the time in which they have to be performed. 34``` 35scasp hanoi_scasp_7.pl 36scasp hanoi_scasp_8.pl 37scasp hanoi_scasp_9.pl 38``` 39