Super-brain hacker

Chapter 548 Technical House

Today's chapter will be added tomorrow.

Every inch of the surrounding space seems to be piled up with all kinds of electronic equipment and components. The light is dim and crowded. Lin Hong feels as if he has come to the electronic market of the City God Temple in a city in mainland China.

After a while, he saw that the electronic accessories and components related to computers gradually increased.

In front, a young man with his frontal bangs dyed yellow is playing computer games in the store.

At this time, Huang Yue, who was walking in front of him, suddenly stopped. He turned his head to Guang Yongyuan and said, "According to the old rules."

After saying that, he walked forward alone.

"Old rules?" Lin Hong looked at Guang Yongyuan with doubtful eyes.

Guang Yongyuan had to explain: "If you want to enter this circle, you must prove that your technology has reached this level. Although they all know me, they are all brainless and only recognize technology but not people.

Around and around, Lin Hong finally understood that if he wanted to continue to move forward, he must pass the test they set, which was quite a bit of a breakthrough.

"Interesting." Lin Hong smiled and didn't care about it. He asked, "What projects do you have?"

Guang Yongyuan said: "Programming, cracking and network penetration. Of course, it is not necessary to pass all of them, as long as one of them can be recognized by them. You must have no problem. You're just going through the scene.

Guang Yongyuan has seen Lin Hong's cracking technology. Even Lin Hong, who is such a difficult bone as "Invincible Hero", has been done without much effort, let alone their entry test?

At this time, the hair dye young man who was playing the game before had quit the game. He shook the yellow hair on his forehead and said to Lin Hong, "Please."

The first level, programming.

Lin Hong didn't have any nonsense. When he sat in the seat of the young man just now, he saw that a question had appeared in the monitor. Obviously, they were very familiar with this kind of thing and had their own fixed test process.

The title given to Lin Hong is "Use basic operations to write the most efficient square root function you can achieve."

square root is a very important and complex operation in mathematics. It is usually difficult to implement this function in a computer, so programming languages generally encapsulate these functions. When programming, if the square root operation is involved, just call the functions in the function library directly. Few people will understand how the bottom layer is achieved.

Moreover, it can be realized on the one hand, and whether it can be efficient in computing is on the other hand.

The operation efficiency of a program is often an important difference between a master and a rookie. When a real hacker is programming, it not only realizes the function, but also pursues the highest efficiency. Sometimes it may be just a symbolic change, and its execution efficiency is very different.

The difference between one execution may not be seen, but what if there are a thousand cycles and 10,000 cycles?

There is often a gap in efficiency between programs written by masters and rookies. If you want to write efficient and elegant programs, you must have an understanding of the essence of the programming language and the underlying computer, and also have rich programming experience. In this regard, practice is the only way to improve your own strength.

Lin Hong knows that in the operation of finding the square root, there is an algorithm called Newton iterative method. Its principle is: If a number is X, assume that its square root is Y. If the difference between the square and X of Y is greater than a given error, continue to assume the next value, so it continues. Until the value within the allowed error is finally obtained.

As for how to assume this value, the method used is to take the average, in which division and multiplication must be used many times.

In a computer, its essence is actually addition. The operation of the whole CPU is actually an adder. When Lin Hong realized the super-brain CPU structure, it was based on an adder structure. As for the subsequent subtraction, multiplication and division operations, they are all derived on the basis of this adder. Come on.

directly use Newton's iteration method to find the square root, which is the practice of ordinary people. Lin Hong doesn't have to think about it and knows that if it is really achieved in this way, it is obviously impossible to pass.

Lin Hong had a clue after thinking for a moment. He checked the compiler in the computer and found that the computer was well prepared. There were not only some common programming language compilers on the market, such as C, BAISC, J**A, C++ and other languages, and even some very niche programming languages. Words, such as Ada, Blue, ISP, etc.

In the end, Lin Hong pulled out the C language compiler in the computer and typed the code directly.

After only 20 seconds, Lin Hong completed the writing of the function.

He called and executed it with a function. The program ran successfully without any errors, and passed it all at once.

After thinking about it, he deleted two lines again and merged the two steps into one. The final total number of function codes was exactly ten lines.

"Okay." Lin Hongdao.

Guang Yongyuan, standing behind him, is still frowning at his program at this moment.

He can't figure out why Lin Hong wrote it like this.

"Is it going to be better so soon?" The young man who dyed his hair was a little surprised.

Just when he gave up his seat, he took out a handheld game console from a corner to play, but as soon as he began to play, he heard Lin Hong say that it was OK.

This is the first time among many challengers.

The hair-dyed young man leaned over and took a look, and his face was slightly stunned. Although he could understand most of the ten lines of code written by Lin Hong, he did not understand a few details for a while.

He added Lin Hong's function to the time statistics macro. After 10,000 executions, he finally showed the time, 965 milliseconds, that is to say, less than a second.

He looked at Lin Hong with respectful eyes and said, "You have passed the test. I have been here for two years. In the past two years, no less than 50 people have passed here, but no one has ever done this step. Not only does the result ensure the accuracy, but also the time of execution 10,000 times does not exceed one second.

Lin Hong smiled. There is nothing to be proud of about his praise. These are the most basic things. As long as you understand the operation of the CPU, you should basically be able to achieve it. There is nothing to be proud of.

Guang Yongyuan asked at this time, "A Hong, I don't quite understand it. Don't you use the binary search method to find the square root?"

Guang Yongyuan is not best at this aspect. After all, he was born in the wild road, and the basic part is not very solid. He was confused about Lin Hong's ten lines of code.

What he said about binary search is actually one of the implementations of the bull team iteration method.

Lin Hong nodded: "The algorithm is indeed this, but here, I use binary shifts instead of multiplication and division. Look..."

Lin Hong saw that he didn't understand it very well, so he re-arranged the compiler, down the breakpoint, tracked the memory assignment of the variable, and explained while operating: "At the binary level, we decide whether each binary bit is 0 or 1 from front to back. Therefore, we can go from the highest bit to the lowest bit, Whether the product result is greater than the target number, if it is greater than the target number, then the digit will keep 0. In this case, we don't need to really calculate the multiplication on the top 1, but add the previous result, plus the previous number of the previous 1 to move twice the position of so many bits in 1, plus the position of the previous 1 /P>

After Lin Hong's demonstration and explanation, Guang Yongyuan suddenly realized, and the young man behind him also nodded with relief. Although he knew the general principle, he still did not understand some details. After listening to Lin Hong's complete explanation, he understood.

That is to say, the whole algorithm Lin Hong uses binary-level operations, which is difficult to think of, or no program can implement faster than his algorithm.

It only took more than 20 seconds to complete the first level, and the answer is so excellent that I have never encountered it before.

Lin Hong originally wanted to see what was going on later, but after seeing Lin Hong's program, Huang Yue directly announced that Lin Hong had passed the test, and there was no need to continue to break through the test.

This question was actually made by Huang Yue himself. He gave a standard answer at the beginning, which was also the implementation of the binary level, but there is still a considerable gap between the two.

Although this is the most basic thing, it is these things that can see a person's level most clearly.

Obviously, Lin Hong is stronger than Huang Yue in this respect, not to mention that Guang Yongyuan told him before that Lin Hong is still a cracking master.

In the end, Lin Hong successfully entered their base camp, that is, a fairly large hall, but there were ten computers and servers of various brands, which looked a little crowded.

In the hall, there were many people, all of whom were young people. When they saw the new members, some applauded and some whistled to welcome them. However, that's all. After the routine welcome ceremony, they once again focused on their computer monitors.

Huang Yue introduced two people to Lin Hong, one is Yuan Lebang, the other is so fat that he can't even bend his waist, and he has a smiling face like Maitreya Buddha. The field he is good at is game cracking, and the person Guang Yongyuan wants to dig most is him.

The other is Ruan Feizhou, with thick black-framed glasses. He is good at hardware cracking. On his desk, he is full of various electronic components and the latest game consoles, including Sony's PS game consoles and Nintendo's GBA and NDS series game consoles. -

On Ruan Feizhou's body, Lin Hong saw Gu Wei's shadow.

Their place is not a company, not even a team. They just gather together based on their interests. Huang Yue provides them with a free place, and this is Yaliao Street, where any electrical appliances and components can be easily found here.

They are a group of technical houses who are crazy about technology.