Skip to content

Commit f791672

Browse files
author
[FacuFalcone]
committed
First Commit Combinatorial Calculus
1 parent 9d98508 commit f791672

17 files changed

Lines changed: 553 additions & 0 deletions

File tree

Combination/Combinations.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2021 [FacuFalcone]
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
from Permutations.Factorial import Factorial as F
24+
25+
26+
def SimpleCombinatory():
27+
"""
28+
Calculate the simple combination of K elements from N total elements.
29+
Only Nature is important.
30+
"""
31+
try:
32+
print("\n###### Simple Combinatory #######")
33+
print("C(n, k)")
34+
numberN = int(input("Value for n: "))
35+
numberK = int(input("Value for k: "))
36+
n = F(numberN)
37+
k = F(numberK) * F((numberN - numberK))
38+
print(f"Simple Combination of C({numberN},{numberK}): ")
39+
print(f"Formula: {n}! / ( {k}! * ({n-k})! )")
40+
print(f"Result: {n/k}")
41+
except Exception as e:
42+
print(f"Error: {e}")
43+
44+
45+
def CompoundCombinatory():
46+
"""
47+
Calculate the simple combination of K elements from N total elements, being able to repeat.
48+
Only Nature is important.
49+
"""
50+
print("\n###### Compound Combinatory #######")
51+
try:
52+
print("C'(n, k)")
53+
numberN = int(input("Value for n: "))
54+
numberK = int(input("Value for k: "))
55+
n = numberN + numberK - 1
56+
k = F(numberN - 1) * F(numberK)
57+
print(f"Compound Combination of C'({numberN},{numberK}):")
58+
print(f"Formula: ({numberN} + {numberK} - 1) / ({numberN} - 1)!{numberK}!")
59+
print(f"Result: {F(n)/k}")
60+
except Exception as e:
61+
print(f"Error: {e}")

Combination/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2021 [FacuFalcone]
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.

Main.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2021 [FacuFalcone]
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
from Permutation import Permutations as P
24+
from Combination import Combinations as C
25+
from Variation import Variations as V
26+
27+
28+
def SelectOperation(option: int):
29+
try:
30+
if option == 1:
31+
P.SimplePermutation()
32+
elif option == 2:
33+
V.SimpleVariation()
34+
elif option == 3:
35+
C.SimpleCombinatory()
36+
elif option == 4:
37+
P.ComposedPermutation()
38+
elif option == 5:
39+
V.CompoundVariation()
40+
elif option == 6:
41+
C.CompoundCombinatory()
42+
except Exception as e:
43+
print(f"Error: {e}")
44+
45+
46+
def CombinatorialCalculus():
47+
appName = "Combinatorial Calculus"
48+
version = "v1.2.0"
49+
author = "Facu Falcone"
50+
print("Select an option from the ones below")
51+
print("1 - Simple Permutation.\n2 - Simple Variation.\n3 - Simple Combination.")
52+
print("4 - Compound Permutation.\n5 - Compound Variation.\n6 - Compound Combination.")
53+
try:
54+
option = int(input("Your option: "))
55+
SelectOperation(option)
56+
except Exception as e:
57+
print(f"Error: {e}")
58+
finally:
59+
print(f"\n## {appName} {version} by {author}. ##\n")
60+
61+
62+
if __name__ == '__main__':
63+
CombinatorialCalculus()

Media/img/CCF.png

8.61 KB
Loading

Media/img/CPF.png

12.9 KB
Loading

Media/img/CVF.png

4.2 KB
Loading

Media/img/SCF.png

7.79 KB
Loading

Media/img/SPF.png

4.35 KB
Loading

Media/img/SVF.png

5 KB
Loading

Media/img/menu_app.png

4.55 KB
Loading

0 commit comments

Comments
 (0)