If you're an intern or apprentice then the entire point of you being there is to learn, so ask as much as you can.
Otherwise, time is money, both your time and the time of the person(s) you're asking. Assuming both outcomes are equally likely (being able to figure it out on your own vs not being able to), and assuming that the person you would ask has the time and is willing to help,
if
your time at your value plus the value of you learning
is less than or equal to
their time at their value plus the value of them teaching
then
try to figure it out on your own
else feel free to ask away