mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
Docs: Update Gemini benchmark results
This commit is contained in:
381
results.json
381
results.json
@@ -78,159 +78,276 @@
|
||||
"9_stream_visualizer": 28.426358369000255
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:1.1": {
|
||||
"10_scrypt_hash": 19.25561597,
|
||||
"11_geospatial": 16.537793451,
|
||||
"1_dijkstra": 19.709102094000002,
|
||||
"2_convex_hull": 23.759404848,
|
||||
"3_lis": 23.048148686,
|
||||
"4_determinant": 20.935209288,
|
||||
"5_markdown_parser": 34.398462477999985,
|
||||
"6_csv_processor": 43.183913065,
|
||||
"7_scheduler": 31.16975645300001,
|
||||
"8_json_validator": 22.189696912000013,
|
||||
"9_stream_visualizer": 27.786803166999977
|
||||
"10_scrypt_hash": 20.09197308799997,
|
||||
"11_geospatial": 16.744538625000043,
|
||||
"1_dijkstra": 20.368975195999724,
|
||||
"2_convex_hull": 27.382338132999838,
|
||||
"3_lis": 17.644244979000185,
|
||||
"4_determinant": 16.541462185999844,
|
||||
"5_markdown_parser": 24.495124363999814,
|
||||
"6_csv_processor": 30.402239049999974,
|
||||
"7_scheduler": 40.37338068899978,
|
||||
"8_json_validator": 16.042334551000035,
|
||||
"9_stream_visualizer": 20.290600096000357
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:1": {
|
||||
"10_scrypt_hash": 16.73660885900003,
|
||||
"11_geospatial": 27.702141619000002,
|
||||
"1_dijkstra": 24.343912240999984,
|
||||
"2_convex_hull": 22.499538950000016,
|
||||
"3_lis": 23.92277027799998,
|
||||
"4_determinant": 19.12632760900003,
|
||||
"5_markdown_parser": 24.235546227000015,
|
||||
"6_csv_processor": 28.255928477999987,
|
||||
"7_scheduler": 52.90334799400001,
|
||||
"8_json_validator": 16.544846496000012,
|
||||
"9_stream_visualizer": 28.031947036999977
|
||||
"10_scrypt_hash": 23.12222202300001,
|
||||
"11_geospatial": 26.206914669000078,
|
||||
"1_dijkstra": 26.885644016999752,
|
||||
"2_convex_hull": 28.454881988000125,
|
||||
"3_lis": 21.56611355999997,
|
||||
"4_determinant": 12.317508710999974,
|
||||
"5_markdown_parser": 42.852985185000115,
|
||||
"6_csv_processor": 38.87679926400026,
|
||||
"7_scheduler": 50.29471840999974,
|
||||
"8_json_validator": 14.745134738999884,
|
||||
"9_stream_visualizer": 25.84060898800008
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:0.9": {
|
||||
"10_scrypt_hash": 18.39214110999997,
|
||||
"11_geospatial": 21.698826697999962,
|
||||
"1_dijkstra": 31.32494983399997,
|
||||
"2_convex_hull": 33.63882225600001,
|
||||
"3_lis": 22.98625518599991,
|
||||
"4_determinant": 9.706784340000013,
|
||||
"5_markdown_parser": 25.077740615000017,
|
||||
"6_csv_processor": 38.424850744000054,
|
||||
"7_scheduler": 40.46733092999994,
|
||||
"8_json_validator": 21.866049754999928,
|
||||
"9_stream_visualizer": 29.938616987999993
|
||||
"10_scrypt_hash": 19.74835643199971,
|
||||
"11_geospatial": 20.92234129700018,
|
||||
"1_dijkstra": 23.868050303000025,
|
||||
"2_convex_hull": 34.55523202600004,
|
||||
"3_lis": 20.2101665719999,
|
||||
"4_determinant": 39.270334673000036,
|
||||
"5_markdown_parser": 33.19924508200027,
|
||||
"6_csv_processor": 41.52472499500029,
|
||||
"7_scheduler": 49.9266366109997,
|
||||
"8_json_validator": 26.833344192000105,
|
||||
"9_stream_visualizer": 21.42339840399986
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:0.8": {
|
||||
"10_scrypt_hash": 22.864061476000003,
|
||||
"11_geospatial": 21.802520365000003,
|
||||
"1_dijkstra": 25.727360443000098,
|
||||
"2_convex_hull": 20.067116691999953,
|
||||
"3_lis": 17.514798727000016,
|
||||
"4_determinant": 26.222232214999966,
|
||||
"5_markdown_parser": 27.822983316000084,
|
||||
"6_csv_processor": 31.795846373000067,
|
||||
"7_scheduler": 45.54547771500005,
|
||||
"8_json_validator": 20.04490028099995,
|
||||
"9_stream_visualizer": 31.52293631999986
|
||||
"10_scrypt_hash": 21.932031273999716,
|
||||
"11_geospatial": 28.99488797000004,
|
||||
"1_dijkstra": 26.922454760999884,
|
||||
"2_convex_hull": 33.567102398000195,
|
||||
"3_lis": 20.515141533999703,
|
||||
"4_determinant": 21.268977479999887,
|
||||
"5_markdown_parser": 40.8980531250001,
|
||||
"6_csv_processor": 32.91058637899999,
|
||||
"7_scheduler": 80.64269605799997,
|
||||
"8_json_validator": 20.85698480999982,
|
||||
"9_stream_visualizer": 37.75345811099932
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:0.7": {
|
||||
"10_scrypt_hash": 23.39639778,
|
||||
"11_geospatial": 23.114445250999882,
|
||||
"1_dijkstra": 24.20112610200001,
|
||||
"2_convex_hull": 29.664885391999967,
|
||||
"3_lis": 15.16884128500009,
|
||||
"4_determinant": 36.34684787500021,
|
||||
"5_markdown_parser": 27.07226724700001,
|
||||
"6_csv_processor": 36.69383957000007,
|
||||
"7_scheduler": 41.66182964499993,
|
||||
"8_json_validator": 24.68038384200004,
|
||||
"9_stream_visualizer": 32.811990770999806
|
||||
"10_scrypt_hash": 19.486387687000445,
|
||||
"11_geospatial": 22.537344641000033,
|
||||
"1_dijkstra": 24.757761477999388,
|
||||
"2_convex_hull": 25.543014148999937,
|
||||
"3_lis": 19.770237300000154,
|
||||
"4_determinant": 22.60989380299952,
|
||||
"5_markdown_parser": 42.83827392700035,
|
||||
"6_csv_processor": 34.6238196200002,
|
||||
"7_scheduler": 45.15323736399971,
|
||||
"8_json_validator": 28.7569554270003,
|
||||
"9_stream_visualizer": 25.663316451999357
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:0.6": {
|
||||
"10_scrypt_hash": 20.319240230000112,
|
||||
"11_geospatial": 14.71396687299991,
|
||||
"1_dijkstra": 29.94397802599985,
|
||||
"2_convex_hull": 30.130152880999958,
|
||||
"3_lis": 22.789678306000074,
|
||||
"4_determinant": 13.336225186000112,
|
||||
"5_markdown_parser": 26.61024377000006,
|
||||
"6_csv_processor": 23.28925823200005,
|
||||
"7_scheduler": 31.414080646000105,
|
||||
"8_json_validator": 18.36662647700007,
|
||||
"9_stream_visualizer": 31.141520149999998
|
||||
"10_scrypt_hash": 22.85184260199964,
|
||||
"11_geospatial": 26.641837239999322,
|
||||
"1_dijkstra": 22.808483874000608,
|
||||
"2_convex_hull": 23.80214131500013,
|
||||
"3_lis": 21.100967756000347,
|
||||
"4_determinant": 10.740180964999832,
|
||||
"5_markdown_parser": 36.143312074000015,
|
||||
"6_csv_processor": 53.21065433599986,
|
||||
"7_scheduler": 59.45305509700067,
|
||||
"8_json_validator": 21.731487070000732,
|
||||
"9_stream_visualizer": 29.278473306000233
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:0.5": {
|
||||
"10_scrypt_hash": 26.257502701000078,
|
||||
"11_geospatial": 27.292514397000197,
|
||||
"1_dijkstra": 26.930725388999797,
|
||||
"2_convex_hull": 28.365386472000043,
|
||||
"3_lis": 20.404020288000115,
|
||||
"4_determinant": 19.956521905999864,
|
||||
"5_markdown_parser": 41.075851207999975,
|
||||
"6_csv_processor": 33.550666006000014,
|
||||
"7_scheduler": 54.52258278499986,
|
||||
"8_json_validator": 30.504760077999904,
|
||||
"9_stream_visualizer": 25.344985834000166
|
||||
"10_scrypt_hash": 21.873170082999394,
|
||||
"11_geospatial": 20.211224280000664,
|
||||
"1_dijkstra": 26.509259402999653,
|
||||
"2_convex_hull": 28.398400859000162,
|
||||
"3_lis": 27.511312441000715,
|
||||
"4_determinant": 9.919108345000073,
|
||||
"5_markdown_parser": 33.96838048799988,
|
||||
"6_csv_processor": 34.895041311000476,
|
||||
"7_scheduler": 65.26757784599997,
|
||||
"8_json_validator": 22.589250137999652,
|
||||
"9_stream_visualizer": 28.14733931099996
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:0.4": {
|
||||
"10_scrypt_hash": 16.79715236100019,
|
||||
"11_geospatial": 25.48661641700007,
|
||||
"1_dijkstra": 17.67472643599985,
|
||||
"2_convex_hull": 34.115073089000305,
|
||||
"3_lis": 18.289524143000133,
|
||||
"4_determinant": 22.224696940999944,
|
||||
"5_markdown_parser": 53.21322759300005,
|
||||
"6_csv_processor": 39.43421280799993,
|
||||
"7_scheduler": 30.78163343900023,
|
||||
"8_json_validator": 26.184069054999853,
|
||||
"9_stream_visualizer": 21.324422691999935
|
||||
"10_scrypt_hash": 24.754794635999946,
|
||||
"11_geospatial": 22.880691410999745,
|
||||
"1_dijkstra": 18.020111163999886,
|
||||
"2_convex_hull": 20.038773117000236,
|
||||
"3_lis": 11.807387412999757,
|
||||
"4_determinant": 20.521637209000065,
|
||||
"5_markdown_parser": 35.67531904900074,
|
||||
"6_csv_processor": 23.8520766750006,
|
||||
"7_scheduler": 31.85370118200034,
|
||||
"8_json_validator": 17.14643698600028,
|
||||
"9_stream_visualizer": 25.974873207000083
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:0.3": {
|
||||
"10_scrypt_hash": 22.419933818999677,
|
||||
"11_geospatial": 14.525312852999662,
|
||||
"1_dijkstra": 24.24144133199984,
|
||||
"2_convex_hull": 27.67347379200021,
|
||||
"3_lis": 13.649138154000044,
|
||||
"4_determinant": 28.68561609600019,
|
||||
"5_markdown_parser": 44.175827321999705,
|
||||
"6_csv_processor": 40.22086091799987,
|
||||
"7_scheduler": 42.102860941999595,
|
||||
"8_json_validator": 24.13780150000006,
|
||||
"9_stream_visualizer": 22.134434574999847
|
||||
"10_scrypt_hash": 31.34955882699974,
|
||||
"11_geospatial": 21.212845159000718,
|
||||
"1_dijkstra": 14.686580670000055,
|
||||
"2_convex_hull": 36.39883294000011,
|
||||
"3_lis": 13.597776002999396,
|
||||
"4_determinant": 24.862609581999482,
|
||||
"5_markdown_parser": 36.88983640800044,
|
||||
"6_csv_processor": 36.582046242999844,
|
||||
"7_scheduler": 37.754115211999974,
|
||||
"8_json_validator": 16.674394439999947,
|
||||
"9_stream_visualizer": 25.583348608000204
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:0.2": {
|
||||
"10_scrypt_hash": 24.400115432000252,
|
||||
"11_geospatial": 32.89142006099969,
|
||||
"1_dijkstra": 36.531734934999605,
|
||||
"2_convex_hull": 30.47034405499976,
|
||||
"3_lis": 14.03327947399998,
|
||||
"4_determinant": 15.886417729000096,
|
||||
"5_markdown_parser": 43.89735358300013,
|
||||
"6_csv_processor": 36.24166352199996,
|
||||
"7_scheduler": 49.958096608999654,
|
||||
"8_json_validator": 21.518541840999852,
|
||||
"9_stream_visualizer": 30.054751582999714
|
||||
"10_scrypt_hash": 25.04706531199999,
|
||||
"11_geospatial": 18.636367162999697,
|
||||
"1_dijkstra": 23.471250179999508,
|
||||
"2_convex_hull": 32.36644217699953,
|
||||
"3_lis": 21.03346423900034,
|
||||
"4_determinant": 33.63182032500021,
|
||||
"5_markdown_parser": 45.76653377099987,
|
||||
"6_csv_processor": 44.927907913000325,
|
||||
"7_scheduler": 41.063800591999666,
|
||||
"8_json_validator": 26.052476222000085,
|
||||
"9_stream_visualizer": 20.329862430999988
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:0.1": {
|
||||
"10_scrypt_hash": 21.251296984999907,
|
||||
"11_geospatial": 28.01666565400036,
|
||||
"1_dijkstra": 22.908056412999983,
|
||||
"2_convex_hull": 31.488867672999856,
|
||||
"3_lis": 19.367484238999896,
|
||||
"4_determinant": 16.061534822999967,
|
||||
"5_markdown_parser": 30.51042381200008,
|
||||
"6_csv_processor": 20.860845792999957,
|
||||
"7_scheduler": 34.17653273200011,
|
||||
"8_json_validator": 14.083612348000054,
|
||||
"9_stream_visualizer": 19.854906946000177
|
||||
"10_scrypt_hash": 16.787732964999975,
|
||||
"11_geospatial": 20.16605759199988,
|
||||
"1_dijkstra": 31.337674549999647,
|
||||
"2_convex_hull": 15.677699519000017,
|
||||
"3_lis": 19.142893268000336,
|
||||
"4_determinant": 26.106286918999626,
|
||||
"5_markdown_parser": 25.228105368999763,
|
||||
"6_csv_processor": 36.924520573999736,
|
||||
"7_scheduler": 49.74383629500028,
|
||||
"8_json_validator": 17.1179925739998,
|
||||
"9_stream_visualizer": 24.9906886749994
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:0": {
|
||||
"10_scrypt_hash": 22.467800446999725,
|
||||
"11_geospatial": 23.184671450000256,
|
||||
"1_dijkstra": 28.33117579400027,
|
||||
"2_convex_hull": 26.517016473000403,
|
||||
"3_lis": 17.292057299999986,
|
||||
"4_determinant": 22.012527137000113,
|
||||
"5_markdown_parser": 44.51245308799995,
|
||||
"6_csv_processor": 35.65954501500027,
|
||||
"7_scheduler": 31.53722489799978,
|
||||
"8_json_validator": 21.652465214000085,
|
||||
"9_stream_visualizer": 28.28463803699985
|
||||
"10_scrypt_hash": 20.874672585999594,
|
||||
"11_geospatial": 22.346452704999596,
|
||||
"1_dijkstra": 28.580189787000418,
|
||||
"2_convex_hull": 25.09971364900004,
|
||||
"3_lis": 16.770306450999342,
|
||||
"4_determinant": 22.11130663099978,
|
||||
"5_markdown_parser": 42.952995118000544,
|
||||
"6_csv_processor": 34.98289658599999,
|
||||
"7_scheduler": 28.964328855000435,
|
||||
"8_json_validator": 21.71179311800003,
|
||||
"9_stream_visualizer": 27.561015010000208
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:2": {
|
||||
"10_scrypt_hash": 18.850475267999997,
|
||||
"11_geospatial": 26.061414934000002,
|
||||
"1_dijkstra": 32.080058634000004,
|
||||
"2_convex_hull": 40.262037018,
|
||||
"3_lis": 23.863135326000002,
|
||||
"4_determinant": 21.64576313800001,
|
||||
"5_markdown_parser": 35.426119787000005,
|
||||
"6_csv_processor": 41.461592468999996,
|
||||
"7_scheduler": 63.031456737,
|
||||
"8_json_validator": 17.80283297700004,
|
||||
"9_stream_visualizer": 37.456500977999994
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:1.9": {
|
||||
"10_scrypt_hash": 26.550956544000016,
|
||||
"11_geospatial": 28.613920013999973,
|
||||
"1_dijkstra": 26.252092659999967,
|
||||
"2_convex_hull": 51.264573769999956,
|
||||
"3_lis": 30.342489231000012,
|
||||
"4_determinant": 29.058629305999958,
|
||||
"5_markdown_parser": 30.14169296200003,
|
||||
"6_csv_processor": 29.499591516999992,
|
||||
"7_scheduler": 85.24949619800003,
|
||||
"8_json_validator": 20.337025739999955,
|
||||
"9_stream_visualizer": 40.432301935
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:1.8": {
|
||||
"10_scrypt_hash": 17.1179911150001,
|
||||
"11_geospatial": 29.514046728000046,
|
||||
"1_dijkstra": 28.144339148,
|
||||
"2_convex_hull": 30.832829297999968,
|
||||
"3_lis": 22.427721954999956,
|
||||
"4_determinant": 12.77717681199999,
|
||||
"5_markdown_parser": 33.72199084900005,
|
||||
"6_csv_processor": 37.25121678799996,
|
||||
"7_scheduler": 71.505791187,
|
||||
"8_json_validator": 25.41118813699996,
|
||||
"9_stream_visualizer": 21.328009533000177
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:1.7": {
|
||||
"10_scrypt_hash": 18.910409689000108,
|
||||
"11_geospatial": 30.51153287200001,
|
||||
"1_dijkstra": 21.085283119000028,
|
||||
"2_convex_hull": 37.588829656000016,
|
||||
"3_lis": 21.455840754000004,
|
||||
"4_determinant": 15.062050559000111,
|
||||
"5_markdown_parser": 28.85249140900001,
|
||||
"6_csv_processor": 44.475366975999904,
|
||||
"7_scheduler": 62.510325283000014,
|
||||
"8_json_validator": 24.96264758999995,
|
||||
"9_stream_visualizer": 32.618002833000155
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:1.6": {
|
||||
"10_scrypt_hash": 18.07594707799982,
|
||||
"11_geospatial": 24.192698191999924,
|
||||
"1_dijkstra": 23.389250704000005,
|
||||
"2_convex_hull": 30.81265446199989,
|
||||
"3_lis": 21.40121195099992,
|
||||
"4_determinant": 11.822610518000088,
|
||||
"5_markdown_parser": 22.82010067499988,
|
||||
"6_csv_processor": 33.57937185800006,
|
||||
"7_scheduler": 83.33972460600012,
|
||||
"8_json_validator": 25.279451872000006,
|
||||
"9_stream_visualizer": 27.714689797000027
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:1.5": {
|
||||
"10_scrypt_hash": 18.69272038900014,
|
||||
"11_geospatial": 23.77197485099989,
|
||||
"1_dijkstra": 26.440856348,
|
||||
"2_convex_hull": 29.677680263000074,
|
||||
"3_lis": 26.63670439099986,
|
||||
"4_determinant": 25.75282643499994,
|
||||
"5_markdown_parser": 41.91444458999997,
|
||||
"6_csv_processor": 28.044683143000118,
|
||||
"7_scheduler": 50.095482387,
|
||||
"8_json_validator": 15.720686942999949,
|
||||
"9_stream_visualizer": 18.935609488999937
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:1.4": {
|
||||
"10_scrypt_hash": 24.387901307999854,
|
||||
"11_geospatial": 29.17852593200025,
|
||||
"1_dijkstra": 23.139700418999883,
|
||||
"2_convex_hull": 34.18627439399995,
|
||||
"3_lis": 22.094377453000284,
|
||||
"4_determinant": 15.912985173999797,
|
||||
"5_markdown_parser": 28.417516086000017,
|
||||
"6_csv_processor": 32.795155487999786,
|
||||
"7_scheduler": 42.208218053000046,
|
||||
"8_json_validator": 15.106514658999629,
|
||||
"9_stream_visualizer": 25.44312660600012
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:1.3": {
|
||||
"10_scrypt_hash": 20.99151984900003,
|
||||
"11_geospatial": 20.858707120000386,
|
||||
"1_dijkstra": 24.934105057999957,
|
||||
"2_convex_hull": 31.693044794999995,
|
||||
"3_lis": 15.41439853399992,
|
||||
"4_determinant": 18.300773887000048,
|
||||
"5_markdown_parser": 31.605673247999977,
|
||||
"6_csv_processor": 41.59330867599975,
|
||||
"7_scheduler": 57.69496162199974,
|
||||
"8_json_validator": 18.894077386000195,
|
||||
"9_stream_visualizer": 27.242338625999633
|
||||
},
|
||||
"gemini-3-pro-preview TEMP:1.2": {
|
||||
"10_scrypt_hash": 19.87584538699966,
|
||||
"11_geospatial": 31.579098602999935,
|
||||
"1_dijkstra": 31.312650417000054,
|
||||
"2_convex_hull": 39.108151202999984,
|
||||
"3_lis": 18.894060660999735,
|
||||
"4_determinant": 27.813572447000073,
|
||||
"5_markdown_parser": 33.95318160999985,
|
||||
"6_csv_processor": 39.11827627599985,
|
||||
"7_scheduler": 43.091859620000236,
|
||||
"8_json_validator": 24.684869859999978,
|
||||
"9_stream_visualizer": 19.26046375499992
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,6 @@ const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...k].map(b => (b + 256).toString(16).slice(1)).join('')
|
||||
return Array.from(k, b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -1,7 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/scrypt.js');
|
||||
const e = new TextEncoder();
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32);
|
||||
return Array.from(k, b => b.toString(16).padStart(2, '0')).join('');
|
||||
};
|
||||
export default hashPassword;
|
||||
@@ -1,5 +1,5 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js');
|
||||
const e = new TextEncoder();
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32);
|
||||
return [...k].map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
};
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const e = new TextEncoder()
|
||||
const h = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...h].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -1,7 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return Array.from(k, b => b.toString(16).padStart(2, '0')).join('')
|
||||
const h = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return Array.from(h, b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -1,7 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://unpkg.com/scrypt-js?module')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
const hashPassword = async (pwd, salt) => {
|
||||
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/scrypt.js')
|
||||
const enc = new TextEncoder()
|
||||
const key = await scrypt(enc.encode(pwd), enc.encode(salt), 1024, 8, 1, 32)
|
||||
return [...key].map(b => (b + 256).toString(16).slice(1)).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -1,7 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...k].map(b => b.toString(16).padStart(2, 0)).join('')
|
||||
}
|
||||
const hashPassword = async (pwd, salt) => {
|
||||
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm');
|
||||
const e = new TextEncoder();
|
||||
const h = await scrypt(e.encode(pwd), e.encode(salt), 1024, 8, 1, 32);
|
||||
return Array.from(h, b => b.toString(16).padStart(2, '0')).join('');
|
||||
};
|
||||
export default hashPassword;
|
||||
@@ -1,7 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const hashPassword = async (pwd, salt) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return Array.from(k, b => b.toString(16).padStart(2, '0')).join('')
|
||||
const h = await scrypt(e.encode(pwd), e.encode(salt), 1024, 8, 1, 32)
|
||||
return [...h].map(v => v.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -1,7 +1,7 @@
|
||||
const hashPassword = async (pwd, salt) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const enc = txt => new TextEncoder().encode(txt)
|
||||
const key = await scrypt(enc(pwd), enc(salt), 1024, 8, 1, 32)
|
||||
return Array.from(key, b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js');
|
||||
const enc = new TextEncoder();
|
||||
const hash = await scrypt(enc.encode(pwd), enc.encode(salt), 1024, 8, 1, 32);
|
||||
return Array.from(hash, b => b.toString(16).padStart(2, '0')).join('');
|
||||
};
|
||||
export default hashPassword;
|
||||
@@ -1,7 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...k].map(b => (b + 256).toString(16).slice(1)).join('')
|
||||
const h = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...h].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -0,0 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -0,0 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -0,0 +1,9 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const e = new TextEncoder()
|
||||
return Array.from(
|
||||
await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32),
|
||||
b => b.toString(16).padStart(2, '0')
|
||||
).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -0,0 +1,7 @@
|
||||
const hashPassword = async (password, salt) => {
|
||||
const { scrypt } = await import('https://unpkg.com/scrypt-js@3.0.1/scrypt.js')
|
||||
const enc = str => new TextEncoder().encode(str)
|
||||
const buf = await scrypt(enc(password), enc(salt), 1024, 8, 1, 32)
|
||||
return Array.from(buf, b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -0,0 +1,7 @@
|
||||
const hashPassword = async (pwd, salt) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(pwd), e.encode(salt), 1024, 8, 1, 32)
|
||||
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -0,0 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -0,0 +1,11 @@
|
||||
const hashPassword = async (password, salt) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const encoder = new TextEncoder()
|
||||
const buffer = await scrypt(
|
||||
encoder.encode(password),
|
||||
encoder.encode(salt),
|
||||
1024, 8, 1, 32
|
||||
)
|
||||
return [...buffer].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -0,0 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt: k } = await import('https://esm.sh/scrypt-js@3.0.1')
|
||||
const e = t => new TextEncoder().encode(t)
|
||||
const r = await k(e(p), e(s), 1024, 8, 1, 32)
|
||||
return [...r].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -1,7 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const hashPassword = async (pwd, salt) => {
|
||||
const { scrypt } = await import('https://esm.sh/scrypt-js')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
const k = await scrypt(e.encode(pwd), e.encode(salt), 1024, 8, 1, 32)
|
||||
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -0,0 +1,7 @@
|
||||
const hashPassword = async (p, s) => {
|
||||
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js/+esm')
|
||||
const e = new TextEncoder()
|
||||
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return Array.from(k, b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -1,10 +1,12 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const T = await import('https://esm.sh/@turf/turf')
|
||||
const pts = readings
|
||||
.filter(r => T.booleanPointInPolygon(T.point(r.loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc)
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
|
||||
|
||||
return pts.length < 2 ? 0 : +T.length(T.lineString(pts), { units: 'kilometers' }).toFixed(2)
|
||||
}
|
||||
const coords = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(({ loc }) => loc);
|
||||
|
||||
return coords.length < 2 ? 0 :
|
||||
Math.round(length(lineString(coords), { units: 'kilometers' }) * 100) / 100;
|
||||
};
|
||||
export default analyzeGPS;
|
||||
@@ -1,12 +1,13 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
|
||||
const { booleanPointInPolygon, point, lineString, length } =
|
||||
await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
|
||||
|
||||
const pts = readings
|
||||
.filter(({ loc }) => t.booleanPointInPolygon(t.point(loc), boundary, { ignoreBoundary: true }))
|
||||
const valid = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(({ loc }) => loc);
|
||||
.map(({ loc }) => loc)
|
||||
|
||||
return pts.length < 2 ? 0 :
|
||||
Math.round(t.length(t.lineString(pts), { units: 'kilometers' }) * 100) / 100;
|
||||
};
|
||||
return valid.length < 2 ? 0 :
|
||||
Math.round(length(lineString(valid), { units: 'kilometers' }) * 100) / 100
|
||||
}
|
||||
export default analyzeGPS;
|
||||
@@ -1,14 +1,12 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const T = await import('https://esm.sh/@turf/turf');
|
||||
const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
|
||||
|
||||
const pts = readings
|
||||
.filter(r => T.booleanPointInPolygon(T.point(r.loc), boundary, { ignoreBoundary: true }))
|
||||
.filter(({ loc }) => t.booleanPointInPolygon(t.point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc);
|
||||
.map(r => r.loc)
|
||||
|
||||
if (pts.length < 2) return 0;
|
||||
|
||||
const len = T.length(T.lineString(pts), { units: 'kilometers' });
|
||||
return Math.round(len * 100) / 100;
|
||||
};
|
||||
return pts.length < 2 ? 0 :
|
||||
Math.round(t.length(t.lineString(pts), { units: 'kilometers' }) * 100) / 100
|
||||
}
|
||||
export default analyzeGPS;
|
||||
@@ -1,6 +1,5 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
|
||||
|
||||
const pts = readings
|
||||
.filter(({ loc }) => t.booleanPointInPolygon(t.point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
|
||||
const t = await import('https://esm.sh/@turf/turf');
|
||||
|
||||
const coords = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
|
||||
const pts = readings
|
||||
.filter(({ loc }) => t.booleanPointInPolygon(t.point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(({ loc }) => loc);
|
||||
|
||||
return coords.length < 2
|
||||
? 0
|
||||
: +length(lineString(coords), { units: 'kilometers' }).toFixed(2);
|
||||
return pts.length < 2 ? 0 :
|
||||
Math.round(t.length(t.lineString(pts), { units: 'kilometers' }) * 100) / 100;
|
||||
};
|
||||
export default analyzeGPS;
|
||||
@@ -1,10 +1,12 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const t = await import('https://esm.sh/@turf/turf');
|
||||
const pts = readings
|
||||
.filter(r => t.booleanPointInPolygon(t.point(r.loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc);
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
|
||||
|
||||
return pts.length < 2 ? 0 : +t.length(t.lineString(pts), { units: 'kilometers' }).toFixed(2);
|
||||
};
|
||||
const path = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc)
|
||||
|
||||
return path.length < 2 ? 0 :
|
||||
Math.round(length(lineString(path), { units: 'kilometers' }) * 100) / 100
|
||||
}
|
||||
export default analyzeGPS;
|
||||
@@ -1,12 +1,9 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
|
||||
|
||||
const path = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
|
||||
const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
|
||||
const pts = readings
|
||||
.filter(r => t.booleanPointInPolygon(t.point(r.loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(({ loc }) => loc);
|
||||
|
||||
return path.length < 2 ? 0 :
|
||||
Math.round(length(lineString(path), { units: 'kilometers' }) * 100) / 100;
|
||||
.map(r => r.loc);
|
||||
return pts.length < 2 ? 0 : +t.length(t.lineString(pts), { units: 'kilometers' }).toFixed(2);
|
||||
};
|
||||
export default analyzeGPS;
|
||||
@@ -1,10 +1,13 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const T = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
|
||||
const pts = readings
|
||||
.filter(r => T.booleanPointInPolygon(T.point(r.loc), boundary, { ignoreBoundary: true }))
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf')
|
||||
|
||||
const path = readings
|
||||
.filter(r => booleanPointInPolygon(point(r.loc), boundary))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc)
|
||||
|
||||
return pts.length < 2 ? 0 : +T.length(T.lineString(pts), { units: 'kilometers' }).toFixed(2)
|
||||
return path.length < 2
|
||||
? 0
|
||||
: +length(lineString(path), { units: 'kilometers' }).toFixed(2)
|
||||
}
|
||||
export default analyzeGPS;
|
||||
@@ -1,12 +1,14 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
|
||||
|
||||
const pts = readings
|
||||
.filter(r => booleanPointInPolygon(point(r.loc), boundary, { ignoreBoundary: true }))
|
||||
const coords = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc);
|
||||
.map(({ loc }) => loc);
|
||||
|
||||
return pts.length < 2 ? 0
|
||||
: +length(lineString(pts), { units: 'kilometers' }).toFixed(2);
|
||||
if (coords.length < 2) return 0;
|
||||
|
||||
const total = length(lineString(coords), { units: 'kilometers' });
|
||||
return Math.round(total * 100) / 100;
|
||||
};
|
||||
export default analyzeGPS;
|
||||
@@ -1,14 +1,11 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf')
|
||||
|
||||
const path = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary))
|
||||
const turf = await import('https://esm.sh/@turf/turf');
|
||||
const coords = readings
|
||||
.filter(({ loc }) => turf.booleanPointInPolygon(turf.point(loc), boundary))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(({ loc }) => loc)
|
||||
.map(r => r.loc);
|
||||
|
||||
if (path.length < 2) return 0
|
||||
|
||||
const dist = length(lineString(path), { units: 'kilometers' })
|
||||
return Math.round(dist * 100) / 100
|
||||
}
|
||||
return coords.length < 2 ? 0 :
|
||||
Math.round(turf.length(turf.lineString(coords), { units: 'kilometers' }) * 100) / 100;
|
||||
};
|
||||
export default analyzeGPS;
|
||||
@@ -0,0 +1,12 @@
|
||||
export const analyzeGPS = async (readings, boundary) => {
|
||||
const { point, booleanPointInPolygon, lineString, length } = await import('https://esm.sh/@turf/turf@6.5.0')
|
||||
|
||||
const coords = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc)
|
||||
|
||||
return coords.length < 2 ? 0 :
|
||||
Math.round(length(lineString(coords), { units: 'kilometers' }) * 100) / 100
|
||||
}
|
||||
export default analyzeGPS;
|
||||
@@ -0,0 +1,11 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
|
||||
|
||||
const path = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc);
|
||||
|
||||
return path.length < 2 ? 0 : +length(lineString(path)).toFixed(2);
|
||||
};
|
||||
export default analyzeGPS;
|
||||
@@ -0,0 +1,13 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const { booleanPointInPolygon: inside, point, lineString, length } = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
|
||||
|
||||
const path = readings
|
||||
.filter(({ loc }) => inside(point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(({ loc }) => loc)
|
||||
|
||||
if (path.length < 2) return 0
|
||||
|
||||
return +length(lineString(path), { units: 'kilometers' }).toFixed(2)
|
||||
}
|
||||
export default analyzeGPS;
|
||||
@@ -0,0 +1,13 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const turf = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
|
||||
|
||||
const pts = readings
|
||||
.filter(r => turf.booleanPointInPolygon(turf.point(r.loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc);
|
||||
|
||||
return pts.length < 2
|
||||
? 0
|
||||
: +turf.length(turf.lineString(pts), { units: 'kilometers' }).toFixed(2);
|
||||
};
|
||||
export default analyzeGPS;
|
||||
@@ -0,0 +1,9 @@
|
||||
const analyzeGPS = async (data, boundary) => {
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
|
||||
const pts = data
|
||||
.filter(d => booleanPointInPolygon(point(d.loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(d => d.loc)
|
||||
return pts.length < 2 ? 0 : +length(lineString(pts)).toFixed(2)
|
||||
}
|
||||
export default analyzeGPS;
|
||||
@@ -0,0 +1,11 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const { point, booleanPointInPolygon, lineString, length } = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
|
||||
|
||||
const path = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc);
|
||||
|
||||
return path.length < 2 ? 0 : +length(lineString(path)).toFixed(2);
|
||||
};
|
||||
export default analyzeGPS;
|
||||
@@ -0,0 +1,11 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const { point, booleanPointInPolygon, lineString, length } = await import('https://esm.sh/@turf/turf')
|
||||
|
||||
const path = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(r => r.loc)
|
||||
|
||||
return path.length < 2 ? 0 : +length(lineString(path), { units: 'kilometers' }).toFixed(2)
|
||||
}
|
||||
export default analyzeGPS;
|
||||
@@ -0,0 +1,12 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const T = await import('https://esm.sh/@turf/turf')
|
||||
const valid = readings
|
||||
.filter(r => T.booleanPointInPolygon(T.point(r.loc), boundary))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
|
||||
if (valid.length < 2) return 0
|
||||
|
||||
const line = T.lineString(valid.map(v => v.loc))
|
||||
return Math.round(T.length(line) * 1e2) / 1e2
|
||||
}
|
||||
export default analyzeGPS;
|
||||
@@ -1,14 +1,13 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf')
|
||||
const T = await import('https://esm.sh/@turf/turf');
|
||||
|
||||
const path = readings
|
||||
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
|
||||
const pts = readings
|
||||
.filter(({ loc }) => T.booleanPointInPolygon(T.point(loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts)
|
||||
.map(({ loc }) => loc)
|
||||
.map(r => r.loc);
|
||||
|
||||
if (path.length < 2) return 0
|
||||
|
||||
const dist = length(lineString(path), { units: 'kilometers' })
|
||||
return Math.round(dist * 100) / 100
|
||||
}
|
||||
return pts.length < 2
|
||||
? 0
|
||||
: +T.length(T.lineString(pts), { units: 'kilometers' }).toFixed(2);
|
||||
};
|
||||
export default analyzeGPS;
|
||||
@@ -0,0 +1,9 @@
|
||||
const analyzeGPS = async (readings, boundary) => {
|
||||
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
|
||||
const valid = readings
|
||||
.filter(r => booleanPointInPolygon(point(r.loc), boundary))
|
||||
.sort((a, b) => a.ts - b.ts);
|
||||
|
||||
return valid.length < 2 ? 0 : +length(lineString(valid.map(r => r.loc))).toFixed(2);
|
||||
};
|
||||
export default analyzeGPS;
|
||||
@@ -1,22 +1,22 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: Q } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new Q({ comparator: (a, b) => a.w - b.w })
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? 1/0)) continue
|
||||
if (w > (d[n] ?? Infinity)) continue
|
||||
|
||||
for (let v in g[n]) {
|
||||
let t = w + g[n][v]
|
||||
if (t < (d[v] ?? 1/0)) {
|
||||
d[v] = t
|
||||
q.queue({ n: v, w: t })
|
||||
let k = w + g[n][v]
|
||||
if (k < (d[v] ?? Infinity)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1/0
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,19 +1,21 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: P } = await import('https://esm.sh/js-priority-queue');
|
||||
const q = new P({ comparator: (a, b) => a.w - b.w }), d = { [s]: 0 };
|
||||
q.queue({ n: s, w: 0 });
|
||||
const { default: Q } = await import('https://esm.sh/js-priority-queue')
|
||||
const d = { [s]: 0 }, q = new Q({ comparator: (a, b) => a[1] - b[1] })
|
||||
q.queue([s, 0])
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue();
|
||||
if (n === e) return w;
|
||||
if (w > (d[n] ?? 1 / 0)) continue;
|
||||
for (const k in g[n] || {}) {
|
||||
const t = w + g[n][k];
|
||||
if (t < (d[k] ?? 1 / 0)) {
|
||||
d[k] = t;
|
||||
q.queue({ n: k, w: t });
|
||||
const [u, w] = q.dequeue()
|
||||
if (u === e) return w
|
||||
if (w > (d[u] ?? 1/0)) continue
|
||||
|
||||
for (let v in g[u]) {
|
||||
const k = w + g[u][v]
|
||||
if (k < (d[v] ?? 1/0)) {
|
||||
d[v] = k
|
||||
q.queue([v, k])
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0;
|
||||
};
|
||||
return 1/0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,20 +1,25 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: P } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new P({ comparator: (a, b) => a.w - b.w })
|
||||
const m = { [s]: 0 }
|
||||
q.queue({ n: s, w: 0 })
|
||||
const { default: P } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm');
|
||||
const q = new P({ comparator: (a, b) => a.w - b.w });
|
||||
const d = { [s]: 0 };
|
||||
|
||||
q.queue({ n: s, w: 0 });
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (m[n] ?? 1 / 0)) continue
|
||||
for (const k in g[n] || {}) {
|
||||
const t = w + g[n][k]
|
||||
if (t < (m[k] ?? 1 / 0)) {
|
||||
m[k] = t
|
||||
q.queue({ n: k, w: t })
|
||||
const { n, w } = q.dequeue();
|
||||
|
||||
if (n === e) return w;
|
||||
if (w > (d[n] ?? 1/0)) continue;
|
||||
|
||||
for (let v in g[n]) {
|
||||
let k = w + g[n][v];
|
||||
if (k < (d[v] ?? 1/0)) {
|
||||
d[v] = k;
|
||||
q.queue({ n: v, w: k });
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
|
||||
return 1/0;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -1,19 +1,18 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }
|
||||
const d = { [s]: 0 }, q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? 1 / 0)) continue
|
||||
const { n: u, w } = q.dequeue()
|
||||
if (u === e) return w
|
||||
if (w > (d[u] ?? 1 / 0)) continue
|
||||
|
||||
for (const [v, cost] of Object.entries(g[n] || {})) {
|
||||
const t = w + cost
|
||||
if (t < (d[v] ?? 1 / 0)) {
|
||||
d[v] = t
|
||||
q.queue({ n: v, w: t })
|
||||
for (const v in g[u]) {
|
||||
const nw = w + g[u][v]
|
||||
if (nw < (d[v] ?? 1 / 0)) {
|
||||
d[v] = nw
|
||||
q.queue({ n: v, w: nw })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: Q } = await import('https://esm.sh/js-priority-queue')
|
||||
const d = { [s]: 0 }, q = new Q({ comparator: (a, b) => a.w - b.w })
|
||||
const { default: P } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new P({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }
|
||||
q.queue({ n: s, w: 0 })
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? 1 / 0)) continue
|
||||
for (const [v, c] of Object.entries(g[n] || {})) {
|
||||
const k = w + c
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
for (let k in g[n]) {
|
||||
const t = w + g[n][k]
|
||||
if (t < (d[k] ?? 1 / 0)) {
|
||||
d[k] = t
|
||||
q.queue({ n: k, w: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,19 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }, v = new Set()
|
||||
|
||||
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w }), d = { [s]: 0 }
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (v.has(n)) continue
|
||||
v.add(n)
|
||||
|
||||
for (const k in g[n]) {
|
||||
const t = w + g[n][k]
|
||||
if (t < (d[k] ?? Infinity)) {
|
||||
d[k] = t
|
||||
q.queue({ n: k, w: t })
|
||||
if (w > (d[n] ?? 1 / 0)) continue
|
||||
for (const v in g[n]) {
|
||||
const k = w + g[n][v]
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,25 +1,19 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue');
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w });
|
||||
const d = { [s]: 0 };
|
||||
|
||||
q.queue({ w: 0, n: s });
|
||||
|
||||
const { default: Q } = await import('https://esm.sh/js-priority-queue');
|
||||
const q = new Q({ comparator: (a, b) => a.w - b.w }), m = { [s]: 0 };
|
||||
q.queue({ n: s, w: 0 });
|
||||
while (q.length) {
|
||||
const { w, n } = q.dequeue();
|
||||
|
||||
const { n, w } = q.dequeue();
|
||||
if (n === e) return w;
|
||||
if (w > (d[n] ?? 1 / 0)) continue;
|
||||
|
||||
if (w > (m[n] ?? 1/0)) continue;
|
||||
for (const v in g[n]) {
|
||||
const k = w + g[n][v];
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k;
|
||||
q.queue({ w: k, n: v });
|
||||
if (k < (m[v] ?? 1/0)) {
|
||||
m[v] = k;
|
||||
q.queue({ n: v, w: k });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1/0;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -1,19 +1,22 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: P } = await import('https://esm.sh/js-priority-queue');
|
||||
const q = new P({ comparator: (a, b) => a.c - b.c }), d = { [s]: 0 };
|
||||
q.queue({ n: s, c: 0 });
|
||||
const { default: P } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new P({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, c } = q.dequeue();
|
||||
if (n === e) return c;
|
||||
if (c > (d[n] ?? 1 / 0)) continue;
|
||||
for (let v in g[n]) {
|
||||
let k = c + g[n][v];
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k;
|
||||
q.queue({ n: v, c: k });
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? Infinity)) continue
|
||||
|
||||
for (const k in g[n]) {
|
||||
const c = w + g[n][k]
|
||||
if (c < (d[k] ?? Infinity)) {
|
||||
d[k] = c
|
||||
q.queue({ n: k, w: c })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0;
|
||||
};
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,5 +1,5 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }
|
||||
|
||||
@@ -7,15 +7,14 @@ const findShortestPath = async (g, s, e) => {
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? 1 / 0)) continue
|
||||
|
||||
for (const k in g[n] || {}) {
|
||||
const c = w + g[n][k]
|
||||
if (c < (d[k] ?? 1 / 0)) {
|
||||
d[k] = c
|
||||
q.queue({ n: k, w: c })
|
||||
for (const [v, c] of Object.entries(g[n] || {})) {
|
||||
const t = w + c
|
||||
if (t < (d[v] ?? 1 / 0)) {
|
||||
d[v] = t
|
||||
q.queue({ n: v, w: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue/+esm')
|
||||
const costs = { [start]: 0 }
|
||||
const queue = new PQ({ comparator: (a, b) => a.cost - b.cost })
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const dist = { [start]: 0 }
|
||||
|
||||
queue.queue({ node: start, cost: 0 })
|
||||
q.queue({ n: start, w: 0 })
|
||||
|
||||
while (queue.length) {
|
||||
const { node, cost } = queue.dequeue()
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === end) return w
|
||||
if (w > (dist[n] ?? Infinity)) continue
|
||||
|
||||
if (node === end) return cost
|
||||
if (cost > (costs[node] ?? Infinity)) continue
|
||||
|
||||
for (const [neighbor, weight] of Object.entries(graph[node] || {})) {
|
||||
const nextCost = cost + weight
|
||||
if (nextCost < (costs[neighbor] ?? Infinity)) {
|
||||
costs[neighbor] = nextCost
|
||||
queue.queue({ node: neighbor, cost: nextCost })
|
||||
for (const v in graph[n]) {
|
||||
const d = w + graph[n][v]
|
||||
if (d < (dist[v] ?? Infinity)) {
|
||||
dist[v] = d
|
||||
q.queue({ n: v, w: d })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,19 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: P } = await import('https://cdn.skypack.dev/js-priority-queue')
|
||||
const d = { [s]: 0 }, q = new P({ compare: (a, b) => a.w - b.w })
|
||||
q.queue({ id: s, w: 0 })
|
||||
while (q.length) {
|
||||
const { id, w } = q.dequeue()
|
||||
if (id === e) return w
|
||||
if (w > (d[id] ?? 1 / 0)) continue
|
||||
for (let n in g[id]) {
|
||||
const k = w + g[id][n]
|
||||
if (k < (d[n] ?? 1 / 0)) {
|
||||
d[n] = k
|
||||
q.queue({ id: n, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,22 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n: u, w: c } = q.dequeue()
|
||||
if (u === e) return c
|
||||
if (c > (d[u] ?? 1 / 0)) continue
|
||||
|
||||
for (const v in g[u] || {}) {
|
||||
const k = c + g[u][v]
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,25 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
|
||||
const q = new PQ({ comparator: (a, b) => a.d - b.d })
|
||||
const D = { [s]: 0 }
|
||||
|
||||
q.queue({ n: s, d: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, d } = q.dequeue()
|
||||
|
||||
if (n === e) return d
|
||||
if (d > (D[n] ?? 1 / 0)) continue
|
||||
|
||||
for (const [v, w] of Object.entries(g[n] || {})) {
|
||||
const c = d + w
|
||||
if (c < (D[v] ?? 1 / 0)) {
|
||||
D[v] = c
|
||||
q.queue({ n: v, d: c })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,23 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }
|
||||
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? 1 / 0)) continue
|
||||
|
||||
for (const v in g[n] || {}) {
|
||||
const k = w + g[n][v]
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,21 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: P } = await import('https://esm.sh/js-priority-queue');
|
||||
const q = new P({ comparator: (a, b) => a.w - b.w }), m = { [s]: 0 };
|
||||
q.queue({ n: s, w: 0 });
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue();
|
||||
if (n === e) return w;
|
||||
if (w > (m[n] ?? 1 / 0)) continue;
|
||||
|
||||
for (const [k, v] of Object.entries(g[n] || {})) {
|
||||
const t = w + v;
|
||||
if (t < (m[k] ?? 1 / 0)) {
|
||||
m[k] = t;
|
||||
q.queue({ n: k, w: t });
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,27 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue');
|
||||
const q = new PQ({ compare: (a, b) => a.d - b.d });
|
||||
const m = { [s]: 0 };
|
||||
const v = new Set();
|
||||
|
||||
q.queue({ n: s, d: 0 });
|
||||
|
||||
while (q.length) {
|
||||
const { n, d: c } = q.dequeue();
|
||||
if (n === e) return c;
|
||||
if (v.has(n)) continue;
|
||||
v.add(n);
|
||||
|
||||
const adj = g[n] || {};
|
||||
for (const k in adj) {
|
||||
const t = c + adj[k];
|
||||
if (t < (m[k] ?? Infinity)) {
|
||||
m[k] = t;
|
||||
q.queue({ n: k, d: t });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,24 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: Q } = await import('https://cdn.skypack.dev/js-priority-queue')
|
||||
const q = new Q({ comparator: (a, b) => a.d - b.d })
|
||||
const m = { [s]: 0 }
|
||||
|
||||
q.queue({ n: s, d: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, d } = q.dequeue()
|
||||
|
||||
if (n === e) return d
|
||||
if (d > (m[n] ?? 1/0)) continue
|
||||
|
||||
for (const v in g[n]) {
|
||||
const t = d + g[n][v]
|
||||
if (t < (m[v] ?? 1/0)) {
|
||||
m[v] = t
|
||||
q.queue({ n: v, d: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1/0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,25 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue@0.1.5')
|
||||
const q = new PQ({ compare: (a, b) => a.d - b.d })
|
||||
const dist = { [start]: 0 }
|
||||
|
||||
q.queue({ n: start, d: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, d } = q.dequeue()
|
||||
|
||||
if (n === end) return d
|
||||
if (d > (dist[n] ?? Infinity)) continue
|
||||
|
||||
for (const [v, w] of Object.entries(graph[n] || {})) {
|
||||
const t = d + w
|
||||
if (t < (dist[v] ?? Infinity)) {
|
||||
dist[v] = t
|
||||
q.queue({ n: v, d: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,24 +1,25 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PQ } = await import('https://cdn.skypack.dev/js-priority-queue');
|
||||
const queue = new PQ({ comparator: (a, b) => a.d - b.d });
|
||||
const dists = { [start]: 0 }, visited = new Set();
|
||||
const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
|
||||
const dists = new Map([[start, 0]])
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a.w - b.w })
|
||||
|
||||
queue.queue({ n: start, d: 0 });
|
||||
pq.queue({ n: start, w: 0 })
|
||||
|
||||
while (queue.length) {
|
||||
const { n, d } = queue.dequeue();
|
||||
if (n === end) return d;
|
||||
if (visited.has(n)) continue;
|
||||
visited.add(n);
|
||||
while (pq.length) {
|
||||
const { n, w } = pq.dequeue()
|
||||
|
||||
if (n === end) return w
|
||||
if (w > (dists.get(n) ?? 1 / 0)) continue
|
||||
|
||||
for (const [neighbor, weight] of Object.entries(graph[n] || {})) {
|
||||
const newDist = d + weight;
|
||||
if (newDist < (dists[neighbor] ?? Infinity)) {
|
||||
dists[neighbor] = newDist;
|
||||
queue.queue({ n: neighbor, d: newDist });
|
||||
const newWeight = w + weight
|
||||
if (newWeight < (dists.get(neighbor) ?? 1 / 0)) {
|
||||
dists.set(neighbor, newWeight)
|
||||
pq.queue({ n: neighbor, w: newWeight })
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity;
|
||||
};
|
||||
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,25 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.d - b.d })
|
||||
const m = { [s]: 0 }
|
||||
|
||||
q.queue({ n: s, d: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, d } = q.dequeue()
|
||||
if (n === e) return d
|
||||
if (d > (m[n] ?? 1 / 0)) continue
|
||||
|
||||
const adj = g[n] || {}
|
||||
for (const k in adj) {
|
||||
const v = d + adj[k]
|
||||
if (v < (m[k] ?? 1 / 0)) {
|
||||
m[k] = v
|
||||
q.queue({ n: k, d: v })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,15 +1,25 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
|
||||
if (s.length < 3) return s
|
||||
const x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
const m = (l) => l.reduce((h, p) => {
|
||||
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
return h
|
||||
}, [])
|
||||
const l = m(s)
|
||||
const u = m([...s].reverse())
|
||||
return [...l.slice(0, -1), ...u.slice(0, -1)]
|
||||
}
|
||||
const findConvexHull = async (P) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||
|
||||
const U = _.uniqWith(P, _.isEqual);
|
||||
if (U.length < 3) return U;
|
||||
|
||||
const S = _.sortBy(U, ['x', 'y']);
|
||||
|
||||
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
|
||||
const build = (list) => {
|
||||
const h = [];
|
||||
list.forEach(p => {
|
||||
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||
h.push(p);
|
||||
});
|
||||
return h;
|
||||
};
|
||||
|
||||
const l = build(S);
|
||||
const u = build([...S].reverse());
|
||||
|
||||
return [...l.slice(0, -1), ...u.slice(0, -1)];
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -1,13 +1,19 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y']);
|
||||
if (s.length < 3) return s;
|
||||
const k = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
||||
const f = (h, p) => {
|
||||
while (h.length > 1 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||
h.push(p);
|
||||
return h;
|
||||
};
|
||||
return [...s.reduce(f, []).slice(0, -1), ...s.reduceRight(f, []).slice(0, -1)];
|
||||
};
|
||||
const { default: _ } = await import('https://esm.sh/lodash')
|
||||
const u = _.uniqWith(pts, _.isEqual)
|
||||
if (u.length < 3) return u
|
||||
const s = _.sortBy(u, ['x', 'y'])
|
||||
const cp = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
const scan = (lst) => {
|
||||
const h = []
|
||||
lst.forEach(p => {
|
||||
while (h.length >= 2 && cp(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
})
|
||||
return h
|
||||
}
|
||||
const l = scan(s)
|
||||
const uH = scan(s.reverse())
|
||||
return _.concat(l.slice(0, -1), uH.slice(0, -1))
|
||||
}
|
||||
export default findConvexHull;
|
||||
@@ -1,27 +1,18 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||
|
||||
if (!Array.isArray(pts)) throw new Error('Input must be an array');
|
||||
const u = _.uniqWith(pts, _.isEqual);
|
||||
if (u.length < 3) return u;
|
||||
|
||||
const s = _.sortBy(u, ['x', 'y']);
|
||||
const k = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
||||
const h = [];
|
||||
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
|
||||
if (s.length < 3) return s
|
||||
const h = [], x = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
|
||||
for (const p of s) {
|
||||
while (h.length >= 2 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||
h.push(p);
|
||||
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
}
|
||||
|
||||
const t = h.length + 1;
|
||||
const t = h.length + 1
|
||||
for (let i = s.length - 2; i >= 0; i--) {
|
||||
const p = s[i];
|
||||
while (h.length >= t && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||
h.push(p);
|
||||
while (h.length >= t && x(h[h.length - 2], h[h.length - 1], s[i]) <= 0) h.pop()
|
||||
h.push(s[i])
|
||||
}
|
||||
h.pop()
|
||||
return h
|
||||
}
|
||||
|
||||
h.pop();
|
||||
return h;
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -1,24 +1,29 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const findConvexHull = async points => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
|
||||
if (s.length < 3) return s
|
||||
|
||||
const cross = (a, b, o) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
|
||||
const build = (list) => {
|
||||
const h = []
|
||||
for (const p of list) {
|
||||
while (h.length >= 2 && cross(h[h.length - 1], p, h[h.length - 2]) <= 0) h.pop()
|
||||
h.push(p)
|
||||
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y'])
|
||||
if (sorted.length < 3) return sorted
|
||||
|
||||
const cross = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
const hull = []
|
||||
|
||||
for (const p of sorted) {
|
||||
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
|
||||
hull.pop()
|
||||
}
|
||||
return h
|
||||
hull.push(p)
|
||||
}
|
||||
|
||||
const l = build(s)
|
||||
const u = build([...s].reverse())
|
||||
const lowerLen = hull.length + 1
|
||||
for (let i = sorted.length - 2; i >= 0; i--) {
|
||||
const p = sorted[i]
|
||||
while (hull.length >= lowerLen && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
|
||||
hull.pop()
|
||||
}
|
||||
hull.push(p)
|
||||
}
|
||||
|
||||
l.pop()
|
||||
u.pop()
|
||||
|
||||
return [...l, ...u]
|
||||
hull.pop()
|
||||
return hull
|
||||
}
|
||||
export default findConvexHull;
|
||||
@@ -1,16 +1,24 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const u = _.uniqWith(pts, _.isEqual)
|
||||
if (u.length < 3) return u
|
||||
const s = _.sortBy(u, ['x', 'y'])
|
||||
const cp = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
|
||||
const scan = (lst) => lst.reduce((h, p) => {
|
||||
while (h.length >= 2 && cp(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
return h
|
||||
}, [])
|
||||
const l = scan(s)
|
||||
const up = scan([...s].reverse())
|
||||
return [...l.slice(0, -1), ...up.slice(0, -1)]
|
||||
const findConvexHull = async (p) => {
|
||||
const { default: _ } = await import('https://cdn.skypack.dev/lodash');
|
||||
const s = _.sortBy(_.uniqWith(p, _.isEqual), ['x', 'y']);
|
||||
if (s.length < 3) return s;
|
||||
|
||||
const x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
||||
const h = [];
|
||||
|
||||
for (const i of s) {
|
||||
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], i) <= 0) h.pop();
|
||||
h.push(i);
|
||||
}
|
||||
|
||||
const t = h.length + 1;
|
||||
for (let i = s.length - 2; i >= 0; i--) {
|
||||
const k = s[i];
|
||||
while (h.length >= t && x(h[h.length - 2], h[h.length - 1], k) <= 0) h.pop();
|
||||
h.push(k);
|
||||
}
|
||||
|
||||
h.pop();
|
||||
return h;
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -1,17 +1,21 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
|
||||
if (s.length < 3) return s
|
||||
const k = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
|
||||
const m = (v) => {
|
||||
const h = []
|
||||
for (const p of v) {
|
||||
while (h.length >= 2 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y']);
|
||||
if (s.length < 3) return s;
|
||||
|
||||
const h = [], x = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], s[i]) <= 0) h.pop();
|
||||
h.push(s[i]);
|
||||
}
|
||||
return h
|
||||
}
|
||||
const l = m(s), u = m(s.reverse())
|
||||
return l.slice(0, -1).concat(u.slice(0, -1))
|
||||
|
||||
for (let i = s.length - 2, t = h.length + 1; i >= 0; i--) {
|
||||
while (h.length >= t && x(h[h.length - 2], h[h.length - 1], s[i]) <= 0) h.pop();
|
||||
h.push(s[i]);
|
||||
}
|
||||
|
||||
h.pop();
|
||||
return h;
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -1,22 +1,23 @@
|
||||
const findConvexHull = async points => {
|
||||
const { default: _ } = await import('https://esm.sh/lodash')
|
||||
const s = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y'])
|
||||
if (s.length < 3) return s
|
||||
const findConvexHull = async (points) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
|
||||
|
||||
const h = [], x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
if (sorted.length < 3) return sorted;
|
||||
|
||||
s.forEach(p => {
|
||||
while (h.length >= 2 && x(h.at(-2), h.at(-1), p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
})
|
||||
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
|
||||
const t = h.length + 1
|
||||
for (let i = s.length - 2; i >= 0; i--) {
|
||||
while (h.length >= t && x(h.at(-2), h.at(-1), s[i]) <= 0) h.pop()
|
||||
h.push(s[i])
|
||||
}
|
||||
const buildHull = (list) => {
|
||||
const hull = [];
|
||||
list.forEach(p => {
|
||||
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) hull.pop();
|
||||
hull.push(p);
|
||||
});
|
||||
return hull;
|
||||
};
|
||||
|
||||
h.pop()
|
||||
return h
|
||||
}
|
||||
const lower = buildHull(sorted);
|
||||
const upper = buildHull([...sorted].reverse());
|
||||
|
||||
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -1,24 +1,19 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||
const { default: _ } = await import('https://esm.sh/lodash@4');
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y']);
|
||||
|
||||
if (s.length < 3) return s;
|
||||
|
||||
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
const h = [];
|
||||
const k = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
const add = (h, p) => {
|
||||
while (h.length > 1 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||
h.push(p);
|
||||
};
|
||||
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], s[i]) <= 0) h.pop();
|
||||
h.push(s[i]);
|
||||
}
|
||||
const l = [], u = [];
|
||||
s.forEach(p => add(l, p));
|
||||
for (let i = s.length - 1; i >= 0; i--) add(u, s[i]);
|
||||
|
||||
const t = h.length + 1;
|
||||
for (let i = s.length - 2; i >= 0; i--) {
|
||||
while (h.length >= t && cross(h[h.length - 2], h[h.length - 1], s[i]) <= 0) h.pop();
|
||||
h.push(s[i]);
|
||||
}
|
||||
|
||||
h.pop();
|
||||
return h;
|
||||
l.pop(); u.pop();
|
||||
return [...l, ...u];
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -1,23 +1,18 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
if (!pts?.length || pts.length < 3) return pts || [];
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
|
||||
if (s.length < 3) return s
|
||||
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y']);
|
||||
const k = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
||||
|
||||
const scan = (list) => {
|
||||
const h = [];
|
||||
for (const p of list) {
|
||||
while (h.length >= 2 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||
h.push(p);
|
||||
const x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
const scan = (arr, h = []) => {
|
||||
for (const p of arr) {
|
||||
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
}
|
||||
return h
|
||||
}
|
||||
return h;
|
||||
};
|
||||
|
||||
const l = scan(s);
|
||||
const u = scan(s.reverse());
|
||||
|
||||
return [...l.slice(0, -1), ...u.slice(0, -1)];
|
||||
};
|
||||
const l = scan(s), u = scan([...s].reverse())
|
||||
return [...l.slice(0, -1), ...u.slice(0, -1)]
|
||||
}
|
||||
export default findConvexHull;
|
||||
@@ -1,22 +1,17 @@
|
||||
const findConvexHull = async (points) => {
|
||||
const findConvexHull = async points => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const P = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y'])
|
||||
if (P.length < 3) return P
|
||||
|
||||
const xp = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
|
||||
const scan = (arr) => {
|
||||
const h = []
|
||||
for (const p of arr) {
|
||||
while (h.length >= 2 && xp(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
const s = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y'])
|
||||
if (s.length < 3) return s
|
||||
const x = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
|
||||
const scan = (arr, h = []) => {
|
||||
arr.forEach(p => {
|
||||
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
}
|
||||
})
|
||||
return h
|
||||
}
|
||||
|
||||
const l = scan(P)
|
||||
const u = scan(P.reverse())
|
||||
|
||||
return [...l.slice(0, -1), ...u.slice(0, -1)]
|
||||
const l = scan(s)
|
||||
const u = scan([...s].reverse())
|
||||
return l.slice(0, -1).concat(u.slice(0, -1))
|
||||
}
|
||||
export default findConvexHull;
|
||||
@@ -0,0 +1,17 @@
|
||||
const findConvexHull = async points => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const p = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y'])
|
||||
if (p.length < 3) return p
|
||||
const h = [], x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
for (let i = 0; i < p.length; i++) {
|
||||
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], p[i]) <= 0) h.pop()
|
||||
h.push(p[i])
|
||||
}
|
||||
for (let i = p.length - 2, t = h.length + 1; i >= 0; i--) {
|
||||
while (h.length >= t && x(h[h.length - 2], h[h.length - 1], p[i]) <= 0) h.pop()
|
||||
h.push(p[i])
|
||||
}
|
||||
h.pop()
|
||||
return h
|
||||
}
|
||||
export default findConvexHull;
|
||||
@@ -0,0 +1,28 @@
|
||||
export const findConvexHull = async (points) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||
const P = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
|
||||
|
||||
if (P.length < 3) return P;
|
||||
|
||||
const cross = (a, b, o) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
|
||||
const buildChain = (nodes) => {
|
||||
const hull = [];
|
||||
for (const p of nodes) {
|
||||
while (hull.length >= 2 && cross(hull[hull.length - 1], p, hull[hull.length - 2]) <= 0) {
|
||||
hull.pop();
|
||||
}
|
||||
hull.push(p);
|
||||
}
|
||||
return hull;
|
||||
};
|
||||
|
||||
const lower = buildChain(P);
|
||||
const upper = buildChain([...P].reverse());
|
||||
|
||||
lower.pop();
|
||||
upper.pop();
|
||||
|
||||
return [...lower, ...upper];
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -0,0 +1,22 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
|
||||
if (s.length < 3) return s
|
||||
|
||||
const k = (a, b, o) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
|
||||
const build = (list) => {
|
||||
const stack = []
|
||||
for (const p of list) {
|
||||
while (stack.length > 1 && k(stack[stack.length - 1], p, stack[stack.length - 2]) <= 0) {
|
||||
stack.pop()
|
||||
}
|
||||
stack.push(p)
|
||||
}
|
||||
return stack
|
||||
}
|
||||
|
||||
const l = build(s)
|
||||
const u = build([...s].reverse())
|
||||
return [...l.slice(0, -1), ...u.slice(0, -1)]
|
||||
}
|
||||
export default findConvexHull;
|
||||
@@ -0,0 +1,23 @@
|
||||
const findConvexHull = async (rawPoints) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const pts = _.sortBy(_.uniqWith(rawPoints, _.isEqual), ['x', 'y'])
|
||||
if (pts.length < 3) return pts
|
||||
|
||||
const cross = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
|
||||
const build = (list) => {
|
||||
const h = []
|
||||
list.forEach(p => {
|
||||
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
})
|
||||
return h
|
||||
}
|
||||
|
||||
const lower = build(pts)
|
||||
const upper = build([...pts].reverse())
|
||||
|
||||
lower.pop(), upper.pop()
|
||||
return [...lower, ...upper]
|
||||
}
|
||||
export default findConvexHull;
|
||||
@@ -0,0 +1,23 @@
|
||||
export const findConvexHull = async (pts) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const S = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
|
||||
if (S.length < 3) return S
|
||||
|
||||
const cross = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
const chain = (list) => {
|
||||
const h = []
|
||||
for (const p of list) {
|
||||
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
const l = chain(S)
|
||||
const u = chain([...S].reverse())
|
||||
|
||||
l.pop()
|
||||
u.pop()
|
||||
return l.concat(u)
|
||||
}
|
||||
export default findConvexHull;
|
||||
@@ -0,0 +1,19 @@
|
||||
const findConvexHull = async (points) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
|
||||
|
||||
if (sorted.length < 3) return sorted;
|
||||
|
||||
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
|
||||
const scan = (list) => list.reduce((h, p) => {
|
||||
while (h.length > 1 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||
return h.push(p), h;
|
||||
}, []);
|
||||
|
||||
const lower = scan(sorted);
|
||||
const upper = scan([...sorted].reverse());
|
||||
|
||||
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -0,0 +1,18 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm')
|
||||
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
|
||||
if (s.length < 3) return s
|
||||
|
||||
const k = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
const f = (h, p) => {
|
||||
while (h.length >= 2 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
return h
|
||||
}
|
||||
|
||||
const l = _.reduce(s, f, [])
|
||||
const u = _.reduceRight(s, f, [])
|
||||
|
||||
return [..._.dropRight(l), ..._.dropRight(u)]
|
||||
}
|
||||
export default findConvexHull;
|
||||
@@ -0,0 +1,17 @@
|
||||
const findConvexHull = async (points) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||
const pts = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
|
||||
if (pts.length < 3) return pts;
|
||||
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
const chain = (list) => {
|
||||
const h = [];
|
||||
for (const p of list) {
|
||||
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||
h.push(p);
|
||||
}
|
||||
return h;
|
||||
};
|
||||
const lower = chain(pts), upper = chain([...pts].reverse());
|
||||
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -1,23 +1,31 @@
|
||||
const findConvexHull = async (points) => {
|
||||
if (!Array.isArray(points)) throw new Error('Input must be an array');
|
||||
|
||||
const { default: _ } = await import('https://esm.sh/lodash');
|
||||
const P = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
|
||||
if (P.length < 3) return P;
|
||||
|
||||
const uniq = _.uniqWith(points, _.isEqual);
|
||||
if (uniq.length < 3) return uniq;
|
||||
|
||||
const sorted = _.sortBy(uniq, ['x', 'y']);
|
||||
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
const h = [];
|
||||
|
||||
for (const p of P) {
|
||||
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||
h.push(p);
|
||||
const build = (list) => {
|
||||
const hull = [];
|
||||
for (const p of list) {
|
||||
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
|
||||
hull.pop();
|
||||
}
|
||||
|
||||
const t = h.length + 1;
|
||||
for (let i = P.length - 2; i >= 0; i--) {
|
||||
while (h.length >= t && cross(h[h.length - 2], h[h.length - 1], P[i]) <= 0) h.pop();
|
||||
h.push(P[i]);
|
||||
hull.push(p);
|
||||
}
|
||||
return hull;
|
||||
};
|
||||
|
||||
h.pop();
|
||||
return h;
|
||||
const lower = build(sorted);
|
||||
const upper = build([...sorted].reverse());
|
||||
|
||||
lower.pop();
|
||||
upper.pop();
|
||||
|
||||
return [...lower, ...upper];
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -0,0 +1,18 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const _ = (await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')).default;
|
||||
const u = _.uniqWith(pts, _.isEqual);
|
||||
if (u.length < 3) return u;
|
||||
const s = _.sortBy(u, ['x', 'y']);
|
||||
const k = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
||||
const b = (list, h = []) => {
|
||||
for (const p of list) {
|
||||
while (h.length > 1 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
|
||||
h.push(p);
|
||||
}
|
||||
return h;
|
||||
};
|
||||
const l = b(s);
|
||||
const r = b(s.reverse());
|
||||
return l.slice(0, -1).concat(r.slice(0, -1));
|
||||
};
|
||||
export default findConvexHull;
|
||||
@@ -1,7 +1,9 @@
|
||||
const findLISLength = async nums => {
|
||||
const { bisectLeft } = await import('https://esm.sh/d3-array')
|
||||
const findLISLength = async (nums) => {
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const tails = []
|
||||
for (const n of nums) tails[bisectLeft(tails, n)] = n
|
||||
for (const x of nums) {
|
||||
tails[bisectLeft(tails, x)] = x
|
||||
}
|
||||
return tails.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -1,7 +1,7 @@
|
||||
const findLISLength = async a => {
|
||||
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const t = []
|
||||
for (const n of a) t[b(t, n)] = n
|
||||
return t.length
|
||||
const findLISLength = async nums => {
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const tails = []
|
||||
for (const n of nums) tails[bisectLeft(tails, n)] = n
|
||||
return tails.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -1,7 +1,11 @@
|
||||
const findLISLength = async nums => {
|
||||
const { bisectLeft } = await import('https://esm.sh/d3-array')
|
||||
const findLISLength = async (arr) => {
|
||||
if (!arr?.length) return 0
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const tails = []
|
||||
for (const n of nums) tails[bisectLeft(tails, n)] = n
|
||||
for (const n of arr) {
|
||||
const i = bisectLeft(tails, n)
|
||||
i < tails.length ? tails[i] = n : tails.push(n)
|
||||
}
|
||||
return tails.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -1,5 +1,5 @@
|
||||
const findLISLength = async nums => {
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const { bisectLeft } = await import('https://esm.sh/d3-array')
|
||||
const tails = []
|
||||
for (const n of nums) tails[bisectLeft(tails, n)] = n
|
||||
return tails.length
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const findLISLength = async (nums) => {
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const tails = []
|
||||
for (const x of nums) tails[bisectLeft(tails, x)] = x
|
||||
return tails.length
|
||||
const findLISLength = async a => {
|
||||
const { bisectLeft: b } = await import('https://esm.sh/d3-array')
|
||||
const t = []
|
||||
for (const n of a) t[b(t, n)] = n
|
||||
return t.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -1,11 +1,7 @@
|
||||
const findLISLength = async (nums) => {
|
||||
const findLISLength = async nums => {
|
||||
const { bisectLeft } = await import('https://esm.sh/d3-array')
|
||||
const tails = []
|
||||
|
||||
for (const x of nums) {
|
||||
tails[bisectLeft(tails, x)] = x
|
||||
}
|
||||
|
||||
for (const n of nums) tails[bisectLeft(tails, n)] = n
|
||||
return tails.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -1,9 +1,7 @@
|
||||
const findLISLength = async n => {
|
||||
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const t = []
|
||||
for (const x of n) {
|
||||
t[b(t, x)] = x
|
||||
}
|
||||
return t.length
|
||||
const findLISLength = async nums => {
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const tails = []
|
||||
for (const n of nums) tails[bisectLeft(tails, n)] = n
|
||||
return tails.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -1,7 +1,7 @@
|
||||
const findLISLength = async nums => {
|
||||
const { bisectLeft: search } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const tails = []
|
||||
for (const n of nums) tails[search(tails, n)] = n
|
||||
return tails.length
|
||||
const findLISLength = async a => {
|
||||
const { bisectLeft: b } = await import('https://esm.sh/d3-array')
|
||||
const t = []
|
||||
for (const n of a) t[b(t, n)] = n
|
||||
return t.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -1,7 +1,7 @@
|
||||
const findLISLength = async n => {
|
||||
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const t = []
|
||||
for (const x of n) t[b(t, x)] = x
|
||||
return t.length
|
||||
const findLISLength = async a => {
|
||||
const { bisectLeft: b } = await import('https://esm.sh/d3-array')
|
||||
const q = []
|
||||
for (const n of a) q[b(q, n)] = n
|
||||
return q.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -1,7 +1,10 @@
|
||||
const findLISLength = async a => {
|
||||
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
async function findLISLength(a) {
|
||||
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array/+esm')
|
||||
const t = []
|
||||
for (const n of a) t[b(t, n)] = n
|
||||
for (const n of a) {
|
||||
const i = b(t, n)
|
||||
i < t.length ? t[i] = n : t.push(n)
|
||||
}
|
||||
return t.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -0,0 +1,7 @@
|
||||
const findLISLength = async nums => {
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const tails = []
|
||||
for (const n of nums) tails[bisectLeft(tails, n)] = n
|
||||
return tails.length
|
||||
}
|
||||
export default findLISLength;
|
||||
10
tests/3_lis/outputs_gemini/gemini-3-pro-preview TEMP_1.3.js
Normal file
10
tests/3_lis/outputs_gemini/gemini-3-pro-preview TEMP_1.3.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const findLISLength = async a => {
|
||||
const { bisectLeft: b } = await import('https://esm.sh/d3-array')
|
||||
const t = []
|
||||
for (const v of a) {
|
||||
const i = b(t, v)
|
||||
i < t.length ? t[i] = v : t.push(v)
|
||||
}
|
||||
return t.length
|
||||
}
|
||||
export default findLISLength;
|
||||
10
tests/3_lis/outputs_gemini/gemini-3-pro-preview TEMP_1.4.js
Normal file
10
tests/3_lis/outputs_gemini/gemini-3-pro-preview TEMP_1.4.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const findLISLength = async (n) => {
|
||||
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const t = []
|
||||
for (const v of n) {
|
||||
const i = b(t, v)
|
||||
i < t.length ? t[i] = v : t.push(v)
|
||||
}
|
||||
return t.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -0,0 +1,7 @@
|
||||
const findLISLength = async (nums) => {
|
||||
const { bisectLeft: b } = await import('https://esm.sh/d3-array@3');
|
||||
const t = [];
|
||||
for (const n of nums) t[b(t, n)] = n;
|
||||
return t.length;
|
||||
};
|
||||
export default findLISLength;
|
||||
@@ -0,0 +1,9 @@
|
||||
const findLISLength = async (nums) => {
|
||||
const { bisectLeft } = await import('https://esm.sh/d3-array@3');
|
||||
const tails = [];
|
||||
for (const n of nums) {
|
||||
tails[bisectLeft(tails, n)] = n;
|
||||
}
|
||||
return tails.length;
|
||||
};
|
||||
export default findLISLength;
|
||||
@@ -0,0 +1,7 @@
|
||||
const findLISLength = async nums => {
|
||||
const { bisectLeft: search } = await import('https://esm.sh/d3-array')
|
||||
const tails = []
|
||||
for (const n of nums) tails[search(tails, n)] = n
|
||||
return tails.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -0,0 +1,7 @@
|
||||
const findLISLength = async (n) => {
|
||||
const { bisectLeft: b } = await import('https://esm.run/d3-array')
|
||||
const t = []
|
||||
for (const v of n) t[b(t, v)] = v
|
||||
return t.length
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -0,0 +1,9 @@
|
||||
const findLISLength = async (nums) => {
|
||||
const { bisectLeft } = await import('https://esm.sh/d3-array');
|
||||
const tails = [];
|
||||
for (const n of nums) {
|
||||
tails[bisectLeft(tails, n)] = n;
|
||||
}
|
||||
return tails.length;
|
||||
};
|
||||
export default findLISLength;
|
||||
@@ -1,9 +1,7 @@
|
||||
const findLISLength = async nums => {
|
||||
const { bisectLeft } = await import('https://esm.sh/d3-array')
|
||||
const sub = []
|
||||
for (const n of nums) {
|
||||
sub[bisectLeft(sub, n)] = n
|
||||
}
|
||||
return sub.length
|
||||
const findLISLength = async a => {
|
||||
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
const t = []
|
||||
for (const n of a) t[b(t, n)] = n
|
||||
return t.length
|
||||
}
|
||||
export default findLISLength;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user