code for logical programming problems