check whether two lines (x1,x2) and (x3,x4) on the x-axis do overlap or not
It returns True if they DO overlap, otherwise False
As an example, (1,5) and (2,6) overlaps but not (1,5) and (6,8).
The solution was based on the following schema:
A0------------------A1
B0------B1 B0------B1
if B1<A0 OR B0>A1 then
Line B does NOT overlap Line A
else
Line B DOES ovelap Line A
Therefore, we need to make sure the A and B are ordered:
def swap(X):
'''
this function does make sure the pair is
ordered (a,b) where a<b
(10, -5) would become (-5, 10)
'''
if X[0]>X[1]:
return (X[1],X[0])
return X
A, B = swap(A), swap(B)
Proposed solution:
def isbovera(A,B):
# Return True if A Line overlaps B Line; False otherwise
A, B = swap(A), swap(B)
return not (B[1]<A[0] or B[0]>A[1])
In order to call this function, please take a look at the testOverlapV0.py
(venv) C:\work\vanhack\venv\Quiz\test_A>python testOverlapV0.py
This program that accepts two lines (x1,x2) and (x3,x4) on the x-axis and returns whether they overlap (True) or not overlap (False)
Enter total number of lines to check, default=1 pair to check
please add 1 lines to be checked - use comma
(1,2),(3,4) should be typed as 1,2,3,4
1,5,2,6
(1.0, 5.0) (2.0, 6.0) True
True means (1,2) and (5,6) do overlap
Let's check the following pair (1,5) and (6,8)
(1,5) and (6,8) should be entered as below:
1,5,6,8
(1.0, 5.0) (6.0, 8.0) False
False means (1,2) and (6,8) do NOT overlap
Note: We are using float although has no mention about it - set/intersection could also handle it but only for int figures
in order to run it as a batch module, a text file should be created with n pairs (comma separeted) as follow:
first line, number of pair to check second line next pair to check and so on
ex:
4
13 , -6 , -8 , 3
-15 , -6 , 4 , -11
-4 , -2 , 0 , -20
-18 , 9 , 10 , 12
** please check testsample.txt **
python testOverlapV0.py <testsample.txt
This program that accepts two lines (x1,x2) and (x3,x4) on the x-axis and returns whether they overlap Enter total number of lines to check, default=1 pair to check please add 100 lines to be checked - use comma (1,2),(3,4) should be typed as 1,2,3,4
(13.0, -6.0) (-8.0, 3.0) True
(-15.0, -6.0) (4.0, -11.0) True
(-4.0, -2.0) (0.0, -20.0) True
(-18.0, 9.0) (10.0, 12.0) False
Metadata
Release files for isover10 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| isover10-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for isover10-0.1.5-py3-none-any.whl |
Release files / isover10-0.1.5-py3-none-any.whl
| Download URL | isover10-0.1.5-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27f6983d0ee8b5b24b692d727d7eae3bebbdbabc97fbb870cd5a82ebcfee0b9f
|
|
BLAKE2b-256 checksum How to use checksums |
f49de9b44a5df195349aedfe485623485a5bbb06945b2ea36cb78c903ba145ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
|
Security for isover10 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.