Solution by Tore Andersson
