The Hunger Games - Zoo Disaster!

Story
It's a Zoo Disaster!
Kata Task
INPUT
TASK
OUTPUT
Notes
Example
Solutions
Last updated

Last updated
*Working*
<table>
<tr><td>1<td>fox can't eat bug<td><pre>"fox,bug,chicken,grass,sheep"</pre></tr>
<tr><td>2<td>bug can't eat anything<td><pre>"fox,bug,chicken,grass,sheep"</pre></tr>
<tr><td>3<td><span style='color:red'>chicken eats bug</span><td><pre>"fox,chicken,grass,sheep"</pre></tr>
<tr><td>4<td><span style='color:red'>fox eats chicken</span><td><pre>"fox,grass,sheep"</pre></tr>
<tr><td>5<td>fox can't eat grass<td><pre>"fox,grass,sheep"</pre></tr>
<tr><td>6<td>grass can't eat anything<td><pre>"fox,grass,sheep"</pre></tr>
<tr><td>7<td><span style='color:red'>sheep eats grass</span><td><pre>"fox,sheep"</pre></tr>
<tr><td>8<td><span style='color:red'>fox eats sheep</span><td><pre>"fox"</pre></tr>
</table>
*Output*
```["fox,bug,chicken,grass,sheep", "chicken eats bug", "fox eats chicken", "sheep eats grass", "fox eats sheep", "fox"]def who_eats_who(zoo):
rules = dict(
antelope=['grass'],
sheep=['grass'],
bug=['leaves'],
giraffe=['leaves'],
panda=['leaves'],
bear=['big-fish','bug','chicken','cow','leaves','sheep'],
chicken=['bug'],
cow=['grass'],
fox=['chicken','sheep'],
lion=['cow','antelope']
)
rules['big-fish']=['little-fish']
res_seq = [zoo]
new_zoo = zoo.split(',')
someone_died = True
while someone_died:
someone_died = False
for i, anim in enumerate(new_zoo):
if anim not in rules.keys():
continue
animal_to_eat_indx = None
if i != 0 and new_zoo[i-1] in rules[anim]:
animal_to_eat_indx = i-1
elif i != len(new_zoo)-1 and new_zoo[i+1] in rules[anim]:
animal_to_eat_indx = i+1
if animal_to_eat_indx != None:
res_seq.append("%s eats %s" % (anim, new_zoo[animal_to_eat_indx]) )
del new_zoo[animal_to_eat_indx]
someone_died = True
break
res_seq.append(",".join(new_zoo))
return res_seq