dark mode light mode Search Menu
Search

The Ant and The Grasshopper

dierken on Flickr

One summer day, a grasshopper came upon an ant who was collecting grain. The grasshopper watched as the ant struggled to remove a kernel from a fallen stalk. After a few minutes, the grasshopper spoke.

“Little ant, what are you doing?” the grasshopper asked.

“Collecting food for the winter,” responded the ant in a weary voice. He was exhausted from a day of hard labor.

“But it’s the middle of the summer,” said the grasshopper. “Winter isn’t for months, and food is plentiful. Why do you spend your day like this?”

The ant paused for a moment while he thought. “It’s the algorithm that we use,” he finally replied.

“Algorithm?” asked the grasshopper.

“A set of steps or instructions for accomplishing a task,” explained the ant. “Like when a carpenter builds a chair, he uses an algorithm that includes measuring, cutting, smoothing, and hammering.”

“What task does your algorithm solve?” asked the grasshopper. “Does it solve the problem of having too much time during the summer?” He chuckled out loud at his own joke.

“It accomplishes the task of keeping the colony healthy all year round. Everyday, we have a set of tasks that we perform. During the summer we spend the mornings collecting food, the afternoons digging tunnels, and the nights sleeping. It might not sound like much, but it ensures that we have food during the cold winter.”

“That sounds like a simple algorithm,” said the grasshopper.

“Algorithms can be simple or complex,” explained the ant. “They can even include steps that require other algorithms to solve. For example, when I collect food, I use a special food collection algorithm. It has five steps: 1) walk to the field, 2) search for a wheat stalk with grain on it, 3) remove a kernel of grain from the stalk, 4) carry the grain back to the ant hill, and 5) place the grain in the storage tunnel. I follow those exact steps to collect a giant pile of grain.”

“That sounds boring,” said the grasshopper. “I don’t use algorithms. I just do whatever I want, whenever I want. Complete freedom. In fact, I think I’m going to climb to the top of the wheat stalk and sing for a while. I bet your algorithm doesn’t let you do that.”

The ant shrugged in response. He had his algorithm, and thus his next steps. This had worked for his colony for hundreds of years. While the grasshopper jumped away singing, the ant returned to his task.

Epilogue

Six months later, a harsh winter engulfed the land. The grasshopper scavenged the frozen, bare wheat field for food. There was not a single kernel to be found.

At the same time, the ant was safe and warm in his colony’s tunnels. He was hard at work following his winter day algorithm, which consisted of: digging tunnels, eating, and relaxing. He greatly preferred the winter algorithm to the summer one. As he worked on extending the eastern food tunnel, he paused and thought back to the grasshopper. He wondered if the grasshopper was still spending his days singing in the wheat fields, or whether he had learned the value of a good algorithm.

If you liked this story, the author has written many more collected in several books linked below, including in July 2016 Search: A Tale of Algorithms, Computation, and Conspiracy. This story is reprinted with permission of the author, Jeremy Kubica.

Learn More

Computational Fairy Tales

http://computationaltales.blogspot.com
http://computationaltales.blogspot.com/p/book.html
https://twitter.com/compfairytales

The CS Detective: An Algorithmic Tale of Crime, Conspiracy, and Computation

To be released July 2016, you can order early and get a discount.
https://www.nostarch.com/searchtale

Best Practices of Spell Design

http://www.amazon.com/Practices-Spell-Design-Jeremy-Kubica/dp/1481921916

Computational Fairy Tales

http://www.amazon.com/Computational-Fairy-Tales-Jeremy-Kubica/dp/1477550291/

SmallTalks: Jeremy Kubica and Computational Fairy Tales

https://vimeo.com/70188494