forked from adrianeyre/codewars
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBulk.py
More file actions
16 lines (16 loc) · 636 Bytes
/
Bulk.py
File metadata and controls
16 lines (16 loc) · 636 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def bulk(arr):
p = 0; c = 0
if arr!=[]:
for i in range(0,len(arr)):
items = arr[i].split(",")
for item in range(0,len(items)):
unit = items[item].split("g ")
units = int(unit[0])/100
protein = units * food[unit[1]][0]
carbohydrate = units * food[unit[1]][1]
fat = units * food[unit[1]][2]
p += protein
c += (protein * 4) + (carbohydrate * 4) + (fat * 9)
if p % 1 == 0: p = int(p)
if c % 1 == 0: c = int(c)
return "Total proteins: "+str(p)+" grams, Total calories: "+str(c)