Advanced 3
Hello! This is page 15 of the course called “Y Combinator for Non-programmers”. If you just got here, click here to read from the beginning.

Y Combinator for
Non-programmers

Advanced 4: Y Combinator

Slide 1 / 13

The most complicated lunchbox ever

In this page, I’ll show you the most complicated lunchbox ever.

The most complicated lunchbox ever

It will be hard, but you don’t need to understand everything. Even if you don’t fully get it, you should keep reading.

Looking for some other page?

Advanced 3·
·Advanced 5
Slide 2 / 13

On the previous page…

On the previous page, Saya came up with a lunchbox that might be able to reproduce the “Repeat” feature .

Can we reproduce this lunchbox that uses
the “Repeat” feature
…with this lunchbox?
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1

According to Saya, the above lunchbox will repeat three times, just like when using the “Repeat” feature .

If you run this lunchbox…
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1
Just like the “Repeat” feature ,
it repeats three times on
123
3
2
1
And calculates

Let’s see if this is actually true.

Slide 3 / 13

What steps does it go through?

On this page, we’ll run the lunchbox that I came up with, and see what steps it goes through.

When we run this…
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1
What steps does it go through…
…before it becomes the same as
the “Repeat” feature ?
123
3
2
1

Yeah, we need to see what happens in between the beginning and the end.

Slide 4 / 13

Let’s run it!

Ok, let’s do it.

  • We’ll pause several times in between for explanation.
  • You don’t have to follow all the steps with your eyes. Just glance over it. Save your eyes!
  • If you can’t wait, press Skip to the next stopping point →”.

Press Run !

2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1

It’s so complicated…

It’s not too bad if you look carefully.

Take a look at this yellow section in the middle.

Take a look at this yellow section
in the middle
1245
5
3
12
2
1
1234
4
3
2
1
34
12
2
1
1234
4
3
2
1
2
1

Let’s ignore this section for now. We don’t need to worry about it until later.

We’ll replace it with the “Ignore for Now” sign:

Ignore the yellow section for now
1234
4
Ignore
for Now
3
2
1

It’s much simpler now.

Now, let’s take a look at the bottom section of the “Conditional” feature :

Because is , which is NOT zero, it chooses .

Check if is
1234
4
Ignore
for Now
3
2
1
Because is NOT , it chooses
1234
4
Ignore
for Now
3
2
1
123
3
Ignore
for Now
2
1
Slide 5 / 13

The second time

We’ll now un-ignore the section we ignored earlier:

Un-ignore the section we ignored earlier
123
3
Ignore
for Now
2
1
134
4
2
12
2
1
1234
4
3
2
1
23
12
2
1
1234
4
3
2
1
1

Let’s continue. Press Run !

134
4
2
12
2
1
1234
4
3
2
1
23
12
2
1
1234
4
3
2
1
1

Oh! This yellow section is exactly the same as the one we ignored last time.

This yellow section is exactly the same
as the last time
123567
7
6
4
12
2
1
1234
4
3
2
1
45
12
2
1
1234
4
3
2
1
3
2
1

Yes: This yellow section has appeared again.

Hmm… interesting.

Let’s ignore this section again:

Let’s ignore the yellow section again
123456
6
5
Ignore
for Now
4
3
2
1

I’ve highlighted the differences from the last time in yellow below. Take a look.

Last time
1234
4
Ignore
for Now
3
2
1
This time
123456
6
5
Ignore
for Now
4
3
2
1

Pay attention to these two differences in particular:

  • was before, but it’s now .
  • There’s now a icon on the bottom.

I see, the number in went from to .

So it decreased by one.

The number in decreased by one

Maybe: If we continue, maybe the number in will become next?

Let’s see if that turns out to be true.

Slide 6 / 13

The third time

Let’s continue. We’ll un-ignore the section we ignored earlier.

Un-ignore the section we ignored earlier
123456
6
5
Ignore
for Now
4
3
2
1
123567
7
6
4
12
2
1
1234
4
3
2
1
45
12
2
1
1234
4
3
2
1
3
2
1

Press Run !

123567
7
6
4
12
2
1
1234
4
3
2
1
45
12
2
1
1234
4
3
2
1
3
2
1

Again: The middle section is exactly the same as before. So we’ll ignore this again:

This yellow section is exactly the same
as the last time…
12346789
9
8
7
5
12
2
1
1234
4
3
2
1
56
12
2
1
1234
4
3
2
1
4
3
2
1
So let’s ignore it for now
12345678
8
7
6
Ignore
for Now
5
4
3
2
1

Let’s compare it with the previous iteration again.

I’ve highlighted the differences from the last time in yellow below.

Last time
123456
6
5
Ignore
for Now
4
3
2
1
This time
12345678
8
7
6
Ignore
for Now
5
4
3
2
1

Pay attention to these two differences in particular:

  • was before, but it’s now .
  • Another icon was added to the bottom.

I’m seeing the pattern…

The number in has changed from to to . It’s decreasing by one.

is decreasing by one

So, maybe: will become next?

Let’s check.

Slide 7 / 13

The fourth and the last time

We’re almost done. I just un-ignored the section we ignored earlier.

Press Run !

12346789
9
8
7
5
12
2
1
1234
4
3
2
1
56
12
2
1
1234
4
3
2
1
4
3
2
1

Again: The middle section is exactly the same as before. So we’ll ignore this again:

This yellow section is exactly the same
as the last time…
123457891011
11
10
9
8
6
12
2
1
1234
4
3
2
1
67
12
2
1
1234
4
3
2
1
5
4
3
2
1
So let’s ignore it for now
12345678910
10
9
8
7
Ignore
for Now
6
5
4
3
2
1

Let’s compare it with the previous iteration again.

I’ve highlighted the differences from the last time in yellow below.

Last time
12345678
8
7
6
Ignore
for Now
5
4
3
2
1
This time
12345678910
10
9
8
7
Ignore
for Now
6
5
4
3
2
1

finally became .

Exactly! So it now chooses , which is .

Check if is
12345678910
10
9
8
7
Ignore
for Now
6
5
4
3
2
1
It chooses ,
which is
12345678910
10
9
8
7
Ignore
for Now
6
5
4
3
2
1
123
3
2
1

Wow! It’s now exactly like using the “Repeat” feature .

Yes. It then calculates , so…

The final result is .

123
3
2
1
The final result is

That’s it! Let’s summarize what we’ve seen so far.

Slide 8 / 13

Summary of the steps it goes through

Here’s what happened:

2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1
After some more steps,
is
1234
4
Ignore
for Now
3
2
1
After some more steps,
is
123456
6
5
Ignore
for Now
4
3
2
1
After some more steps,
is
12345678
8
7
6
Ignore
for Now
5
4
3
2
1
After some more steps,
is
12345678910
10
9
8
7
Ignore
for Now
6
5
4
3
2
1
Because is ,
It chooses ,
which is
12345678910
10
9
8
7
Ignore
for Now
6
5
4
3
2
1
It repeats three times…
123
3
2
1
The final result is
Slide 9 / 13

Reproducing the “Repeat” feature

So, we confirmed that: If you run the original lunchbox, it repeats three times on .

If you run this lunchbox…
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1
Just like the “Repeat” feature ,
it repeats three times on
123
3
2
1
And calculates

Therefore, this is exactly the same as this mathbox that uses the “Repeat” feature :

Exactly the same as this

So: The above mathbox with the “Repeat” feature can be reproduced by the lunchbox we used on this page.

We can reproduce this mathbox with
the “Repeat” feature
…using this lunchbox
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1
Slide 10 / 13

Reproducing any mathbox with the “Repeat” feature

Now, here’s the important part. This mathbox has:

  • on the top, and…
  • is repeated times.
on the top, and
is repeated times

To reproduce this, we needed to put and on these two places:

We needed to put and
on these two places:
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1

Now, here’s a question: How can we reproduce this mathbox that calculates ?

How can we reproduce this mathbox?

Maybe: We change the previous lunchbox to use and instead, like this?

Put and in these two places
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1

Exactly! That’s how you reproduce using a lunchbox.

We can reproduce this mathbox with
the “Repeat” feature
…using this lunchbox
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1

For example: If you wanted to reproduce this mathbox that calculates

To reproduce this mathbox
that calculates

You can reuse the earlier lunchbox: Just use for and for .

Instead of and
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1
Use and
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1

If you run the above lunchbox, it will repeat six times on :

If you run this…
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1
It repeats six times on
123456
6
5
4
3
2
1
And calculates

I see…

Slide 11 / 13

We reproduced the “Repeat” feature !

Congratulations! You reproduced the “Repeat” feature successfully.

Yay!

We reproduced the “Repeat” feature

By the way, here’s an additional question:

Can you figure out how to reproduce this mathbox that repeats instead of ?

How can we reproduce this mathbox
that repeats instead of ?

Hmm… maybe: We use the same lunchbox as the last time, but use instead of ?

Instead of
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1
Use
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1

Correct! By doing so, you can reproduce a mathbox that repeats :

You can reproduce this mathbox…
…with this lunchbox
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1

I see…

Slide 12 / 13

Y Combinator

Hmm… it’s very interesting that we can reproduce the “Repeat” feature using a lunchbox.

Yeah. And now, I want to talk about an important point.

Take a look at the bottom half of the lunchbox that reproduces :

Take a look at the bottom half of the lunchbox
that reproduces :
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1

Now, take a look at the bottom half of the lunchbox that reproduces :

Take a look at the bottom half of the lunchbox
that reproduces :
2
1
1234
4
3
2
1
12
1
12
2
1
1
12
2
1

Notice that: Both cases have this bottom half in common.

Both cases have this bottom half in common
1
12
2
1
1
12
2
1

Right, but what’s so special about it?

In fact: This bottom half is what makes reproducing the “Repeat” feature possible.

This bottom half is what makes reproducing
the “Repeat” feature possible
1
12
2
1
1
12
2
1

I see. So this lunchbox is necessary for reproducing the “Repeat” feature

Yes. And this lunchbox has a special name, actually.

What’s the name?

It’s called “Y Combinator”.

This lunchbox is called “Y Combinator
1
12
2
1
1
12
2
1

Y Combinator”? That’s a strange name…

But it’s really interesting to think that, such a simple lunchbox (with only two kinds of food items) can reproduce the “Repeat” feature .

It’s like magic!

Indeed!

Y Combinator is magical!

Note: There are other lunchboxes that are called “Y Combinator”. If you’re curious, press “Continue reading” below. (It’s optional.)

Slide 13 / 13

Will we get the “Repeat” feature back?

After successfully reproducing the “Repeat” feature , the villagers are now demanding the devil to return it:

We reproduced the “Repeat” feature using a lunchbox.

Now, give it back to us!

Grr…

Will the villagers get it back? Check on the next page.

Go to Next PageContinue to Advanced 5
1 more advanced level left!
Advanced 3
Japanese Site (日本語版) · About this Site · Twemoji