Solving Mamono Sweeper requires a constraint satisfaction solver. (or is MUCH more easily solved that way)
Unfortunately, there aren't really any in Perl. While there are several powerful ones in Python: