Question: In Python please 1) 100 dogs stand in a line. The first one holds a bag full of biscuits. Initially, none of the dogs has

In Python please

In Python please 1) 100 dogs stand in a line. The first

1) 100 dogs stand in a line. The first one holds a bag full of biscuits. Initially, none of the dogs has a stick. 2) Each dog along the line takes a turn as "runner" and carries the bag of biscuits. The runner starts with themselves and walks down the line of dogs giving or taking away biscuits. After they are done, the runners return to their position, handing the bag off to the next runner, and are done for the game. 3) The runner goes down the line of dogs, starting with themselves. For each dog whose position is a multiple of their own, then * if the dog has a stick, the runner takes it away. * if the dog has no stick, the runner gives a stick. (i.e., if runner is in position 7, they check whether they and dog 17 21 28 etc. have biscuits) Who has a stick at the end of the game? Hint: Start by importing some essentials from NumPy from numpy import zeros Create an array containing the number of biscuits each dog holds. biscuits = zeros (100) The values in biscuits can only be either 0 or 1 according to the rules. Be careful with array indexing: dog #1 is indicated by biscuits[0] You have two options for modeling the runner: a) Use the % operator to find modulus (remainder on division) to check if each dog is a multiple b) Use a step size in the range function to skip over dogs as the runner goes down the line Here's how to structure option b: At any one time, there are two players interacting, the runner with the bag, and the dog in the line where the runner stops. So, we need nested loops. The outer loop has each player taking a turn as runner. The inner loop goes thru each dog the runner interacts with. Note that the step size is runner+1 to account for the offset for runner in range(100): for dog in range(runner, 100, runner+1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!