I'm bored and was trying to explain Trig IDs to a student. One analogy I came up with was trying to make 25 cents from pennies and nickels. If you know that a nickel is five cents, and a penny is one, you can make 25 cents.
And then I got bored so I made this:
Twenty-five cents:
penny, nickel, dime, quarter.
= 25p
= 20p + 1n
= 15p + 2n
= 10p + 3n
= 5p + 4n
= 5n
= 3n + 1d
= 1n + 2d
= 1q
Recently, my brother had asked me what is the process for writing out all the combinations of elements in sets? For example...
Set A consists of these elements:and I want to write out every combination possible; so:
a1, a2, a3.
Set B:
b1, b2.
Set C:
c1, c2, c3, c4.
a1, b1, c1;What is the process my brain goes through?
a1, b1, c2;
a1, b1, c3;
a1, b1, c4;
a1, b2, c1;
a1, b2, c2;
a1, b2, c3;
a1, b2, c4;
a2, b1, c1;
a2, b1, c2;
a2, b1, c3;
a2, b1, c4;
a2, b2, c1;
a2, b2, c2;
a2, b2, c3;
a2, b2, c4;
a3, b1, c1;
a3, b1, c2;
a3, b1, c3;
a3, b1, c4;
a3, b2, c1;
a3, b2, c2;
a3, b2, c3;
a3, b2, c4.
My brother wanted to know the process, because he was writing a computer program, and wanted to make it shorter--fewer lines of code. I'm not a programmer, so I don't know/remember exactly what his code says, but it does something like this:
For every a1,Something terrible like that. And he doesn't just have A, B and C; he has about fourteen of these, so his code gets pretty dang long!
for every b1,
write out an element of Set C.
For every a1,
for every b2,
write out an element of Set C.
...
I thought; and thought; and thought about this, but I couldn't simplify it.
And then, I realized, no matter how many (few) elements in each set, there will be more rows than columns (assuming it's organized this way). So, instead of filling out the "chart" one row at a time, maybe it would be shorter to fill it out one column at a time! You'd just have to tell your program how many times to write each element before moving to the next element in the set (eg: how many times to write "a1" before writing "a2", etc), and when to stop, I guess, if programs require that.
But what is the method to write all the combinations of coins needed to make some amount of money? Wooo, Canadian monies.
Man am I tired,
--Charissa
No comments:
Post a Comment