Question: Python: I have a perfectly square 30m x 30m backyard. I bought 10 trees and I want to plant them in totally random places so
Python: I have a perfectly square 30m x 30m backyard. I bought 10 trees and I want to plant them in totally random places so that it looks more natural. Im concerned that if we plant any two trees within 3m of each other, then they will have a hard time growing. Create a program that makes a 30x30 2D list, and randomly assigns positions for 10 trees. You must keep re-doing the process until no two trees are within 3 meters of each other. [50 marks] Note: use pythagorean theorem to calculate distance.
For example, here is an invalid backyard This backyard is invalid because the two circled trees are 2.82 meters apart. One treba at position (1,1) and the other is at (3, 3). The distance is 1-V2) + (--(8 - 1)* + (3 - 17 - 2+2 V82.82 meters Here is a valid backyard
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
