You are viewing a single comment's thread. Return to all comments →
Crazy 1-liner in Python3. :D
print(*(lambda s: sorted(range(1, len(s) + 1), key=lambda i: s[i - 1]))(tuple(sum(map(int, input().split())) for _ in range(int(input())))))
print(*(q[0]+1 for q in sorted([(i, sum(map(int, input().split()))) for i in range(int(input()))], key=lambda x: (x[1], x[0]))))
Nice! I was curious if anyone else had posted one. I tried to make mine somewhat readable (for a one-liner).
print(*[customer for (time, customer) in sorted([(sum(map(int,input().split())), i+1) for i in range(int(input()))])])
def jimOrders(orders): orders = list(enumerate(orders)) orders.sort(key=lambda x:x[1][0] + x[1][1]) return [i[0]+1 for i in orders]
def jimOrders(orders):
orders = list(enumerate(orders)) orders.sort(key=lambda x:x[1][0] + x[1][1]) return [i[0]+1 for i in orders]
Your code as one line.
[i[0] for i in sorted(enumerate(orders, 1), key = lambda x: sum(x[1]))]
how does lambda x:x[1][0] + x[1][1] work ?
woah
dude u are god of geeks:)
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Jim and the Orders
You are viewing a single comment's thread. Return to all comments →
Crazy 1-liner in Python3. :D
Nice! I was curious if anyone else had posted one. I tried to make mine somewhat readable (for a one-liner).
Your code as one line.
[i[0] for i in sorted(enumerate(orders, 1), key = lambda x: sum(x[1]))]
how does lambda x:x[1][0] + x[1][1] work ?
woah
dude u are god of geeks:)