I have not found a definitive answer for where the story originates, although I'm under the impression that it actually began in Zen Buddhism as a sort of a koan:
Zen teachers often tell the story of a young monk who asked a Zen master:
“How long will it take me to attain enlightenment?”
The master thought for a few moments and replied: “About ten years.”
The young monk was upset and said: “But you are assuming I am like the other monks and I am not. I will practice with great determination.”
“In that case,” replied the Master, “twenty years.”
A grasping, ambitious mind is an impediment to enlightenment.
That said, every quotation I've found is relatively modern with early examples going back to the 1970s at best. It does not seem to appear in the classic Koan books of The Blue Cliff Record (Chinese: Bìyán Lù; Japanese: Hekiganroku), The Book of Equanimity (also known as the Book of Serenity; Chinese: Cóngróng Lù; Japanese: Shoyoroku), or The Gateless Gate (also known as The Gateless Barrier; Chinese: Wúménguān; Japanese: Mumonkan). And honestly, the way in which it ends clearly with an aphorism is counter to the original Koans, which generally had an accepted answer, but a cryptic one intended to make you think rather than to feel that you understood.
Some references I've found are to "The Taste of Banzo's Sword" which is a similar one, but focused on martial arts (albeit swordwork). Its first telling that I've found is the 1919 collection, 101 Zen Stories.
Matajuro Yagyu was the son of a famous swordsman. His father, believing that his son’s work was too mediocre to anticipate mastership, disowned him.
So Matajuro went to Mount Futara and there found the famous swordsman Banzo. But Banzo confirmed the father’s judgment. "You wish to learn swordsmanship under my guidance?" asked Banzo. "You cannot fulfill the requirements."
"But if I work hard, how many years will it take to become a master?" persisted the youth.
"The rest of your life," replied Banzo.
"I cannot wait that long," explained Matajuro. "I am willing to pass through any hardship if only you will teach me. If I become your devoted servant, how long might it be?"
"Oh, maybe ten years," Banzo relented.
"My father is getting old, and soon I must take care of him," continued Matajuro. "If I work far more intensively, how long would it take me?"
"Oh, maybe thirty years," said Banzo.
"Why is that?" asked Matajuro. "First you say ten and now thirty years. I will undergo any hardship to master this art in the shortest time!"
"Well," said Banzo, "in that case you will have to remain with me for seventy years. A man in such a hurry as you are to get results seldom learns quickly."
"Very well," declared the youth, understanding at last that he was being rebuked for impatience, "I agree."
Matajuro was told never to speak of fencing and never to touch a sword. He cooked for his master, washed the dishes, made his bed, cleaned the yard, cared for the garden, all without a word of swordsmanship.
Three years passed. Still Matajuro labored on. Thinking of his future, he was sad. He had not even begun to learn the art to which he had devoted his life.
But one day Banzo crept up behind him and gave him a terrific blow with a wooden sword.
The following day, when Matajuro was cooking rice, Banzo again sprang upon him unexpectedly.
After that, day and night, Matajuro had to defend himself from unexpected thrusts. Not a moment passed in any day that he did not have to think of the taste of Banzo’s sword.
He learned so rapidly he brought smiles to the face of his master. Matajuro became the greatest swordsman in the land.