[Programming Problem] Paint Fence

You are painting a fence of n posts with k different colors. You must paint the posts following these rules: Every post must be...