-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSkiJump_7kyu.html
More file actions
58 lines (46 loc) · 1.85 KB
/
SkiJump_7kyu.html
File metadata and controls
58 lines (46 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<html>
<head>
<script type="text/javascript">
function skiJump(mountain) {
var height = mountain.length;
var result = (height * height * 1.5 * 9 / 10).toFixed(2);
if(result < 10)
result += " metres: He's crap!"
else if(result < 25)
result += " metres: He's ok!"
else if(result < 50)
result += " metres: He's flying!"
else
result += " metres: Gold!!"
return result;
}
</script>
</head>
<body>
<h1>Verifiche:</h1>
<script type="text/javascript">
document.write(skiJump(['*']) + ': 1.35 metres: He\'s crap!' + "<br>");
document.write(skiJump(['*', '**', '***']) + ': 12.15 metres: He\'s ok!' + "<br>");
</script>
<hr>
<pre>
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 value 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 to two dp.
You must return the length of the resulting jump as a string in the following format:
Jump < 10 = 'X metres: He's crap!'
Jump > 10 && < 25 = 'X metres: He's ok!'
Jump > 10 && < 50 = 'X metres: He's flying!'
Jump > 50 = 'X metres: Gold!!'
In this case 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:
[*****, ******, *******, ********, *********]
</pre>
</body>
</html>