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

Non-programmers

Slide 1 / 9

On the last page, we learned that, by using Saya’s lunchbox, we can reproduce the “Plus 1” feature of a mathbox.

In a mathbox, we use

In a lunchbox, we use

Saya’s lunchbox to reproduce

the “Plus 1” feature .

Saya’s lunchbox to reproduce

the “Plus 1” feature .

1

Lunchbox that can be converted to

1

13

2

23

1

That’s it for the quick review. Let’s continue.

Looking for some other page?

Slide 2 / 9

Looks like Saya noticed something strange.

Hey guys, can you take a look at this?

First, this lunchbox can be converted to , right?

’s with on the bottom-right

→ Can be converted to

→ Can be converted to

1

1

Yes, but what about it?

What do you think happens if I combined it with my lunchbox that reproduces the “Plus 1” feature ?

If I combined it with my lunchbox that

reproduces the “Plus 1” feature …

reproduces the “Plus 1” feature …

1

1

1

1

13

2

23

1

What happens

when you run it?

when you run it?

Well, because it calculates …

It should become a lunchbox that can be converted to , right?

Should become a lunchbox

that can be converted to …?

that can be converted to …?

Let’s run it to check.

Slide 3 / 9

Press Run . You can also skip to the end.

1

1

1

1

13

2

23

1

Unfortunately: I won’t be able to convert this lunchbox into a mathbox.

Can’t convert this into a mathbox

12

2

1

Why not? Because it doesn’t follow this pattern.

There needs to be one

on the top-right and some number of

’s on the bottom-right

on the top-right and some number of

’s on the bottom-right

One

Some’s

There needs to be exactly one on the top-right, but there are two in this case.

There needs to be exactly one

on the top-right, but there are two.

That’s why it cannot be converted to a mathbox.

on the top-right, but there are two.

That’s why it cannot be converted to a mathbox.

12

2

1

Hmm… what’s going on? Last time, it worked…

Slide 4 / 9

Let me tell you what’s going on.

First, let’s label each item with t, l, m, or r.

Label items as t l m r

1

tt

1

tt

1

l

1

m

m

13

r2

rr

23

r

1

Notice that: The sandwiches are labeled as either t or m.

The sandwiches are labeled as

either t or m

either t or m

1

tt

1

tt

1

l

1

m

m

13

r2

rr

23

r

1

Now, here’s the secret: If the same item exists in both t and m, then the result changes.

In this case, is in both t and m.

That’s why it couldn’t calculate .

tm

If the same item exists in both t and m,

then the result changes

then the result changes

Really? Why does that happen?

Let me use a simple example to explain.

Slide 5 / 9

Here’s a simple example that illustrates my point:

- The left lunchbox has different t and m.
- The right lunchbox has the same t and m (both ).

Let’s see what happens to each lunchbox.

t and m

are different

are different

2

1

tl

12

m

r

2

1

tl

12

m

r

2

1

tl

12

m

r

2

1

tl

12

The bottom two

are different

are different

1

1

t and m

are the same

are the same

2

1

tl

12

m

r

2

1

tl

12

m

r

2

1

tl

12

m

r

2

1

tl

12

The bottom two

are the same

are the same

1

1

We’re not done yet, but did you notice something?

The bottom two are different on the left, but they’re the same on the right.

Yes. And if we continue until the end…

- On the left, the hamburger (which was r) will remain.
- On the right, the chicken (which was t) will remain.

1

tl

1

r

1

tl

1

1

tl

1

r

1

tl

1

r

1

tl

1

So this is before and after:

Before:

t and m

are different

t and m

are different

2

1

tl

12

m

r

After:

Before:

t and m

are the same

t and m

are the same

2

1

tl

12

m

r

After:

So, this illustrates that: If the same item exists in both t and m, then the result changes.

tm

If the same item exists in both t and m…

The result changes

Slide 6 / 9

Let’s go back to the previous example that could NOT calculate .

This failed because was in both t and m, which caused the result to change.

Couldn’t calculate

because was in both t and m,

which caused the result to change.

because was in both t and m,

which caused the result to change.

1

tt

1

tt

1

l

1

m

m

13

r2

rr

23

r

1

Hmm… then what should we do in this case? Just give up?

Let’s not give up. I think there’s a way.

But… what can we do?

Let’s ask Minion if we can change the rule to fix this.

Minion: I’d like to ask you for a favor. Can we please add a special rule?

Special rule? What do you mean by that?

I’d like the following special rule to apply in cases like this:

- If the same item appears in both t and m…
- Change one of them to something different.

tm

Can we use this special rule?

If the same item appears in

both t and m,

change one of them to

something different

If the same item appears in

both t and m,

change one of them to

something different

Sure, that’s fine.

Thank you!

What… you can change the rule just like that?

Slide 7 / 9

Let’s add the following special rule:

- If the same item appears in both t and m…
- It will automatically change conflicting t’s to something different.

t

If the same item appears in

both t and m,

it will automatically change

conflicting t to something different.

both t and m,

it will automatically change

conflicting t to something different.

So, if there’s the same item in both t and m… (in this case: )

Warning: Same item in t m

1

tt

1

tt

1

l

1

m

m

13

r2

rr

23

r

1

Because of this special rule: The sandwiches in t will now become something else.

t

The sandwiches in t

will now become something else.

will now become something else.

What does it become then?

It will turn into a random food item that’s not yet used.

In this case, it becomes fried potatoes .

tt

It turns into fried potatoes ,

a random food item

that’s not yet used.

a random food item

that’s not yet used.

Special rule:

Change t to something else

Change t to something else

1

tt

1

tt

1

l

1

m

m

13

r2

rr

23

r

1

on the top became .

And t and m no longer overlap now.

Yes. Let’s continue then. Press Run :

1

tt

1

tt

1

l

1

m

m

13

r2

rr

23

r

1

Yay! It became a lunchbox that can be converted to .

’s with on the bottom-right

→ Can be converted to

→ Can be converted to

12

2

1

That means it calculated successfully.

Yes. Let’s summarize what we just did.

Slide 8 / 9

What we learned: If you combine Saya’s lunchbox which reproduces the “Plus 1” feature …

Saya’s lunchbox which reproduces

the “Plus 1” feature

the “Plus 1” feature

13

2

23

1

…with the following lunchbox which can be converted to …

’s with on the bottom-right

→ Can be converted to

→ Can be converted to

1

1

Then: There will be the same item () in both t and m.

Because of this, if we don’t do anything, it won’t be able to calculate .

is in both t and m

1

tt

1

tt

1

l

1

m

m

13

r2

rr

23

r

1

Because there’s a conflict in

t and m,

If we don’t do anything, it won’t be

able to calculate

t and m,

If we don’t do anything, it won’t be

able to calculate

However, the special rule applies in this case:

- If the same item appears in both t and m…
- It will automatically change conflicting t’s to something different.

Warning: Same item in t m

1

tt

1

tt

1

l

1

m

m

13

r2

rr

23

r

1

Special rule:

Change t to something else

Change t to something else

1

tt

1

tt

1

l

1

m

m

13

r2

rr

23

r

1

By doing this, it will be able to calculate .

I get it, but I don’t know if I can remember to use this rule…

Don’t worry: This special rule will appear starting from the next page, but you don’t have to memorize it. It will just happen automatically.

You just need to know that these rules exist, and you should be fine.

Slide 9 / 9

Anyway: We figured out how to reproduce the “Plus 1” feature .

As you promised, give us our mathboxes back!

Grr…

Will the villagers get their mathboxes back? Let’s see on the next page.

Go to Next PageContinue to Intermediate 5

1 more intermediate level left!