Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new-member-32: tails of the high seas #115

Open
ghost opened this issue Apr 15, 2016 · 2 comments
Open

new-member-32: tails of the high seas #115

ghost opened this issue Apr 15, 2016 · 2 comments
Assignees

Comments

@ghost
Copy link

ghost commented Apr 15, 2016

adapted from a beta kata of mine on codewars

Tails of the High Seas

It is a little past midnight in your cool developer crib, and you have just received a shaky text from your most faithful client. Somewhere in your client's hushed emojis, you make out a plea for an emergency favor. Your client is adrift, stuck in the Caribbean on his "modestly-sized" yacht, and a swashbucklin' galleon full of monkeys trained by Keith Richards himself is fast approaching. Your client needs a function ASAP to calculate the likelihood of victory so that he/she may make an informed decision.

keef_for_president

Through the power of Tinder, your client will create two smoking object profiles that you can swipe right on and pass along to your function. These objects represent your client's ("modestly-sized," he could not emphasize that enough) yacht and the wild barrel of sea-faring monkeys -- they will look like the following:

{hit_points: 20,
orangutans: 5,
chimpanzees: 3,
gorillas: 4,
jane_reporting_4_duty: false},

{hit_points: 70,
crew: 35}

You also found a sticky note under your rear end with the following power levels:

  • Orangutans: 5
  • Chimpanzees: 3
  • Gorillas: 9
  • Humans: 1

The dynamics of your function, bite_me_monkey, boil down to this:

  • The highest numeric outcome of your functions' two competing sides determines the return string of bite_me_monkey
    • If the final primate number is greater than or equal to your client's final number, then the primates win and the function should return "Abandon ship! Save your own skin and blame it on the 'modestly-sized' yacht!"
    • Otherwise, return "Everything's good, I'll see you in the office on Monday."
  • A third function parameter, terrain, determines which side has an advantage in the fight:
    • If the terrain bonus is "island," then the humans have 20 extra points on top of their fighting battle number.
    • If the terrain bonus is "sea," then the primates have 10 extra points on top of their fighting battle number.
  • The monkey object will contain a Boolean wildcard value, jane_reporting_4_duty, that confirms whether or not Jane Goodall is present. If so, then the primates' fighting battle value is multiplied by half of however many chimpanzees are present (this is applied after any terrain bonus).
  • The two fighting battle numbers are calculated by:
    • Multiplying power levels against the headcount of the appropriate species.
    • Taking the aggregate of those products and adding it to the appropriate object's hit points value

Godspeed! The fate of the free world does not depend on this. However, your client may never be able to maintain a healthy relationship with local zoos or enjoy James Franco's dimples ever again...

ex:

bite_me_monkey( {
    hit_points: 20, 
    orangutans: 5, 
    chimpanzees: 3, 
    gorillas: 4, 
    jane_reporting_4_duty: true
  }, {
    hit_points: 70, 
    crew: 35
  }, 
  "island"
)

// ---> "Abandon ship! Save your own skin and blame it on the 'modestly-sized' yacht!"

here is the function shell to get you started:

function bite_me_monkey (monkObj, clientObj, terrain) {
  // commit piracy here
}

here are a few more example cases to test:

bite_me_monkey( {
    hit_points: 10,
    orangutans: 5,
    chimpanzees: 4, 
    gorillas: 2, 
    jane_reporting_4_duty: true
  }, {
    hit_points: 50, 
    crew: 70
  }, 
  "island"
)

// ---> "Everything's good, I'll see you in the office on Monday."

// -----------------------------------------------------------------------

bite_me_monkey( {
    hit_points: 10, 
    orangutans: 5, 
    chimpanzees: 8, 
    gorillas: 9, 
    jane_reporting_4_duty: false
  }, {
    hit_points: 50, 
    crew: 70
  }, 
  "sea"
)

// ---> "Abandon ship! Save your own skin and blame it on the 'modestly-sized' yacht!"
@juliankolbe
Copy link

I would like to take this one! :)

@juliankolbe juliankolbe self-assigned this May 27, 2016
@juliankolbe
Copy link

posted solution now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants