7 kyu
Radio DJ helper function
438 of 858patrickwalkowicz
Loading description...
Sorting
Filtering
Algorithms
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.
Nice one!
Enjoyable kata, thanks!
python new test framework is required. updated in this fork
Approved
Sometimes you will get a number N instead of a string in format "mm:ss" as a song's playback.
JavaScript:
You're mutating the preloaded objects, please do not do that.
IMHO 6 kyu kata. Pretty intresting, as for me
Hello, for some reason when attempting, the test number 4 always fails, no matter what the number is. I tried the same tests on a jupyter notebook and works fine.
I'm using python.
Greetings
This comment has been hidden.
Enabled in this fork
No random tests in JS
Node 18. (
mocha
+chai
) should be enabledYou can pass the tests by using
< playback
instead of<= playback
.Random tests shouldn't rely on
Preloaded
code in Python.Tests and description do not match on the time criteria: test fails when song duration equals the specified time.
Only Ruby had this issue, fixed in this fork
Fun Kata, good job.
One issue:
Instructions are inaccurate as of the value of songs['playback']. Actual value in the list is an int in seconds (e.g. 317), not a string with minutes and seconds (e.g. "5:17").
songs
is an array. Andsongs[0]['playback']
orsongs[1]['playback']
should be strings. I just checked it again.The input argument is in seconds.
Are you sure you are getting an int in the songs array playbacks? Could you post your code here (mark it as spoiler)?
I'm so sorry, you are correct. I was debugging and added a print statement after converting the times into ints. I copied the output thinking that was the original list.
This comment has been hidden.
You don't check if the playback time of first element is less than the input to the function. In this case, it is not. So, no other songs get chosen. Because no song exists which has a playback greater than
216
(songs[0]'s time) but less than215
(input).You are right) thank you)
This comment has been hidden.
Note that
songs
is a global array. When your function is called the first time, it modifies the array. (parses and replaces the playback times)The second time your function is called, you get the error, because you are trying to parse the playbacks again even though they are already integers.
You either need to modify the array once (outside the function). Or create a new array with the parsed values if you want to do this every time the function is called.
What is
songs
? Is it an argument? Is it a global variable?Description in Python is also wrong: it's a list of dicts ->
{'title': 'Title', 'artist': 'Artist', 'playback': '03:36'}
It should be explained as it is impossible to solve this task without it.
This comment has been hidden.
As I said above, an array of object
{artist: 'Artist', title: 'Title String', playback: '04:30'}
is not a correct object in Python.songs is not an array of objects. It is an array of dictionaries, which is a completely different data type.
When you write
artist, title or playback
without quotes in Python, it has to be an existing variable (aka. an object).As I said above,
artist, title and playback
are transformed into string for Python translation.Description just needs a little note to explain this.
Description and initial solution in python modified to make the format more clear.
Thanks for Python users!
Python translation kumited.
Cool, thank you!
Ruby translation kumited.
Hello! Thanks for previous Python contribution! I couldn't find your Ruby translation in the admin panel. Also, I usually receive email notifications about kumited translations but it didn't happen for this one.
Not really sure what could be the problem here. But here's the direct link to the translation. Does this work?
Function name in setup code is wrong. It should be
longestPossible
instead offilterByTime
.Thanks for letting me know.