Do professors work through all the homework problems they assign to students? I'm wondering if this is case especially for time-consuming work like programming problems in computer science spanning several thousand lines of code. 

Or when a professor teaches a new course they are not intimately familiar with e.g. did not take it during undergrad.

For professors that don't do this, how (if at all possible) do they address homework concerns during office hours? Is it recommended for professors to know the ins and outs of all problems they assign?
For many professors, undergraduate courses are simple enough that when they go over 1-2 problems, they can grasp them quickly. For others, they go over solution manuals and previous notes to recall and remember how to do them. Some assign office hours to TAs, where the TA deals with students and their homework. Keep in mind that many schools do tell the professors which courses they will teach next semester/year, so they have plenty of time to prepare and develop their notes and slides.

I would be more worried about professors teaching graduate level courses that are not familiar with. It seems that many issues/inconsistencies occur at this level.