Writing code during an interview is a party trick. But then HR seldom goes beyond party tricks when hiring software professionals.
HR can screen out those who are obviously unqualified, but the final hiring decision should be vested in the manager or team leader who will be responsible for the new hire's performance.
Depending on the nature of the project, the manager or team leader may need to spend considerable time selecting his direct reports from available qualified candidates.