Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
npjd committed Oct 10, 2021
1 parent cd611e6 commit 2d8c28d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions CCC/studentCouncilBreakfast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
pink = int(input())
green = int(input())
red = int(input())
orange = int(input())

moneyNeeded = int(input())

minimun = moneyNeeded
combinations =0
used =[]

def recursion(pc,gc,rc,oc):
global pink,green,red,orange,moneyNeeded,minimum,combinations,used
if pc*pink + gc*green + rc*red + oc*orange == moneyNeeded and [pc,gc,rc,oc] not in used:
combinations +=1
minimum = min(pc+gc+rc+oc,moneyNeeded)
used.append([pc,gc,rc,oc])
return
elif pc*pink + gc*green + rc*red + oc*orange < moneyNeeded:
recursion(pc+1,gc,rc,oc)
recursion(pc,gc+1,rc,oc)
recursion(pc,gc,rc+1,oc)
recursion(pc,gc,rc,oc+1)

recursion(0,0,0,0)
print(used)
print(combinations)
print(minimum)

0 comments on commit 2d8c28d

Please sign in to comment.