Yes, references will help you.

As to design the algorithm, think about what you need to do to make shift work the first time (shifting ABCDE to be BCDEA). What do you need to do with the variables and so on to make this happend. When you have come up with that solution the rest will be obvious