Sharpen up
Description:
In music on the planet nubulax, there are eight notes in each octave of a scale. This is how they look on a piano as 'white notes':
"G" "A" "B" "C" "D" "E" "F" "G"
Each DIFFERENT note has it's own SHARP (#).
Sharps must be ordered to any scale in the following pattern:
F# C# G# D# A# E# B#
It's possible to work out which sharps are in a major scale from its root (the first note of the scale) using these three steps:
- Decide which is the first note of your scale (e.g. E).
- On a piano, find the note immediately below the root (in this case D).
- Using the sharp pattern, count up to (and including) D.
The above example shows that E major has 4 sharps: F#, C#, G#, D#.
Design a function that takes any root note and returns the corresponding number of sharps in an array.
"E" --> should return ["F#", "C#", "G#", "D#"]
The exception to this rule is C major, which has no sharps at all. If root C is entered, the function should return "no sharps".
"C" --> should return "no sharps"
The function should return "undefined note" if the taken object is anything other than one of the the seven capitalised 'white notes' on the piano.
"fkuy8" --> should return "undefined note"
Stats:
Created | Nov 5, 2015 |
Published | Nov 27, 2015 |
Warriors Trained | 229 |
Total Skips | 38 |
Total Code Submissions | 213 |
Total Times Completed | 95 |
JavaScript Completions | 38 |
Python Completions | 49 |
Ruby Completions | 21 |
Total Stars | 5 |
% of votes with a positive feedback rating | 85% of 53 |
Total "Very Satisfied" Votes | 41 |
Total "Somewhat Satisfied" Votes | 8 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 52 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |