7 kyu
Music Theory: Find the Melodic Interval Between Two Notes
107 of 210joekotvas
Loading description...
Algorithms
Strings
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.
Description should be language-agnostic
Hi,
The unit used for "intervals" is not given. Tones ? semi tones? ...? Currently, someone not familiar with music theory will have to retro-engineer the logic to solve the kata.
Cheers
Hi! The unit is neither tones nor semitones, but rather letter note names. This is the standard way to refer to melodic and harmonic intervals in every music theory class I have taken.
C to a E has four semitones (or two whole tones), and is called a 3rd, specifically a major third, because it comprehends three note names.
E to G has three semitones, or 1.5 whole tones, but is also called a 3rd, specifically a minor third, because it also comprehends three note names.
I've added a note in the description to emphasize this concept; hopefully it will be helpful.
Your test ('A0', 'B0', 2). From 'A0' to 'B0' or 1 note(!), or 2 semitones. ('F4', 'B4', 4). From 'B4' to 'F4' or 4 notes(!), or 6 semitones. So what we searching???
Melodic and harmonic intervals are named for the distance from one letter name to the other letter name, first and last note inclusive
('A0', 'A0') => 1 (unison) ('A0', 'B0') => 2 (second)
This is standard convention for musicians. The ordinal number is then paired with a modifier such as 'major', 'minor', 'perfect', etc... but that is beyond the scope of this kata
It measures Degree intervals (of the Major Scale), regardless of the Pitch intervals between degrees, starting with value
1
for the zero distance interval. As author mentioned, each letter represents such degree. Octave numbers are added to be able to measure degree intervals across octaves.well, the wording is still totally awful, for non musicians... XD
If the input is exactly 2 notes, why it is supplied as an array? This will make a lot of other languages unhappy.
How?
It's not ideal, it's not necessary, but I fail to see how this is an
Issue
. It doesn't break the kata, does it?If your standard is as low as "it doesn't break the kata" then everything is fine (it also explains why beta katas are so horrible I suppose). However katas are also meant to teach good practices: when a kata can't even use the most natural, sense making input format this cannot be count as good practice.
Note that in almost all strongly typed languages there are no way to specify your input is an array with exactly 2 elements (and no, tuple isn't one, that's a completely different construct). Once this happens, you're opening a massive source of error for everyone: Will the tests accidentally put more or less elements? Do I need to validate this as a user? Will some translator decide to do a dick move and make users mandatory to validate this? Given the average quality of CW katas, especially translations, these can all happen, and they're all solved by choosing a type that isn't literally retarded for the job. So I don't see why this issue has to be put under the rug for the general desire of "pushing every beta kata past approval ASAP".
Thanks for your (rather pointed 😅) feedback. I've updated the kata to accept exactly two arguments. Unfortunately this has invalidated all previous solutions, but I guess that is part of the beta process.
Python translation: https://www.codewars.com/kumite/63fab99d4776ef4c7ef2cf73?sel=63fab99d4776ef4c7ef2cf73
Thanks! I've made various changes in response to the issues noted in discourse here. Would you update the translation so I can approve and resolve?
Updated: https://www.codewars.com/kumite/63fab99d4776ef4c7ef2cf73?sel=63fc5d63b15a215e8c3018c1
Thank you.
I was already worried about all that stuff for this one. Fortunately, it didn't assume prior knowledge, didn't go beyond every existing piano in the world, and didn't expect me to deal with those ridiculous irregular half note intervals. Also, simple input parsing. Sometimes I just don't want all those complications, you know?
It's not a bad idea, but it's a different kata, and it needs specs on par with this one.
Other opinions are undoubtedly available. :]
sure, but author had estimated rank of 6 kyu, so I hinted about options to make this actually a 6 ;)
I just voted
7
:Pagreed to have a simple kata for beginners
I would change the name to
Find the Pitch Interval Between Two Notes
, because there are several types of intervals.From a quick scan of the internet, it seems most authors who use the term "Pitch Interval" are referring to an interval measured in semitones, whereas here I am referring to the interval size measured across note letter names (typically stated as an ordinal number such as 3rd or 4th), which is generally paired with an interval quality (such as major or perfect).
I understand you want to differentiate between rhythm intervals and pitch intervals. How about "Find the Letter Note Interval Between Two Notes"? Or "Find the Melodic Interval Between Two Notes"?
melodic interval seems fine
EDIT: I was mistaken, not "Pitch", but better "Degree" intervals.
Tests use a different argument format than description text, examples, and initial code. It doesn't really matter what it is, but it should be consistent .
Resolved. 👍🏼
Time to republish?
Tests are not written very maintainably. Reference solution is unnecessarily complicated ( apart from being incorrect ), there is an undeclared, therefore global (!), variable, and even though notes are simply an enumeration you have also found a way to complicate generating those.
Please do better.
Thanks for the feedback. I'll work on it.
This is the first time I've created a kata, and I'm not familiar with the correct process for incorporating others' work. Your solution was clearly better than my first attempt; is is acceptable for me to update this kata with your solution as the reference solution?
All right, I believe I've resolved each of these issues. Again, thank you for taking the time to review my code.
Much better! :]
You still have an undeclared variable, now in
getRandomNote
. If it's white, it's suspect. It should be orange.Got it; fixed. 👍🏼
Random tests expect negative results.
Yet here the interval from D6 up to B6 is a major sixth. Or if you wish, you could say it's a major sixth from B6 down to D6. Either way, -4 makes no sense.
Thanks for taking the time to make a note of this! I've improved the testing function; it should be good to go now.