7 kyu
Speed Control
277 of 16,534g964
Description:
In John's car the GPS records every s
seconds the distance travelled from an origin (distances are measured in an arbitrary but consistent unit).
For example, below is part of a record with s = 15
:
x = [0.0, 0.19, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25]
The sections are:
0.0-0.19, 0.19-0.5, 0.5-0.75, 0.75-1.0, 1.0-1.25, 1.25-1.50, 1.5-1.75, 1.75-2.0, 2.0-2.25
We can calculate John's average hourly speed on every section and we get:
[45.6, 74.4, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0]
Given s
and x
the task is to return as an integer the *floor*
of the maximum average speed per hour obtained on the sections of x
.
If x length is less than or equal to 1 return 0
since the car didn't move.
Example:
With the above data your function gps(s, x)
should return 74
Note
With floats it can happen that results depends on the operations order. To calculate hourly speed you can use:
(3600 * delta_distance) / s
.
Happy coding!
Fundamentals
Mathematics
Similar Kata:
Stats:
Created | Nov 15, 2015 |
Published | Nov 15, 2015 |
Warriors Trained | 49230 |
Total Skips | 10694 |
Total Code Submissions | 85229 |
Total Times Completed | 16534 |
Ruby Completions | 368 |
Python Completions | 3460 |
JavaScript Completions | 3392 |
Haskell Completions | 277 |
C# Completions | 816 |
Java Completions | 1805 |
CoffeeScript Completions | 21 |
Clojure Completions | 160 |
C++ Completions | 1434 |
PHP Completions | 736 |
Elixir Completions | 224 |
Crystal Completions | 20 |
F# Completions | 83 |
C Completions | 926 |
TypeScript Completions | 440 |
OCaml Completions | 65 |
Shell Completions | 95 |
Kotlin Completions | 725 |
Julia Completions | 36 |
R Completions | 150 |
PowerShell Completions | 98 |
Go Completions | 826 |
Nim Completions | 25 |
Rust Completions | 446 |
Reason Completions | 8 |
Racket Completions | 37 |
Scala Completions | 130 |
Dart Completions | 369 |
Lua Completions | 108 |
Perl Completions | 28 |
D Completions | 11 |
Erlang Completions | 19 |
NASM Completions | 6 |
Total Stars | 423 |
% of votes with a positive feedback rating | 85% of 2122 |
Total "Very Satisfied" Votes | 1589 |
Total "Somewhat Satisfied" Votes | 416 |
Total "Not Satisfied" Votes | 117 |