Coding challenge

Write some code that will solve this problem: There is an airplane with 100 seats, and 100 flyers each have 1 seat number assigned to them. Each passenger is supposed to board the plane in order, so passenger 1 goes first. But, the first passenger unknowingly sits in a random seat, but from then on all the passengers sit in their correct position. That is, unless their seat is taken, in which case they also take a random seat. What is the probability that the final passenger sits in their correct seat (#100)? (Ans: 50%)

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: