-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjim_orders.py
40 lines (22 loc) · 888 Bytes
/
jim_orders.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Solutions of the challenge proposed on Hackerrank at https://www.hackerrank.com/challenges/jim-and-the-orders/problem
import math
import random
import re
import sys
def jimOrders(orders):
total = [] # list of lists
for i in range(len(orders)):
a = orders[i][0]+orders[i][1]
total.append([i+1,a]) # the first element is the customer number, the second element is prep time + order number
total = sorted(total, key=lambda x: x[1]) # sort the previous list according to ascending order
ord = [] # array in which customer numbers will be stored
for i in range(len(total)):
ord += [total[i][0]]
return ord
if __name__ == '__main__':
n = int(input())
orders = []
for _ in range(n):
orders.append(list(map(int, input().rstrip().split())))
result = ''.join(map(str, jimOrders(orders)))
print(result)