Chapter 198 - 126: It’s on Me, Part 2
Chu Ge grew more agitated as he spoke. He pulled a cigarette from his pocket and was about to light it, but after a glance at Chen Zhuo, he irritably stuffed it back in.
"It was supposed to be a simple inventory system—just build a front-end and connect it to a database. But the boss insisted on adding this insane allocation logic."
Chu Ge gestured with his hands.
"Supplies are tight. Orders from municipal hospitals get absolute priority, followed by the big chain pharmacies, and finally the small clinics in the counties below. And we can’t just cut off the small clinics completely—we have to reserve a ten percent base inventory and distribute it to them proportionally."
Chen Zhuo listened quietly without interrupting.
"When Lu Jia wrote the allocation algorithm, she used nested loops."
Chu Ge rubbed his temples, a headache brewing.
"If an order comes from a hospital, it goes down path A: check inventory, deduct. If it’s from a pharmacy, it goes down path B: check inventory, deduct proportionally. Logically, there’s nothing wrong with that."
Chu Ge paused, his expression turning grim.
"But the deadline is tonight. Lu Jia and I threw in thirty thousand lines of simulated data for a pressure test. Thirty thousand orders, all with different priority tags, flooded in at once. Those If-Else conditional statements were nested five or six layers deep. The server has to repeatedly traverse, compare, and sort all those tens of thousands of orders in the background."
"And then?" Chen Zhuo asked.
"And then the CPU usage shot straight to one hundred percent, the memory maxed out, the case fan spun so fast it nearly started smoking, and the system crashed."
Chu Ge leaned back in his chair.
"The algorithm’s time complexity is just too high. Lu Jia and I spent the whole afternoon tweaking parameters, but no matter what we changed, it ended in a deadlock. The boss said it has to be running by tonight. If it can’t handle these thirty thousand concurrent requests, we’ll lose the final payment of over ten thousand yuan."
After he finished, Chu Ge stared at Chen Zhuo, his eyes full of desperate hope.
"Brother Zhuo, you’re brilliant, and you have a strong foundation in math. Can you help me sort this out? What’s fundamentally wrong with the underlying logic?"
Chen Zhuo sat in his chair, his gaze falling on the copy of *Landau* on the desk. He thought silently for a few seconds.
He understood.
’The problem Chu Ge and Lu Jia are facing,’ he thought, ’is that they’re trying to navigate a maze using the most direct, clumsiest brute-force method.’
’With a small amount of data, the computer can handle checking identities one by one, queuing them up, and allocating resources.’
’But once the data volume explodes exponentially, the nested loops become a computational black hole.’
’In terms of pure logic, it’s isomorphic to the dead end he had encountered while reading that paper from the Princeton team.’
’Delian’s team tried to use continuous spacetime calculus to cross the Singularity and encountered divergence. Chu Ge and his team tried to use linear conditional statements to process a huge number of intertwined orders and encountered a memory overflow.’
Chen Zhuo nodded.
"Your approach was flawed from the very beginning."
Chen Zhuo’s tone was even.
Chu Ge was stunned, his mouth hanging half-open.
"Flawed? Allocation based on conditional logic—isn’t that the most reliable planning method taught in programming books?"
Chen Zhuo didn’t rush to explain.
He reached for the sheet of scratch paper he’d been using earlier, the one covered in physics derivation formulas.
He glanced at the dense calculations on its surface—the Landau theory he had just been completing. Chen Zhuo casually flipped the paper over, revealing the other side, which was printed with obsolete C code.
The line spacing of the code was wide, leaving plenty of white space in between.
In a blank area, he used his pen to lightly draw a black ink dot.
"You’re treating these orders like people lining up to buy tickets."
Chen Zhuo explained as he drew.
"The line gets too long, so you set up three different lanes at the ticket gate. For every person that comes through, you have to ask, ’Where are you from?’ before deciding which lane to send them down. When the crowd gets too big, the gate gets completely jammed."
Chu Ge leaned in closer, his eyes fixed on the black dot under Chen Zhuo’s pen.
"If they don’t line up, how are you supposed to sort them?" Chu Ge asked.
Chen Zhuo drew a few more black dots, spaced far apart from the first one, and then connected them with straight lines.
"Treat them as individual state nodes."
With a flick of his wrist, Chen Zhuo sketched the structure of a bipartite graph on the paper, not the tree-like branching Chu Ge had described.
"Abandon the mindset of linear traversal. Abstract the hospitals, pharmacies, and clinics directly into algebraic points with different weights. Abstract the existing inventory into a set."
In another blank space on the paper, Chen Zhuo quickly jotted down a few basic variables from Discrete Mathematics, then applied a minimalist matrix mapping formula.
"In this Discrete Matrix, you don’t need to ask ’if.’ An order comes in, and it brings its weight value with it—say, 3 for a hospital, 2 for a pharmacy, 1 for a clinic. You directly perform a multiplicative mapping between the order matrix and the inventory matrix. The ones with higher weights will naturally get matched to an inventory node first."
Chen Zhuo added a final stroke to the formula.
"If an inventory node is depleted to zero, it becomes inactive in the matrix, and subsequent mappings will automatically skip it. All the logic is completed in a single matrix operation, instead of running through tens of thousands of nested loops."
After writing the last line, Chen Zhuo pushed the scratch paper in front of Chu Ge.
Chu Ge stared down at the clear matrix structure on the paper, his brain rapidly translating the mathematical symbols into the database language he was familiar with.
Although Chu Ge’s foundation in mathematics wasn’t as strong as Chen Zhuo’s, he had, after all, managed to get into a place like the junior class at Keda. His logical comprehension could still be considered top-tier.
He looked at it for about half a minute.
"Holy shit..."
Chu Ge snapped his head up. The look of dejection in his eyes was completely gone, replaced by the bright spark of sudden enlightenment.
