Combination, Permutation, Factorial

Introduction

whatdescription
combination In mathematics, a combination is a selection of items (from a set) where the order in which the objects are selected does not matter.

For example, given three letters (A,B,C), there are three combinations of two that can be drawn from this set:
(A,B), (A,C), and (B,C). (Note: A,B is the same as B,A)
factorial In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers
less than or equal to n.

For example: 5! = 1*2*3*4*5
permutation In mathematics, a permutation is a selection of items (from a set) where the order in which the objects are selected does matter.

For example, there are six permutations (orderings) of the set {A,B,C}: written as tuples, they are
(A,B,C), (A,C,B), (B,A,C), (B,C,A), (C,A,B), and (C,B,A).
setA set is a collection of distinct, well-defined objects.

Check out
from itertools import permutations, combinations_with_replacement

Project #1

Create an interactive program

  1. Displays the definitions above (or make better,more understandable ones)
  2. Ask the user to select Combination, Permutation, Factorial
  3. if combination selected
    • ask the user to enter a set of unique elements (numbers, letters, words, ...)
    • define a reasonable set of elements that can be entered (n < 8?)
    • display all of the combinations
  4. if permutation selected
    • ask the user to enter a set of unique elements (numbers, letters, words, ...)
    • define a reasonable set of elements that can be entered (n < 8?)
    • display all of the permutations
  5. if factorial selected
    • ask the user to enter an integer
    • define a reasonable limit (n < 1000?)
    • display the factorial
  6. loop

Project # 2

Modify the program created in Project #1. Ask the user if they want to see the intermediate steps?

For example if factorial, display something like...

1*2 = 2 1*2*3 = 6 1*2*3*4 = 24 1*2*3*4*5 = 120 ... ... ...

If the output is to big, display the first n (n < 10?) and maybe the last one.

Project #3

Describe what "sampling with and without replacement" means. Which of the above definitions describe "with" and "without"?

Which of the above definitions describe dealing a set of random (shuffled) cards (52)? How many different hands are there when dealing 5 cards?

FYI - Other Interesting Factorial Functions

Links

Combination (Wikipedia)

Permutation (Wikipedia)

Factorial (Wikipedia)

Combinations and Permutations - What's the Difference?