5 kyu
The Hunger Games - Foxes and Chickens (Poison)
43 of 237dinglemouse
Description:

Story
Old MacDingle had a farm.
It was a free-range chicken farm with a fox problem, as we learned earlier:
So old MacDingle decided to lay fox bait around the farm to poison the foxes.
Foxes F
eat chickens C
When foxes eat fox bait X
they die.
Fox bait is harmless to chickens.
Chickens in cages []
are safe (unless a fox has got into the cage with them!)
Kata Task
Given the initial configuration of foxes and chickens what will the farm look like the next morning after the hungry foxes have been feasting?
Examples
Ex1 - chickens outside cages when foxes about | Before |
CCC[CCC]FCC[CCCCC]CFFFF[CCC]FFFF |
After |
...[CCC]F..[CCCCC].FFFF[CCC]FFFF | |
Ex2 - a fox in a chicken cage | Before |
...[CCC]...[CCCFC].....[CCC].... |
After |
...[CCC]...[...F.].....[CCC].... | |
Ex3 - foxes are poisoned | Before |
CCCCC...XCCCCCCCCC....FFF.X..CF |
After |
CCCCC...X.................X.... | |
Ex4 - a bit of everything | Before |
...CC...X...[CCC]CCC[CCCXCCCF]CCCC[CFC]FCC |
After |
...CC...X...[CCC]...[CCCX....]....[.F.]... |
Notes
- Anything not a fox, a chicken, fox bait, or a cage is just dirt
.
- All cages are intact (not open-ended), and there are no cages inside other cages
- The same fox bait can kill any number of foxes
- A hungry fox will always eat as many chickens as he can get to, before he is tempted by the bait
- Foxes can jump over cages to get to chickens/bait on the other side
Strings
Algorithms
Similar Kata:
Stats:
Created | May 13, 2017 |
Published | May 21, 2017 |
Warriors Trained | 822 |
Total Skips | 70 |
Total Code Submissions | 2446 |
Total Times Completed | 237 |
Java Completions | 43 |
JavaScript Completions | 77 |
Python Completions | 106 |
C# Completions | 27 |
Total Stars | 59 |
% of votes with a positive feedback rating | 97% of 78 |
Total "Very Satisfied" Votes | 73 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 5 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 5 kyu |