Rule system

Chapter 73: The Key to Algorithm Design

To design an algorithm to crack the third-order Rubik's Cube, the first thing to be clear is two points.

One is input data.

The input data is the nine grid colors corresponding to the six faces of the three-dimensional Rubik's cube. The feature of the data is that there are six colors, and the total number of each color is nine. In addition, the color corresponding to the middle of the six faces is fixed. .

The second is to output data, which is the purpose of calculation, to get the minimum steps required to solve the Rubik's Cube.

As long as this condition can be achieved, other desired data, such as the process of achieving the lowest steps, are just simple records made by the way during the operation of the program.

After clarifying the input and output data, the front and rear frames are almost out.

This is similar to the algorithm package sent by Zhang Zhen, except that the difficulty level has been increased by tens, hundreds of times, or even higher.

Next, the design begins.

Modeling.

Modeling is to turn a real problem into a mathematical problem, using mathematical formulas and codes to express the relationship between the cubes of the Rubik's cube and the possible conversion methods.

There are two ways to do this.

One takes the space position as the base point, that is, when the position is fixed, the color will change; the other takes the fixed color grid as the base point to form a position change.

After choosing the modeling method, we enter the real design process.

Zhao Yi had just begun to think, when he ran into a huge problem: how to determine a kind of twisting, is to let the magic direction approach the restoration process, instead of making it more chaotic?

This is a super problem.

Solving this problem is almost equivalent to completing the algorithm.

Therefore, this road is nowhere.

Think again.

Then consider it from another angle, you can find the face with the most of the same color, and use it as the base point to realize the restoration. Just like most people's choice, first restore one face of the third-order Rubik's Cube, and the others become much easier.

However, science is rigorous.

How to prove that starting from the face with the most of the same color, the restoration speed is the fastest?

How to prove that it is the fastest to restore one face first?

When Zhao Yi just started to design the program, he encountered a lot of problems. He took a deep breath, and his logical thinking ended.

Next is time for causal thinking.

Zhao Yi understood the difficulty of algorithm design. He opened the system interface and simply used a research coin.

Scientific Research Coin: 15.

[Use research coins to enhance causal thinking.

Scientific research coin-1, assist in improving causal thinking ability and obtain inspirational effects.Duration: Sixty minutes.

moment.

The mode of thinking has changed.

Zhao Yi stared at the computer screen again, and his thinking jumped. Instead of entangled in the puzzle he thought of, he jumped to the data analysis input to the Rubik's Cube.

For example, taking the center color of each face as the reference, small grids of the same color on other faces are converted to the corresponding center face, the minimum number of steps required.

For example, how many grids are next to grids of the same color, as well as their specific positions, must be recorded in detail.

and many more.

After consuming scientific research coins to improve the causal thinking mode, the use of "Causal Law" and "Law of Connection" became subconscious things. He kept thinking, tapping his fingers constantly, putting the content he thought out on Convert to code on the keyboard.

write.

Write again.

One hour passed.

Zhao Yi pressed his forehead hard and found that his brain was abnormally tired. He glanced at the energy value: [Energy: 65104.

No wonder!

Looking at the code on the screen, he gritted his teeth and used four learning coins.

[Consumption of learning coins to increase energy!

Energy +40.

Although it is not difficult to earn learning coins, more than 20 are credited every day, but I am still not used to supplementing energy.

Energy, can sleep supplement!

Using learning coins to replenish energy is like playing games to recharge and buy experience. It is a bit too extravagant.

carry on!

Scientific Research Coin: 14.

[Use research coins to enhance causal thinking.

Scientific research coin-1, assist in improving causal thinking ability and obtain inspirational effects.Duration: Sixty minutes.

After working for more than half an hour, Zhao Yi compiled 21 data analysis of the input Rubik's Cube. After his fingers stopped, he subconsciously used the "Law of Causality" to measure whether the data was effective for solving the Rubik's Cube.

Using this method, three irrelevant analysis data have been eliminated, and the remaining eighteen kinds of analysis are all helpful to restore the Rubik's Cube.

Next, continue to make judgments.

Whether a twist can help restore the Rubik's Cube can be obtained by using the Law of Causality.

Find out several or more than a dozen twisting methods that help the Rubik's Cube restore, put them together and compare them with the analyzed data.

These are the conditions.

When all the conditions are completed, the "Law of Liaison" can be used to prove the reasons for the conclusions drawn.

This is the causal way of thinking.

Find the result first, perfect the conditions, and the last step is the seeking process. After the process is in place, you can write code to express it.

Zhao Yi is still in trouble.

Time, energy.

He has found the key to the algorithm design, but roughly estimated that the code needs to be written at least a few thousand lines. With his work efficiency, it will take at least ten hours.

"Forget it, go to bed first!"

"Continue tomorrow!"

...

Zhao Yi got up early the next day, turned on the computer and read the post on the forum.

The post is extremely hot!

There were more than 4,000 replies from the bottom alone.

Because it involves hot search gossip, there are good multimedia on the Internet, and all the news is released to reprint the content of the post.

On the index list of search websites, a related hot search was added, named'Genius hacker column data reply Jia Hongning', and the popularity jumped to third place.

This is related to the content of the post.

For some controversial gossip incidents, most of the parties involved are interviewed and express their opinions and opinions. Even if they post a reply, they will at most reveal some news and win sympathy.

Zhao Yi's post is surprising. His method of directly listing data has greatly improved the style of gossip.

In addition, the controversy is also the cause of hotness.

The data listed on the post caused controversy in blockbuster movies. A well-known PhD in mathematics expressed his opinion, “The optimal steps to crack a third-order Rubik’s cube are unimaginable, and ordinary home computers are definitely incalculable.”

He also said, "There is no effective optimization algorithm for the time being."

Simultaneously.

There are also many voices in support of Zhao Yi on the Internet, who believe that he cannot utter the data indiscriminately, and other professionals say that rough calculations cannot get specific data, but they can judge that Jia Hongning’s Rubik’s Cube is simpler than Zhou Junkai’s. Some, especially in the last competition, the gap is very obvious.

Zhao Yi felt it was time to stand up.

Although there are some voices in support of him, it may be disadvantageous to continue, and it is indeed necessary to do something to guide public opinion.

It's time for school.

He decided to go to school with his Netbook, and then post at school.

The atmosphere of the school is similar.

Because the incident involves the students of the school, there are large-scale discussions in the school, and almost everyone knows the post. Many people hope to ask Zhao Yi how to calculate the result.

"Wait, I will write it out."

Zhao Yi went to Sun Laoban to talk about it. He planned to use the self-study class to edit a post and post it on the Internet for explanation. Unexpectedly, President Wang Chengmin came to him directly.

"Zhao Yi!"

Wang Chengmin cared, "I think the Internet is talking about you, the data of your post..."

A group of people brought their ears together.

Zhao Yi looked at He Ronghua a little depressed, "Lend me the Rubik's Cube."

"it is good."

He Ronghua immediately sent the Rubik's Cube.

Zhao Yi looked at the Rubik's Cube in his hand and moved his fingers quickly, completing the restoration in about ten seconds.

Many people were stunned.

Zhao Yi turned his head and said to the surroundings, "Help count, count once every 90 degrees, and count twice as 180 degrees."

"it is good!"

A group of people looked at it seriously.

Zhao Yi deliberately slowed down the speed to make it easier for other people to count. For almost a minute, he turned the cube seventeen times and said, "This is the cube before Jia Hongning's first attempt in the game. It took me 17 steps to change it, and I can change it back 17 times."

"Hiss~~~"

Let alone other students, even Wang Chengmin took a breath of air.

He immediately took Zhao Yi to the principal’s office, "Come on! Come! I'll make a video for you and post it online to see who will doubt it."

Zhao Yi smiled and followed.

He originally wanted to post a post to describe the way to turn the Rubik's Cube, but it was really troublesome to describe in words, and it was relatively simple to shoot a video.