Intermediate 4
Hello! This is page 11 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

Intermediate 5: Subtract One

Slide 1 / 8

What we got back is…

Ok, fine! Since you got the question right, I’ll return your mathboxes.

Here it is!

I’ll return this!

Wait… that’s it?

This is a mathbox with the “Plus 1” feature , but…

What about the ones with the “Minus 1” feature or the “Repeat” feature ?

The “Minus 1”
feature
The “Repeat”
feature

I can’t return those yet.

The only ones I’m returning for now are mathboxes with the “Plus 1” feature .

Wait, what? No way!

But… you promised to return the mathboxes!

I said I’ll return the mathboxes…

But I never promised to return all of the features.

Nooo! You’re a liar!

Well, I’m a devil after all.

Looking for some other page?

Intermediate 4·
·Advanced 1
Slide 2 / 8

What do we need to do?

So… what do we need to do to get all of the features back?

Well… on the previous pages, I asked you to reproduce the “Plus 1” feature using a lunchbox.

Reproduce the “Plus 1” feature
Using a lunchbox
1
Lunchbox that can be converted to
1
13
2
23
1

So, if you want the “Minus 1” feature or the “Repeat” feature back…

You must reproduce them using lunchboxes.

The “Minus 1”
feature
Reproduce with
a lunchbox
The “Repeat”
feature
Reproduce with
a lunchbox

What!

We struggled to reproduce using a lunchbox. I don’t know if we can reproduce or

If you can’t do it, you won’t get them back.

But… we need the “Minus 1” feature and the “Repeat” feature !

Without these features, we won’t be able to calculate subtractions or add/subtract large numbers.

I guess we have to try…

Slide 3 / 8

A hint for reproducing the “Minus 1” feature

Don’t worry: Minion will give you a hint on how to reproduce those features using lunchboxes.

Yes. Let me give you a hint for reproducing the “Minus 1” feature .

How can we reproduce
the “Minus 1” feature ?

To reproduce the “Minus 1” feature using a lunchbox, you need to fill each icon on the following lunchbox with a specific pattern.

If you fill each icon
with a specific pattern, you can
reproduce the “Minus 1” feature
3
2
1
12
2
1
123

Hmm… it looks really complicated.

It’s complicated, but if you do it correctly, you can use it to subtract from a number:

Combine with a lunchbox
that can be converted to
1
Lunchbox that can be converted to
1
3
2
1
12
2
1
123
If you run it,
it will become a lunchbox
that can be converted to
Lunchbox that can be converted to

Now, try to guess what goes in each icon.

But… this lunchbox looks so complicated.

I don’t think we can do it…

Slide 4 / 8

Saya’s lunchbox, again

The villagers were struggling, but it looks like Saya’s got an idea:

Hey guys, I think I have an idea.

What…? Saya, did you figure it out?

I don’t know if this is correct, but come take a look.

I filled each icon…
3
2
1
12
2
1
123
…as follows
3
2
1
12
2
1
123

Hmm… I don’t think Saya’s going to be correct twice in a row, but let’s try anyway.

Ok. Let’s first combine it with a lunchbox that can be converted to .

If the result is , that means it correctly calculates , right?

We want it to calculate
Combine Saya’s lunchbox with
a lunchbox that can be converted to
1
Lunchbox that can be converted to
1
3
2
1
12
2
1
123
If it becomes a lunchbox that can be
converted to , success.
Otherwise, failure

Let’s run it with this lunchbox that can be converted to .

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

Here’s what happens if you combine them:

Combine with a lunchbox
that can be converted to
1
1
1
1
3
2
1
12
2
1
123

Ok, let’s run it.

Slide 5 / 8

What happens if you run it?

Let’s run the above lunchbox. We’ll run it for a while and pause for an explanation.

Press Run . You can also skip to the next stopping point.

1
1
1
1
3
2
1
12
2
1
123

This is so complicated. My eye hurts!

You don’t have to follow all the steps with your eyes. Just glance over it. Save your eyes!

Hey guys, take a look! t and m are both pizza now.

Warning: Same item in t m
1
t
t
l
1
12
r
m
2
r
r
1

The special rule applies, and the pizza in t changes to something else, right?

Press Next to apply the special rule.

Warning: Same item in t m
1
t
t
l
1
12
r
m
2
r
r
1

The special rule just applied, and the pizza in t became sushi .

Now, let’s run it until the end.

1
t
t
l
1
12
r
m
2
r
r
1

The resulting lunchbox can be converted to .

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

So, by using Saya’s lunchbox,

  • A lunchbox that can be converted to
  • Becomes a lunchbox that can be converted to .
Combine Saya’s lunchbox with
a lunchbox that can be converted to
1
Lunchbox that can be converted to
1
3
2
1
12
2
1
123
The result is a lunchbox that can be
converted to
Lunchbox that can be converted to

Because it calculated , it’s a success!

Yay!

Wow…

Slide 6 / 8

Can it calculate ?

Well: Just because you were able to calculate , it doesn’t necessarily mean that your lunchbox has reproduced the “Minus 1” feature .

It needs to be able to subtract 1 from any number.

It needs to be able to subtract 1 from
any number.

That’s a good point…

For example: Can your lunchbox calculate ?

Combine Saya’s lunchbox with
a lunchbox that can be converted to
1
Lunchbox that can be converted to
1
3
2
1
12
2
1
123
If it becomes a lunchbox that can be
converted to , success.
Otherwise, failure

Let’s try it. Here’s a lunchbox that can be converted to .

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

Let’s combine it with my lunchbox:

Combine Saya’s lunchbox with
a lunchbox that can be converted to
1
12
2
1
1
3
2
1
12
2
1
123

Ok, let’s run it.

  • We won’t pause in the middle this time. It’ll go all the way to the end.
  • You don’t have to follow all the steps with your eyes. Just glance over it.
  • It will take some time, so if you can’t wait, press Skip to the end →”.

Press Run !

1
12
2
1
1
3
2
1
12
2
1
123

The resulting lunchbox can be converted to .

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

So, by using Saya’s lunchbox,

  • A lunchbox that can be converted to
  • Becomes a lunchbox that can be converted to .
Combine Saya’s lunchbox with
a lunchbox that can be converted to
1
Lunchbox that can be converted to
1
3
2
1
12
2
1
123
The result is a lunchbox that can be
converted to
Lunchbox that can be converted to

That means it calculated , so it’s a success!

Yay!

Grr…

Slide 7 / 8

We reproduced The “Minus 1” feature !

Saya is correct. Her lunchbox does reproduce the “Minus 1” feature !

The “Minus 1” feature can be
reproduced…
Using Saya’s lunchbox
1
Lunchbox that can be converted to
1
3
2
1
12
2
1
123

Awesome!

Wow… Saya, you’re a genius!

No, I’m just lucky. But anyway, we showed that the “Minus 1” feature can be reproduced using a lunchbox.

A mathbox that uses the “Minus 1” feature
can be “reproduced” using a lunchbox

Note: Just like the last problem, this problem was very hard. We didn’t expect you to answer it.

As long as you can look at the answer and understand why it’s correct, you’ll be fine.

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

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

Slide 8 / 8

That’s it for the intermediate levels!

Hey devil, we’ve reproduced the “Minus 1” feature using a lunchbox!

(Although it was Saya who did all the work…)

Grr…

As promised, give us the “Minus 1” feature back!

Fine, I will give it back to you!

Yay!

We got the “Minus 1” feature back!