You are given a string whose characters describe a one-dimensional arrangement of colored balls, the holes that belong to those colors, and unoccupied positions. An uppercase letter denotes a ball of one specific color, while the lowercase version of the same letter denotes the hole assigned to that color. The symbol '#' denotes an empty spot.
Your task is to determine the smallest number of steps required to bring every ball into its matching hole. During a single step, a ball may be transferred to a spot directly adjacent to it.
Implement min_steps_to_match(sequence), which accepts the string as its argument and returns the minimum number of steps as an integer.
Example 1:
Input: sequence = 'R,#,b,#,r,B,b'
Output: 5
sequence = R, #, b, #, r, B, b5
Ignoring commas, the row is R # b # r B b at positions 0 through 6.
sequence = R, #, b, #, r, B, b5
Ignoring commas, the row is R # b # r B b at positions 0 through 6.