Draft

Chord searcher

Description:

Task Overview

The objective of this kata is to turn a series of musical notes into the corresponding chord. At the bottom of this description is a basic explanation of the musical theory used. With that information this kata should be solvable, regardless of your knowledge of music theory.

Input

The input will, for chords, be a list containing strings, all representing a single note. An example of this is ["C", "E", "G"]. However, any input can be expected, and has to be handled correctly.

Output

The chords you need to find will have 3, 4 or 5 notes, and will be minor, major, dominant, augmented or diminshed chords. They will contain a note (A capital letter, possibly followed by a # or b), will then (if relevant) be followed by a lower-case min, maj, dim, or aug, followed by a number 5, 7, or 9. It will, in other words, follow this regex notation:

[A-G][#b]?(aug|min|maj|dim)?[579]?

For every valid combination, an example is provided in the sample tests.

Error handling

Errors fall in two categories. Either something is wrong with the format of the input, or the input is technically correct, but our program simply does not know which chord it is. For an input in the second category, you will be expected to return "Unknown chord". If the input is in the wrong style all-together, you will need to raise a custom error. When something is wrong with the list, (it is not a list or it is the wrong length) you need to raise ListError. If there is something wrong with the individual items inside the list (It contains items that are not strings, it is not a functional musical note, and so on), you need to raise NoteError.

Music Theory

For those with a limited knowledge of music (notation), below I'll explain very crudely the basics which you will need to know to complete this kata. Some parts have been simplified, both to limit the amount of weird exceptions, and to make the kata completable for everyone.

There are 12 musical notes which are the building blocks of all chords, seperated by half-steps: A, A#/Bb, B, C, C#/Db, D, D#/Eb, E, F, F#/Gb, G, G#/Ab. A # means the note is half a step up from the note, a b means it's lowered half a step. A D# is identical to a Eb. Both notations can occur, and it is expected that your code can deal with this! Also, as you can see, there is no half-note between B and C or between E and F. This does not mean an F cannot be lowered half a step though!

A chord is build up of several notes, with a specific amount of half-notes between them. The easiest example, a major chord, is build up of the root note (the first one, which incidently also specifies which chord it is.), then 4 half-steps, then 3 half-steps. This means a Cmaj is build up of a C, a E, and a G. With the examples given above, you should be able to deduce how each chord is built up.

Data Structures
Algorithms
Strings

Similar Kata:

Stats:

CreatedFeb 14, 2019
Warriors Trained5
Total Skips0
Total Code Submissions24
Total Times Completed4
Python Completions4
Total Stars0
% of votes with a positive feedback rating50% of 2
Total "Very Satisfied" Votes1
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes1
Total Rank Assessments3
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Olafz Avatar
Ad