7 kyu
Histogram data
125 of 804Jenik
Loading description...
Fundamentals
Algorithms
Arrays
Data Science
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
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]
pass
Python:
New test framework should be used
Corresponding imports are missing in test cases
No matter how many times I read the description, I don't understand what is being asked.
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 one0
, three1
s, one2
, one3
, no4
s, no5
s and one6
, 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 matches0
and1
, the second2
and3
, and so forth.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.The expected result was wrong in the tests. Fixed.
Python translation. Please, review and approve (the author is inactive).
Approved.
Description could do with some improvements:
bin width
should probably bebinWidth
so it matches the variable nameThank 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.
Thanks Jenik! Looks good
Why
Kata.Histogram(data, 2));
gives output4,2,0,1
? shouldn't it be2,4,0,1
?data = [1, 1, 0, 1, 3, 2, 6], binWidth = 2. This means that all zeroes and ones fall to the first bin (it starts with 0 and has width 2) which gives four elements (1,1,0,1). The next bin is for twos and threes - there are two of them (3, 2) etc.
Thanks.
Question resolved.
thanks
approved~~interesting!