solution to "brainfuck" problem on hackerrank.com