So this blog wouldnt contain any code, just pure math that I think might help with programming + I wouild recmmend knowing math because know good math allow you to save A LOT of code. + This is my blog to compile what I've learned, I hope that when you read this you would learn something.
- Theory:
- definition n! = n * (n-1) * (n-2) * .... * 1
- amount of ways to permute a sequence of n numbers is n!, this can be proven by fixing the first element which we can take n element as the first element, then it would be a sub problem, permutating n-1 elemnts, so we get n! = (n-1)! * n -> we have proven for all n
- amount of ways to permute k elements out of n elements is (n!/ (n — k)!), this is simple because we can use the same proof as n!, but we have and ending at n — k.
- amount of ways to of picking k elements out of n elements where order doesen't matter is (n! / (n-k)!k!), this is simple, we continue from permutating k elements out of n elements, and then because the k element could be permutate in k! (first proof), we can just divide by k! so we fix the order without overcounting the permutations.
- The amount of ways to permute a sequence of duplicate elemnts is (n! / (c1! * c2! * c3!...)) where c stand for each character amount, why this work, for each subset of characters, we could permute then c1! ways, because its duplicate, all permutation the same so we want to divide by c1! so they dont count duplicates.
Problems: 1. How many distinguishable arrangements are there of 1 brown tile, 1 purple tile, 2 green tiles, and 3 yellow tiles in a row from left to right? (Tiles of the same color are indistinguishable.) - Use the word arranging theory I said above - (1 + 1 + 2 + 3)! / 3! / 2! = 7! / 3! / 2! = 420 2. A child builds towers using identically shaped cubes of different colors. How many different towers with a height of 8 cubes can the child build with 2 red cubes, 3 blue cubes, and 4 green cubes? (One cube will be left out.) + This is simple test, casework: + if red cubes is left out, 8! / (3! * 4!) = 280 + if blue cub is left out, 8! / (2! * 2! * 4!) = 420 + if green cube is left out, 8! / (2! * 3! * 3!) = 560 + answer = 280 + 420 + 560 = 1260 ways. 3. A license plate in a certain state consists of 4 digits, not necessarily distinct, and 2 letters, also not necessarily distinct. These six characters may appear in any order, except that the two letters must appear next to each other. How many distinct license plates are possible? + Consider the permutations in letter and numbers + for the numbers we have 4 numbers, and foe each number it could be either from 1 to 10 + so the amount of permutation for the numbers is 10^4 + for each character we have 26 options, so we 26^2 + for the amount of different license plate, the positions I could choose for the 2 characters is (6 — 2 + 1) because it could be entirely to the left of the numbers answer = 10^4 * 26^2 * 5 = 33,800,000
- At a gathering of 30 people, there are 20 people who all know each other and 10 people who know no one. People who know each other hug, and people who do not know each other shake hands. How many handshakes occur within the group?
- Total amount of Handshake is C(30, 2)
- Amount of handshake/hug that people who know each other do is C(20 2)
- we can caculate by hand as below (30 * 29) / 2 — (20 * 19) / 2 => 15 * 29 — 190 = 435 — 190 = 245
- In a table tennis tournament every participant played every other participant exactly once. Although there were twice as many right-handed players as left-handed players, the number of games won by left-handed players was 40% more than the number of games won by right-handed players. (There were no ties and no ambidextrous players.) What is the total number of games played?
- This problem compared to the previous problem is more obscure but we could solve by putting limits on N could be
- Consider the number of right player = 2n, left player = n;
- Ratio of games win, left player : right player -> 7 : 5
- total amount of games = C(3n, 2)
- we get this inequality -> 5/12 * C(3n,2) >= C(2n, 2) -> 2n(2n-1) <= 5/12 * 3n(3n-1)
-
24(n-1) <= 15(3n-1)
-
48n — 24 <= 45n — 15
-
3n <= 9 => n <= 3 After getting n <= 3, we can just test n for every value = {1,2,3} and find the valid one.




