7 kyu

Histogram data

125 of 804Jenik
Description
Loading description...
Fundamentals
Algorithms
Arrays
Data Science
  • Please sign in or sign up to leave a comment.
  • plb3rd Avatar

    There are 54 data points but only 3 unique values. How can a histogram have more than 3 bins?

    [2, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 2] should equal [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 2]

  • ejini战神 Avatar

    Python:

    • New test framework should be used

    • Corresponding imports are missing in test cases

  • julianborie Avatar

    No matter how many times I read the description, I don't understand what is being asked.

    • user9396321 Avatar

      You're making a histogram from a set of data. It's a bar graph of "bins" (ranges) of numbers vs. their frequency in the set. The return value is the heights of the columns in the histogram.

      For the data [1, 1, 0, 1, 3, 2, 6], binWidth = 1 in the example, there is one 0, three 1s, one 2, one 3, no 4s, no 5s and one 6, so the output will be [1, 3, 1, 1, 0, 0, 1] -- the frequencies of each element for all the possible bins. Each bin just contains a single number.

      If binWidth = 2, each bin covers two numbers. The first bin matches 0 and 1, the second 2 and 3, and so forth.

  • cekstedt Avatar

    Your description reads On empty input you should return empty output. However, on receiving an empty input [] your tests expect [0], which is not an empty output. It is a list containing a value. Please update your description with your actual expectations.

  • FArekkusu Avatar

    Python translation. Please, review and approve (the author is inactive).

  • RobsonMoon Avatar

    Description could do with some improvements:

    • Spelling mistakes: correspodning and witdh
    • Numbers are inconsistently words or digits
    • bin width should probably be binWidth so it matches the variable name
    • Jenik Avatar

      Thank you, I tried to reformulate the description (and correct mistakes). It's funny that this kata I made some 3 years ago and had no attendance since, is now active.

      Suggestion marked resolved by Jenik 6 years ago
    • RobsonMoon Avatar

      Thanks Jenik! Looks good

  • eb110 Avatar

    Why Kata.Histogram(data, 2)); gives output 4,2,0,1 ? shouldn't it be 2,4,0,1?

  • KataSideKick Avatar

    approved~~interesting!