7 kyu
What a "Classy" Song
2,661 of 5,099this is my username
Loading description...
Fundamentals
Object-oriented Programming
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.
"Random Tests Given: rYan,sYndney,luke,eriC,melisa expected 3 to equal 5 Completed in 2ms Given: joe,beN,amanda,JeSicA,syndNEy expected 3 to equal 4 Given: eRic,jesica,cAleB,amaNdA,caleB expected 0 to equal 1 Completed in 1ms"
Hello. I can't pass 5 random tests. I don't understand what my mistake is. I pass all other tests. Help me to understand.
You should try to restructure your code to avoid using global variables. It's very confusing to understand how the class works right now.
Keep in mind that you can use the constructor to add additional variables without resorting to globals.
B1ts, Your advice regarding variables helped me solve the problem. Thank you.
I didn't think this alone would be enough, but ok :D Glad you solved it!
I think it's very hard for 7 kyu in python. I wouldn't solve it without googling a bit.
I proposed a minor evolution of test case and subject to add a hint about instance VS class variable in python and a clean test case to display it before random tests. It is done through a fork. I think it could help a lot with the recurrent issue on python random tests.
I think struggling with this for a bit is a good way to learn the difference between instances of a class and class variables. On the other hand, I'm struggling to keep up with all the issues.
I think I'll keep it as is. If they have a hard time they can get your hint from discourse.
This comment has been hidden.
love to see it
what is the day and does it affect the code?
"Days" are really test cases. so with each new test case, you are suposed to calculate the number of new listeners.
If on the first test
mountMoose.howMany(['John', 'Fred', 'BOb', 'carl', 'RyAn']);
is called, then your function should return 5 because they are all new listeners, as it is the first test (or "day").On the second test (or "day") if
mountMoose.howMany(['JoHn', 'Luke', 'AmAndA']);
is called, then your function would retrun 2 because John already listened in the first test.Hopefully this helps.
Thanks :)
Hello, in javascript. Random tests are always with the same song as basic tests? Because im getting some errors, I think maybe is because it is anpther song.
Or listeners must be reset in random tests?
Each random tests uses a new song.
It makes sense that if a new Song object is instantiated that it would start with no listeners yet.
I liked this one !
for people who think the random tests are wrong: be aware that in the fixed sample tests you have listeners, but in the random tests the listeners are not the one's in the sample tests. => 'bob' in a random test case may be new, if 'bob' only appeared in the sample tests before
and how am i supposed to know if he changed the thing?
The random tests have issues: all listeners: ['john', 'fred', 'ryan', 'bob', 'carl', 'amanda', 'luke', 'caleb', 'furgus', 'kate', 'joe', 'jesica', 'ben', 'melisa', 'eric', 'syndney'] listeners of that day: {'bob', 'amanda', 'ryan', 'ben'}
the correct new listeners should be 0 but the expected result is 1
What language are you using?
Also check out what @4Ricardo says above, that may be your issue.
This comment has been hidden.
I am getting a failed test for : expected undefined to equal 'Mount Moose'
I've defined the variables in my class within the constructor, not sure what else I am missing.
Found my issue. It was a spelling mistake.
if there are two identical names in the incoming array, it identifies them as two different people. This is not specified in the exercise.
Also if the same person listened to it more than once a day it should only count them once.
Example mount_moose = Song('Mount Moose', 'The Snazzy Moose')
day 1
mount_moose.how_many(['John', 'joHN', 'carl']) => 2
Some randome tests in python have issues, they have already the name and they except it as a new listener.
I don't understand, can you give an example.
Old listeners = {'BOB', 'RYAN', 'CARL', 'FURGUS', 'CALEB', 'AMANDA', 'KATE', 'LUKE', 'FRED', 'JOHN'} "New" listeners = ['LUKE', 'RYAN', 'ERIC', 'CALEB', 'MELISA'] My answer = {'BOB', 'RYAN', 'CARL', 'MELISA', 'FURGUS', 'CALEB', 'AMANDA', 'ERIC', 'KATE', 'LUKE', 'FRED', 'JOHN'}
The correct answer is 5, but the new listeners are only ERIC and MELISA (they didn't listen the song), and LUKE, RYAN and CALEB have already listen the song, so I return as answer 2 but is wrong.
A minor typo in the description:
.. in a case-insensit[I]ve manner
Fixed!
Java Translation
Aproved!
This comment has been hidden.
There should a fixed test of the same person appearing multiple times inside a input list. It only appears some of the time in random tests.
Fixed!
"Viewers" doesn't make sense in a song context. They should be called listeners.
Done
Added python translation.
Why did you raise an issue? shouldn't it be a suggestion?
Whoops my bad.
Idk whether you've changed anything but the description is still unclear about the expected output.
@Sensei Furgus
The tested value is not the unique views, (which would be the number of unique people viewing each day) but rather the number of new views (so excluding people who viewed on previous days).
Probably say something like new unique views, since you want both.
Yes thank you thats the word I'm looking for!
The
title
andartist
are unrelated to the task and should be removed.Sorry about the delay (I lost internet connection). I added random tests for
title
andartist
:)What do you mean unrelated to the task? The task is to create a class that accepts two parameters, and has a function that calculates unique views. I think you must be just focusing on the function instead of the whole class. The only problem was that I forgot random tests, as you mentioned :) Thanks for pointing that out though.
I'm not sure what you mean by, "a variable which is never used", but this is just your opinion, not an issue :)
This comment has been hidden.
I don't see how this is a problem with the kata, this is a problem with your code. The kata is supposed to do that.
The expected result is the number of people who haven't heard the song at all, though.
Thats what that means. I will change the discription to be more clear.
The
title
andartist
are unrelated to the task and should be removed.(...or tested...)
They are tested
Firstly, there's only one fixed test, so it's effectively not tested at all. Secondly, asking the user to create a variable which is never used is a pointless and stupid requirement. Reraising.
i agree with farekkusu