CODE Indonesia interview question

Question about logic programming & some SQL