Hanoi towers game histoty8/12/2023 ![]() Only defines the function for arguments where the Char in the first Pin of the Plate is 'o', you also need to provide equations for when the character is something else. ![]() Hanoi 1 log = transformaLista(moveLOD log) swapoLID : Change the positions of the intermediate rods and destination rods. ![]() swapLOI: Change the positions of the origin rods and intermediate rods. Type Log = (Plate, ) - Represents a state formed by the configuration of rods and a list of strings that will record the movements made by the algorithm. Type Plate = (Pin, Pin, Pin) - Represents the configuration of the three rods.(Origin,Intermediate,Destination type Pin = (Char, Int) - Represents a rod, named for a character and the number of disks in it. Additionally a string with information about the movement is piling on list of strings. MoveLOD: moves 1 disc from the first position to third the pin in the third position of the triplet. The code below solves hanoi returning a list of moves using predefined functions moveLOD,swapLOI and swapLID.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |