(brute-force) solution to problem 27 added