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

# .css-1nqcc75{color:#ec407a;}Advanced 2:Reproducing the “Conditional” Feature

Slide 1 / 9

### Reproducing the “Conditional”feature

The villagers were trying to reproduce the “Conditional” feature using a lunchbox.

Reproduce the “Conditional” feature
…using a lunchbox

Let’s review again: If is , then the result is

If is
in becomes the final result

And: If is NOT , then the result is .

If is NOT
in becomes the final result

Hmm… how can I reproduce this using a lunchbox?

Looking for some other page?

Slide 2 / 9

### Saya’s Idea

As usual, Saya seems to have an idea.

Hey, can you take a look at this?

Reproduce the “Conditional” feature
Using a lunchbox.
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234

Wow, thanks Saya. Let’s see if this actually works.

Slide 3 / 9

### If you use for

First: Let’s try the case for :

• On the bottom section that says “Lunchbox that can be converted to ,
• Let’s put a lunchbox that can be converted to .
On the bottom section that says
“Lunchbox that can be converted to
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234
Use a lunchbox
that can be converted to
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234

We will use this lunchbox that can be converted to :

’s with on the bottom-right
→ Can be converted to

Let’s try running it. Press Run !

Use a lunchbox
that can be converted to
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
1234

The result is a lunchbox that can be converted to .

Lunchbox that can be converted to

Right. And this is the same as using the “Conditional” feature , right?

If we use the “Conditional” feature :

If we use for
The final result is

If we use Saya’s lunchbox:

If we use for
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234
The final result is
Lunchbox that can be converted to

Right, in both cases, if we start with , the final result is .

Slide 4 / 9

### If we use for

Next: Let’s try the case for NOT . So we’ll use instead.

• On the bottom section that says “Lunchbox that can be converted to ,
• Let’s put a lunchbox that can be converted to .
On the bottom section that says
“Lunchbox that can be converted to
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234
Use a lunchbox
that can be converted to
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234

We will use this lunchbox that can be converted to :

’s with on the bottom-right
→ Can be converted to
1
1

Let’s try running it. Press Run !

Use a lunchbox
that can be converted to
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
1234
1
1

This time, the result is a lunchbox that can be converted to .

Lunchbox that can be converted to

Right. Again, this is the same as using the “Conditional” feature , right?

If we use the “Conditional” feature :

If we use for
The final result is

If we use Saya’s lunchbox:

If we use for
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234
The final result is
Lunchbox that can be converted to

Right, in both cases, if we start with , the final result is .

Slide 5 / 9

### So Saya’s right?

So… it looks like Saya’s lunchbox successfully reproduced the “Conditional” feature ?

Reproduce the “Conditional” feature
Using a lunchbox.
Question: Is this the correct way to
reproduce it?
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234

Let’s do a final check, just in case.

Final check?

Slide 6 / 9

### Fill all of

As a final check:

• Let’s fill all of with some random numbers, and…
• See if my lunchbox can reproduce it.

Hmm, what do you mean by that?

For example:

• On the following mathbox, if we fill each of with
• Then the final result would be .
If we fill each of
With …then,
Because is
The final result is ,
which was in

Let’s try the same thing with my lunchbox, and see if the result is also .

• I will also use for , and…
• If we run it and the final result is just like the above, it’s a success!
In Saya’s lunchbox…
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234
Use for
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234
If it becomes a lunchbox that can be
converted to , then success

I see, if this works, we can be pretty sure that Saya’s lunchbox has reproduced the “Conditional” feature correctly.

Let’s check.

Slide 7 / 9

### Let’s check!

So I filled each of with lunchboxes that can be converted to .

Use for
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234
Fill with lunchboxes that can be
converted to
4
12
2
1
3
1
1
2
1
1234

Let’s run it. Press Run !

4
12
2
1
3
1
1
2
1
1234

The result is a lunchbox that can be converted to .

’s with on the bottom-right
→ Can be converted to
1
1

The result is , which is the same as using the “Conditional” feature .

If we use the “Conditional” feature :

The result is

If we use Saya’s lunchbox:

4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234
The result is also
Lunchbox that can be converted to

So it’s a success!

Yay! Saya, you’re awesome!

Slide 8 / 9

### Summary

Good job, Saya. You’re correct!

You have successfully reproduced the “Conditional” feature .

The “Conditional” feature
…can be reproduced by
Saya’s lunchbox
4
Lunchbox that can be converted to
3
Lunchbox that can be converted to
2
1
Lunchbox that can be converted to
1234

Yay!

So, we now know that: The “Conditional” feature can be reproduced using a lunchbox.

The “Conditional” feature
can be reproduced using a lunchbox

Note: There are other lunchboxes that can reproduce the “Conditional” feature . Saya’s lunchbox is not the only solution.

If you’re curious, press “Continue reading” below. (It’s optional.)

Slide 9 / 9

### But what aboutthe “Repeat”feature ?

I understand that we can reproduce the “Conditional” feature , but…

What we really need to do is to reproduce the “Repeat” feature .

Repeat
times
Reproduce with
a lunchbox
Repeat
times
Reproduce with
a lunchbox

Right, but remember what I said on the last page:

The “Conditional” feature is related to the “Repeat” feature .

The “Conditional” feature
is related to
the “Repeat” feature

Therefore, because you were able to reproduce the “Conditional” feature using a lunchbox…

You’re now very close to reproducing the “Repeat” feature as well.

Because we reproduced
the “Conditional” feature
using a lunchbox…
We’re now very close to reproducing
the “Repeat” feature

Hmm… ok, can you explain more?

We don’t even know how these two features are related…

Go to Next PageContinue to Advanced 3

### Before you take a break…

Before you go: I’d really appreciate it if you could retweet the following tweet before closing this page.

If you have a question or a comment: Please reply to the above tweet with a screenshot, or email me at shu@chibicode.com. You can also discuss this on Hacker News.

If you’re a programmer:

To keep reading this course: Press the button below!

Go to Next PageContinue to Advanced 3