Skip to content

Commit d603b1e

Browse files
author
[FacuFalcone]
committed
Upgrade to version v1.5.008
1 parent 29ddcaa commit d603b1e

4 files changed

Lines changed: 46 additions & 33 deletions

File tree

Combination/Combinations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def SimpleCombinatory():
3030
"""
3131
try:
3232
print("\n###### Simple Combinatory #######")
33-
print("C(n, k)")
33+
print("###### C(n, k) ######")
3434
numberN = int(input("Value for n: "))
3535
numberK = int(input("Value for k: "))
3636
n = F(numberN)
3737
k = F(numberK) * F((numberN - numberK))
3838
print(f"Simple Combination of C({numberN},{numberK}): ")
39-
print(f"Formula: {n}! / ( {k}! * ({n-k})! )")
39+
print(f"Formula: {numberN}! / ( {numberK}! * ({numberN-numberK})! )")
4040
print(f"Result: {n/k}")
4141
except Exception as e:
4242
print(f"Error: {e}")
@@ -49,7 +49,7 @@ def CompoundCombinatory():
4949
"""
5050
print("\n###### Compound Combinatory #######")
5151
try:
52-
print("C'(n, k)")
52+
print("###### C'(n, k) ######")
5353
numberN = int(input("Value for n: "))
5454
numberK = int(input("Value for k: "))
5555
n = numberN + numberK - 1
6.19 MB
Binary file not shown.

Main.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,26 @@
2626
from Variation import Variations as V
2727

2828

29+
def PrintMenu() -> int:
30+
"""
31+
Prints in console the menu of the app.
32+
"""
33+
option = 0
34+
print("Select an option from the ones below")
35+
print("1 - Simple Permutation.\n2 - Simple Variation.\n3 - Simple Combination.")
36+
print("4 - Compound Permutation.\n5 - Compound Variation.\n6 - Compound Combination.")
37+
try:
38+
option = int(input("Your option: "))
39+
except Exception as e:
40+
print(f"Error: {e}")
41+
finally:
42+
return option
43+
44+
2945
def SelectOperation(option: int):
46+
"""
47+
Receives an integer to do any of the 6 functions of the combinatorial calculus.
48+
"""
3049
try:
3150
if option == 1:
3251
P.SimplePermutation()
@@ -45,45 +64,31 @@ def SelectOperation(option: int):
4564
except Exception as e:
4665
print(f"Error: {e}")
4766

48-
def PrintMenu()->int:
49-
"""
50-
Prints in console the menu of the app.
51-
"""
52-
option = 0
53-
print("Select an option from the ones below")
54-
print("1 - Simple Permutation.\n2 - Simple Variation.\n3 - Simple Combination.")
55-
print("4 - Compound Permutation.\n5 - Compound Variation.\n6 - Compound Combination.")
56-
try:
57-
option = int(input("Your option: "))
58-
except Exception as e:
59-
print(f"Error: {e}")
60-
finally:
61-
return option
6267

6368
def CleanScreen():
6469
"""
6570
Cleans the screen.
6671
"""
6772
return lambda: os.system('cls')
6873

74+
6975
def CombinatorialCalculus():
7076
appName = "Combinatorial Calculus"
71-
version = "v1.5.007"
77+
version = "v1.5.008"
7278
author = "Facu Falcone"
7379
continueExec = "y"
74-
75-
while continueExec=='y':
80+
81+
while continueExec == 'y':
7682
print(f"\n## {appName} {version} by {author}. ##\n")
7783
print("#################################")
78-
79-
option = PrintMenu()
80-
SelectOperation(option)
84+
85+
SelectOperation(PrintMenu())
8186

8287
print("#################################")
83-
continueExec = input("\nWrite Y to do another calculus or N to close the app: ")
88+
print("Write Y to do another calculus or N to close the app.")
89+
continueExec = input("\nYour option (Y/N): ")
8490
continueExec = continueExec.lower()
8591
CleanScreen()()
86-
8792

8893

8994
if __name__ == '__main__':

Permutation/Permutations.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def SimplePermutation():
2929
"""
3030
print("\n###### Simple Permutation #######")
3131
try:
32-
print("Pn = n!")
32+
print("###### Pn = n! ######")
3333
numberN = int(input("Value for n: "))
3434
try:
3535
fact = F(numberN)
@@ -50,25 +50,33 @@ def ComposedPermutation():
5050
dividend = 1
5151
listCases = []
5252
formulaTop = "("
53-
formulaBot = ""
53+
formulaBot = " "
54+
5455
print("\n###### Compound Permutation #######")
5556
try:
56-
print("P n1, n2 ..nn = (n1 + n2 + ..nn) / (n1)! (n2)! ..(nn)!")
57+
print("###### P n1, n2 ..nn = (n1 + n2 + ..nn) / (n1)! (n2)! ..(nn)! ######")
5758
number = int(input("Amount of Variables: "))
5859
for case in range(1, number+1):
5960
listCases.append(int(input(f"Value for {case}° n: ")))
6061
sumCases += listCases[case-1]
6162

6263
for case in listCases:
6364
dividend *= F(case)
64-
formulaBot += str(case) + "!"
65+
formulaBot += str(case) + "! "
66+
6567
if listCases.index(case) == (len(listCases)-1):
66-
formulaTop += str(case) + ")!"
68+
formulaTop += str(case) + ")!\n"
6769
else:
6870
formulaTop += str(case) + " + "
6971

70-
print(f"Compound Permutation of {number} variables: ")
71-
print(f"Formula: {formulaTop} / {formulaBot}")
72-
print(f"Result: {F(sumCases) / dividend}")
72+
middle = "-"*(4*number) + "\n"
73+
fullFormula = formulaTop + middle + formulaBot
74+
print(f"\n#### Compound Permutation of {number} variables: ")
75+
print(f"#### Formula: ")
76+
print(fullFormula)
77+
print(f"#### Result: {F(sumCases) / dividend}")
7378
except Exception as e:
7479
print(f"Error: {e}")
80+
#(1 + 2 + 5 + 6 + 7)!
81+
#--------------------
82+
# 1! 2! 3! 5! 6! 7!

0 commit comments

Comments
 (0)