Chapter Seventy-Three: The Key to Algorithm Design

To design an algorithm to crack the third-order Rubik's Cube, two things must first be clarified.

One is the input data.

The input data is the six sides of the three-dimensional Rubik's cube, the corresponding nine grid colors, the characteristics of the data are, there are six colors, each color is a total of nine, in addition, the color corresponding to the middle of the six faces is fixed.

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

As long as this condition can be achieved, other desired data, such as the process of achieving the minimum steps, is only a simple record made in the process of program operation.

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

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

Next, the design begins.

Modeling.

Modeling is to turn real problems into mathematical problems, and use mathematical formulas and codes to express the relationship between the small grids of the Rubik's cube and the possible ways to transform them.

There are two ways to do this.

One is based on the spatial position, that is, the color will change when the position is fixed, and the other is based on the small grid of fixed color to form a position change.

Once you've chosen how you want to model, it's time to get into the real design process.

Zhao Yi had just entered into thinking when he encountered a huge problem: how to determine a kind of twisting is to make the demon move closer to the direction of restoration, rather than making it more chaotic?

It's a super puzzle.

Solving this puzzle is almost equivalent to completing the algorithm.

So, this road is not going to work.

Think again.

So think about it from another angle, you can find the face with the most colors of the same color, and use this as the basis to achieve restoration, just like most people's choice, restore one side of the third-order Rubik's Cube first, and the others will become much easier.

However, the science is rigorous.

How do you prove that starting with the face with the most colors of the same color, the restoration is the fastest?

How do you prove that restoring a polygon first is the fastest?

Zhao Yi had just started designing the program, and he encountered a lot of problems, he took a deep breath, and his logical thinking ended here.

Next is causal thinking time.

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

[Research Coins: 15.] 】

[Use Research Coins to improve causal thinking.] 】

[Scientific Research Coin -1, assist in improving the ability of causal thinking, and obtain the effect of inspiration. Duration: sixty minutes. 】

Moment.

The mindset has changed.

Zhao Yi stared at the computer screen again, and his thinking jumped, he didn't dwell on the problem he thought of, but jumped to the data analysis of the Rubik's Cube.

For example, based on the center color of each face, the minimum number of steps required to convert a small grid of the same color on the other faces to the corresponding center face.

For example, how many squares are next to each other of the same color, as well as the exact orientation in which they are located, should be recorded in detail.

Wait a minute.

After the consumption of scientific research coins improved the causal thinking mode, the use of "The Law of Cause and Effect" and "The Law of Contact" became a subconscious thing, and he kept thinking, his fingers kept tapping, and he put the content he thought out on the keyboard and converted it into code.

Compose.

Rewrite.

An hour passed.

Zhao Yi pressed his forehead hard, his brain felt abnormally tired, and he glanced at the energy value: [Energy: 61/104. 】

No wonder!

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

[Consume Learning Coins to Boost Your Energy!]

[Energy +40.] 】

Although it is not difficult to earn learning coins, and more than 20 are credited to the account every day, I am still not used to using them to replenish my energy.

Energy, can sleep to replenish!

Using learning coins to replenish energy is like playing a game to buy experience, which is a bit too extravagant.

Go on!

[Research Coins: 14.] 】

[Use Research Coins to improve causal thinking.] 】

[Scientific Research Coin -1, assist in improving the ability of causal thinking, and obtain the effect of inspiration. Duration: sixty minutes. 】

After continuing to work for more than half an hour, Zhao Yi compiled 21 data analysis of the input Rubik's Cube, and after his fingers stopped, he subconsciously used the "Law of Cause and Effect" to measure whether the data was effective in restoring the Rubik's Cube.

Using this method, three irrelevant analysis data were excluded, and the remaining eighteen analyses were all helpful for restoring the Rubik's Cube.

Next, move on to the judgment.

Whether a twist helps to restore the Rubik's Cube can be determined using the Law of Cause and Effect.

Find a few or a dozen twisting methods that can help the cube and compare them with the data being analyzed.

These are the conditions.

When all the conditions have been perfected, the Law of Liaison can be used to prove the process by which the conclusions reached are produced.

This is the causal way of thinking.

The first step is to find the result, improve the conditions, and the last step is to seek the process, and after the process, you can write code to express it.

Zhao Yi still ran into trouble.

Time, energy.

He had already found the key to the design of the algorithm, but a rough estimate showed that the code would take at least a few thousand lines to write, and at least ten hours or more with his work efficiency.

"Forget it, go to bed first!"

"Tomorrow!"

......

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

The post is extremely hot!

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

Because of the gossip involved in hot searches, there are good multimedia on the Internet, and news is published to reprint the content of the post.

On the index list of search websites, a related hot search was added, called 'Genius Hacker Column Data Reply to Jia Hongning', and the popularity jumped to the third place.

It depends on the content of the post.

In some controversial gossip incidents, most of the parties are interviewed, express their opinions and opinions, even if they post a reply, at most they break some news, win sympathy, and so on.

Zhao Yi's post is novel, and his direct listing of data has improved the style of gossip a lot.

In addition, controversy is also the reason for the popularity.

The data listed on the post caused a lot of controversy, with a well-known doctor of mathematics commenting that 'the amount of computation required to solve the optimal steps of the third-order Rubik's cube is unimaginably large, and it would certainly be impossible for an ordinary home computer to calculate'.

He also said that "there is no effective optimization algorithm for the time being".

Meantime.

There are also many voices on the Internet who support Zhao Yi, thinking that it is impossible for him to say the data indiscriminately, and other professionals said that rough calculations cannot lead to specific data, but they can judge that Jia Hongning's Rubik's Cube is simpler than Zhou Junkai's, especially in the last competition, the gap is very obvious.

Zhao Yi felt it was time to stand up.

Although there are some voices supporting him, it may be detrimental to continue, and something should be done to guide public opinion.

It's time for school.

He decided to take Netbook to school and post to the school.

The atmosphere at the school is similar.

Because the matter involved the students of the school, there was a large discussion in the school, and almost everyone knew about the post, and many people hoped to ask Zhao Yi how to calculate the results.

"Wait, I'll write it. ”

Zhao Yi went to talk to Sun Laoban, and planned to use the self-study class to edit a post and post it on the Internet for explanation, but he didn't expect Principal Wang Chengmin to come over directly.

"Zhao Yi!"

Wang Chengmin said with concern, "I see that the Internet is talking about you, and the data of your post ......"

A group of people leaned their ears together.

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

"Good. ”

He Ronghua immediately sent the Rubik's Cube over.

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

A lot of people were stunned.

Zhao Yi turned his head and said to the surroundings, "Help count the numbers, count every ninety degrees, count once, one hundred and eighty degrees." ”

"Good!"

A group of people watched carefully.

Zhao Yi deliberately slowed down the speed very slowly, so that others could count, and in about a minute, he turned it seventeen times, then picked up the Rubik's Cube and said, "This is the Rubik's Cube before Jia Hongning's first restoration in the competition, I used seventeen steps to transform it, and I can transform it back seventeen times." ”

"Hiss~~~"

Not to mention other students, even Wang Chengmin took a breath of cool air when he heard it.

He immediately pulled Zhao Yi and went to the principal's office, "Come on! Come on! I'll take a video for you and post this on the Internet to see who doubts it again." ”

Zhao Yi smiled and followed.

He originally wanted to post an expression of the way to turn the Rubik's Cube, but the text description is really troublesome, and it is relatively much easier to shoot a video.