repl.it
@oliverosz/

WineTasting

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import math

def nCr(n, r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)

# returns the number of wines, from which the sedative one can be determined by the given number of tasters, in the given hours
# it is assumed that tasting a wine takes no time, and the sedative kicks in in under 1 hour
def wines(tasters, hours):
  if tasters is 0 or hours is 0:
    return 1
  result = 0
  for awake in range(tasters + 1):
    result += nCr(tasters, awake) * wines(awake, hours - 1)
  return result

print(wines(3, 3))