fork(2) download
  1. RoomItems = "stol stul dverj krovatj kompjuter"
  2. DirtyRoom = "vatjkrotulsredvjlostkompterju"
  3.  
  4. RoomItems = sorted(RoomItems.split(" "), key=len)[::-1]
  5.  
  6. def Yarr(RoomItems, DirtyRoom):
  7. for Item in RoomItems:
  8. if all(char in DirtyRoom[0:len(Item)] for char in Item):
  9. print Item, DirtyRoom[0:len(Item)]
  10. RoomItems.remove(Item)
  11. DirtyRoom = DirtyRoom.replace(DirtyRoom[0:len(Item)],"")+DirtyRoom[0:len(Item)]
  12. Yarr(RoomItems, DirtyRoom)
  13.  
  14. Yarr(RoomItems, DirtyRoom)
Success #stdin #stdout 0.09s 8856KB
stdin
Standard input is empty
stdout
krovatj vatjkro
stul tuls
dverj redvj
stol lost
kompjuter kompterju