Beta

Sharpen up

38 of 95tu6619

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"
Fundamentals
Arrays

More By Author:

Check out these other kata created by tu6619

Stats:

CreatedNov 5, 2015
PublishedNov 27, 2015
Warriors Trained229
Total Skips38
Total Code Submissions213
Total Times Completed95
JavaScript Completions38
Python Completions49
Ruby Completions21
Total Stars5
% of votes with a positive feedback rating85% of 53
Total "Very Satisfied" Votes41
Total "Somewhat Satisfied" Votes8
Total "Not Satisfied" Votes4
Total Rank Assessments52
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • tu6619 Avatar
  • GiacomoSorbi Avatar
  • bidouille Avatar
  • cliffstamp Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad