đź’¬ Gold panning Help

I feel like its a weird place to get hung up but here i am. I have no idea what i am missing when it comes to getting the sell function to work for the total instead of selling the first pan.

Can you explain in English what steps you’d take, say, if you were panning for gold in person and selling nuggets in person?

I would start by panning, total up what was found then sell that.

Could you break that down into small, explicit steps then turn those steps into code?

That’s kind of where i’m struggling. I get that I want to sell the total number of panned gold but I can’t seem to translate that appropriately .

let found = pan()
repeat(5){
pan()
found = found + pan()
sell(found)
}

Here is what I have so far. am I at least moving in the right direction ?

I would start by panning, total up what was found then sell that.

Break that down into small, explicit English steps. Explain it to me like I’m 5, step by step.

first we pan, then we add up how much we’ve found, then we would pan again add that to our total. Pan once more and total that up with the rest. once we have everything for the day we would go sell the total amount of gold we have panned for the day.

first we pan, then we add up how much we’ve found, then we would pan again add that to our total. Pan once more and total that up with the rest.

This sounds like you’re doing “pan” then “add” repeatedly.

once we have everything for the day we would go sell the total amount of gold we have panned for the day.

This sounds lke it occurs after the repeated work is completed.

When I pull the sell function outside of the repeat the code doesn’t sell any of the panned gold. :distorted_face: It like it is not acknowledging anything after we do the panning

  1. Can you share the code?
  2. How many times are you calling pan()?

let found = pan()
repeat(5){
pan()
found = found +pan()+pan()+pan()
}
sell(found)

I tried adjusting that but the editor wont let me call it more than one other time before giving me a error

How many times would that call pan()? Use the scrubber if you’re unsure to go through the code one bit at a time!

this should call pan() 4 times once for the initial found and then 3 more times for the addition. when i add anymore the scrubber just says oops something’s wrong and doesnt give me any more info.

Once for the initial found. Then once (total 2) after the repeat(5) line. Then three more times on the found = line (5). Then repeat that 4 more times with 4 calls each (5 + 4 * 4 = 21 times)!

first we pan, then we add up how much we’ve found, then we would pan again add that to our total. Pan once more and total that up with the rest.

This mentions “pan then add” three times. Your code does “pan, pan, pan, pan, pan, add” … five times. Those aren’t the same thing!

wooo yeah okay got it so i’m way off.

let found = 0
repeat(5){
pan()
found = pan() + found
}
sell(found)

going through the scrubber I am seeing that when the code like this the first time i calls pan() it is not adding that to my total. so it doesn’t seem to be totaling up the panned gold until it starts on the 2nd iteration then stops functioning all together after the 4th

Why are you panning twice in the loop?

first we pan, then we add up how much we’ve found, then we would pan again add that to our total. Pan once more and total that up with the rest.

This only mentioned panning once in each section.

I am not understanding how this is panning twice in the loop.

How many times is pan() inside the loop?

I see it’s in there twice but i understood that section to be totaling it up and when i look through the scrubber it seems to be doing just that.

If pan() is in the loop twice, then it will call pan() twice. Every time Jiki sees pan(), Jiki will call the function/go panning.