- عدد ۰ نشاندهنده سگ است.
- هر لیست نشاندهنده یک خانه است و هر عدد ۱ نشاندهنده یک اتاق خالی است.
- مکان سگ را به صورت خانه و اتاقی که در آن قرار دارد برگردانید. در هر ساختمان فقط یک سگ گمشده وجود دارد.
نمونه ورودی و خروجی
LostDog([1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]) ➞ {"Dog1": "House (2) and Room (1)", "Dog2": "House (3) and Room (2)"}
LostDog([1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1]) ➞ {"Dog1": "House (1) and Room (6)", "Dog2": "House (2) and Room (1)", "Dog3": "House (3) and Room (2)", "Dog4": "House (4) and Room (3)"}
LostDog([1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1]) ➞ {"Dog1": "House (4) and Room (4)"}
LostDog([1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]) ➞ {"Dog1": "House (2) and Room (1)", "Dog2": "House (3) and Room (2)"}
LostDog([1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1]) ➞ {"Dog1": "House (1) and Room (6)", "Dog2": "House (2) and Room (1)", "Dog3": "House (3) and Room (2)", "Dog4": "House (4) and Room (3)"}
LostDog([1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1]) ➞ {"Dog1": "House (4) and Room (4)"}
LostDog([1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]) ➞ "Dog not found!"
نظرات