Python Forum
compare and find the nearest element ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
compare and find the nearest element ?
#1
hello,
I need a little help, I have a list (element has 2 elements(X and Y)), and I need to find, in this list, which element is the nearest of my mouse (we have already X and Y of the mouse).
Can you help me please ?

Also, can you know how can I wrote "move away" for evade if they are bomb in approach ? like " Xbomb - 30px ", can it work ?

PS : I'm french, sorry if I make misstake in my message... Doh
Reply
#2
Please show the code you have created so far in code tags.
Reply
#3
(Jan-14-2023, 09:54 PM)Yoriz Wrote: Please show the code you have created so far in code tags.
what I must put ?
the entire code ?
Reply
#4
Show the minimal amount of code required to show the problem you require help with.
For instance how do you represent a list of x and y coordinates, how is the x and y of the mouse represented.
What is a xbomb in relation to the above and what does 30px represent.
Reply
#5
If your problem is "nearest" match to a list of numbers,
you can easily write a small example program to demonstrate the problem .
While doing that, you may find that the python module "bisect"
comes very close to what you want, if I understand your question correctly.
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Get numpy ceil and floor value for nearest two decimals klllmmm 4 1,265 Jun-07-2023, 07:35 AM
Last Post: paul18fr
  Find (each) element from a list in a file tester_V 3 1,205 Nov-15-2022, 08:40 PM
Last Post: tester_V
  [SOLVED] [Beautifulsoup] Find if element exists, and edit/append? Winfried 2 4,284 Sep-03-2022, 10:14 PM
Last Post: Winfried
  How to find the second lowest element in the list? Anonymous 3 1,999 May-31-2022, 01:58 PM
Last Post: Larz60+
  Compare each element of an array in a logic statement without using a for loop leocsmith 3 5,850 Apr-01-2021, 07:57 PM
Last Post: deanhystad
  Rounding to the nearest eight wallgraffiti 2 2,072 Jul-15-2020, 06:05 PM
Last Post: wallgraffiti
  how to compare two different size images in python and find corresponding pixel value squidsirymchenry 1 4,569 Feb-03-2020, 06:48 AM
Last Post: michael1789
  find nearest number d3fi 7 3,940 Aug-26-2019, 09:32 PM
Last Post: ichabod801
  Finding nearest point of a Multidigraph in Python 3.7 stixmagiggins 5 3,754 Aug-24-2019, 08:51 AM
Last Post: ThomasL
  compare element of a dictionary Amniote 1 2,156 May-23-2019, 05:21 PM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020