7 kyu

Ski Jump

658 of 1,145PG1

Description:

You are a skier (marked below by the X). You have made it to the Olympics! Well done.

\_\_\_X\_
\*\*\*\*\*\
\*\*\*\*\*\*\
\*\*\*\*\*\*\*\
\*\*\*\*\*\*\*\*\
\*\*\*\*\*\*\*\*\*\\.\_\_\_\_/

Your job in this kata is to calculate the maximum speed you will achieve during your downhill run. The speed is dictated by the height of the mountain. Each element of the array is a layer of the mountain as indicated by the diagram above (and further below). So for this example the mountain has a height of 5 (5 rows of stars). Speed is mountain height * 1.5.

The jump length is calculated by (mountain height * speed * 9) / 10. Jump length should be rounded to 2 decimal places.

You must return the length of the resulting jump as a string in the following format:

  • when less than 10 m: "X metres: He's crap!"
  • between 10 and 25 m: "X metres: He's ok!"
  • between 25 and 50 m: "X metres: He's flying!"
  • when more than 50 m: "X metres: Gold!!"

So in the example case above, the right answer would be "33.75 metres: He's flying!"

Sadly, it takes a lot of time to make arrays look like mountains, so the tests wont all look so nice. To give an example, the above mountain would look as follows in most cases:

[*****, ******, *******, ********, *********]

Not as much fun, eh?

p.s. if you think "metre" is incorrect, please read this

Fundamentals
Strings
Arrays
Mathematics

More By Author:

Check out these other kata created by PG1

Stats:

CreatedSep 29, 2016
PublishedOct 24, 2016
Warriors Trained2025
Total Skips23
Total Code Submissions4264
Total Times Completed1145
JavaScript Completions658
Ruby Completions77
Crystal Completions9
CoffeeScript Completions10
Python Completions430
Total Stars21
% of votes with a positive feedback rating84% of 257
Total "Very Satisfied" Votes191
Total "Somewhat Satisfied" Votes51
Total "Not Satisfied" Votes15
Total Rank Assessments18
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • PG1 Avatar
  • anter69 Avatar
  • nbeck Avatar
  • cliffstamp Avatar
  • ejini战神 Avatar
Ad