Advertisement
adapap

Keyboard Prodigy Explanation

Dec 20th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. In order to count how many times Nozart played the keys of a major scale, we need to learn a bit about music theory. A keyboard (or piano) is composed of a series of the same notes, called octaves.
  2. Picture: http://musichowtoread.weebly.com/uploads/1/1/8/6/11864535/3012199_orig.jpg
  3. This picture shows all of the notes in an octave. When moving from one key to the one directly to the right of it, whether it is black or white, the distance between two adjacent notes is called a semitone. One octave starts and ends on the same note, a distance of 12 semitones (6 tones).
  4.  
  5. Each note has a letter between A-G that describes its sound. Adding a sharp sign (#) increases the note by one semitone, and a flat (b) decreases it by one semitone. A major scale is comprised of 8 notes in a sequence. The distance between these notes follows the pattern: tone, tone, semitone, tone, tone, tone, semitone
  6.  
  7. Each line in the input represents a sequence of 8 notes that Nozart plays. We have to determine whether or not these notes make up a valid major scale. Let's say one sequence of notes is this:
  8. C D E F G A B C
  9.  
  10. This is a valid scale because if you reference the picture, the distances between notes follows the major scale pattern. The input may not necessarily give you these notes in order, and it may substitute notes with flats or sharps with the same value. Here is a shuffled version of the above example:
  11. F G A C E C D B
  12.  
  13. The following is an example of same-value substitutions (# is one semitone higher, b is one semitone lower):
  14. E# G A B# Fb B# D Cb
  15.  
  16. Now go find out if Nozart really can become a ♬usica♩ prod♪gy!
  17.  
  18. [Additional Test Cases]
  19. ==============================
  20. Valid Sequences:
  21. E# G# B Gb D# Db Gb Bb
  22. F Bb Eb G G# C Db Ab
  23. Fb Ab C# Bb D# B Gb Cb
  24. G E# A B# Bb Eb D A#
  25. G# B# G F C# Ab Bb Eb
  26. ==============================
  27. Invalid Sequences:
  28. A G F# G B# Gb Gb Ab
  29. Eb D G A# E# Gb Bb A
  30. D# C# D B Bb Cb Eb E#
  31. Ab Fb D F Eb Bb G D#
  32. C G# Cb G# E# C D A#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement