Statistics

Problem Statement for "LazyGuitar"

Problem Statement

Being a lazy guitarist, you want to find out how little movement you have to make in order to play a certain song.

A guitar is a musical instrument with 6 strings. Each string is tuned to a particular pitch, or note. For this problem, we will assign a number to each note. The notes will be numbered such that higher numbered notes always have a higher pitched sound than lower numbered notes. The strings are tuned as follows:

low E string: starts at note 0.
A string: starts at note 5.
D string: starts at note 10.
G string: starts at note 15.
B string: starts at note 19.
high E string: starts at note 24.

Using these strings, you can play up to 6 notes simultaneously, one per string. A group of notes played together simultaneously is called a "chord".

There are 24 frets on your guitar. A fret is a piece of metal which lays in the wooden fretboard underneath all the strings, and is used to change the pitch of a string to sound higher. To play fretted notes, you place your left hand around the fretboard such that your thumb is behind the fretboard, and your other fingers are above the strings. To use a fret, you press down the string with your finger behind the fret, and it shortens the length of the string that vibrates. Each fret increments the note pitch by 1. For example, the 4th fret on the A string is note 9, and the 13th fret on the G string is note 28. To play the starting note of a string (also known as an "open" note), you play the string without using any frets for that string. To play a "fretted" note, you place your finger behind the fret and then pluck the note. For example, to play D (note 10), you could either use the 10th fret on the low E string, the 5th fret on the A string, or play an open D string.

In order to play any frets on the fretboard, your hand can slide back and forth along the fretboard. A hand position is identified by the lowest fret that you could play in that position. In any particular position p, you can only use frets numbered p through p + 3, inclusive. For example, in position 5, you can play frets 5 - 8 on any of the strings. You can play open notes from any position, since you simply don't put your finger down for that string. In addtion, you only have 4 fingers that you can use to play fretted notes (your thumb must remain behind the fretboard), so if 5 notes are to be played, at least 1 of them must be played with an open string. Likewise, for 6 notes at a time, 2 must be open strings. You cannot use one finger to play multiple fretted notes.

To move your fingers while in the same position costs no energy, but to move your hand to another position costs 1 unit of energy plus n units of energy, where n is the difference between the last position and the new position. For example, to move from position 5 to position 19 costs 15 units of energy (19 - 5 is 14, + 1 for the move).

Given a String[] music, in which each element is a single-space separated list of integers representing a note or a chord to play for each moment in time, return the minimum amount of energy required to play the song, or -1 if the song cannot be played. If one of the elements in music has a chord that cannot be played from a single position, the song is unplayable. You cannot move to another position in the middle of playing a chord.

It costs you no energy to move to the position required to play the first element, since you can start with your hand there.

Definition

Class:
LazyGuitar
Method:
minEnergy
Parameters:
String[]
Returns:
int
Method signature:
int minEnergy(String[] music)
(be sure your method is public)

Notes

  • You have unusually long fingers, so as long as the frets you must play for each element of music are within the specified range of the position, you can play them (this is not realistic, as normal fingers can't play all possible combinations of notes).

Constraints

  • music will have between 1 and 50 elements, inclusive.
  • Each element of music will consist only of characters '0'-'9' inclusive, and space characters.
  • Each element of music will be a single space delimited list of integers, with no leading/trailing spaces, and no extra leading zeros.
  • Each element of music will contain between 1 and 6 integers, inclusive.
  • All integers in music will be between 0 and 48, inclusive.

Examples

  1. {"0", "12", "15", "6", "5", "12", "0", "12", "15", "6", "5", "12"}

    Returns: 0

    The introduction line to a well known metal song. There are several positions that require 0 energy to play this song: 1, 4, 5, and 6

  2. {"0", "2", "4", "5", "7", "9", "11", "12"}

    Returns: 0

    The standard scale starting at the E note. By staying in position 1, you can play the music with all open or fretted notes.

  3. {"1 2"}

    Returns: -1

    The only string you can play both of these notes on is the low E string. Since one string cannot produce two notes, this song cannot be played.

  4. { "5 7", "5 7", "5 7", "5 7", "5 7", "5 7", "4 7", "4 7", "4 7", "4 7", "4 7", "4 7", "2 11", "2 11", "2 11", "2 11", "0 9", "2 11", "0 12", "0 12", "0 12", "0 12", "2 11", "4 9", "5 7", "5 7", "5 7", "5 7", "5 7", "5 7", "4 7", "4 7", "4 7", "4 7", "4 7", "4 7", "2 11", "2 11", "2 11", "2 11", "0 9", "2 11", "0 12" }

    Returns: 6

    Think chinese eating devices. This well known tune can be played by starting in position 2, and moving to position 1 after the first six chords. Since the song repeats, you must move back to position 2, and then back to position 1, for a total of 3 moves of one position each.

  5. {"1 48"}

    Returns: -1

  6. {"22","34", "29", "27", "39", "29", "38","29","22","34", "29", "27", "39", "29", "38","29", "24","34", "29", "27", "39", "29", "38","29","24","34", "29", "27", "39", "29", "38","29", "27","34", "29", "27", "39", "29", "38","29","27","34", "29", "27", "39", "29", "38","29"}

    Returns: 0

  7. {"7","14","7","10","3","14","3","10","7","14","7","10","3","14","3","10","15"}

    Returns: 0

  8. {"24","26","24","19", "24","31","29","24", "17","19","24","29", "31","36","31","29", "41","34","36","41", "29","31","40","28", "24","28","31","36", "40","36","31","28"}

    Returns: 0

  9. {"5 5", "16 19 21 30 5 6"}

    Returns: 0

    Here, for the first chord, two of the exact same note must be played at the same time. By playing one of the notes with the 5th fret on the low E string, and one with the open A string, the chord can be played. The second chord can be played by playing the 6th fret on the low E, D, G, and high E strings, and playing open A and B strings.

  10. {"24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0","24 19 15 10 5 0"}

    Returns: 0

  11. {"20 27 28"}

    Returns: 0

  12. {"34 5", "34 10 11 28", "14 19", "19 14 12 19 24 0", "19 8 23", "30 9 14 33 10 15", "40 36 0 34 24 5", "20 40 31 17 10 19", "33 19 25 9 5", "17 27", "18 15 10", "42 23 28 47 10 15", "15 44", "15 21 29 0 10", "22 8 20 27 0 10", "30 41 28 19 0", "26 40"}

    Returns: 82

  13. {"0 19 37 17 10", "26 22", "35 10 27 19 19", "46 10", "29 35 22 41", "43 38 20", "35 21", "19 15 0", "33 21 16 38 10", "0 30 26", "5 46 37", "24 20 30 38", "22 0 7 29", "23 36", "23 15 5 42", "35 10 19 15", "9 22 26 17", "0 27 20 30", "39 28", "33 24 0 29 19 5", "43 19 23 32 10 19", "5 8", "27 20 13 19", "35 8 10 14 15 19", "28 5 30", "5 34 45 38 19 0", "10 19", "17 19", "21 10 15 29 19"}

    Returns: 112

  14. {"14 22", "44 25 30 17", "5 19 45 19 10 15", "32 19 26 38 24", "9 21", "10 37 19", "21 9", "25 27 17 43 19 15", "35 28 17 42 5 15", "31 17 22", "25 16", "5 35 24 18", "24 39 19", "11 32 22", "0 21 19 10 15", "22 25 31", "40 15 5", "41 27 32 24 0 15", "36 43 21", "0 10 18 21 19", "5 13 18 19 24", "17 14 21 25", "17 19 0 5 19 24", "0 18 7 22 24 10", "31 26 13 6 15 10", "22 29", "15 40 44 21", "39 42 20 25 10", "15 6 5 22 19", "16 27 24 10", "32 24 5 18 10", "36 30 10 39 5 0", "20 46 37", "43 38 19 24 10", "19 34 19 44", "26 24 38 21 19", "15 40 25 22 19 0", "0 23 20", "34 39 23 19", "30 27", "11 25 35 30 5 10", "15 5 18 6 19 24", "34 19 10 12 5", "15 24 18 38 15", "30 23"}

    Returns: 146

  15. {"24 32 29", "41 0 34", "6 19", "25 10", "18 24 33 28 0 5", "26 9 28", "0 32", "36 10 41 29 0 5", "23 37 18 31 19", "0 24", "15 24 13 24 0", "36 40 46", "7 24 15 9 15", "10 22 19 33 0 5", "17 32", "3 10 12 17 24", "38 33 29 0", "14 18 2 28 5", "16 27 40 5 15", "17 22", "24 27", "34 37 12 17 10", "19 33 24 10 5 19", "15 27 7 31 5 10"}

    Returns: 113

  16. {"5 24 31 9 15", "29 33 10 14", "19 24 17", "25 15", "23 46", "19 5 15 9", "19 23 26 5 0", "5 41 24 23", "33 37 25 40", "19 24", "28 5 22", "29 5 8 32 10 15", "34 0 24", "25 21 5", "30 35 44 38", "18 16", "27 19 19 15 0 24", "0 37 31", "26 13", "36 42 46 0", "6 16 11 21 19", "14 17 9 28 15", "18 38", "19 28", "9 16 15 19 24", "24 5", "20 24 32 28", "29 34 15 19 0", "37 21", "32 18 28", "15 41 15 19", "10 29 16 19 24", "11 16", "30 42 0", "9 13 10 35 15", "26 38 24", "33 17", "15 36 24 15", "43 33 35 10", "10 33 43", "30 20 0 19 5", "12 21", "26 21 35 10", "30 38 21", "4 17", "9 14"}

    Returns: 167

  17. {"29 37 34 24", "38 35 31 20 24 5", "45 35 26 20 10", "41 47 5 32", "37 21 34", "24 17 12 9 15", "32 18 15 29", "25 29 21 6 5", "9 25 16 35 19", "35 23 24 17 10 15", "20 28 9", "19 28 15 8 10", "3 8 16 24", "31 14 22", "32 38 0 19 10", "33 39", "14 24 22 9 0 15", "19 15 34 26 0", "24 6", "30 38 10 31", "35 17 10", "22 32 24 27 15", "39 42", "37 30 39 46"}

    Returns: 90

  18. {"23 30", "24 16 21", "19 31 10", "15 19 37 24 15 19", "15 19 23", "12 22 19 36 15 5", "24 9 16 21", "36 12 31", "42 30 37 15 5 10", "5 29 19 6", "19 22 10 45 15 5", "31 16 24", "5 22 5 24 10 19", "39 42 21", "24 6 17 12 15", "24 19 10 0 5", "6 24 10 12 15 24", "13 4 6 19 19", "29 16 22 35 0", "44 27 30", "35 30 16", "9 18", "7 19 24", "13 30 8", "32 36 40 20", "35 28", "37 15 26", "40 13 35 18 10", "44 40 18", "27 31 10 20", "44 33 38 25 19", "24 19 21", "24 44 34 21 19", "40 47 0 5 10", "36 19", "26 2 6 10", "10 34 25", "36 29 33"}

    Returns: 189

  19. {"5 0 23", "8 19 13 33 10 15", "29 10 34 16 10 15", "27 17 13", "42 35 19", "34 38 43 5", "28 32 36", "8 10", "29 25 33", "5 32 25 9 10", "27 10", "10 23 14 25 24 0", "19 15 26 9 24", "31 28 12 18 24 10", "31 23", "34 41 18 20 10 15", "41 0 5 10", "15 21 24 11 24 19", "21 6 5 30 10", "22 0 31", "13 23 9", "10 39"}

    Returns: 51

  20. {"18 10 27 30", "5 33 21 37 24", "5 18", "22 32 24 42 15 5", "19 30", "28 37 40", "27 24 31 22", "10 28 5 19 15 24", "21 28 34 35", "27 41 29 16 19 5", "24 0 5 11 19 15", "27 36", "15 35 0 31 5 10", "37 48 43 0 5", "32 21 28 14 5 24", "15 5", "28 33 39 15 5", "24 32 36", "20 24 28 17 0", "12 24 19 36", "31 34", "11 28 14 36", "19 31 37 44 0", "1 28 20 13 5", "27 21 30 11 24", "38 22 42 33", "16 27 19 19 0", "18 29 33 25", "20 28 31 35 19", "17 13 24", "18 27 23", "37 24 28", "8 15 17 5 19", "20 10 45 24", "12 17 20 19", "5 33", "25 14 10 28 10 24", "39 31 20 34 24", "30 0", "23 19", "11 16", "26 40 24 22 15", "22 29 9 4", "38 33 41", "15 27 33 13", "12 0 7 23 24 15", "15 29 19"}

    Returns: 256

  21. {"28 31 38 22 24", "15 21 17 10", "29 21 0 25", "26 9 12 17 15", "17 31 24", "3 19 11 15 15 24", "21 15 24", "2 6 11", "0 25 10 32", "21 37 33 40 0 10", "10 29 19 5 19 5", "15 37 41 16 5", "32 25 39 37 24 0", "14 26 35", "24 20 19 31", "31 17 15 14 19", "21 17 26 5 0", "0 26 30 20 24 5", "14 20 10 15", "30 40", "25 15 40 22 19 0", "23 5 19 33 0", "8 14 24 17 19 15", "35 21 28 39 10 0", "23 15", "13 30 23 16 19", "9 19 10 16 15", "0 41 35", "18 22 28 32 19 24", "0 34", "28 34 10", "22 16 27 14", "44 30 35", "18 21 37 0 15", "32 15 42 23", "29 0", "20 13 35 16 19 15", "10 0 10 28", "24 11", "13 30 4 8", "23 41 27 31 19 0", "23 10 30 14", "15 40 33 16", "7 16 12 23 24", "0 23 34 24 10 19", "40 35", "15 20"}

    Returns: 210

  22. {"24 9 15 19 10 24", "19 4", "13 21 24 22", "10 19", "28 33 39 42 0 5", "48 40", "31 23 0 16 15 5", "45 24 33", "15 15 21 39 10", "31 40 37 21 0", "23 5 34", "24 6 10 14", "0 24", "11 10 0 31", "34 27 12", "5 24 27 15 0 10", "18 5 35", "30 20 35 39 5 24", "31 10 29 36 0 5", "38 32 19 45 0", "5 10", "18 21 24 15 19 0", "43 21 37 17", "29 10", "16 24 36", "15 34 26 24 15", "36 30 39 24", "43 0 30 37 19 5", "19 15", "45 28 23 10", "10 24 36 33 24 0", "2 12 26 19 19 5", "37 15 22 20", "15 31", "18 19 0 20 15", "11 7"}

    Returns: 167

  23. {"41 35", "7 21 12 16", "38 24 34", "26 46", "28 15 19", "23 30", "28 32 10 35 0 5", "39 46 0 28 10", "30 33 24 14", "26 41 38 47", "32 13 19 28", "28 32 17 14", "28 32", "6 16 30", "22 15 18", "32 15 27 20 15", "43 23 24", "27 5 16 19 5 15", "33 10", "16 15 20 35 24 10", "24 27 8 5 10", "27 12 34 19", "10 18", "43 27 34 41 0 10"}

    Returns: 138

  24. {"20 29 5 32", "5 22 25", "22 39", "13 0 10 15 24 19", "7 26", "34 16 27 13 10 19", "10 15 5", "34 5 36 29", "0 15 22 24", "6 24 5", "15 19 45 0", "15 32 21 19", "21 0", "30 39 47 25 15", "5 26 42 34 15 0", "24 32 15 17", "33 9 5 19 15 19", "15 10 0 21 19", "23 15 5 7 10 24", "25 36 21 30", "19 28 0 21 5", "19 24 29 14 19 24", "38 30", "36 24 30 5"}

    Returns: 77

  25. {"15 26", "2 20 26 14", "17 21", "40 0", "19 5 21", "15 19 31 45", "32 19 24", "23 10 26 0 24", "12 15 20 28 0", "15 18 23", "5 13 16 27 15 24", "20 39 28 18", "18 26 23 0 5", "37 15 23 18 15", "15 12 23 24 5 0", "41 24 0 26", "32 15 11 35 5 10", "48 29 42 21", "20 26 28 33", "27 38 45 41", "11 27", "0 34 14", "36 34", "21 18", "15 28", "10 24 27 17 0", "34 5 0", "19 25", "10 40 26", "7 31 15 9 19 10"}

    Returns: 150

  26. {"5 22 5 10", "9 15 23", "39 5 35", "9 5 35", "23 32 20 28 24 0", "0 29 19 25 5", "20 10 41 5", "28 19 26 24 0", "2 18 28 24", "34 24 29 0", "33 36 10 5 0 24", "35 19 8", "32 23 19 0 5 10", "1 15 26 9 19", "0 10"}

    Returns: 73

  27. {"20 26 30 10 24 5", "40 46 39 22 5", "34 24", "29 8 12 19 10", "33 23 36", "15 5 19 23", "42 35 0 20", "39 15", "46 36 19 41 5 10", "16 25 21 34 19 0", "12 26 24 38 19 5", "14 39", "29 15 0", "19 16 27 11 10 24", "20 25", "19 43 32 19", "24 10 15 38 24 0", "26 9", "17 22 25 31 0", "19 26", "39 17 41", "21 0 34 28"}

    Returns: 89

  28. {"28 20 9", "28 24 6 21 5 10", "16 0", "5 39 12", "16 19 25 19", "15 10 24 22", "37 15", "40 28 21 24 5 15", "30 35 0 42 10", "22 34 40 28", "20 33 10", "25 10 36 0", "18 40 23 26", "10 32 5 30 24", "24 36 5 35 10", "19 43 24 39 10 15", "46 39 21", "45 18 35 24 10 19", "0 5 31 24", "12 4 24 27 5", "41 15 27 46 10", "38 36 43 20 5 10", "34 23 27 39 0", "44 34", "40 16 19", "17 15", "4 7 21 12 15", "33 35 14 15 5", "18 24"}

    Returns: 105

  29. {"5 15 36", "23 27", "29 24 17 27", "25 44 30 36 0", "26 30 33 11 5", "2 23 6 19 10 24", "10 28 7 17", "33 25 28 19 19 24", "20 8 19 13 24 0", "36 41 15 5", "23 25 32 16", "33 15 0", "3 22 9 24", "7 5", "28 32 40", "11 30 17 38 10", "22 7", "38 24 27 48", "8 32 14 10 15", "28 24", "3 28 8", "22 27 2 14 5 15", "22 26", "5 10", "31 47", "26 37 44 29", "44 30 19 27 15"}

    Returns: 158

  30. {"19 15 24", "25 3 5 14", "32 37 11", "31 38 39 45", "35 28 33 42", "16 36 15 20 10", "16 31", "12 18 23", "32 17 27 34 5", "29 0 24 5 10 15", "20 16", "18 23 36 26", "10 32 34 18 0 15", "20 29", "15 35 37 14 10", "22 5 32", "28 24", "22 7", "18 25", "20 9 24 27 10", "12 22 27 15 24", "24 15", "2 16 6 22 10 24", "33 21", "31 28 35", "5 37", "37 15 15 5 10 24", "31 36 5 0 10", "15 24 14 26 0", "3 11", "30 20 35 27 24 0", "23 27 31 38 19", "25 19 21 24 0", "32 37 42 0 5 10", "15 19 20 33", "33 19 21", "19 21 10 34 19", "10 28 13 31", "19 24 34"}

    Returns: 122

  31. {"36 29 33 41", "5 21 9 27 19 24", "18 22 26", "43 35", "13 15 25 22", "21 24 10 30", "19 25 29 32", "16 37 10 11", "19 21 10", "19 21 10", "19 12 22 26", "40 19 21", "3 23", "2 27 6 18 19 10", "22 17 38 42", "14 34 25 29", "19 11 29", "10 32 9 26 5", "10 31 6 12 15", "26 31 38", "35 38 10 17", "0 15 20", "38 34 15 25 0 5", "29 34"}

    Returns: 83

  32. {"14 32", "19 45 20 28", "34 0 32", "9 18 28 16 15 24", "21 16 15", "16 24 10 22 15", "25 10", "20 21 27", "8 10 27 23 24 5", "21 26 33 0 19", "15 19 27", "24 11 19 15 5", "27 14 9 19", "34 24 10 37 24", "38 28 32 22 0 5", "9 20 24 25 19 5", "26 5 31", "17 36 11 10 15 19", "30 24 24 19 0", "22 24 16 13 15", "22 11 16 27 24", "24 5 27 32 0 10", "38 36 14", "10 11", "41 46 28", "41 19", "17 24 5 13 15", "36 44", "10 5", "41 26 19 21 15 19", "16 20 31 26 19", "15 37", "35 0 39 18 15 10", "24 5 22 10 0 19", "39 16 23 26", "41 34 24 29 0", "23 31 15 37", "12 15 6", "24 35", "21 26", "10 44 33 18 5"}

    Returns: 148

  33. {"24 32 5 38 19", "39 28", "0 25 27 35 19", "29 30 14 38 5", "38 25", "0 39 5 42 10 15", "25 5 29 33 0 10", "23 15 9 28", "6 19 10 16 19 24", "15 32", "24 24 10", "12 22 36", "16 8 3 12 19 24", "12 19 24 23 0 5", "37 10 42 0 5 15", "1 6", "21 34 26 11", "24 19 11 14 10 15", "38 23", "18 19", "24 32 13", "29 4 26 9", "32 12 24 19", "19 10 35 43 19", "28 9 35 15 5 10", "40 17 5 35 10", "28 44 18 24 15 19"}

    Returns: 129

  34. {"41 16 26 15", "8 10 17 23", "5 10 18 25 19 0", "24 19 10", "18 5", "10 33 20 31 24 0", "34 26 17 12 19 10", "11 20 15 25 19", "5 19 24 26", "33 13 8 21 15 19", "13 18 24", "10 16 10", "29 26", "20 39 44 5 10 15", "19 8 28 15 15 0", "9 20 27 15 0 10", "19 31 39 12 10 15", "30 35", "25 15 22 24 19", "35 0 43 21 10", "26 21 11 30 0 10", "33 37 19 24", "19 11 32 14 15 19", "33 37 18", "15 38 32 0 5 10", "24 15 31 41 5 0", "22 7 3", "42 19", "20 9 13 21 24 0", "36 34", "32 27 22", "8 26 13 23", "14 0 8 21 15", "22 17", "9 25 21 36 19 5"}

    Returns: 190

  35. {"25 10 35 40 0", "38 40 21 32 0 10", "19 15 26", "20 25 30 36 19", "31 16", "10 35 40 47 0", "37 40 24 24", "40 10 33", "21 12 37 16 19", "24 11 10", "29 23 32 10 5 10", "15 28 10 23", "24 27 31", "19 23", "9 21 26 29 24 5", "15 17 23 19", "30 34 9 14 10 15", "24 22", "41 24 35 0 5", "47 37 42 22 5 10", "22 4 17 5 24 10", "24 10 5 0 19", "33 25 5 18 15", "16 5", "23 31 28 36", "32 30 19 26 0 5", "30 19 10", "28 40 23", "44 25 40", "21 32 34 39 0 10", "28 5 15 18 19", "42 39 45 24 5", "31 10", "15 28", "31 17", "19 10 30 33", "32 5", "38 36 10 24 0 5", "28 23 14 18 19", "33 18", "16 38 33 43 5", "5 34 38 40 24 0", "19 31", "5 8 19", "25 38 23 41 10", "34 5 22 12"}

    Returns: 170

  36. {"38 30", "10 35 36 43 0", "19 14 21", "35 32", "1 22 28 8 10", "23 27 14 17 24", "10 41 32 21 0 19", "15 37 11 16 19 10", "27 34 7", "18 13 26 30", "34 12 25", "23 8 10 14 19 24", "45 15", "18 12 32 6 15 19", "34 29 21 25 24 0", "24 29", "26 29 34", "39 10", "24 32 21 31 24", "18 38 15 24", "24 19 18 21", "14 26 32 39 5 19"}

    Returns: 84

  37. {"10 31 35 37 0 5", "10 18 23 28 0", "17 4 8 13 19", "10 28", "10 25 33 38 24 0", "17 29 31 15", "32 18 41 27 19", "26 17", "7 13", "12 24 24 20 0", "10 15 0 28 5", "21 29 26 7 5", "41 43 19 5 10 15", "7 31 20", "38 24", "33 20 5", "19 31", "33 13 20 9 15 19", "2 8 10 18", "18 15", "20 15", "28 0 26 5 10", "20 11", "10 47 28 36 19", "34 28 36 43 24 0", "42 26 0 22 15", "10 19 35 25 19", "24 39 15", "34 40", "27 35 20 19", "19 26 24 10", "30 25 15 0 5", "24 23 29 0 5", "15 24", "5 24 20 12 15", "29 32 35", "12 18 15", "25 32 24 16", "19 24 0 24 10", "37 25 33", "39 5 24", "9 16 23 18 19 24", "25 20 36 29 0 5", "19 8 27 10 0", "36 33", "15 10 27 42 24", "23 40 36", "28 7 4 10 15", "33 36", "42 21"}

    Returns: 217

  38. {"28 21 19 11", "10 24 13 21 19 15", "31 10 15 33 10", "34 25 5 10", "15 19 18 9 24", "24 36", "40 34 15 30 5 10", "17 10 11 25 19 24", "4 27 10 23 5", "8 34 5", "27 33", "16 8 33 23", "20 44 34 23 10", "42 26", "23 29 15 0", "0 24 10 15 19", "35 39 32 24", "35 10 5", "15 12 9 29 19", "0 39 32 24 5 15", "31 27 36 41 24"}

    Returns: 68

  39. {"35 19", "15 5 10 20 19 24", "8 14 19 0 19 24", "31 17 23 36 0", "30 24", "22 25 24 32 19 15", "26 5 10", "18 26 32 40 15 0", "32 0 5", "24 11 19 0", "30 20 38 40 5 24", "46 10 0 29 15 19", "26 35 14 12", "31 20 24 15", "31 23 36", "25 21 10", "33 15 27 10", "41 25", "37 43 18", "25 12 5 32", "12 19 10 24 0 24", "23 27", "15 14 21 8 19 24", "43 28"}

    Returns: 97

  40. {"1 6 11 16 20 26"}

    Returns: -1

    remember that you can't play more than 4 fretted notes at a time.

  41. {"22 29 20", "10 24 13", "0 2", "1 15 14 25 19", "15 6 24 5", "15 15 24 4 19", "0 25 30 35 19 24", "23 18", "5 9 17", "5 31 23", "34 29 40 44 0 5", "17 36 25 33 0 15", "36 22 29 19", "33 30 10 9 5", "17 20 26 4", "16 42", "23 37", "9 10", "7 26", "21 32 8 17", "39 15 23 27 15", "29 22 36 15", "9 22 10 24", "10 7 15 20", "33 21 40 15 24 5", "15 22 26 24 19 0", "25 32 19 36 10 24", "16 15 13 24 0", "13 10 29 37", "33 36 24 27", "10 19", "24 15 5", "35 40 27", "38 29 32 25", "29 32", "10 14 29 31 24 5", "13 28 21", "25 18 35 15 24"}

    Returns: -1

  42. {"33 43 38 27 24", "38 17 10", "33 5 17 19 15 0", "44 16", "19 15 36 19 15 10", "7 15 5 25 24 10", "41 38 0 15", "22 17 27 5", "0 31", "9 25 30 17", "19 5 29 40 15", "29 15 15 9 24", "22 0 26 30 24 5", "21 32", "31 16 6 11 15 19", "28 18 35", "18 9 15 19", "5 19", "38 36 24"}

    Returns: -1

  43. {"31 37 20 23", "19 20", "33 28 21 17", "38 39", "16 41 27 38", "15 15 19 23 19", "21 26 15 33 19", "15 35 26 0 24 5", "0 25 42", "16 26 32 37 5", "24 34 7 19 19 5", "23 34 38 10", "26 13 38 30 10", "24 10 33 20 19", "42 25", "27 24 0 16 10 19", "34 13 29", "24 18 29", "0 31 18", "17 23 0", "10 15 27", "35 27 10 31", "30 16 19 27 24 0", "20 29 7", "13 16 23", "28 2 7", "42 13", "24 26 13 0 10", "5 41 25 30", "18 23 37", "22 36 15", "17 15 19 30 0 5", "23 40 0 28 15", "10 29 20", "5 24 12 22 19 10", "5 21 27 0", "45 41", "12 17 20 27", "39 30 34 10", "19 3 10 18 24 5", "10 12 22", "20 37 27", "14 20 10", "34 36 24", "26 31", "38 40 45 22 10", "19 10 34 43 5", "19 26 28 35 19", "22 30 5 8"}

    Returns: -1

  44. {"45 20 19 24 10", "38 18", "19 24 11 16 10", "27 0", "34 39 41 19 10 5", "11 48", "34 40 29 37 0", "22 18 26 34", "19 43 21 10", "27 43 17 23 15 19", "43 41 20", "10 26 3 5 15 19", "33 14 5 24 15 24", "31 22", "8 11 10 20", "16 5 29 5 19 15", "35 19 23", "19 23 34 27 24", "23 25", "23 12 17", "26 9 13 10 15", "29 14", "21 16 10 32 24", "12 24 28 20", "36 16 21 27", "21 10 24 32", "22 20 29 39", "19 44 26", "20 19 24", "19 31", "5 35 44 20 10", "14 0 16 24 19", "43 23 35", "34 36 26 0 19 24", "44 35 20 19", "25 17 34 15", "12 38 17 21", "15 41", "16 0", "36 12 5 22", "19 34 23 28 0", "18 38 29 5 24 15", "28 15", "13 10 17 28", "32 28 37", "15 40 19 34 10", "28 41 32 21", "22 7 10 10 19", "3 13 7"}

    Returns: -1

  45. {"30 46 39 0", "26 15 10", "27 15", "15 8", "46 20 5 31 15 19", "30 19 22 0 5 19", "21 28", "33 11 18 22 19", "26 33 15 24 0 5", "25 17 21 6", "17 29 10 2 5 19", "37 19 27", "19 0", "41 48 27", "6 17 19 24", "21 31 15", "27 35", "19 38 15", "30 19", "19 20", "0 19", "13 4 28 19 5", "17 32", "15 26 20 32 19 24", "33 15 26", "2 19", "10 15", "25 19 29 5 5", "31 38 24 16", "23 33", "10 43 45 5", "16 21 10 25 24 0", "17 48", "21 25 19 15 24 0", "27 40 31 19", "0 5 19 34", "26 5", "19 9 22 15 24", "24 21 29", "29 10 7 25 5 24", "21 24 28 34", "12 15 17 23 19"}

    Returns: -1

  46. {"15 31", "0 5", "22 10 41 15 19", "19 19 36", "28 3 9 13 15", "32 40 36 47 0 5", "6 31 12 24", "22 28 15 38 24", "18 24 22 1", "6 6", "28 19 13 6 5 15", "41 36 0 20", "3 20 29 19 5 10", "15 26 21 30 0 5", "27 15 16 22 19", "35 28 10 37 0 5", "10 19", "16 30 21 28 24", "5 16"}

    Returns: -1

  47. {"14 4 24 9", "37 12 16 20 19", "31 46 26 36", "19 31 43 15 5 19", "12 5 22 28 19 24", "16 22 25 6", "41 41", "46 32 23 28 15", "20 23 3 27 5 10", "5 0 17 19", "24 15 0 8 10 19", "46 22 19 32 15", "32 37 42", "34 29 12", "13 18 32 23 24 15", "27 14 22 34 15 24"}

    Returns: -1

  48. {"30 44", "35 27 28 0 5", "5 26 15 36", "24 5", "25 14 20 3 24 5", "30 25", "18 37 22", "13 5 17 0 19", "5 27 20 24 15 0", "19 5 11", "24 10 32", "42 39 5 10 0 24", "47 18", "9 33 12 17 15", "15 36 18 40", "17 34 25 29", "20 24 8 14 15 19", "33 35 40", "25 24", "26 32 39 21 24", "10 42 36", "45 32 22 29", "21 25", "21 33 30 25 19 24", "10 10 21 25 24 0", "31 28 38", "10 11 15 18 19", "5 0 27 14 15 19", "34 11 21 16 15", "32 28 40 45 0", "29 10 13 19", "23 15 10 28 24 0", "17 37 33 39 10 5", "47 29 36 43 10", "15 14 5 32", "19 24 31 36 0 5"}

    Returns: -1

  49. {"24 11 25 15 19 10", "15 27", "24 9", "35 43 25 19 10", "33 10 23 19", "29 13 5", "38 22", "39 15 31", "9 46", "34 5 39 29", "14 20", "30 17 6 10 15", "21 0", "9 15 25 3", "5 33 39 15 10", "10 20", "30 35 40 45 0 5", "27 10 19 46 15", "38 42 21", "38 33 43 10 0 5", "26 31 33", "0 7", "29 24 33 11", "10 23 24", "26 10 15 19 24 0", "14 4 21 25", "12 33 29", "10 5 0 31", "14 28 31 36 5 10", "32 19 15 23 19", "38 22", "25 44", "15 22 19 24 10", "19 35 26 11 5 10", "18 19 33", "24 37 19 10 24 15", "24 15 30 21", "20 19", "15 38", "19 24", "10 28 15 20 19", "21 24 31 15", "11 9", "10 24 26", "6 24 31 23 5"}

    Returns: -1

  50. {"22 4 8 13", "23 32 27 19", "10 14 34 30 15 0", "23 27 34 9 5 10", "24 12 8 18", "19 41 15 19 10 15", "29 6 18", "24 28", "15 15 24 32 0 5", "19 40 5 28", "10 45 26 36 0", "12 2 21", "23 44 30 19", "8 45", "31 15 35 42 5 10", "13 19 25 29", "10 22 44 40 5 15", "13 32", "29 26 34 0", "24 28 13", "25 37 31 39 24", "20 9 29 34 15", "20 27 19", "27 31 15 39 0", "23 28 31 40", "15 5 39 33 0", "32 36", "40 23 30", "17 2", "9 24", "31 26 23 13", "12 10", "0 12 20 19 24", "37 32 0", "35 37 42 29 0", "38 43 5 18 10", "20 4 10 14 24 19", "24 24 3"}

    Returns: -1

  51. { "11 13 19", "19 32 14 18 15", "36 26 31", "19 39 24", "32 0 35 10 24", "17 24 5 26 19 15", "15 28 20 35", "33 22 29 37", "5 22 5 15 15", "34 22 43 25 10", "35 16 12 27 19", "28 46 35 33", "10 25 18", "27 19 22 33 19", "41 48 27 0", "27 40", "16 21", "19 30", "34 44 41 19 5", "23 19 9", "24 0 19", "31 27 37 19 24", "5 30 11 15 10 19", "27 32 24 36 0", "21 26 14 30", "32 16 22 5 19", "41 25 30 19", "29 9 3", "5 15 19", "31 4 11 25 10 15", "23 40 27 18 15 19", "16 12 23 24 24", "9 27 19 11 19 0", "32 13 17 10 15" }

    Returns: 180

  52. { "44 39 18 36 10 5", "20 26 32", "28 32 0 14 10 15", "7 21 19 30 5", "26 29 5 23 5 10", "29 36", "34 24 18 11 5 19", "19 6 10 14", "15 32 19 28 15", "5 22 28 30", "26 31 42 36 0 5", "46 27", "23 12 8 28", "17 33", "20 34 38 15 10", "5 24", "43 33 19 19 5", "0 18 39 24", "5 31", "28 36", "20 10 0 30 19 24", "31 6 15 24 5", "32 27 38 0", "19 10 15 25 24", "28 19 39 13", "0 15 22 12", "16 21 24", "5 11 31", "8 34 19 23", "19 22", "10 29 34", "41 0", "0 14 21", "10 15 5 41 15", "42 47 23", "16 10 31 27 24", "12 16 19 29 15 0", "10 24 6 23", "32 17", "16 21 27 24", "24 15 0", "19 32 33 15 24" }

    Returns: 156

  53. {"1 6 11 16 20 24"}

    Returns: -1

  54. { "44 48" }

    Returns: -1

  55. { "43 48" }

    Returns: 0

  56. { "5 25", "48" }

    Returns: 7


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: