Code sketch to solve various problems