Beta

Pirates!! Time to Plunder - Don't spoil the Spoils

Description:

Ahoy Matey!

If you have succesffully managed your cannon crew and only fired when the cannons were ready then you have won the naval battle. If you haven't, do the Kata here.

What comes after besting dirty sea-dogs? Plundering and the spoils of battle!

Your crew has now collected all the riches from the defeated enemies. You need to make sure the Spoils(rewards/riches) are not spoiled(ruined).

They get spoiled(ruined) if not enough of your crew gets their fair share, or if one or more get too much of a share.

You have 4 inputs:

  • spoils total - The value of riches plundered (will be int)
  • expenses - The percentage of the spoils_total, before captain_tax is taken out, that is taken for expenses and ship repairs (i.e. expenses = 5 means 5 percent of total spoils were used for expenses)
  • captain tax - The amount of money you as captain skim off the top before distributing to your crew
  • crew - a table of crew members where keys represent their names and values represent the amount of money they took

Crew example:

{
  "Wallace": 25,
  "Jimmy": 23,
  "Petey": 15,
  "George": 12
}

In that above example, Petey and George obviously have less than the others. Or Wallace and Jimmy took more than they should have.

Your task is to take in the array above and determine if each crew member got their fair share. If they didn't then there is either a thief or thieves, or the captain is greedy.

There are three possible outcomes. Here's some examples using the above crew:

If one or more got more than their fair share return the name of the thief or thieves with orders to walk the plank in alphabetical order like so:

"Jimmy, Wallace - Walk the plank!"

If they all got their fair share then everyone is happy:

"Yo-Ho. Yo-Ho. A pirate's life for me!"

If one or more didn't get their fair share, but the rest did (meaning no theives) then that means the missing money is with the Captain. Return the following with the names of the crew members in alphabetical order who lost their fair share.

"Captain needs his gold! Sorry George, Petey"
Algorithms

Similar Kata:

Stats:

CreatedSep 21, 2016
PublishedSep 22, 2016
Warriors Trained292
Total Skips14
Total Code Submissions362
Total Times Completed36
Python Completions36
Total Stars10
% of votes with a positive feedback rating76% of 17
Total "Very Satisfied" Votes9
Total "Somewhat Satisfied" Votes8
Total "Not Satisfied" Votes0
Total Rank Assessments19
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • j_codez Avatar
  • Blind4Basics Avatar
  • FArekkusu Avatar
Ad