Exercise and solution for locking