The Hunger Games - Zoo Disaster!
Description:

Story
A freak power outage at the zoo has caused all of the electric cage doors to malfunction and swing open...
All the animals are out and some of them are eating each other!
It's a Zoo Disaster!
Here is a list of zoo animals, and what they can eat
- antelope eats grass
- big-fish eats little-fish
- bug eats leaves
- bear eats big-fish
- bear eats bug
- bear eats chicken
- bear eats cow
- bear eats leaves
- bear eats sheep
- chicken eats bug
- cow eats grass
- fox eats chicken
- fox eats sheep
- giraffe eats leaves
- lion eats antelope
- lion eats cow
- panda eats leaves
- sheep eats grass
Kata Task
INPUT
A comma-separated string representing all the things at the zoo
TASK
Figure out who eats whom until no more eating is possible.
OUTPUT
A list of strings (refer to the example below) where:
- The first element is the initial zoo (same as INPUT)
- The last element is a comma-separated string of what the zoo looks like when all the eating has finished
- All other elements (2nd to last-1) are of the form
X eats Y
describing what happened
Notes
Animals can only eat things beside them
Animals always eat to their LEFT before eating to their RIGHT
Always the LEFTMOST animal capable of eating will eat before any others
Any other things you may find at the zoo (which are not listed above) do not eat anything and are not edible
Example
Input
"fox,bug,chicken,grass,sheep"
Working
1 | fox can't eat bug | "fox,bug,chicken,grass,sheep" |
2 | bug can't eat anything | "fox,bug,chicken,grass,sheep" |
3 | chicken eats bug | "fox,chicken,grass,sheep" |
4 | fox eats chicken | "fox,grass,sheep" |
5 | fox can't eat grass | "fox,grass,sheep" |
6 | grass can't eat anything | "fox,grass,sheep" |
7 | sheep eats grass | "fox,sheep" |
8 | fox eats sheep | "fox" |
Output
["fox,bug,chicken,grass,sheep", "chicken eats bug", "fox eats chicken", "sheep eats grass", "fox eats sheep", "fox"]
Similar Kata:
Stats:
Created | Apr 28, 2017 |
Published | Jun 7, 2017 |
Warriors Trained | 12259 |
Total Skips | 4151 |
Total Code Submissions | 33231 |
Total Times Completed | 2770 |
Java Completions | 496 |
JavaScript Completions | 854 |
Python Completions | 1064 |
Haskell Completions | 44 |
C# Completions | 263 |
COBOL Completions | 2 |
Go Completions | 53 |
Rust Completions | 41 |
Total Stars | 520 |
% of votes with a positive feedback rating | 96% of 568 |
Total "Very Satisfied" Votes | 522 |
Total "Somewhat Satisfied" Votes | 44 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 8 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |