Skip to content

Commit

Permalink
first commit of movie weekend
Browse files Browse the repository at this point in the history
  • Loading branch information
innovationchef committed May 13, 2016
1 parent 29c6745 commit 94fb062
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
55 changes: 55 additions & 0 deletions movie_weekend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
def getmin(listing, rate_list):
x = -1
k = 1
maxm = -1
difference = 0
# for p in listing: print p
while k<len(listing):
if listing[x] == listing[x-k]:
if cmp(rate_list[x], rate_list[x-k]) > 0:
if rate_list[maxm]>=rate_list[x]:
continue
else:
maxm = -1
elif cmp(rate_list[x], rate_list[x-k]) < 0:
temp_max = x-k
old_difference = difference
difference = rate_list[x-k] - rate_list[x]
if difference>old_difference :
maxm = x-k
else:
maxm = temp_max
elif cmp(rate_list[x], rate_list[x-k]) == 0:
maxm = x-k
else :
return(len(listing) + maxm + 1)
k += 1
return(len(listing) + maxm + 1)

# for k in range(0, len(listing)):


testcases = int(raw_input())
if(testcases<1 or testcases>5):
exit()
for i in range(0, testcases):
n = int(raw_input())
if(n<1 or n>100):
exit()
length_list = map(int,raw_input().split(" "))
rating_list = map(int,raw_input().split(" "))
if(len(length_list)<1 or len(length_list)>100 or len(rating_list)<1 or len(rating_list)>100):
exit()
product = 0
product_list = []
j = 0
while j<n:
product = length_list[j]*rating_list[j]
product_list.append(product)
j += 1
print(getmin(product_list, rating_list))
# for p in product_list: print p




2 changes: 1 addition & 1 deletion tricoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
summation = []
j = 0
while sum <= N :
sum = sum + j
sum = (j*(j+1))/2
summation.append(sum)
j = j+1
print(j-2)
Expand Down

0 comments on commit 94fb062

Please sign in to comment.