UVa 12096: Updated version