7 kyu

Find Parallel Octaves

96 of 155Simple Rick

Description:

You've sent your students home for the weekend with an assignemnt. The assignment is to write a 4 part harmony consisting of 4 chords.


Scale:

The major scale has 7 notes:

"do re mi fa sol la ti"


Chord:

For this assignment a chord may consist of any 4 notes from the major scale. Example:

example chord = 'do re fa sol'


Harmony:

Each harmony consists of 4 chords:

harmony = [chordOne, chordTwo, chordThree, chordFour]


Octave:

When two singers are singing the same note like below (do) the interval between them is called an octave:

v         v
do re mi do 
^         ^


Parallel Octave:

A parallel octave occurs when two singers move from one chord to the next staying one octave apart. For example:

do mi sol do        
v          v    < Parallel octave
ti re fa  ti

This harmony contains a parallel octave because the bass and soprano are both singing 'do' on the first chord, and then on the second chord they both move to 'ti'. In other words they stay one octave apart from eacthother as they move from one chord to the next.

A parallel octave does NOT occur when two singers stay one octave apart but do not move or change notes from one chord to the next. For example:

do re mi do
|         |     < NOT a parallel octave
do re mi do     

Your Task

You want to write a function to detect whether the harmony contains any parallel octaves. If it contains parallel octaves return "Fail" otherwise return "Pass".


Examples

harmony = [
  'do re mi fa' ,
  'mi fa sol do' ,
  'fa ti fa ti' ,
    |     |             < NOT a parallel octave
  'fa do fa mi' , 
  ]
  
  
  

This student should 'Pass' because the bass and alto are singing octaves on the 3rd and 4th chord'fa' but they do not move.

harmony = [
  'mi re  mi fa' ,
    |      |          < Parallel octave
    v      v
  'sol fa sol do',
    |      |          < Parallel octave
    v      v
  'fa ti  fa  ti' ,
  'fa do  fa  mi' , 
  ]

This student should 'Fail' because the bass and alto stay one octave apart on the first and second chord and they move to another note together. mi -> sol

There is also another parallel octave as they move from the second to third chord. sol->fa

harmony = [
 'mi mi mi mi' ,
 'fa mi do re' ,
 'ti ti ti ti' ,
 'fa mi do re' ,          No parallel octaves
 ]

This student should 'Pass' because there are no parallel octaves in this harmony.

Algorithms

Similar Kata:

Stats:

CreatedJul 22, 2022
PublishedJul 22, 2022
Warriors Trained881
Total Skips28
Total Code Submissions720
Total Times Completed155
JavaScript Completions96
Python Completions63
Ruby Completions8
Total Stars20
% of votes with a positive feedback rating72% of 43
Total "Very Satisfied" Votes26
Total "Somewhat Satisfied" Votes10
Total "Not Satisfied" Votes7
Total Rank Assessments9
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Simple Rick Avatar
  • dfhwze Avatar
Ad