Question: 1 . Write a function ( using python language ) that takes an integer n and outputs all possible pairs. For example, when n =

1. Write a function (using python language) that takes an integer n and outputs all possible pairs. For example, when n=5, the output should look like:
y y ---
y - y --
y -- y -
y --- y
- y y --
- y - y -
- y -- y
-- y y -
-- y - y
--- y y
2. Modify the function to display only pairs that are at a minimum distance d. For example, if the minimum distance is d=2, the above example for n=5 will become:
y - y --
y -- y -
y --- y
- y - y -
- y -- y
-- y - y
3. Explore how that changes the number of pairs from n(n1)/2. Find a formula in terms of n and d.

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 Programming Questions!