moophis: implement question d with a naive algorithm