Baby Pickle and the Spaghetti Code

Click here to read all the Pickle stories in chronological order.

One time Pickle wanted to make some spaghetti for dinner. He looked all over the kitchen, but he couldn’t find any boxes of spaghetti. He decided to make a spaghetti machine so that he could make his own spaghetti.

He collected all the ingredients that he needed: flour, eggs, salt and oil. Then he got a holding function. It had a big bowl to hold all the ingredients.

Pickle put his ingredients into the holding function and added a mixing function to mix them all together. Then he put a squeezing function that would take the pasta dough and squeeze it out into a long piece of spaghetti.

After that, he was going to add a cutting function to cut the long piece of spaghetti into shorter pieces, but first he had to go to the bathroom.

While Pickle was using the bathroom, Baby Pickle came along. He looked at all the pieces of Pickle’s machine to see what it would do. He saw how it would make one long piece of spaghetti come out of the squeezing function.

Then Baby Pickle had an idea. He took the squeezing function off the machine and put it through a ×100 function so that he had one hundred squeezing functions. Then he put them all onto Pickle’s machine, so that the dough would get squeezed into one hundred pieces instead of just one piece.

As soon as Baby Pickle heard Pickle coming out of the bathroom, he raced away and hid under the bed in the playroom. When Pickle got back to his spaghetti machine, it was bristling with squeezing functions. “Oh, no!” cried Pickle. “How am I going to cut all the spaghetti that comes out of all these different squeezing functions? I only have one cutting function!”

Then he saw the ×100 function where Baby Pickle had dropped it. Pickle put the cutting function into the ×100 function and went around to each of the squeezing functions to put a cutting function on the end of each one. Now the spaghetti would get squeezed out through one hundred squeezing functions and cut by one hundred cutting functions. But how would he collect all those pieces of spaghetti into a bowl?

Pickle built a conveyor belt to carry the bowl around to all the different cutting functions so it could catch each piece of spaghetti as it came out. Then he turned on the spaghetti machine to see what would happen.

The holding function that held all of the ingredients put them into the mixing function, which mixed them all up. Then the mixing function put the mixed-up pasta dough into all the squeezing functions. Each squeezing function squeezed out the dough into a long piece of spaghetti, and the cutting function at the end of each squeezing function cut each piece in half. Then all the pieces of spaghetti fell down. A few of them fell into the bowl as it whizzed by on the conveyor belt, but most of the spaghetti just fell on the conveyor belt.

The bowl got to the end of the conveyor belt and Pickle picked it up. It had four pieces of spaghetti inside. He got a fork and tried to eat them, but they were so long that it was hard to pick them up with the fork.

“This machine needs some work,” said Pickle. He looked at one of the cutting functions and saw that it was set to one. He decided to change the setting to three so it would cut the spaghetti into quarters instead of halves. This would make the pieces a lot shorter and easier to eat.

Pickle went around from one cutting function to the next, changing the setting on each one. He kept count of how many he had changed: 10, 20, 30 . . . . Pickle got tired and took a break after he had changed 60 cutting functions. He was more than half-way done! 70, 80, 90 . . . .

When Pickle got to 97, he couldn’t find any more cutting functions that were still set to one. All the functions he looked at were already set to three. “Did I count wrong or did I skip some cutting functions?” he wondered.

Pickle searched and searched but he couldn’t find any more cutting functions to change. He decided that it would be okay if a few of the spaghetti pieces came out too long. Most of the spaghetti would be short and that was good enough.

Next Pickle had to figure out the bowl problem. He put the bowl into the ×100 function and out came one hundred bowls. He arranged all the bowls on the conveyor belts, with one bowl under each cutting function. Now all the spaghetti would fall into a bowl.

At the end of the conveyor belt, he put a pouring function. The bowls would feed into it and the pouring function would pour each bowl out into a bigger bowl that Pickle put at the bottom.

Pickle put more flour, eggs, salt and oil into the holding function and ran his spaghetti machine again. The mixing function mixed up all the ingredients and the squeezing functions squeezed out long pieces of spaghetti. This time the cutting functions cut each piece three times to make four short pieces of spaghetti. The spaghetti pieces fell into the bowls that were waiting on the conveyor belts. Then the conveyor belts brought all the bowls into the pouring function, and the pouring function poured all the spaghetti into one big bowl for Pickle to eat.

And that’s the story of Pickle and the Spaghetti Machine.

Baby Pickle and the Surprise Party

Not much math in this one, just a bunch of Baby Pickle antics.

Click here to read all the Pickle stories in chronological order.

One day Baby Pickle woke up and decided that he wanted to have a surprise party. So he wrote letters to all of his friends, like this:

Dear Baby Square,

Please come to Baby Pickle’s house for a party. This party is for Baby Pickle but don’t tell him, because it’s a surprise. Make sure to bring lots of presents.

Love, Pickle

Baby Pickle put the letters into the mailbox and the mail carrier came and delivered them to all the babies. They all got really excited and started wrapping presents to bring to the party.

Then Baby Pickle wrote a letter to Mommy Pickle:

Dear Mommy Pickle,

Let’s host a surprise party for Baby Pickle. Would you please go to the grocery store and get some party food?

Love, Daddy Pickle

And Baby Pickle wrote a letter to Daddy Pickle that went like this:

Dear Daddy Pickle,

Wouldn’t it be fun to have a party for Baby Pickle? But let’s keep it a surprise. I’ll get the food and you can get the house cleaned up and set the table for everybody. (All the babies are coming over.)

Love, Mommy Pickle

So Mommy Pickle went to the grocery store and bought all kinds of yummy food: chips and soda and pickles and pickle salad and pickle cake and pickle ice cream.

Meanwhile Daddy Pickle was vacuuming all over the house and bringing in some extra chairs for the babies to sit in.

Baby Pickle wrote one more letter:

Dear Pickle,

We’re having a surprise party for Baby Pickle today. Would you please take him out to get ice cream so he won’t see all the guests coming in the house?

Love, Mommy and Daddy Pickle

So Pickle came over to Baby Pickle and said, “Hey, want to go get some ice cream?”

“Yes!” said Baby Pickle, and they went to Baby Pickle’s favorite ice cream place and ate ice cream cones together.

When they got home, Baby Pickle came inside the house and everyone jumped out of their hiding places and shouted, “Surprise!”

And Baby Pickle had a great party with all the other babies and opened lots of presents and ate lots of yummy food.

And that’s the story of Baby Pickle and the surprise party.

Pickle and the Bugs

I got the idea for this story after a conversation with Luke about the difference between real bugs and computer bugs. (He had overheard Claudiu announcing his success in finally solving a tricky work bug.)

Click here to read all the Pickle stories in chronological order.

This is a story about the time Pickle decided to make a sorting machine to sort Duplos. He had a hopper at the top—

Luke: It was a holding function.

Pickle started with a holding function at the top, to hold all the Duplos. Then he put a color sorter that sorted red things this way, yellow things that way, blue things another way, and so on for all the colors.

Luke: And he had separators to keep the colors from mixing when they came out. And a take-aparter function.

. . . And Pickle put in a take-aparter function that took apart the Duplos that were stuck together. And then he put a size-sorting function that separated the big pieces from the small pieces. And he put a shape sorter to separate the Duplos with round or sloped edges from the Duplos with only square corners.

After Pickle was done putting all these functions together, he decided to test his sorting machine. He gathered up all the Duplos from the playroom and dumped them into the holding function.

The Duplos went through the color sorter and the take-aparter and the size sorter and the shape sorter. When they came out at the bottom, all the red Duplos were in one area and all the blue Duplos were in another area. But there were some yellow Duplos mixed in with the other colors.

“Oh no,” said Pickle. “There’s a bug in my machine. I have to figure it out.” So Pickle looked very carefully until he figured out the problem: when a red Duplo and a yellow Duplo were stuck together, the color-sorting function would put the whole assembly in the reds’ place. Then the take-aparter would take them apart and the yellow Duplo would be in the wrong place!

Luke: So he took it apart . . .

So Pickle took apart his machine and moved the take-aparter to the beginning, after the holding function but before all the sorting functions. Now when he tested it out, all the colors went to the correct places.

Luke: And then he went to the bathroom . . .

Then Pickle needed to go to the bathroom. While he was doing his toilet visit, Baby Pickle came over to the sorting machine. Baby Pickle had a big bucket full of toy bugs — red bugs, green bugs, blue bugs, yellow bugs, all kinds of different bugs. And he dumped it into the holding function. Then he heard Pickle coming back so he rushed away into the playroom and hid under the bed.

The take-aparter function took apart the bugs that were tangled up with each other. Then the color-sorting function put all the different colors in different places. The size sorter separated the big bugs from the small bugs and the shape sorter separated all the different shapes of bugs.

When Pickle came back to his sorting machine, bugs were coming out of it!

“Oh no!” cried Pickle. “My machine must have another bug and it’s making bugs everywhere!”

Pickle thought the sorting machine must have a bug-making function in it that was turning the Duplos into bugs. He searched and searched, but he couldn’t find anything. Where were the bugs coming from?

Then he heard giggling coming from under the bed in the playroom, and he saw the empty bug bucket. Pickle realized that Baby Pickle had tricked him by putting bugs into the machine instead of Duplos.

After all the bugs were done popping out, Pickle added a filter function to the top of the holding function. It said, “If x equals a Duplo, then x can come through.”

All the bugs were mixed into the Duplos, so Pickle dumped them into the filter function. It let the Duplos go through into the holding function, but all the bugs slid out the side because they were not Duplos. Pickle put the bucket there to catch them.

And that’s the story of Pickle and the Bugs.

Pickle and the FizzBuzz Machine

I told the below story to Luke a few days after I taught him the rules of FizzBuzz. I say story, but it’s really a thinly-veiled programming exercise! Not that I had any complaints from Luke about the lack of plot; he was fully engaged in helping me design a FizzBuzz algorithm. I really like how the Pickle universe has become our playground for exploring all these fun abstract concepts.

Click here to read all the Pickle stories in chronological order.

One day, Pickle decided to make a FizzBuzz machine out of functions. The first thing he needed was a number-counting function, so he went over to the Closet of Functions and pulled one out. The number-counting function had a place on the side where you could set the number you wanted to count to. If you sent it to ten, it would count from one all the way up to ten.

Luke: And he had a noise-making function.

And Pickle also got a noise-making function that made noises. So when Pickle hooked up the noise-making function to the counting function, the noise-making function said “ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN.”

Then Pickle got a fizz function. Inside the fizz function it said, “If x is a multiple of 3 then say ‘Fizz,’ else say x.” So if a one came into the fizz function it would go “one” but if a three or a six came in, it would go “fizz.”

Pickle disconnected the noise-making machine from the counting function and put the fizz function between them.

Luke: Then he put in a buzz function.

Pickle was about to put in a buzz function, but first he wanted to test what he had so far. He set the counting function to ten and started it up. The numbers came out of the counting function and went into the fizz function. Then the output of the fizz function went into the noise-making machine and it said, “ONE, TWO, FIZZ, FOUR, FIVE, FIZZ, SEVEN, EIGHT, FIZZ, TEN.”

Now Pickle was ready to add the buzz function. It was similar to the fizz function. It said, “If x is a multiple of 5 then say ‘Buzz,’ else say x.” Pickle hooked it up so it came between the fizz function and the noise-making function. When he turned the whole thing on, the noise-making machine said, “ONE, TWO, FIZZ, FOUR, BUZZ, FIZZ, SEVEN, EIGHT, FIZZ, BUZZ.”

Then Pickle changed the setting on the counting function to make it go all the way up to twenty. And when he ran it, the noise-making machine said, “ONE, TWO, FIZZ, FOUR, BUZZ, FIZZ, SEVEN, EIGHT, FIZZ, BUZZ, ELEVEN, FIZZ, THIRTEEN, FOURTEEN, FIZZ, SIXTEEN, SEVENTEEN, FIZZ, NINETEEN, BUZZ”

Then Pickle realized that he had a problem! Instead of saying FizzBuzz for fifteen, his machine was just saying Fizz! This was because the fizz function turned the fifteen into “Fizz.” When this “Fizz” got to the buzz function, the buzz function put “Fizz” in for x and said, “If ‘Fizz’ is a multiple of 5 then say ‘Buzz,’ else say ‘Fizz.'”

[At this point my plan was to have Pickle add a fizzbuzz function at the beginning, to catch all the multiples of fifteen, but Luke had a different idea. Unfortunately I don’t remember the exact words he used to describe his idea, but once I had confirmed that I understood it correctly, I incorporated it into the story.]

So Pickle disconnected the fizz and buzz functions from each other and placed them side-by-side instead. Then he put in a splitter so the output from the number-counting function went into both functions at the same time. After the fizz and buzz functions, he put a mixer function to combine the output from the fizz function with the output from the buzz function.

Pickle tested out his machine to make sure it was working properly. “ONE, TWO, FIZZ, FOUR, BUZZ, FIZZ, SEVEN, EIGHT, FIZZ, BUZZ, ELEVEN, FIZZ,THIRTEEN, FOURTEEN, FIZZBUZZ, SIXTEEN, SEVENTEEN, EIGHTEEN—”

Luke: No it said Fizz!
Me: Oh yeah, you’re right!

“. . . SEVENTEEN, FIZZ, NINETEEN, BUZZ.” Whew! Pickle was so happy that he had gotten his FizzBuzz machine to work.

And that’s the story of Pickle and the FizzBuzz machine.

Updates

I envisioned this story as a once-and-done event, but Luke has continued to play with the idea of a FizzBuzz Machine over the course of the past few weeks.

Luke: Do you know how Pickle got the FizzBuzz Machine to do that?
Me, starting to pay attention: What?
Luke: He set the fizz function to one and the buzz function to two. Fizz, FizzBuzz. Fizz, FizzBuzz. Fizz, FizzBuzz.
Me: Ah, yes.
Luke: Fizz, Fizz, Fizz, Fizz, Fizz. Do you know how he got it to do that?
Me: How?
Luke: He took out the buzz function!
Me: Oh yeah, that works.

Luke: One, Buzz. Three, Buzz. Five, Buzz . . . [he continued up to 13 or so] . . . Do you know how he did that? He took out the fizz function and put back the buzz function. The buzz function was set to two.
Me: 😃

And a few days later:

Luke: If it’s made of threes or it’s a cube, say Fizz. If it’s not made of threes and it’s not a cube, just say the number.
Me: Okay.
Luke: One- . . . so that one should be Fizz. Fizz, Two, Fizz, Four, Five, Fizz, Seven, Fizz, Fizz, Ten . . . .

He made it into the thirties before getting bored. When he got to Twenty-Seven, he decided it should be FizzFizz if it’s a cube and made of threes.

Baby Pickle and the Negative Minus-One-Hundred Function

“Even though our eyes quickly get bored with a silent reading of repeated passages of text, children really enjoy repetition — especially if they can join in.”

Hiroko Fujita & Fran Stallings, How to Fool a Cat

Click here to read all the Pickle stories in chronological order. This story is a direct sequel to Baby Pickle and the Negative M&Ms.

One day Baby Pickle was in the playroom. He had three M&Ms and three mystery functions. They didn’t have any labels on them so he did not know what they did.

Baby Pickle decided to test his first function by putting an M&M inside. Out came two M&Ms!

“Maybe this is a +1 function,” thought Baby Pickle. “Or a ×2 function.”

He put two M&Ms into the function to see which kind it was. Only three M&Ms came out, so he knew it was a +1 function.

Baby Pickle ate three of his M&Ms. Now he only had two left. He put an M&M into the second mystery function, but nothing came out! It was a −1 function.

This made Baby Pickle a little nervous about putting his last M&M into the last mystery function. What if it was another minus function? He would have no M&Ms left!

Baby Pickle put the +1 function into the last mystery function to see what would happen to it. Out came one hundred +1 functions! Now Baby Pickle knew what his last function was; it was a ×100 function.

Baby Pickle stuck all of the +1 functions together to make a really long +100 function. It was so long, it went out the door of the playroom, through the hallway, and into the dining room.

Baby Pickle decided to test his functions to see which one was the best. He already knew the −1 function was the worst because it took away his M&Ms. But what about the +100 function and the ×100 function? Which one would give him more M&Ms?

Baby Pickle put his last M&M into the ×100 function and out came 100 M&Ms. It was a big pile! Baby Pickle started to eat them, but then he remembered his +100 function. He put an M&M into that one, and out came 101 M&Ms.

Baby Pickle knew that 101 was more than 100, so he decided that his +100 function was the best. It gave him the most M&Ms.

Baby Pickle put 100 M&Ms into the +100 function and out came 200 M&Ms. He put those 200 M&Ms back in and out came 300 M&Ms.

Then Baby Pickle had an idea. He put his 300 M&Ms into the ×100 function. Out came 30,000 M&Ms! The pile of M&Ms that came out was so big that it filled up the playroom. It pushed Baby Pickle away. Soon there was no more room for Baby Pickle in the playroom because it was filled with M&Ms. Baby Pickle got pushed through the baby gate and into the hallway by all those M&Ms.

Baby Pickle laughed and laughed. He thought it was funny that the playroom was so full of M&Ms! He wanted to go back in there and play, so he started eating M&Ms and pushing them out of the way. He made a little tunnel into the pile.

Baby Pickle could not think of anything better than this giant pile of M&Ms. He could eat as many as he wanted, because he would never run out! He changed his mind about the +100 function being the best. The ×100 function was even better because he could put in 300 M&Ms and get back 30,000 M&Ms.

But when Baby Pickle turned around, he saw that the tunnel had closed up behind him. He started to get scared because it was dark in the tunnel, inside the pile of M&Ms. He turned around and around, but he couldn’t remember which way he had to dig to get out of there. How would he ever get out of his pile of 30,000 M&Ms?

Then Baby Pickle remembered his −1 function.

He put an M&M into the −1 function and nothing came out. Now he had twenty-nine thousand, nine hundred ninety-nine M&Ms.

He put another M&M into the function and nothing came out. Now he had twenty-nine thousand, nine hundred ninety-eight M&Ms.

He put another M&M into the function and nothing came out. Now he had twenty-nine thousand, nine hundred ninety-seven M&Ms.*

*The repetitive parts of this story serve an important purpose. If you tell this one to your kids, I recommend putting in as many repeats as you can — just keep droning on and on until they start complaining. The goal is to drive home just how big the numbers are.

Baby Pickle wanted to get rid of the pile faster, so he put all twenty-nine thousand, nine hundred ninety-seven M&Ms into the function, but out came twenty-nine thousand, nine hundred ninety-six M&Ms!

Baby Pickle started to get worried. How would he ever get rid of all of these M&Ms?

Then Baby Pickle had another idea. He put the −1 function into the ×100 function. Out came one hundred −1 functions! He stuck them together to make a −100 function.

He put his twenty-nine thousand, nine hundred ninety-six M&Ms into this −100 function, and twenty-nine thousand, eight hundred ninety-six M&Ms came out.

He put those twenty-nine thousand, eight hundred ninety-six M&Ms back into the function and twenty-nine thousand, seven hundred ninety-six M&Ms came out.

He put those twenty-nine thousand, seven hundred ninety-six M&Ms back into the function and twenty-nine thousand, six hundred ninety-six M&Ms came out.

He put those twenty-nine thousand, six hundred ninety-six M&Ms back into the function and twenty-nine thousand, five hundred ninety-six M&Ms came out.

Baby Pickle started to cry. Even with the −100 function, it was taking so long to get rid of the M&Ms. What if he could never do it?

Then Baby Pickle had another idea. He put the −100 function into the ×100 function and out came one hundred −100 functions. He stuck them all together and made a −10,000 function.

Baby Pickle put his twenty-nine thousand, five hundred ninety-six M&Ms into the −10,000 function and nineteen thousand, five hundred ninety-six M&Ms came out.

He put those nineteen thousand, five hundred ninety-six M&Ms back into the function and nine thousand five hundred ninety-six M&Ms came out.

Baby Pickle very carefully took one of the M&Ms out of the pile and set it aside. Then he put the other 9,595 M&Ms into the −10,000 function and negative 405 M&Ms came out. So now he had 405 negative M&Ms plus one regular M&M.

Baby Pickle put the regular M&M into the +100 function five times until he had 501 M&Ms. Now he mixed the 405 negative M&Ms into the pile of regular M&Ms. *Poof! Poof! Poof!* Whenever a negative M&M touched a regular M&M, they both disappeared. Pretty soon Baby Pickle just had a small pile of 96 regular M&Ms.

Baby Pickle took apart all the pieces of the −10,000 function, so that he had one hundred −100 functions again. He put ninety-nine of those −100 functions into the other −100 function and out came a negative −100 function.

Baby Pickle put an M&M into the negative −100 function and out came 101 M&Ms.

Then Baby Pickle put the negative −100 function together with the regular −100 function and *Poof!* they both disappeared.

And that’s the story of Baby Pickle and the Negative Minus One-Hundred Function.

Pickle and the Arithmetic Operators

This story developed on the fly after Luke guessed halfway through that a +2 function would turn one negative M&Ms into three negative M&Ms. I realized that he does not have much experience yet with arithmetic on negative numbers and this gave me the idea to show what happens with all the different operations.

Click here to read all the Pickle stories in chronological order.

One day, Pickle was hungry for a snack. He decided to eat some M&Ms. But when he got his bag of M&Ms out of the cabinet and opened it up, it was empty!

“What happened to my M&Ms?” thought Pickle. “The bag was more than half full when I put it away yesterday.”

Just then, Pickle heard a plonking noise coming from the playroom. He went over to the baby gate and saw Baby Pickle dropping M&Ms into a bucket: plonk, plonk, plonk!

“Hey, those are my M&Ms!” said Pickle. “Give them back to me! Those M&Ms were inside my boundary.”

Pickle tried to go through the baby gate, but it did not let him go through because the filter function said, “If x has M&Ms, then x can go through.” Pickle could not go through because he did not have any M&Ms.

Pickle looked around and saw an M&M that Baby Pickle had dropped on the floor. He picked it up, but the gate would still not let him go through because the filter function said “M&Ms” and he only had one M&M. He searched and searched but he could not find any more M&Ms on the floor.

“That’s okay,” thought Pickle. “I can use a function to get more M&Ms.” He went to the closet of functions and looked around until he found a ×2 function. He put the M&M into that function and out came negative one M&Ms!

“That’s not supposed to happen!” cried Pickle. He looked closely at the label and saw that Baby Pickle had erased the minus sign and replaced it with a times sign.*

*I guess Baby Pickle has learned to read and write since his adventures in the original negative M&M story.

Pickle put his negative M&M into the −2 function and got three negative M&Ms. Then he went back to the gate. But now the function said, “If x has positive M&Ms, then x can come through.” Baby Pickle had changed it so that the gate would not let Pickle through.

Pickle looked at his other functions. They were all labeled with a minus two! But Pickle could see that Baby Pickle had written the labels so he didn’t believe that the functions were really −2 functions. He decided to test them out.

Pickle put one of his negative M&Ms into one of the mystery functions and negative two M&Ms came out. Then he put those two negative M&Ms back into the function and negative four M&Ms came out. He tried putting three negative M&Ms in and negative six M&Ms came out.

“Aha!” cried Pickle. “This must be a ×2 function! But it’s not giving me positive M&Ms because I only have negative M&Ms to put into it.”

Pickle tried the second mystery function to see if it would change his negative M&Ms into positive M&Ms. He put four negative M&Ms into the function, but only two negative M&Ms came out.

“Well, that’s going in the right direction,” thought Pickle. “Maybe this is a +2 function.”

Pickle put one negative M&M into the function, and half of a negative M&M came out. He put that half of a negative M&M back into the function, and a quarter of a negative M&M came out. He put that quarter of a negative M&M into the function and a teeny-tiny eighth of a negative M&M came out. It was so small that it fell on the floor and got lost in the carpet.

“This seems like some kind of ÷2 function,” said Pickle. “I don’t think this function is going to give me any positive M&Ms.”

Pickle tried putting a negative M&M into his last function. Out came a regular M&M!

“I did it!” cried Pickle. “I got a positive M&M!”

He put the positive M&M back into the function and out came three M&Ms. When he put those three M&Ms in, five M&Ms came out. Pickle decided that it must be a +2 function. He fixed the labels on all his functions so he wouldn’t get them confused.

Then Pickle remembered that he was trying to get into the playroom. He went back to the baby gate and tried to go through, but Baby Pickle had changed the function again! Now it said, “If x has more than 100 M&Ms, then x can come through.”

Pickle knew what to do. He put his five M&Ms into the +2 function, and out came seven M&Ms. He put those seven M&Ms back into the function and got nine M&Ms.

“This is going to take a long time,” thought Pickle. “I wonder if there’s a faster way.”

Then Pickle had an idea. He put his nine M&Ms into the ×2 function and got 18 M&Ms. He put those back into the ×2 function and got 36 M&Ms. He put those back into the ×2 function and got 72 M&Ms. He put those back into the ×2 function and got 144 M&Ms.

Now he had more than 100 M&Ms! He went back to the gate, but it did not let him go through. Baby Pickle had changed the function again and this time it said, “If x has 143 M&Ms, then x can go through.”

Pickle was so upset that he almost started to cry. He would never be able to get through the gate if Baby Pickle kept changing the filter function.

“Baby Pickle!” he yelled. “You took all my M&Ms and now you keep changing the function so I can’t come in and get them back.”

Baby Pickle looked at Pickle. Then he looked at Pickle’s 144 M&Ms. Then he started to giggle.

This made Pickle realize that he already had a lot of M&Ms! Why was he still trying to get into the playroom? He put the M&Ms into his empty M&M bag. Now the bag was so full of M&Ms that he couldn’t close it!

“Ok, Baby Pickle, I guess I have enough M&Ms.” Pickle was starting to feel better. “You can keep the ones you took. But next time you want some of my M&Ms, you have to check first because they belong to me!”

Baby Pickle and the Negative M&Ms

A fun thing about telling a story orally is that you don’t need to worry about how to illustrate it. You get a lot more flexibility when you can ignore pesky implementation details, like what a function looks like or how a baby monster truck with wheels instead of hands can pick up tiny objects from the floor.

I’ve been telling Pickle stories to Luke (age 5) for over a year now. Three-year-old Nathan likes to listen and recently he’s been requesting his own stories. But does he ask for Pickle stories? No, he wants Baby Pickle stories. It’s been fun telling stories from Baby Pickle’s point of view. In these stories, I like to incorporate concepts that are relevant for Nathan (like size and shape) now that I know he’s listening more actively.

Click here to read all the Pickle stories in chronological order.

One morning Baby Pickle woke up so early in the morning that everybody else was still sleeping. And Baby Pickle had an idea. He opened up the door to the closet and found some functions. He tried to read the labels to see what they did, but Baby Pickle didn’t know how to read yet. He decided to test out the functions to see what they did. But then he heard a noise that sounded like Mommy Pickle waking up, so Baby Pickle grabbed some functions and rushed into the playroom with them. He hid with them under the bed.

While Baby Pickle was hiding under the bed, he felt something on the floor poking into him. He picked it up and looked at it, and it was an M&M! Baby Pickle was happy because he liked to eat M&Ms. So he ate it. But then Baby Pickle was sad because he didn’t have any more M&Ms.

“I should have put it into a ×100 function,” thought Baby Pickle. “Then I would have one hundred M&Ms and I could eat one and still have one hundred!”

Then Baby Pickle searched around under the bed in case there was another M&M under there. He searched and he searched. He felt something and pulled it out. It was small like an M&M but it was not hard; it was squishy. It was a raisin.

Baby Pickle didn’t want a raisin so he put it back under the bed and kept searching. He felt another small thing. It was small and hard like an M&M, but it was not round. It was a little white cube from the Cuisenaire rods. “That’s a one,” thought Baby Pickle. “I want one M&M.” So Baby Pickle put the one next to him and kept searching.

He searched and he searched. He felt something small and squishy; that was the raisin again. He searched some more. Then he found something small and hard and round, just like an M&M! 

He pulled it out to look at it. It was not an M&M, it was a tiny Lego piece. He put it in his mouth in case it tasted like an M&M, but it did not taste sweet like an M&M. Then Baby Pickle remembered that he was not supposed to put Legos in his mouth so he spit it out on the floor. Baby Pickle could put Lego candy in his mouth, but he could not put regular Legos in his mouth.

Baby Pickle searched some more. He found something small and squishy, but he knew it wasn’t an M&M. He knew that it was just the raisin. He found something big and round. Baby Pickle got excited. Maybe it was a giant M&M! He took it out from under the bed.

It was a yellow ball. Baby Pickle licked it but it didn’t taste like an M&M, it just tasted like yellow paint. Baby Pickle liked the taste of yellow paint so he put the ball in his trunk and kept searching.

He found something small and squished it to see if it was hard or soft. It was soft because it was a raisin. Then he found another small thing. When he squished it, it was hard. And it was also round. It had a smooth surface, just like an M&M. Baby Pickle pulled it out to look at it, and it was a green M&M!

Baby Pickle was really happy because his favorite color was green. He had an M&M! He was so excited to eat it that he put it in his mouth. Oh no! Baby Pickle remembered his plan just in time. He spit the M&M back out so that he could put it into a ×100 function and get one hundred M&Ms. 

Baby Pickle looked at all his functions. He couldn’t remember what the ×100 function looked like. He put his functions in a row and counted them: one, two, three. Three functions.

Baby Pickle put his M&M into the first function to see what happened, and out came two M&Ms. Baby Pickle decided that the first function was a +1 function.

Then he put one of the M&Ms into the second function, but no M&Ms came out! Baby Pickle shook the function to see if something was stuck in there, but still, nothing came out.

Baby Pickle decided that the second function was a garbage function. He did not want a function that would take away his M&Ms.

Baby Pickle started to put his other M&M into the third function to figure out what it would do, but then he stopped himself. What if this function was also a garbage function? If he put his last M&M in there, it would get lost and he would never be able to eat it!

Baby Pickle decided to put the garbage function into the third function. If it got lost in there, that would be okay because he didn’t want that garbage function. But when Baby Pickle put the garbage function into the third function, one hundred garbage functions came out. The third function was a ×100 function!

Baby Pickle put his last M&M into it and out came one hundred M&Ms! Baby Pickle started to eat them. He was so excited. When he got low on M&Ms, he just put another one into the ×100 function. Then he had a nice big pile again.

After a while Baby Pickle was not hungry for M&Ms any more. He thought about what to do next and then he remembered all the garbage functions. What could he do with those? He decided to build the longest function ever by sticking them all together so that whatever came out of one function would go right into the next function. He put two garbage functions together. Then he stuck another one on. He kept sticking on functions. Pretty soon he had to take everything outside because his new function was getting too big to fit in the playroom.

He went into the backyard with all his functions and his leftover M&Ms and kept sticking garbage functions together. Finally he had one hundred garbage functions all stuck together.

Baby Pickle thought this was very funny. It was so long! And it didn’t do anything except throw away garbage!

Baby Pickle decided to test his function by putting an M&M into it. Out came negative ninety-nine M&Ms!

Baby Pickle was so surprised to see those negative M&Ms come out of his giant function. He realized that it must be a minus function. He put one M&M into the ×100 function, and one hundred M&Ms came out. Then he put those one hundred M&Ms into his giant function and zero M&Ms came out.

He made one hundred new M&Ms and added one more to get one hundred one. When he put those one hundred one M&Ms into the giant function, just one M&M came out.

Baby Pickle took one of the garbage functions off of the giant function and put three M&Ms into it, and two M&Ms came out. It was not a garbage function, it was a −1 function!

So when he put one hundred −1 functions together, he had a −100 function. And when he put just one M&M into his −100 function, ninety-nine negative M&Ms came out.

Baby Pickle had never seen negative M&Ms before. He was very excited to have negative M&Ms. This gave him another idea. He would make a surprise for his big brother Pickle!

Baby Pickle knew that Pickle had a bag of M&Ms in the tall cabinet next to the fridge. Pickle had told Baby Pickle not to eat any of them, because they were his special M&Ms. He had won them as a prize at the last big monster truck race. He had put them way up high in the tall cabinet so that Baby Pickle wouldn’t be able to reach them.

But Baby Pickle knew a way to get up there to those M&Ms, and he wasn’t going to eat them. He was going to give Pickle a surprise.

Baby Pickle got a chair from the dining room and pushed it into the kitchen. Then he got the stool from the bathroom and put it on top of the chair. Then he climbed up the chair and onto the stool and stretched himself up as far as he could reach. He grabbed Pickle’s bag of M&Ms and took it out of the cabinet.

Baby Pickle took all his negative M&Ms and put them into the bag. Then he shook it all up. Pickle would be so surprised when he saw all those negative M&Ms mixed in with his regular M&Ms!

Just then, Pickle came into the kitchen. He had woken up and heard a noise that sounded like a chair dragging on the floor.

“Baby Pickle,” he cried, “What are you doing with my M&Ms? I told you to leave those M&Ms alone.”

“I’m doing a surprise for you,” said Baby Pickle. “I didn’t eat any of them.”

Pickle took the bag from Baby Pickle. Baby Pickle waited for the surprise. When Pickle opened the bag, he did look surprised — but he was not happy; he was mad!

“Baby Pickle!” shouted Pickle. “You did eat them. You ate them all up!” Pickle turned the bag upside-down and nothing came out.

Baby Pickle started to cry. He did not want Pickle to be mad at him! Where were all the M&Ms? Then he remembered his ×100 function. He would make the problem better by making more M&Ms for Pickle.

Baby Pickle grabbed the bag and raced outside. He put an M&M into the ×100 function and out came one hundred M&Ms. He poured them into the bag and gave it to Pickle.

“Why didn’t you just eat your own M&Ms, if you had a ×100 function to make as many as you wanted?” asked Pickle. But Baby Pickle was not listening. He was putting an M&M into the −100 function.

Baby Pickle took the ninety-nine negative M&Ms that came out of the −100 function and put them into Pickle’s bag of one hundred green M&Ms. This time he watched very carefully instead of closing the bag.

*Poof!* As soon as a negative M&M touched a regular M&M, they both disappeared. *Poof! Poof! Poof!* Pretty soon there was just one green M&M left in the bag.

Now Pickle understood what had happened to his M&Ms. He forgave Baby Pickle and they made some new M&Ms to fill up the bag again. Pickle liked them even better than the old M&Ms, because they were all green.

They also made some more negative M&Ms, but this time, they didn’t put them in the same bag!

And that’s the story of Baby Pickle and the Negative M&Ms.

Pickle and the Pickle-Salad Function

We had a blast when I first introduced the pickle-salad function a week or two ago. The best part was all the giggles I got out of Daniel every time I said the word “mayonnaise.”

Since then I’ve had to tell a salad-function story every night. Any time I start off with a different story, all I hear from Luke is “But can it also be about the pickle-salad function?” On the bright side, all these repetitions given me a change to work out all the filter function modifications to my satisfaction.

The version below has a happy ending, but most nights Pickle is just about to sink his teeth into the pickle salad when Luke chimes in with “But then the babies….” Eventually I get too sleepy and wrap up the story with poor Pickle still hungry for pickle salad.

Click here to read all the Pickle stories in chronological order.

One time Pickle was playing in the playroom when he started to get hungry. He decided to go out to the kitchen to make himself some pickle salad. But when he got to the baby gate, it would not let him go through. He looked at the filter function and saw that it said, “If x equals big, then x can NOT come through.”

“Baby Pickle!” cried Pickle. “Why do you always change the filter function?”

Pickle added to the function to make it say, “If x equals big AND x equals purple, then x can NOT come through.” Then the gate let him through, because Pickle was not purple, he was green. He went into the kitchen and got out a big bowl and a spoon, and a jar of pickles and the salad-making function. But before he could put his pickles into the function, he heard a bouncing noise coming from the playroom. Pickle decided to go see what was making that bouncing noise.

When he got to the playroom, he saw Baby Pickle playing with Baby Circle, Baby Square and Baby Triangle. They were taking turns climbing onto the dresser and jumping off onto the beanbag chair! They had a little wagon and they were jumping off with it.

Pickle tried to go stop them, but the baby gate would not let him go through! Baby Pickle had changed the filter function again. He had taken out the NOT so it said, “If x equals big AND x equals purple, then x can come through.” Pickle was not purple, so he couldn’t go through. He couldn’t even change the function because he was outside of the playroom and the function was set from the inside.

Then Pickle had an idea. He got some purple paint and painted himself purple. Then the gate let him come through. He stopped those babies from climbing on the dresser and took their wagon back to the kitchen.

Baby Pickle tried to follow Pickle through the gate but the gate would not let him go through because he was not big. So Baby Pickle changed the function to say, “If (x equals big AND x equals purple)* OR x equals baby, then x can come through.” Baby Pickle and Baby Blaze went into the kitchen and picked up the salad-making function that Pickle had put down on the counter. They put it into the wagon and raced away.

*When I’m telling the story out loud, I use pauses and emphasis rather than parentheses to communicate the order of operations. I also use thumbs-up and thumbs-down gestures when we’re evaluating the more complicated boolean expressions. This helps us keep track of which conditions are true and I use motions to show the results of the AND and OR operations.

Pickle chased them back to the playroom but before he could get through the gate, they had added a NOT so it said, “If (x does NOT equal big AND x equals purple) OR x equals baby, then x can come through.”

Pickle couldn’t change the filter function from outside the playroom. He had to figure out a different way to get in there. Meanwhile the babies got a blanket and put it into the salad-making function.

The salad-making function was made of four functions stuck together. First there was a chopping function that chopped up the blanket. When the chopped blanket came out of the chopping function, it went straight into the mayonnaise function that added mayonnaise. Then it went into the salt-and-pepper function that added salt and pepper. Finally it went into the mixing function that mixed it all up. And then, out came blanket salad!

Baby Pickle dumped the blanket salad into the Duplo bin. All the babies rushed over and started squishing the pieces of blanket and squeezing the slippery mayonnaise. Baby Pickle had not taken the Duplos out of the bin, so there were Duplos in there too. And Baby Pickle took the mixing function out of the salad-making function and used it to mix the Duplos into the blanket salad.

Pickle went outside into the backyard and tried to come into the playroom through the back door but it was locked. He went over to the window and looked inside. Baby Triangle came over to the window and waved at Pickle. He got some mayonnaise on the window and then he had an idea. Baby Triangle drew a triangle on the window with mayonnaise. Then Baby Square came over and drew a square on the window. Baby Circle drew a circle, Baby Hexagon drew a hexagon and Baby Reuleaux Triangle drew a Reuleaux triangle.

“No, no, no!” cried Pickle. “Don’t draw on the window with mayonnaise. You’re making a big mess!”

But the babies did not listen to Pickle. They kept drawing all over the window. Then Pickle noticed one shape that was missing in the window: there was no oval. He found a part of the window without very much mayonnaise and looked through. He saw Baby Oval playing with a tow truck. On the back of the tow truck was the key to the back door! The tow truck was towing it.

Pickle went back inside and came over to the baby gate. “Baby Oval, Baby Oval!” he called. “Do you like candy?”

Baby Oval came over and said, “Yes.”

“I will give you a piece of candy if you let me borrow the key.”

Baby Oval gave Pickle the key and Pickle used it to unlock the back door. Then he gave the key back to Baby Oval along with a piece of pickle candy.

(This was not an unsafe bribe because the candy was not a secret. Also, Baby Oval was not breaking any safety rules, and Pickle was not trying to cross Baby Oval’s boundaries.)

Pickle added a NOT to the filter function so it said, “If (x does NOT equal big AND x equals purple) OR x equals baby, then x can NOT come through.” Then he took the salad function away from the babies and rushed through the gate. They couldn’t come through because they were babies.

Pickle put his pickles through the salad-making function and put the pickle salad into a bowl. He got a spoon and scooped up a big spoonful of pickle salad.

Baby Pickle changed the filter function to say, “If x does NOT equal big AND x equals purple AND x equals baby, then x can NOT come through.” Then all the babies could come through because none of them were purple. They all came into the kitchen and opened their mouths wide like this: :O

Pickle said, “Okay babies, I will share my pickle salad with you.” He gave each baby a big spoonful of pickle salad and then he ate the rest himself.

And that’s the story of Pickle and the Pickle-Salad Function.

Baby Pickle and the Pickle Jars

If you’re new to Pickle stories, you might want to read them in chronological order.

Photos in the below post are purely decorative and are not meant to correspond with the train track layout described in the story.

One day Pickle had an idea for a train track. He decided to go into the playroom and build it right away.

But when Pickle tried to go into the playroom, the baby gate did not let him go through! He looked at the filter function and saw that Baby Pickle had set it to say, “If x weighs less than 100 pounds, then x can go through.”

Baby Pickle weighed one pound, so he could go through the gate. But Pickle weighed 101 pounds so he could not go through! He was mad, because he wanted to go into the playroom and build his big train track.

But then Pickle had an idea! He opened up his trunk and took out his spare tire. It weighed five pounds. Pickle rolled the spare tire through the gate, and followed it into the playroom. Without his spare tire, he only weighed 96 pounds, so the gate let him go through. After he got through the gate, he put his spare tire back into his trunk and changed the filter function so that it said, “If x weighs more than 100 pounds, then x can go through.” Then Pickle started to build his train track. He used blocks to make it go up one level.

Baby Pickle came over to the gate but it would not let him through because he did not weigh more than 100 pounds.

Baby Pickle was mad because he could see Pickle building a neat train track that went up and down on the risers. He wanted to drive a train on that train track! He sat down to think of a way to get through the baby gate. Then he had an idea!

Baby Pickle went out to the garage and found some heavy jars of pickles. Each jar weighed 20 pounds. He loaded two jars into his trunk and came over to the baby gate, but it still did not let him through! Baby Pickle only weighed 41 pounds with those two jars. He put them down next to the gate and went back to the garage for some more jars.

In the meantime, Pickle kept working on his train track. He added a section that went up two levels so it could get over the other part that just went up one level.

Baby Pickle loaded himself up with three jars of pickles and came back to the baby gate. He tried again to go through but he still wasn’t heavy enough. He only weighed 61 pounds with those three pickle jars. He put the other two jars into his trunk, but then he was so heavy that he couldn’t make himself go anywhere!

Baby Pickle took out all the jars and went to the kitchen to get himself a cheese stick while he thought about what to do next.

Pickle added another section to his train track. It went under the double-height section and then it went up some blocks until it was triple-height! Then it turned around and went back over the double-height section.

Baby Pickle was sitting in his chair eating his cheese stick when he had a really good idea. As soon as he was done with his cheese stick, he took his chair over to the baby gate. Then he tipped it over so it made a ramp.

Pickle made a long train and started driving it on his track. He drove it over the section that was one level high.

Baby Pickle rolled all five jars of pickles to the top of the ramp. Then he balanced at the very top of the ramp and loaded all five jars of pickles into his trunk.

Pickle finished driving the train on the lowest section of his big track and started driving it on the section that was two levels high. Pickle was very careful not to push his train too fast. He didn’t want his track to fall down.

Baby Pickle rolled down the ramp. He rolled faster and faster. He rolled all the way down the ramp and through the baby gate. With five jars of pickles in his trunk, he weighed 101 lbs. and the gate let him go through!

Pickle’s train got to the section of track that was three levels high. Pickle pushed it very very carefully around the bend.

Booom! Baby Pickle came crashing into Pickle’s track. He knocked down the one-level track. Then he knocked down the two-level track. Then he knocked down the three-level track. Then Baby Pickle knocked down Pickle’s train and then he knocked down Pickle!

“Ouch!” said Pickle. “Hey, you knocked down my track!”

Baby Pickle looked at the broken track and started to cry. Now he couldn’t drive his train on Pickle’s big train track!

Pickle gave him a hug. “It’s okay, Baby Pickle. We can build it again. Do you want to help? You have to be very careful.”

Baby Pickle tried to go over to the pile of track pieces but he couldn’t go anywhere because his trunk was full of pickle jars and he weighed 101 pounds.

And that’s the story of Baby Pickle and the Pickle Jars.

Pickle and the Closet of Functions

This story is a sequel to Pickle and the Boolean Logic Baby Gate. I told it to Luke and Nathan at bedtime, and Luke chimed in with his own additions that sometimes changed the course of the story from how I was intending it to go.

One day Pickle was looking in his closet to see if he could find his snow boots. He searched and he searched, and while he was searching, he found a function. He looked all over the function but he couldn’t find any label that would tell what the function did. It was a mystery function.

“I’ll put a banana in it,” said Pickle. So he put a banana into the function and out came a peeled banana and a banana peel.

“That’s interesting,” said Pickle. Then he put an orange into the function, and out came a peeled orange and an orange peel. Pickle tried putting in an apple, and out came a peeled apple and an apple peel.

“This function would be a very good function for the kitchen,” said Pickle. He put a label on it that said “Peeling Function” and he put it in the kitchen.

Then Pickle remembered that he still hadn’t found his snow boots, so he went back to the closet to look for them again. After a little while, he found another function. It also did not have a label.

“I wonder what this function does,” said Pickle. He put a red Duplo into the function, but nothing came out.

“Oh no!” said Pickle, “I don’t have my Duplo anymore. I should not put special things in this function. I should test it with something that’s not important, like a piece of trash.”

Pickle took the function outside to the trash can and found a big pizza box. He put the pizza box into the function and out came one hundred pizza boxes!

“No, no, no!” said Pickle. “That’s not what I wanted at all!”

“This is a bad function,” said Pickle, and he put the function into the trash can and went back into the house to keep looking for his snow boots.

After Pickle went inside, a squirrel found the function in the trash can. She took it out and put a nut in it, and out came one hundred nuts. The squirrel was very happy about this so she took the function back to her nest. Then she got to work burying her one hundred nuts so she could eat them later.

Meanwhile Pickle was looking all over the place in the closet, trying to find his snow boots. Instead, he found another function.

“What does this function do,” asked Pickle. “How should I test it?”

He didn’t want to test it with a Duplo in case the Duplo went away forever, but he put a Duplo in it anyway and out came one hundred Duplos. 

“Wow,” said Pickle. “This is an amazing function. I definitely want to keep this function, but I had better put it in a safe place. If Baby Pickle gets it, he might put in a dirty diaper.”

So Pickle put the function up on a high shelf and went back to the closet. As soon as Pickle was out of the room, Baby Pickle climbed up to the shelf and got the function. He put a dirty diaper into it and out came one hundred diapers — and the worst thing is, they were poopy diapers!

Baby Pickle put another dirty diaper into the function, and another one, and another one. He kept putting dirty diapers into the function and it made a pile of dirty diapers that got bigger and bigger.

“What’s that poopy smell?” wondered Pickle.

Baby Pickle got tired of smelling that poopy smell, so he went outside and left the poopy diapers in the playroom.

Then Daddy Pickle and Mommy Pickle came and cleaned up the diapers. They went outside to the backyard and brought down the function the squirrel had hidden in her nest. When they looked at it, they saw that it had a conditional statement on the side.

The conditional statement was: “If x equals trash, then output x times one hundred. Otherwise, output nothing.”

“That’s backwards,” said Mommy Pickle. “We need to switch it around.” So they switched the conditional statement around so that it said, “If x equals trash, then output nothing. Otherwise, output x times one hundred.”

Then they put all the dirty diapers into the function and nothing came out. But when the squirrel put nuts into the function, they still came out. They came out both ways because they were not very good objects, and not very bad objects.

Meanwhile, Pickle was still in the closet looking all over for his snow boots, but he was not finding them anywhere. All he found was his rainboots and then he found another mystery function.

Pickle put a ball into the function and out came a snowball. Then he put a tire into the function and out came a snow tire. Then he put bran flakes into the mystery function, and out came snowflakes.

“I know what to do,” said Pickle. He put his rainboots into the function and out came snow boots.

But they were made of snow!