Retired

Median fun fun (retired)

257 of 780majakudlicka

Description:

Description:

The mean (or average) is the most popular measure of central tendency; however it does not behave very well when the data is skewed (i.e. wages distribution). In such cases, it's better to use the median.

Your task for this kata is to find the median of an array consisting of n elements.

You can assume that all inputs are arrays of numbers in integer format. For the empty array your code should return NaN (false in JavaScript/NULL in PHP/nil in Ruby).

Examples:

Input [1, 2, 3, 4] --> Median 2.5

Input [3, 4, 1, 2, 5] --> Median 3

Fundamentals
Arrays
Data Types
Basic Language Features
Mathematics
Algorithms
Logic
Numbers

Similar Kata:

More By Author:

Check out these other kata created by majakudlicka

Stats:

CreatedNov 11, 2016
Warriors Trained1235
Total Skips44
Total Code Submissions3719
Total Times Completed780
JavaScript Completions257
TypeScript Completions54
Python Completions296
Ruby Completions90
Crystal Completions5
PHP Completions118
Total Stars6
% of votes with a positive feedback rating92% of 218
Total "Very Satisfied" Votes186
Total "Somewhat Satisfied" Votes28
Total "Not Satisfied" Votes4
Total Rank Assessments8
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • majakudlicka Avatar
  • GiacomoSorbi Avatar
  • smile67 Avatar
  • donaldsebleung Avatar
  • user5036852 Avatar
  • Glyxerine Avatar
Ad