julzmighty has explained the problem with the more likely combinations.

...
i had a new idea:
Code:
s = 1
def rand7():
global s
s = 1 - s
result = 0
if rand5() > (2+s): result += 1<<0
if rand5() > (2+s): result += 1<<1
if rand5() > (2+s): result += 1<<2
return result

but it uses a global variable and 0 and 7 are about 15% more probable than the rest of the numbers.

...
i wonder how much time the candidates have for this question at nvidia and how many come up with a correct solution. or is this some very well known problem you learn about if you study computer science at an university?