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

Ask A Question

Stats

  • Questions 305k
  • Answers 305k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For the twodimensional case, it should be: Two(int length, int… May 13, 2026 at 9:03 pm
  • Editorial Team
    Editorial Team added an answer date('l, F d, Y h:i A', strtotime($the_date)); date() edit: date(DATE_RFC822,… May 13, 2026 at 9:03 pm
  • Editorial Team
    Editorial Team added an answer Tag the UIAlertViews like this: #define kAlertViewOne 1 #define kAlertViewTwo… May 13, 2026 at 9:03 pm

Related Questions

I want to use a data structure for sorting space-time data (x,y,z,time). Currently a
I've got a regular expression (javascript) which is something like... /(x)(y)+(z)/gi The problem is
Given a set of tuple classes in an OOP language: Pair, Triple and Quad,
Given the following snippet of javascript in a scope: var x = 10; function

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.