Integer to Musical Pitch Classes
Description:
(First in this series: http://www.codewars.com/kata/musical-pitch-classes)
This kata is the inverse of the previous one: you must write a method to_pitch_class
that, when given an integer representing a musical pitch class, returns an array of every name for that note.
There are only twelve pitch classes (which are cyclical, e.g., the note above number 11 is number 0), and the numerical values of the natural notes are as follows:
C: 0, D: 2, E: 4, F: 5, G: 7, A: 9, B: 11
A sharp ("♯") raises a note by one, and a flat ("♭") lowers it by one. For this kata, we'll also be using the double sharp and the double flat, which are exactly what they sound like: the double sharp raises a pitch by two, and the double flat lowers a pitch by two. Since Codewars doesn't allow the characters for sharp, flat, double sharp, and double flat, we'll use the strings "#", "b", "x", and "bb" instead.
Some examples:
to_pitch_class(2) # - > should return ['D', 'Cx', 'Ebb']
to_pitch_class(10) # -> should return ['A#', 'Bb', 'Cbb']
The order of the returned array doesn't matter.
Similar Kata:
Stats:
Created | Feb 9, 2015 |
Published | Feb 9, 2015 |
Warriors Trained | 239 |
Total Skips | 51 |
Total Code Submissions | 582 |
Total Times Completed | 114 |
Ruby Completions | 43 |
JavaScript Completions | 80 |
Total Stars | 9 |
% of votes with a positive feedback rating | 90% of 47 |
Total "Very Satisfied" Votes | 38 |
Total "Somewhat Satisfied" Votes | 9 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 15 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |