Rainfall
Description:
data
and data1
are two strings with rainfall records of a few cities for months from January to December.
The records of towns are separated by \n
. The name of each town is followed by :
.
data
and towns
can be seen in "Your Test Cases:".
Task:
- function:
mean(town, strng)
should return the average of rainfall for the citytown
and thestrng
data
ordata1
(In R and Julia this function is calledavg
). - function:
variance(town, strng)
should return the variance of rainfall for the citytown
and thestrng
data
ordata1
.
Examples:
mean("London", data), 51.19(9999999999996)
variance("London", data), 57.42(833333333374)
Notes:
if functions
mean
orvariance
have as parametertown
a city which has no records return-1
or-1.0
(depending on the language)Don't truncate or round: the tests will pass if
abs(your_result - test_result) <= 1e-2
orabs((your_result - test_result) / test_result) <= 1e-6
depending on the language.Shell
- Shell tests only variance.
- In "function "variance" $1 is "data", $2 is "town".
A ref: http://www.mathsisfun.com/data/standard-deviation.html
data
anddata1
(can be namedd0
andd1
depending on the language; see "Sample Tests:") are adapted from: http://www.worldclimate.com
Stats:
Created | Jan 23, 2016 |
Published | Jan 23, 2016 |
Warriors Trained | 41346 |
Total Skips | 12700 |
Total Code Submissions | 107579 |
Total Times Completed | 7948 |
Ruby Completions | 351 |
Python Completions | 1998 |
JavaScript Completions | 1636 |
CoffeeScript Completions | 20 |
C# Completions | 491 |
Haskell Completions | 87 |
Clojure Completions | 96 |
Java Completions | 989 |
C++ Completions | 457 |
PHP Completions | 351 |
C Completions | 179 |
TypeScript Completions | 230 |
Swift Completions | 209 |
Crystal Completions | 15 |
R Completions | 59 |
Shell Completions | 48 |
OCaml Completions | 23 |
Scala Completions | 168 |
Kotlin Completions | 214 |
F# Completions | 28 |
Julia Completions | 21 |
PowerShell Completions | 33 |
Go Completions | 261 |
Nim Completions | 11 |
Rust Completions | 196 |
Racket Completions | 14 |
Fortran Completions | 3 |
Pascal Completions | 4 |
Perl Completions | 13 |
Elm Completions | 4 |
D Completions | 3 |
Erlang Completions | 6 |
Prolog Completions | 4 |
Total Stars | 726 |
% of votes with a positive feedback rating | 84% of 1311 |
Total "Very Satisfied" Votes | 969 |
Total "Somewhat Satisfied" Votes | 271 |
Total "Not Satisfied" Votes | 71 |