Day 20 – Job

“It’s the job that’s never started as takes longest to finish.”

For the sixth time today, Amrita’s focus spirit was cleaning the toilets. She watched as the fuzzy, glowing ball of pure concentrated magic lifted the scrubber and dutifully removed the several specks of dust that had accumulated in the last fifteen minutes. Then, satisfied with its work, it hovered out of the bathroom and into the kitchen, to sort the food in the refrigerator. Amrita groaned.

“No!” she called after the thing. “Fold the laundry! That’s the next thing on the list! Please, nothing has changed in the fridge in the thirty minutes since you last cleaned it.”

As she shouted this, her younger brother Ravi emerged from the kitchen with a cold soda in hand.

“Actually I might have nudged the eggs,” he said, and grinned when his sister nearly boiled over. “What’s the big deal, anyway? Why not just fold the laundry yourself.”

He passed into the living room, where his laptop waited on the coffee table. He dropped onto the couch and opened it up to reveal a text editor covered in code.

“Why don’t you just add up every number and store them in your head?” Amrita countered. “I went to school for magic. I am going to solve problems with magic.”

Ravi typed out a few things on his computer, made a face, and shut it again. Then he leaned back on the couch so his head was upside-down, facing his sister. “In programming we have this thing–the Rubber Duck principle. When you talk out your problem, sometimes the answer just comes to you.”

“What does the rubber duck have to do with that?” Amrita asked.

“You’re supposed to talk to an inanimate object–like a rubber duck, or a toy on your desk. Point is, let me be your rubber duck. Talk me through this chore magic.”

Amrita sighed, but she did as he suggested. She grabbed a glass jar from the shelf and brought it over to her brother. She sat down and presented it to him so he could get a better look at it.

It was one of those twelve-ounce standard mason jars, filled with layers of multicolored sand. Even as Ravi looked at it, the sand was twisting and shifting, layers rising and falling in the order.

“This,” said Amrita, “is the sand jar that binds the focus spirit. The color, the thickness of the layer, even the shape of the jar is perfectly calculated to represent which tasks the spirit must complete, and how much effort it should spend on them. The task at the top–that’s what the spirit is working on now.”

The task at the top was blue. Ravi threw a glance towards the kitchen and noted the spirit was still rooting around in there. Ravi put a finger up to the jar to measure out the length of some of the layers. Red and blue were thin, but green, all the way at the bottom, was longer than the distance between the tip of his thumb and his knuckle.

“That green one is folding the laundry,” said Amrita. “And no matter what I do, I can’t make it move from the bottom!”

As the spirit hovered out of the kitchen, the blue sand at the top began to slip down the side of the jar, landing towards the bottom. But as soon as it reached the bottom, it quickly moved right up above green. Meanwhile, the spirit began dusting the living room as the yellow sand rose to the top of the pile.

Ravi smacked his head with his wrist.

“Rita, do you know what a priority queue is?”

“Should I?”

Ravi grinned; here was something he could show his sister for once.

“It’s a data structure. A programming thing. A priority queue is a type of list that ranks its items by how important they are. The most important things float to the top, like the sand in your jar.”

“How can you tell what gets ranked higher?” Amrita asked.

“Depends on the program,” Ravi continued. “But if I had to guess, since you made it and all, the little guy wants to do all the faster stuff first and save the harder stuff for later.” While Amrita stuck her tongue out at him, Ravi pointed to the thin layers of sand that continued to cycle back and forth among the top few slots. “But once a task is done, it stays in the queue, so it just…floats right back to the top again.”

“Your spirit will never fold the laundry because it’s simply too much to handle when there are other, smaller tasks it can knock out right now,” Ravi concluded.

Amrita sat with this for a moment. “How do I change the task ranking?” she asked finally. But Ravi was already back on his computer.

“In C++?” he said. “You change the ranking algorithm. In magic? …Didn’t you go to school for that?”

Amrita gave Ravi a playful shove, but she continued to scrutinize the jar. Beside her, Ravi was typing away.

“I should thank you, though,” said Ravi. “Maybe I wasn’t able to help you, but you certainly helped me break through my wall. I’ve never known a rubber duck who could talk back!”