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 aboutBefore
CCC[CCC]FCC[CCCCC]CFFFF[CCC]FFFF
After
...[CCC]F..[CCCCC].FFFF[CCC]FFFF
Ex2 - a fox in a chicken cageBefore
...[CCC]...[CCCFC].....[CCC]....
After
...[CCC]...[...F.].....[CCC]....
Ex3 - foxes are poisonedBefore
CCCCC...XCCCCCCCCC....FFF.X..CF
After
CCCCC...X.................X....
Ex4 - a bit of everythingBefore
...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

Stats:

CreatedMay 13, 2017
PublishedMay 21, 2017
Warriors Trained822
Total Skips70
Total Code Submissions2446
Total Times Completed237
Java Completions43
JavaScript Completions77
Python Completions106
C# Completions27
Total Stars59
% of votes with a positive feedback rating97% of 78
Total "Very Satisfied" Votes73
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes0
Total Rank Assessments5
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
5 kyu
Ad
Contributors
  • dinglemouse Avatar
  • Blind4Basics Avatar
  • KataSideKick Avatar
  • FArekkusu Avatar
  • hobovsky Avatar
Ad