A random programming challenge with a generic state diagram