Jim and the Orders

  • + 1 comment

    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()))])])
    
    • + 2 comments

      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]
      
      • + 0 comments

        Your code as one line.

        [i[0] for i in sorted(enumerate(orders, 1), key = lambda x: sum(x[1]))]

      • + 0 comments

        how does lambda x:x[1][0] + x[1][1] work ?