Submit an Entry

To enter the challenge, you need to signup or login.

This Challenge's Best Entries [View All]

(View the Overall | Perl | PHP | Python | Ruby leaderboard.)

Rank User Size Language Score [?]
1st bearstearns 78 Perl 10,000 (v28)
2nd ySas 78 Perl 10,000 (v11)
3rd shinh 79 Perl 9,873 (v16)
4th kounoike 80 Perl 9,750 (v12)
5th grizzley 82 Perl 9,512 (v3)
6th o0lit3 84 Perl 9,285 (v20)
7th 0xF 86 Perl 9,069 (v4)
8th primo 88 Perl 8,863 (v22)
9th tybalt89 90 Perl 8,666 (v1)
10th yvl 95 Perl 8,210 (v7)

See who is active in this challenge →

Musical Score

(Challenge added 1793 days ago.)

Teach your computer to read music.

Discuss This Challenge →

The Problem

In this challenge you will be required to read a musical score and output the notes in a specific format.

You must read each note and output the corresponding letter name and its the length.

More Information

  • The score will contain between 5 and 15 notes inclusive, and is transcribed on a stave.
  • A stave is made up of five horizontal lines comprising of - (minus) characters separated by lines of spaces.
  • The bottom line in the stave is equivalent to the note 'E'. The line of spaces immediately above the bottom line indicates an 'F', and is of a higher pitch that the 'E' below it. This continues as below. Note that notes only go up to 'G' before starting again at 'A'.
                
                
                
    F ----------
    E           
    D ----------
    C           
    B ----------
    A           
    G ----------
    F           
    E ----------
    Note that the letters aren't included in the input your code will receive.
  • The notes are superimposed on top of the stave using a o (lowercase ooh) character to indicate the 'note head'. This note head indicates the frequency of the note, and therefore the alphabetic representation of it as above. For example, a note placed on the score as below indicates an 'A' :
        
        
        
    ----
        
    ----
        
    ----
    o   
    ----
        
    ----
  • A note, like the 'A' above, is called a 'whole note' and would be played for one whole beat. Other durations can be indicated by including a 'stem' rising from the note, and between zero and three 'flags'. A stem is made up of three | (pipe, or vertical bar) characters stacked immediately above the note head :
        
        
        
    ----
        
    |---
    |   
    |---
    o   
    ----
        
    ----
    A stem with no flags is considered a 'quarter-note', and plays for quarter of a beat.
  • Flags are \ (backslash) characters, and hand on the right hand side of the stem. Each stem halves the time the note is played for. This is a eigth-note :
        
        
        
    ----
        
    |\--
    |   
    |---
    o   
    ----
        
    ----
    A sixteenth-note :
        
        
        
    ----
        
    |\--
    |\  
    |---
    o   
    ----
        
    ----
    A thirty-second note :
        
        
        
    ----
        
    |\--
    |\  
    |\--
    o    
    ----
        
    ----
  • Putting more than one note together gives you a score. Each note can be considered to be four characters wide, with a note being in the first column of each four-character block. For example :
                        
                        
        |\             
    ----|\--|\----------
        |\  |       |\  
    ----o---|---o---|\--
    |       o       |   
    |---------------o---
    |                   
    o-------------------
    
    --------------------
    
    The example above contains the following notes, in order: a quarter note 'G', a thirty-second note 'D', an eighth note 'C', a whole note 'D' and a sixteenth note 'B'.
  • Each note in your output should be in the format letter/length, where letter is A-G and length is the fraction of the note's length when compared to a whole note. As an exception, the length and / character should not be printed if the note is a whole note. Each note in your output should be separated by a single space. Therefore, for the score above, your code should output the following:
    G/4 D/32 C/8 D B/16
  • The notes will be in the following range: E F G A B C D E F. Note that only the letter needs to be printed, the octave is ignored.
  • The length of each note will be one of the following: a whole note, a quarter note, an eighth note, a sixteenth note or a thirty-second note.
  • You can find more information on the representation of notes and note values at Wikibooks' Music Notation Systems page and at Wikipedia's Note value page. Please note the similarity between half-notes and quarter-notes, and filled and unfilled note heads on those pages, and that we aren't using half-notes in this challenge, and assuming one type of note-head.
  • Your submission will be run 8 times. Your submission will have to pass all eight submissions for it to be deemed successful.

More Examples

Out of the eight runs your submission will be subjected to, the first four will always provide the same input. You can see the input and the expected output for these runs below :

For the other four runs, your submission will be provided with random scores. To see a random score, click here. To see more random scores, reload the page.

Thanks

Thanks for Ciaran for submitting this challenge. He hangs around in our IRC channel (#codegolf on freenode) a lot, so please thank him if you see him!