Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 166561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:07:10+00:00 2026-05-11T12:07:10+00:00

Given multiple (x,y) ordered pairs, I want to compare distances between each one of

  • 0

Given multiple (x,y) ordered pairs, I want to compare distances between each one of them. So pretend I have a list of ordered pairs:

pairs = [a,b,c,d,e,f] 

I have a function that takes two ordered pairs and find the distance between them:

def distance(a,b):     from math import sqrt as sqrt     from math import pow as pow     d1 = pow((a[0] - b[0]),2)     d2 = pow((a[1] - b[1]),2)     distance = sqrt(d1 + d2)     return distance 

How can I use this function to compare every ordered pair to every other ordered pair, ultimately finding the two ordered-pairs with the greatest distance between them?

Psuedopsuedocode:

     distance(a,b)      distance(a,c)      ...      distance(e,f) 

Any help would be tremendously appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:07:11+00:00Added an answer on May 11, 2026 at 12:07 pm
    try:      from itertools import combinations  except ImportError:      def combinations(l, n):         if n != 2: raise Exception('This placeholder only good for n=2')         for i in range(len(l)):             for j in range(i+1, len(l)):                 yield l[i], l[j]   coords_list = [(0,0), (3,4), (6,8)]  def distance(p1, p2):     return ( ( p2[0]-p1[0] ) ** 2 + ( p2[1]-p1[1] )**2 ) ** 0.5  largest_distance, (p1, p2) = max([      (distance(p1,p2), (p1, p2)) for (p1,p2) in combinations(coords_list, 2)      ])   print largest_distance, p1, p2 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have multiple multiple choices given to user after the form submit
Given one parent tab set, with each tab having multiple child tab sets. How
I have a List object being accessed by multiple threads. There is mostly one
If I have multiple Oracle clients installed on a given workstation (i.e. Oracle 9
My question is as follows: I have given a workbook to multiple people. They
I have a django application using multiple databases. Given an instance of a model,
I have to give one option in my website to upload multiple files and
Given several vectors/sets, each of which contains multiple integer numbers which are different within
The function below returns all folders in a given directory down to multiple levels.
I have one group table with a recursive relation, so each record has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.