Can someone silplify this simple code?

Try searching the forum for 'combination lock'.