codes from different practice problems