Queen Flower
Chapter 66: Tower of Hanoi
Jiang Lan sighed, seeking wealth and wealth in danger, people die for wealth and birds die for food. She glanced at Xiao Yan next to her, feeling a little uncomfortable. Seeing her look over with sad eyes, Xiao Yan stroked her braid lightly, took her in his arms and soothed her softly, "Don't worry, there is always a way."
Jiang Lan looked at his handsome face as before, and his face was full of tenderness. When he first met in Ningcheng that year, he saw him cold-blooded, blinding other people's eyes, breaking other people's pipa bones, and the memories were dripping with blood. , the image left to her is just the face that looks like a certain star, but now, she actually doesn't remember the actor's face, only this handsome, angular face is left. Always exuding a noble temperament. He is obviously a hero of integrity and justice, but he is always beside her as a rogue and a rogue, exhausting his tenderness.
Jiang Lan also turned around and hugged him, burying his head in his arms, maybe we were about to part, but you must live.
The two are comforting each other, and the crowd here is not calm. Everyone looked at the closed stone gate with different expressions. Some people faintly regretted not quitting at the last moment. Some people looked grim and wanted to provoke everywhere. Commander Wang shouted angrily: "Who kicked the door just now, stand up for me." The crowd split to two sides, and a trembling man stood in the middle. Everyone looked at him like a knife, and it was gouging out at him. Commander Wang walked up to him, without saying a word, he stretched out his hand and broke his neck, he threw the corpse on the ground, swept the crowd with ruthless eyes, "Whoever dares to make his own decisions, this is the end. He glanced at Jiang Xiao and the two who were embracing each other from a distance, and said, "From now on, everyone must unite, and no one should have two hearts. If they can't get out of this underground palace, no one will want to see the sun tomorrow." "
A group of people cheered up and moved forward again, this time not only for the treasure, but also for their own lives.
Although it was underground, an oil lamp would be lit on the wall at intervals. Jiang Lan searched everywhere. There must be air holes leading to the ground, otherwise there would be no oxygen, not to mention that the lights would not turn on, and they would have died early. The reason why Jiang Lan dared to go inside was because the oil lamp that was burning at the beginning made her conclude that there would be no oxygen shortage in the underground palace. I just don't know where this passage is and whether they can be allowed to pass smoothly. I think the people who designed this underground palace are not only good at mathematics, but also strong in mechanical mechanisms.
The crowd suddenly stopped and shouted in disappointment. Jiang Lan looked ahead across the crowd, and saw a huge dark pool in front of him. On the other side of the pool was a stone wall. From a distance, there was no exit. has reached the end of the road. How is this possible?
She looked at the black pool, but saw a round stone tray in the middle of the black pool, standing on a pillar on the water surface, the tray was still some distance from the water surface, like a solitary flower in the pond. lotus. On this tray, there are three columns erected around the center of the tray, distributed in the shape of a zigzag. There are seven stone rings of different sizes on one of the columns, which are stacked together in order from large to small, and the largest is at the bottom.
Jiang Lan laughed in his heart, Xiaoxi, an uncreative guy, was a computer once and a computer all his life, and he couldn't live without the computer. I don't know if this is a dungeon that the world has built for her, and who else can solve it in this world except her.
This is the Tower of Hanoi, the most classic recursive algorithm proposition in computer programs. This question comes from an ancient Indian legend: in a holy temple there were three gemstone needles inserted into a brass plate, and when Brahma, the main **** of Hinduism, was creating the world, he put on one of the needles from the bottom to the top. 64 pieces of gold from big to small, this is the so-called Tower of Hanoi. Ask a monk to move these pieces of gold according to the following rule: move only one piece at a time, no matter which needle is on, the small piece must be on top of the larger piece. The monks prophesied that when all the gold pieces were moved from the pin Brahma wore to the other pin, the world would be destroyed in a thunderclap, and the Brahma pagoda, temples, and sentient beings would also perish.
Thank goodness there are no 64 stone rings here, otherwise the earth would perish and it wouldn't be able to finish moving. Assuming that there are n stone rings that need to be moved, the steps required to finally complete the move are at least 2 to the nth power minus one, that is, f(n)=2^n-1, which is a proven result. There are now seven rings, that is, at least 2^7-1=127 transfers are required.
Jiang Lan has a big head. This is not only physical work, but because there is no computer help, it needs to be carried by hand. When carrying it, it will make you dizzy and make mistakes. When she first played this game, although she knew the principle, she always made mistakes. Basically, when she reached 6 or more, she was dazzled.
Everyone looked at the tray suspiciously, and then looked back at Jiang Lan. Although everyone doesn't admit it on the surface, they all agree in their hearts that this southern barbarian woman with the same face as the bottom of the pot is still a bit virtuous. No wonder Xiao Yan, who is the first master of the dignified dynasty and a talented person, doesn't look down on Wei Shuying, and only likes her. .
"What do you think?" Xiao Yan asked her softly beside her.
"This is also a lock. All the stone rings on a pillar need to be transported to the pillar in the keyhole. Only one ring can be moved at a time, and the big ring must always be under the small ring." Jiang Lan said It was so loud that everyone heard it.
The question didn't seem difficult. Everyone breathed a sigh of relief and walked towards the pool. Under the instructions of Wei Huaisong and Commander Wang, three people flew and swept onto the tray. Two people landed on the tray without any reaction. Then, the tray suddenly vibrated, and then the stone surface between the two pillars suddenly cracked and closed down, like a reverse flower bone, leaving only three pillars and the beam connecting the center at the bottom of the pillars, like a triangle harpoon. In the end, the man didn't notice for a while, and fell straight into the water. Everyone only heard a scream, and then the pool water "Zzizi" with red bubbles, the body quickly separated from the flesh and blood, and disappeared soon.
Everyone was stunned. The two people who were still on the tray were very responsive. When they realized something was wrong, they grabbed the stone pillar to avoid falling into the water. At this time, the falling stone surface slowly retracted, and slowly returned to its original appearance. It seems that this tray can only bear the weight of two people. Everyone broke out in a cold sweat. They didn't expect the tray to have this mechanism, and what was even more unexpected was that the pool was so terrifying that it never came back.
The two people on the tray were trembling and terrifying. They didn't have the energy to move the stone ring at all. The two looked at each other and were afraid of making a move. Everyone held their breath and was very quiet for a while. At this moment, there was a sound of sand and sand. Everyone looked up and looked for it. Only then did they find that there was an hourglass hanging on the top of the tray. The sand was flowing thinly. It will be over soon.
Nima, there is still a time limit. Jiang Lan was shocked, and before he had time to remind him, he heard the sound of "kaka" stones moving and two sounds of falling into the water. The tray became a reverse flower again, and the two of them lost their lives.
Everyone was silent, their hearts were cold, and they hid to the side without making a sound, and no one dared to go up. For a time, everyone's eyes were fixed on Jiang Lan and Xiao Yan, only these two people were their hope.
Jiang Lan thought for a while, she didn't go out immediately, and she was not sure that she would be able to complete the task on time. With so many stone rings, it was easy to make mistakes when nervous. This mistake is not a mistake, it will cost Qingqing's life. In any case, it must be confirmed that it is the least step, and one step does not go wrong.
After making up her mind, Jiang Lan ignored everyone. She took out the treasure map, took out the eyebrow pencil and started to deduce it. The human brain is not a computer, and it is very prone to errors. The best way is to write down every step, and then put it on the tray and move it directly. It would be great if there was a computer, write a program to list the process, Jiang Lan thought sadly.
The solution to the Tower of Hanoi is not difficult, it is a recursive process. In fact, it is still very clear that the number is small. For the actual operation, the processing method of the ring number is different when it is odd and even.
Suppose the three bars are the start bar, the middle bar and the target bar.
When n=1, it is one step, starting bar - target bar
When n=2, the first step is the starting column - the middle column, so that the smallest ring reaches the middle column.
The second step is the starting column - the target column, so that the largest ring reaches the target column.
The third step is the middle column - the target column, so that the smallest ring also reaches the target column.
When n=3, the first step is the starting column - the target column, so that the smallest ring reaches the target column.
The second step is the starting column - the middle column, so that the second ring reaches the middle column.
The third step is the target column - the middle column, so that the smallest ring reaches the middle column.
The fourth step is the starting column - the target column, so that the largest ring reaches the target column.
The next step is to recurse n=3, but the start, middle and target have to be repositioned.
The most important point in the actual handling operation is that when the number of loops is odd, the first step is to start to the target, and when the number of loops is even, it is to start to the middle.
Jiang Lan sorted out his thoughts, marked the pillars with numbers 1, 2, and 3, and drew a picture on the ground. Then he began to write the steps, and he drew as he wrote. When he wrote, he was wrong. Then he started over. Jiang Lan really felt that he My brain is tying a knot, 127 steps, why can't there be a little less ring.
Everyone was eager to see her writing and drawing, but they didn't dare to bother, they all waited for her result. I don't know how long it took, Jiang Lan's deduction was over, and there was no error after careful inspection.
Although the steps are correct, I don't know if the time is too late.
She raised her head and looked at Xiao Yan, "Now you are going to take risks with me, do you dare?"
Xiao Yan pulled up her body and smiled proudly, "It's a big deal, let's be a mandarin duck with the same fate, and we'll take a mandarin duck bath in the pool."
Jiang Lan also laughed, and suddenly his courage multiplied, he has already arrived here, even if there is no treasure, even if there is no golden branch, he will be able to go out smoothly.
You'll Also Like
-
Douluo: Evolve into Dragon God from Luo Sanpao!
Chapter 232 3 hours ago -
Konoha: This Uchiha just wants to lie down
Chapter 700 3 hours ago -
Elf, who made him the gym leader?
Chapter 377 3 hours ago -
In Konoha, Ashura Chakra is dropped at the beginning
Chapter 147 3 hours ago -
Gu Immortal: Start with a Thought Gu
Chapter 69 5 hours ago -
My technique advances once a day
Chapter 97 5 hours ago -
When I saw the health bar, I chose to blow up the world
Chapter 158 5 hours ago -
Disciple, you are too evil.
Chapter 118 5 hours ago -
Game of Thrones: I'm flying a dragon on your face, how do you respond?
Chapter 117 5 hours ago -
Villain: Starts from witnessing the evil experiments of the family
Chapter 581 12 hours ago