Piano/Guitar Fingering
- given musical piece to play, say sequence of n (single) notes with right hand
- fingers 1, 2, . . . , F = 5 for humans
- metric d(f, p, g, q) of difficulty going from note p with finger f to note q with finger g
Correct DP:
- subproblem = min difficulty for suffix notes[i :] given finger f on first note[i]
- guessing = finger g for next note[i + 1]
- recurrence:
- DP[i, f] = min(DP[i + 1, g] + d(note[i], f, note[i + 1], g) for g in range(F))
- DP[n, f] = 0
- topo. order: for i in reversed(range(n)): for f in 1, 2, . . . , F: total time O(nF^2 )
- orig. prob. = min(DP[0, f] for f in 1, . . . , F)