알고리즘 문제/CodeWar
New Cashier Does Not Know About Space or Shift
BEstyle
2022. 10. 25. 13:17
DESCRIPTION:
Some new cashiers started to work at your restaurant.
They are good at taking orders, but they don't know how to capitalize words, or use a space bar!
All the orders they create look something like this:
"milkshakepizzachickenfriescokeburgerpizzasandwichmilkshakepizza"
The kitchen staff are threatening to quit, because of how difficult it is to read the orders.
Their preference is to get the orders as a nice clean string with spaces and capitals like so:
"Burger Fries Chicken Pizza Pizza Pizza Sandwich Milkshake Milkshake Coke"
The kitchen staff expect the items to be in the same order as they appear in the menu.
The menu items are fairly simple, there is no overlap in the names of the items:
1. Burger
2. Fries
3. Chicken
4. Pizza
5. Sandwich
6. Onionrings
7. Milkshake
8. Coke
def get_order(order):
order=order.replace("burger","1Burger ").replace("fries","2Fries ").replace("chicken","3Chicken ").replace("pizza","4Pizza ").replace("sandwich","5Sandwich ").replace("onionrings","6Onionrings ").replace("milkshake","7Milkshake ").replace("coke","8Coke ")
alist=order.split(" ")
alist=sorted(alist[:-1])
for i in range(len(alist)):
alist[i]=alist[i][1:]
return " ".join(alist)