Created
June 6, 2022 03:07
-
-
Save graphemecluster/a2147fe9bc5c0eb976f0732034c94dc3 to your computer and use it in GitHub Desktop.
Code Golf - Interval between two musical notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f=c=>{for(s=0,i=0;c[i];i++){x=c.charCodeAt(i);s+=i?((x^3024)%3-1)*(((x&12)==8)+1)*7:(x+1&15)*2%7}return s},d=(l,r)=>("mmmmPPPMMMM"[(s=f(r)-f(l))+5]||(s<0?"d":"A").repeat(-~(s<0?-s:s)/7))+(((s*4%7)+7)%7+1) | |
// > d("B#","Fb") | |
// "ddd5" | |
// Supported characters: | |
// CDEFGABcdefgabCDEFGABcdefgab | |
// 𝄫♭bb♮♯##𝄪xx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment