-
Notifications
You must be signed in to change notification settings - Fork 0
Programming
Saibaba Vinayakaya Namaha! Saraswati devi
Susan had a great day at work.
Her co-workers admired her new shoe and she was pumped about it.
Her day was otherwise pretty relaxed.
Fixed a bug in a code base and attended the weekly women's meeting.
As the clock strikes 4, her boss walks into her office and gives her a problem to solve.
She thinks about the problem. It is indeed interesting.
She has to calculate the number of ways a person can select k items from a collection of n items.
This is going to help the business a lot.
It is already 5 and she has to head back home.
At home, she is still thinking of her problem and her husband walks in.
She makes both of them coffee and they talk about their day at work.
Normal stuff.
Luckily for Susan, her husband Michael is a math teacher at a local high school.
She asks him how she can figure out how she can solve this issue she has.
Now Micheal is a great teacher.
He makes his students think.
He takes her to her wardrobe.
Michael: Sweets, we are going to take a trip to New Zealand.
M: Here i want you to choose 4 of your shoe.
She has 23 pairs of shoe.
Susan: Are you serious? Are we really going to New Zealand?
S: I am going to buy new shoe.
Micheal replies to her smiling :
M: I expected this.
M: Honey, i am just trying to make you think about your problem.
M: Say we were going on a trip and you had to choose 4 of your 23 pairs of shoe, then you could choose any 4. Right?
S: Right.
M: So this is a common day to day problem.
M: It is a choice problem.
M: If i had to figure out how many ways you could choose your shoe, i would write down all the choices on paper.
M: It would be tedious, for sure, but we will know all the various ways you could select.
M: One of all those "combinations" would be your selection.
S: Hmm..
M: Let us take a simpler case.
M: Imagine you have 2 free movie tickets. And you had to use it up in a week.
S: Okay.
M: And there were 5 movies playing. What would you do?
S: Well, i would look at all the movies and i would choose two and go and watch the movies.
M: That is great.
M: How many ways can you do that?
S: What do you mean - how many ways?
M: Haha. Good question. Come here.
Takes her to the study room, so he can use the drawing board.
M: Instead of having real movie names that are playing at the theater, let us say the movies that are playing now, this week at our theater are a,b,c,d,e.
M: Take this pencil and just write down all the pair of movies you could go to.
S: Okay!
Scribbles.
S: Okay. I have the list ready.
M: Good. Show me.
a,b
a,c
a,d
a,e
b,c
b,d
b,e
c,d
c,e
d,e
M: This is great. 10 ways.
S: Yes.
M: Okay. Now i want you to pay attention to what i say.
S: Okay.
M: What we have done here is take a real world problem and tried to think about it in a general way.
M: In fact, a,b,c,d,e could be anything. They could be movies or songs in a playlist or games at a store or anything else.
S: Oh! I see. That is really clever.
Micheal smiles.
M: Now let us come back to our shoe selection problem.
S: Oh my god. I cannot write down all the combinations sweetie.
M: Don't worry. I wont ask you to.
M: Mathematics gives us an ability to generalize such problems.
M: Let us say there are n things. How can we select r things from these n things?
S: Oh i see.
M: This is called Combination in math.
M: I want you to go and read about it on Wikipedia. And then devise your program.
S: Okay! Thanks so much honey. You are such a good teacher.
Gives Micheal a hug and a kiss.
Armed with this knowledge, Susan understood the problem she was trying to solve.
She could map it to the context at work.
She also understood that she had to generalize her code.
Susan loves functions.
She also loves the fact of having a set of functions at her disposal.