{ "info": { "author": "Miguel Almeida", "author_email": "mplabdev@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Build Tools", "Topic :: Software Development :: Internationalization" ], "description": "\ncheck whether two lines (x1,x2) and (x3,x4) on the x-axis do overlap or not \n\nIt returns True if they DO overlap, otherwise False\n\nAs an example, (1,5) and (2,6) overlaps but not (1,5) and (6,8).\n\nThe solution was based on the following schema:\n\n A0------------------A1\n B0------B1 B0------B1\n\n if B1A1 then\n Line B does NOT overlap Line A\n else\n Line B DOES ovelap Line A\n\n\nTherefore, we need to make sure the A and B are ordered:\n\n def swap(X):\n '''\n this function does make sure the pair is \n ordered (a,b) where aX[1]:\n return (X[1],X[0])\n return X\n\n A, B = swap(A), swap(B)\n\n Proposed solution:\n\n def isbovera(A,B):\n\n # Return True if A Line overlaps B Line; False otherwise\n\n A, B = swap(A), swap(B)\n\n return not (B[1]A[1])\n\nIn order to call this function, please take a look at the testOverlapV0.py\n\n(venv) C:\\work\\vanhack\\venv\\Quiz\\test_A>python testOverlapV0.py\n\nThis program that accepts two lines (x1,x2) and (x3,x4) on the x-axis and returns \nwhether they overlap (True) or not overlap (False)\n\nEnter total number of lines to check, default=1 pair to check\n\nplease add 1 lines to be checked - use comma\n\n(1,2),(3,4) should be typed as 1,2,3,4\n\n1,5,2,6\n\n(1.0, 5.0) (2.0, 6.0) True\n\nTrue means (1,2) and (5,6) do overlap\n\nLet's check the following pair (1,5) and (6,8)\n\n(1,5) and (6,8) should be entered as below:\n\n1,5,6,8\n\n\n(1.0, 5.0) (6.0, 8.0) False\n\nFalse means (1,2) and (6,8) do NOT overlap\n\nNote:\n We are using float although has no mention about it - set/intersection could also handle it but only for int figures\n\n in order to run it as a batch module, a text file should be created with n pairs (comma separeted) as follow:\n\n first line, number of pair to check\n second line next pair to check\n and so on\n\nex:\n\n4\n\n13 , -6 , -8 , 3\n\n-15 , -6 , 4 , -11\n\n-4 , -2 , 0 , -20\n\n-18 , 9 , 10 , 12\n\n** please check testsample.txt ** \n\npython testOverlapV0.py