Coding challenge

A person starts at 0 on the real number line. They toss a fair coin 8 times. If it's heads the move 1 unit in the positive direction. Tails, 1 unit in the negative direction. What is the probability that 4 is reached at some time during this process? Use math.random(1,2) to simulate the coin toss, where 1 is heads and 2 is tails. (Ans: 23/128.) (Ref: 2016 AMC 12A problems/problem #19.)

Type your code here:

Lua reference

See your results here:

Show a friend, family member, or teacher what you've done!

Here is a share link to your code: