Mario s'entraîne pour les jeux olympiques d'hiver
This commit is contained in:
60
Mario s'entraîne pour les jeux olympiques d'hiver.py
Normal file
60
Mario s'entraîne pour les jeux olympiques d'hiver.py
Normal file
@@ -0,0 +1,60 @@
|
||||
import datetime
|
||||
|
||||
input = open("trace_mario.txt").read()
|
||||
# input = open("trace_mario_example.txt").read()
|
||||
|
||||
input = input.splitlines()
|
||||
|
||||
def conpute_distance(pos1, pos2):
|
||||
"""from math import radians, cos, sin, asin, sqrt
|
||||
|
||||
# convert decimal degrees to radians
|
||||
lon1, lat1, lon2, lat2 = map(radians, [pos1["long"], pos1["lat"], pos2["long"], pos2["lat"]])
|
||||
|
||||
# haversine formula
|
||||
dlon = lon2 - lon1
|
||||
dlat = lat2 - lat1
|
||||
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
|
||||
c = 2 * asin(sqrt(a))
|
||||
r = 6371 # Radius of earth in kilometers. Use 3956 for miles. Determines return value units.
|
||||
|
||||
dalt = pos2["alt"] - pos1["alt"]
|
||||
return sqrt((c * r )**2 + dalt**2) * 1000"""
|
||||
from math import pi, cos, sqrt
|
||||
|
||||
r = 6371 * 1000
|
||||
|
||||
dlat = pos2["lat"] - pos1["lat"]
|
||||
dlong = pos2["long"] - pos1["long"]
|
||||
|
||||
dist_lat = (2 * pi * r) / 360 * dlat
|
||||
dist_long = (2 * pi * r * cos((pos1["lat"] + pos1["lat"])/2/360*2*pi)) / 360 * dlong
|
||||
dist_alt = pos2["alt"] - pos1["alt"]
|
||||
|
||||
return sqrt((dist_lat**2+dist_long**2)+dist_alt**2)
|
||||
|
||||
data = []
|
||||
|
||||
for line in input:
|
||||
lat, long, alt, horodate = line.split(" ")
|
||||
data.append({"lat":float(lat), "long":float(long), "alt":float(alt), "time":datetime.datetime.strptime(horodate, "%H:%M:%S")})
|
||||
|
||||
distance = 0
|
||||
duree = datetime.datetime.min
|
||||
montee_descente = "M" #Montée par défaut
|
||||
|
||||
for i in range(1, len(data)):
|
||||
#Check altitude
|
||||
if data[i]["alt"] < data[i-1]["alt"]:
|
||||
montee_descente = "D"
|
||||
elif data[i]["alt"] > data[i-1]["alt"]:
|
||||
montee_descente = "M"
|
||||
|
||||
#If descente
|
||||
if montee_descente == "D":
|
||||
duree = duree + (data[i]["time"] - data[i-1]["time"])
|
||||
distance = distance + conpute_distance(data[i], data[i-1])
|
||||
|
||||
duree = duree - datetime.datetime.min
|
||||
|
||||
print(distance, distance/duree.total_seconds())
|
||||
3756
trace_mario.txt
Normal file
3756
trace_mario.txt
Normal file
File diff suppressed because it is too large
Load Diff
207
trace_mario_example.txt
Normal file
207
trace_mario_example.txt
Normal file
@@ -0,0 +1,207 @@
|
||||
42.57737793959677 2.0706909243017435 1664.274 9:39:26
|
||||
42.577339969575405 2.070648930966854 1665.174 9:39:45
|
||||
42.57734399288893 2.070545917376876 1668.322 9:40:1
|
||||
42.57736897096038 2.0704739168286324 1668.922 9:40:3
|
||||
42.57737894542515 2.0703819673508406 1669.174 9:40:5
|
||||
42.57739495486021 2.0702579990029335 1669.474 9:40:8
|
||||
42.57740291766822 2.0700969826430082 1669.874 9:40:12
|
||||
42.57741197012365 2.0699399895966053 1670.822 9:40:16
|
||||
42.57741197012365 2.0697879418730736 1672.022 9:40:20
|
||||
42.577423956245184 2.0696379896253347 1672.922 9:40:23
|
||||
42.57743795402348 2.0694829244166613 1674.096 9:40:26
|
||||
42.57745899260044 2.0693219918757677 1675.296 9:40:29
|
||||
42.57747994735837 2.0691609755158424 1676.496 9:40:32
|
||||
42.57749495096505 2.0690059941262007 1677.87 9:40:35
|
||||
42.57751791737974 2.0688469894230366 1679.37 9:40:38
|
||||
42.577534932643175 2.0687109511345625 1680.87 9:40:41
|
||||
42.57755094207823 2.0685589872300625 1682.37 9:40:44
|
||||
42.577575920149684 2.0684029161930084 1683.87 9:40:47
|
||||
42.57760098204017 2.0682579930871725 1685.37 9:40:50
|
||||
42.577622942626476 2.0681019220501184 1686.87 9:40:53
|
||||
42.57764892652631 2.067940989509225 1688.37 9:40:56
|
||||
42.57767893373966 2.067781984806061 1689.87 9:40:59
|
||||
42.5777149759233 2.067621974274516 1691.37 9:41:2
|
||||
42.577749928459525 2.0674569346010685 1692.696 9:41:5
|
||||
42.57778194732964 2.0672959182411432 1693.896 9:41:8
|
||||
42.5778169836849 2.067131968215108 1695.096 9:41:11
|
||||
42.57784699089825 2.066976986825466 1696.296 9:41:14
|
||||
42.577875992283225 2.0668199937790632 1697.496 9:41:17
|
||||
42.5778909958899 2.066671969369054 1698.696 9:41:20
|
||||
42.5779049936682 2.0665239449590445 1699.896 9:41:23
|
||||
42.57792494259775 2.0663699693977833 1701.644 9:41:26
|
||||
42.577919997274876 2.0662279799580574 1704.044 9:41:30
|
||||
42.57793491706252 2.0660739205777645 1706.444 9:41:34
|
||||
42.57793692871928 2.0659089647233486 1708.844 9:41:38
|
||||
42.57795092649758 2.0657649636268616 1710.644 9:41:41
|
||||
42.57797892205417 2.0656039472669363 1713.11 9:41:44
|
||||
42.57788999006152 2.065541921183467 1719.11 9:41:48
|
||||
42.577900970354676 2.0653729420155287 1725.11 9:41:52
|
||||
42.577916979789734 2.0652359817177057 1728.392 9:41:55
|
||||
42.57793491706252 2.065098937600851 1730.792 9:41:58
|
||||
42.57795193232596 2.064961977303028 1733.192 9:42:1
|
||||
42.577961990609765 2.064823927357793 1735.444 9:42:4
|
||||
42.57797598838806 2.0646859612315893 1737.244 9:42:7
|
||||
42.57799392566085 2.064550928771496 1739.044 9:42:10
|
||||
42.57801597006619 2.0644119568169117 1740.844 9:42:13
|
||||
42.57803499698639 2.0642749965190887 1743.192 9:42:16
|
||||
42.57805394008756 2.064137952402234 1745.592 9:42:19
|
||||
42.578072967007756 2.06399898044765 1747.9921 9:42:22
|
||||
42.57810398004949 2.0638579968363047 1750.218 9:42:25
|
||||
42.578131975606084 2.0637169294059277 1752.318 9:42:28
|
||||
42.57814697921276 2.0635799691081047 1754.425 9:42:31
|
||||
42.57814899086952 2.06344292499125 1756.37 9:42:34
|
||||
42.57814597338438 2.063351981341839 1757.37 9:42:36
|
||||
42.5781499966979 2.0632159430533648 1758.87 9:42:39
|
||||
42.57816491648555 2.0630799885839224 1760.37 9:42:42
|
||||
42.578178998082876 2.0629429444670677 1761.87 9:42:45
|
||||
42.5781949236989 2.0628059841692448 1763.37 9:42:48
|
||||
42.57820498198271 2.0627139508724213 1764.37 9:42:50
|
||||
42.578219985589385 2.062577996402979 1765.87 9:42:53
|
||||
42.57823498919606 2.0624399464577436 1767.644 9:42:56
|
||||
42.578244963660836 2.062347996979952 1768.844 9:42:58
|
||||
42.57825896143913 2.0622119586914778 1770.644 9:43:1
|
||||
42.578266924247146 2.0621199253946543 1771.844 9:43:3
|
||||
42.57827195338905 2.0620299875736237 1773.392 9:43:5
|
||||
42.57825896143913 2.0619439892470837 1774.992 9:43:7
|
||||
42.578263990581036 2.061849944293499 1776.592 9:43:9
|
||||
42.578267930075526 2.061757994815707 1778.192 9:43:11
|
||||
42.57828092202544 2.061619944870472 1780.37 9:43:14
|
||||
42.57829399779439 2.0614819787442684 1781.87 9:43:17
|
||||
42.57831193506718 2.061338983476162 1783.37 9:43:20
|
||||
42.578326938673854 2.0611959882080555 1784.87 9:43:23
|
||||
42.57834294810891 2.0610539987683296 1786.644 9:43:26
|
||||
42.57835895754397 2.060911925509572 1788.444 9:43:29
|
||||
42.578373961150646 2.060772953554988 1790.244 9:43:32
|
||||
42.57838795892894 2.0606369990855455 1791.87 9:43:35
|
||||
42.57840095087886 2.060499954968691 1793.37 9:43:38
|
||||
42.578412937000394 2.060359977185726 1794.87 9:43:41
|
||||
42.57842995226383 2.060215976089239 1796.518 9:43:44
|
||||
42.57844897918403 2.060069963335991 1798.618 9:43:47
|
||||
42.57846398279071 2.059929985553026 1800.718 9:43:50
|
||||
42.578477980569005 2.059793947264552 1802.818 9:43:53
|
||||
42.57849792949855 2.0596159994602203 1806.3627 9:43:57
|
||||
42.578518968075514 2.059484990313649 1809.0599 9:44:0
|
||||
42.57852793671191 2.0593479461967945 1811.7572 9:44:3
|
||||
42.57853598333895 2.0592109858989716 1814.1862 9:44:6
|
||||
42.578542940318584 2.0590729359537363 1816.5886 9:44:9
|
||||
42.57855894975364 2.0589359756559134 1818.991 9:44:12
|
||||
42.57857596501708 2.0587989315390587 1821.566 9:44:15
|
||||
42.57858099415898 2.0586599595844746 1824.266 9:44:18
|
||||
42.57859691977501 2.058531967923045 1826.966 9:44:21
|
||||
42.57861695252359 2.058372963219881 1830.914 9:44:25
|
||||
42.57863698527217 2.0582529343664646 1834.214 9:44:28
|
||||
42.57865995168686 2.058137934654951 1837.514 9:44:31
|
||||
42.57868492975831 2.058023940771818 1840.962 9:44:34
|
||||
42.57870093919337 2.0579089410603046 1844.8619 9:44:37
|
||||
42.57871191948652 2.0577929355204105 1848.762 9:44:40
|
||||
42.578733963891864 2.057677935808897 1852.662 9:44:43
|
||||
42.57874192669988 2.0575599186122417 1857.11 9:44:46
|
||||
42.57874494418502 2.0574339386075735 1861.61 9:44:49
|
||||
42.5787459500134 2.057308964431286 1866.11 9:44:52
|
||||
42.57875299081206 2.057184996083379 1872.002 9:44:55
|
||||
42.57876891642809 2.057058932259679 1878.902 9:44:58
|
||||
42.578778974711895 2.0569759514182806 1883.5021 9:45:0
|
||||
42.57879096083343 2.056895988062024 1888.102 9:45:2
|
||||
42.57879892364144 2.0568109955638647 1892.702 9:45:4
|
||||
42.57881199941039 2.056691972538829 1899.6019 9:45:7
|
||||
42.5788289308548 2.0565699320286512 1906.5021 9:45:10
|
||||
42.57883798331022 2.0564799942076206 1911.562 9:45:12
|
||||
42.578847957775 2.0563889667391777 1915.48 9:45:14
|
||||
42.57885592058301 2.056299950927496 1919.48 9:45:16
|
||||
42.578865978866816 2.0562079176306725 1923.48 9:45:18
|
||||
42.57887997664511 2.0561159681528807 1927.48 9:45:20
|
||||
42.57889196276665 2.0560279581695795 1931.48 9:45:22
|
||||
42.578905960544944 2.055940954014659 1935.406 9:45:24
|
||||
42.57891593500972 2.0558539498597383 1939.206 9:45:26
|
||||
42.578925993293524 2.055763928219676 1943.006 9:45:28
|
||||
42.57893697358668 2.055675918236375 1946.806 9:45:30
|
||||
42.578948959708214 2.0555859804153442 1950.606 9:45:32
|
||||
42.57896094582975 2.0555019937455654 1953.814 9:45:34
|
||||
42.578972931951284 2.055409960448742 1956.014 9:45:36
|
||||
42.57898399606347 2.0553179271519184 1958.214 9:45:38
|
||||
42.578994976356626 2.0552219543606043 1960.4141 9:45:40
|
||||
42.5790049508214 2.055129921063781 1962.614 9:45:42
|
||||
42.579015931114554 2.055035959929228 1964.814 9:45:44
|
||||
42.57902699522674 2.054941998794675 1967.014 9:45:46
|
||||
42.579037975519896 2.0548499654978514 1969.214 9:45:48
|
||||
42.57904895581305 2.054757932201028 1971.4141 9:45:50
|
||||
42.579054990783334 2.0546669885516167 1973.614 9:45:52
|
||||
42.57906295359135 2.054577972739935 1976.125 9:45:54
|
||||
42.57907594554126 2.054488956928253 1979.11 9:45:56
|
||||
42.57908893749118 2.0543999411165714 1982.11 9:45:58
|
||||
42.57909698411822 2.0543089974671602 1985.125 9:46:0
|
||||
42.579102935269475 2.054215958341956 1988.11 9:46:2
|
||||
42.57911492139101 2.054137922823429 1990.962 9:46:4
|
||||
42.579120956361294 2.054048990830779 1993.562 9:46:6
|
||||
42.579124979674816 2.053957963362336 1996.162 9:46:8
|
||||
42.57913394831121 2.0538669358938932 1998.762 9:46:10
|
||||
42.579141994938254 2.0537809375673532 2001.622 9:46:12
|
||||
42.57915196940303 2.053695945069194 2003.666 9:46:14
|
||||
42.57915792055428 2.0536109525710344 2005.4661 9:46:16
|
||||
42.579165967181325 2.053520930930972 2007.266 9:46:18
|
||||
42.57917392998934 2.053434932604432 2009.066 9:46:20
|
||||
42.579186921939254 2.0533399656414986 2010.866 9:46:22
|
||||
42.57919597439468 2.0532369520515203 2012.37 9:46:24
|
||||
42.57920594885945 2.0531399734318256 2013.37 9:46:26
|
||||
42.579210978001356 2.0530469343066216 2014.37 9:46:28
|
||||
42.579226987436414 2.052923971787095 2016.87 9:46:33
|
||||
42.57922296412289 2.052822969853878 2018.122 9:46:37
|
||||
42.579228999093175 2.0527289249002934 2018.722 9:46:39
|
||||
42.57923897355795 2.052645944058895 2019.322 9:46:41
|
||||
42.57918197661638 2.052695984020829 2022.348 9:46:55
|
||||
42.57913595996797 2.0527129992842674 2023.148 9:46:59
|
||||
42.5791259855032 2.052804948762059 2026.0 9:48:13
|
||||
42.57910595275462 2.0528819784522057 2026.274 9:48:16
|
||||
42.57908994331956 2.052974933758378 2026.574 9:48:19
|
||||
42.57907091639936 2.053052969276905 2026.774 9:48:21
|
||||
42.57904895581305 2.053148942068219 2026.974 9:48:23
|
||||
42.57909396663308 2.053242987021804 2026.1788 9:48:26
|
||||
42.57911492139101 2.053328985348344 2025.2797 9:48:29
|
||||
42.57911894470453 2.0534139778465033 2024.3806 9:48:32
|
||||
42.57915498688817 2.0534989703446627 2023.3263 9:48:40
|
||||
42.57913595996797 2.053603995591402 2019.904 9:49:36
|
||||
42.579124979674816 2.0537099428474903 2019.104 9:49:38
|
||||
42.57909597828984 2.0538459811359644 2018.304 9:49:40
|
||||
42.57909195497632 2.053992999717593 2017.504 9:49:42
|
||||
42.57909497246146 2.054134989157319 2016.408 9:49:44
|
||||
42.579187927767634 2.054297933354974 2014.008 9:49:47
|
||||
42.57921894080937 2.0544779766350985 2012.408 9:49:49
|
||||
42.57921198382974 2.0546709280461073 2010.808 9:49:51
|
||||
42.57922296412289 2.0548549946397543 2009.208 9:49:53
|
||||
42.57924794219434 2.055017938837409 2005.724 9:49:56
|
||||
42.57929898798466 2.0551279932260513 1994.308 9:50:35
|
||||
42.579318936914206 2.0552869979292154 1992.308 9:50:38
|
||||
42.579381968826056 2.055437956005335 1992.308 9:50:40
|
||||
42.579468972980976 2.055581957101822 1992.308 9:50:42
|
||||
42.57954893633723 2.055755965411663 1989.816 9:50:44
|
||||
42.579617919400334 2.0559319853782654 1986.616 9:50:46
|
||||
42.579661924391985 2.056069951504469 1983.416 9:50:48
|
||||
42.57966594770551 2.056168941780925 1980.216 9:50:50
|
||||
42.57973794825375 2.056211940944195 1975.704 9:51:34
|
||||
42.57981891743839 2.056293999776244 1974.504 9:51:37
|
||||
42.579895947128534 2.056365916505456 1972.104 9:51:43
|
||||
42.579939952120185 2.0564759708940983 1969.63 9:51:48
|
||||
42.579981945455074 2.056600945070386 1968.13 9:51:51
|
||||
42.580044977366924 2.0567309483885765 1967.13 9:51:53
|
||||
42.58014698512852 2.0568689983338118 1964.912 9:51:55
|
||||
42.580265924334526 2.056999923661351 1962.512 9:51:57
|
||||
42.58035896345973 2.0571729261428118 1960.112 9:51:59
|
||||
42.58046197704971 2.057340983301401 1957.712 9:52:1
|
||||
42.58052593097091 2.057488923892379 1955.312 9:52:3
|
||||
42.580540934577584 2.0576039236038923 1954.026 9:52:13
|
||||
42.580602960661054 2.0577219408005476 1951.326 9:52:50
|
||||
42.58065694011748 2.057816991582513 1951.026 9:52:53
|
||||
42.580714942887425 2.057945989072323 1949.63 9:52:56
|
||||
42.58073799312115 2.0580609887838364 1948.63 9:52:58
|
||||
42.58078493177891 2.058220999315381 1947.13 9:53:1
|
||||
42.580820973962545 2.0583869609981775 1946.13 9:53:3
|
||||
42.580841928720474 2.058607991784811 1944.086 9:53:5
|
||||
42.58089398033917 2.0588189642876387 1941.886 9:53:7
|
||||
42.580927927047014 2.059043934568763 1939.686 9:53:9
|
||||
42.58095198310912 2.059267982840538 1937.486 9:53:11
|
||||
42.580968998372555 2.059447942301631 1935.286 9:53:13
|
||||
42.58097897283733 2.0596009958535433 1933.956 9:53:15
|
||||
42.58101996034384 2.0597519539296627 1932.756 9:53:17
|
||||
42.58106698282063 2.0598659478127956 1931.556 9:53:19
|
||||
42.581095984205604 2.059970973059535 1929.756 9:53:22
|
||||
42.581077963113785 2.0599879883229733 1928.0 9:54:20
|
||||
Reference in New Issue
Block a user