Skip to content

Commit 712dab1

Browse files
author
ybenchekroun
authored
Create ice_cream_parlor.py
1 parent 4392557 commit 712dab1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

HashMaps/ice_cream_parlor.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# https://www.hackerrank.com/challenges/icecream-parlor/problem
2+
3+
def whatFlavors(costs, money):
4+
cost_dict = {}
5+
for i, cost in enumerate(costs):
6+
if money - cost in cost_dict:
7+
return (cost_dict[money - cost] + 1 , i + 1)
8+
else:
9+
cost_dict[cost] = i
10+
11+
money = 6
12+
costs = [1, 3, 4, 5, 6]
13+
whatFlavors(costs, money)

0 commit comments

Comments
 (0)