Skip to content

Commit

Permalink
Merge pull request hackerearthclub#145 from ScifiDeath/BikeRace
Browse files Browse the repository at this point in the history
Bike race
  • Loading branch information
iamjaspreetsingh authored Oct 16, 2018
2 parents cf23561 + b61b9bb commit 68667b7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions SOLUTIONS/BikeRace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("-f", dest="filepath", required=True)
args = parser.parse_args()
data = args.filepath

with open(data) as reader:
next(reader)
N = M = L = 0
riders = []
for line in reader:
line = line.strip().split()
if len(line) == 2:
riders.append(list(map(lambda x: int(x), line)))
elif len(line) == 3:
N, M, L = list(map(lambda x: int(x), line))
else: # assumes no empty lines
i = 0
while sum([x[0] for x in riders if x[0] >= L]) < M:
riders = [[x[0] + x[1], x[1]] for x in riders]
i += 1
print(i)
riders = []
i = 0
while sum([x[0] for x in riders if x[0] >= L]) < M:
riders = [[x[0] + x[1], x[1]] for x in riders]
i += 1
print(i)

0 comments on commit 68667b7

Please sign in to comment.