Skip to content

Instantly share code, notes, and snippets.

@shahidcodes
Created December 11, 2021 08:50
Show Gist options
  • Save shahidcodes/b2ea3324c9ef5d98c128bd044237cbb5 to your computer and use it in GitHub Desktop.
Save shahidcodes/b2ea3324c9ef5d98c128bd044237cbb5 to your computer and use it in GitHub Desktop.
1000 points.
[[889,382],[550,23],[801,552],[332,71],[838,848],[306,9],[28,130],[571,745],[971,739],[411,304],[878,659],[796,57],[854,22],[97,927],[261,878],[894,67],[849,904],[502,638],[220,345],[703,593],[338,199],[292,308],[581,592],[383,537],[280,296],[828,839],[910,929],[166,105],[628,13],[939,103],[96,418],[699,9],[915,958],[963,370],[21,573],[836,12],[63,118],[519,351],[762,503],[50,408],[519,714],[893,908],[752,991],[139,353],[300,991],[231,35],[824,968],[873,475],[555,553],[239,953],[880,980],[351,760],[749,514],[999,26],[212,890],[281,928],[67,914],[409,629],[282,836],[479,157],[157,677],[6,613],[432,567],[630,118],[304,488],[783,638],[112,135],[565,141],[51,688],[129,31],[905,625],[765,875],[446,102],[985,283],[350,504],[993,475],[128,23],[249,851],[893,51],[716,227],[782,686],[663,727],[382,630],[147,492],[112,945],[912,379],[394,460],[624,100],[34,367],[877,259],[678,29],[37,131],[802,757],[68,379],[96,396],[699,957],[25,417],[2,692],[81,530],[277,275],[816,895],[448,828],[48,784],[977,357],[215,352],[122,73],[645,646],[137,540],[994,369],[373,839],[364,213],[795,71],[361,178],[503,917],[795,782],[491,832],[138,688],[360,793],[708,936],[11,249],[321,115],[140,851],[425,911],[156,782],[264,360],[350,973],[970,80],[299,976],[932,622],[841,838],[766,544],[188,71],[129,882],[891,275],[5,56],[428,973],[945,554],[104,844],[161,656],[909,184],[166,177],[205,908],[194,640],[208,834],[239,212],[934,823],[936,459],[717,525],[922,488],[436,349],[375,592],[465,121],[51,442],[25,1000],[231,347],[490,610],[688,587],[617,137],[149,783],[903,692],[782,844],[299,325],[546,205],[894,979],[174,361],[655,530],[985,625],[497,450],[31,520],[258,388],[243,813],[881,465],[975,861],[110,604],[453,71],[636,625],[468,644],[483,21],[215,763],[386,764],[993,138],[139,109],[903,739],[412,366],[259,458],[313,833],[601,946],[267,48],[822,24],[555,747],[417,290],[54,490],[798,706],[89,668],[687,114],[424,440],[701,474],[178,279],[144,419],[957,338],[808,616],[375,510],[560,304],[712,610],[596,982],[279,282],[136,388],[448,483],[462,652],[179,30],[872,377],[467,614],[271,874],[234,779],[9,931],[148,368],[121,89],[805,771],[289,853],[667,908],[12,206],[388,195],[958,648],[327,134],[504,900],[19,939],[345,817],[397,987],[684,315],[451,216],[170,289],[690,373],[432,675],[491,280],[937,590],[118,674],[807,561],[208,892],[781,434],[970,488],[755,44],[996,727],[997,114],[232,462],[906,818],[701,304],[731,897],[694,891],[216,28],[583,58],[929,665],[335,207],[749,674],[709,389],[562,127],[441,463],[372,342],[937,388],[995,982],[667,447],[397,684],[843,340],[299,966],[823,349],[190,964],[103,486],[94,99],[888,743],[698,745],[798,869],[842,666],[915,334],[457,307],[906,146],[967,306],[803,554],[238,460],[343,304],[282,766],[201,652],[708,477],[544,285],[372,952],[751,656],[35,639],[738,631],[535,638],[77,571],[579,820],[209,30],[290,258],[540,343],[797,447],[7,88],[859,992],[973,389],[291,219],[975,788],[667,899],[554,356],[922,972],[469,745],[705,267],[284,746],[983,530],[500,106],[809,541],[718,96],[666,707],[395,641],[817,477],[593,759],[855,403],[427,895],[69,128],[678,26],[783,721],[11,643],[79,960],[303,350],[720,586],[941,204],[123,613],[615,243],[455,900],[410,591],[830,909],[911,384],[21,581],[326,447],[229,342],[861,945],[943,458],[988,452],[772,543],[131,114],[394,606],[441,939],[352,840],[923,282],[918,31],[11,997],[247,903],[626,290],[613,542],[737,918],[299,199],[245,998],[967,577],[996,469],[37,421],[210,656],[1,26],[248,132],[670,779],[395,458],[555,320],[689,342],[323,659],[409,319],[858,429],[822,201],[10,602],[480,103],[752,395],[674,597],[98,762],[450,347],[521,875],[55,376],[702,455],[317,29],[366,66],[961,470],[694,501],[854,482],[918,99],[38,207],[375,17],[418,356],[340,879],[122,91],[18,238],[728,772],[827,780],[372,662],[626,648],[731,973],[254,277],[244,12],[783,145],[634,782],[215,462],[527,512],[608,486],[935,167],[429,441],[980,17],[798,137],[219,770],[873,714],[976,769],[572,289],[862,643],[645,857],[839,523],[874,561],[298,70],[521,428],[417,572],[632,606],[594,237],[334,943],[793,134],[860,881],[713,156],[254,210],[559,984],[33,393],[878,207],[356,748],[95,758],[672,437],[236,418],[499,408],[183,221],[989,878],[849,137],[97,495],[832,154],[818,959],[97,348],[6,455],[136,693],[960,818],[539,996],[722,773],[255,160],[749,96],[758,719],[180,868],[488,641],[235,935],[72,335],[493,396],[238,661],[25,674],[736,640],[239,658],[256,212],[580,358],[982,237],[42,871],[622,999],[329,535],[540,547],[554,786],[926,109],[926,553],[312,31],[19,958],[779,239],[603,738],[613,956],[922,531],[95,704],[551,394],[927,499],[3,920],[582,430],[122,455],[447,387],[822,301],[171,427],[28,713],[390,369],[508,338],[135,709],[118,78],[776,842],[758,167],[355,333],[465,234],[901,388],[29,66],[989,777],[640,755],[84,92],[857,251],[766,755],[509,37],[322,822],[435,832],[748,831],[614,704],[330,449],[205,109],[943,426],[380,552],[429,113],[309,702],[498,802],[768,692],[33,628],[91,68],[83,503],[269,909],[795,74],[504,86],[97,771],[532,281],[356,174],[794,184],[170,213],[268,236],[672,537],[336,968],[433,299],[269,522],[925,563],[777,874],[420,964],[217,318],[735,875],[805,485],[300,86],[454,216],[330,121],[977,26],[934,404],[834,351],[252,570],[64,449],[594,602],[921,18],[281,555],[750,160],[608,792],[501,112],[157,134],[225,494],[877,383],[299,283],[538,801],[310,974],[517,741],[275,819],[437,665],[708,227],[720,558],[755,853],[568,669],[917,601],[393,653],[558,852],[601,764],[343,840],[481,596],[46,624],[621,259],[943,610],[851,683],[444,233],[540,388],[648,354],[490,154],[646,386],[640,273],[147,650],[396,605],[380,72],[863,180],[813,900],[774,149],[653,955],[507,784],[333,777],[523,66],[627,957],[361,626],[371,561],[79,518],[120,532],[226,375],[804,910],[222,445],[27,251],[290,210],[391,166],[105,699],[669,602],[128,622],[540,62],[613,915],[49,109],[626,541],[945,823],[617,230],[841,53],[637,729],[658,193],[967,6],[900,834],[529,269],[787,174],[269,270],[48,384],[896,725],[39,472],[837,177],[150,71],[519,836],[107,24],[712,657],[534,528],[157,649],[1,969],[55,271],[82,402],[601,203],[212,47],[560,13],[589,255],[866,941],[391,828],[422,513],[613,57],[484,338],[919,897],[981,58],[23,204],[752,927],[957,93],[93,768],[131,473],[54,316],[924,952],[409,19],[334,126],[32,7],[740,510],[37,394],[908,336],[578,386],[145,629],[397,0],[918,413],[10,110],[232,816],[974,926],[254,154],[148,84],[333,711],[397,671],[129,382],[650,114],[687,596],[649,957],[502,64],[170,971],[467,586],[342,334],[396,899],[422,14],[157,578],[870,605],[378,157],[754,770],[402,327],[405,683],[742,407],[929,374],[163,580],[265,947],[320,228],[813,579],[401,309],[524,157],[145,337],[173,197],[858,114],[520,562],[94,930],[558,112],[35,720],[478,952],[949,982],[775,524],[733,122],[908,631],[109,497],[309,87],[574,302],[377,566],[642,12],[676,438],[790,870],[542,743],[112,49],[98,228],[793,929],[796,386],[729,814],[107,625],[199,620],[430,993],[252,776],[435,255],[999,185],[2,965],[747,58],[175,656],[237,483],[579,136],[161,820],[34,397],[675,236],[126,495],[315,586],[917,965],[721,747],[392,19],[260,714],[138,809],[140,507],[117,336],[671,378],[967,63],[365,515],[994,516],[993,488],[554,577],[833,681],[767,196],[705,691],[461,806],[281,197],[6,277],[759,604],[890,452],[497,856],[360,950],[164,546],[520,479],[991,113],[428,480],[483,86],[690,703],[968,899],[64,142],[637,596],[124,763],[742,12],[46,315],[381,3],[244,260],[318,233],[307,570],[344,878],[360,933],[860,22],[687,444],[373,686],[26,224],[322,187],[100,511],[64,817],[353,25],[88,797],[724,422],[214,16],[240,796],[41,676],[835,78],[338,779],[954,836],[77,798],[843,940],[609,777],[626,379],[240,873],[365,388],[975,847],[664,104],[927,502],[739,68],[977,797],[408,597],[755,43],[407,455],[152,378],[690,340],[502,980],[731,269],[339,5],[201,899],[817,854],[271,33],[824,64],[732,147],[358,375],[309,304],[598,944],[868,233],[440,900],[952,779],[188,922],[483,898],[356,909],[242,918],[694,620],[122,578],[872,457],[16,590],[707,860],[508,477],[82,918],[430,557],[305,807],[346,777],[27,628],[748,14],[989,405],[804,900],[773,555],[486,898],[383,816],[521,493],[251,477],[975,480],[742,21],[490,939],[397,934],[542,476],[806,346],[736,847],[834,786],[859,244],[877,883],[701,197],[528,144],[301,56],[344,934],[675,965],[130,654],[208,20],[49,102],[216,318],[792,775],[434,224],[433,130],[887,629],[113,135],[968,838],[590,235],[672,283],[75,250],[761,956],[759,202],[140,208],[117,202],[631,100],[466,297],[326,89],[707,509],[714,4],[609,429],[13,806],[737,502],[132,631],[811,862],[514,336],[391,760],[206,190],[739,364],[253,346],[761,746],[739,247],[365,464],[7,500],[679,328],[491,240],[767,717],[517,240],[451,698],[288,552],[771,666],[984,546],[580,724],[792,226],[916,788],[717,576],[811,781],[779,849],[821,436],[62,947],[360,847],[130,619],[534,586],[768,685],[470,242],[804,506],[45,612],[743,935],[237,278],[21,251],[699,473],[521,193],[108,977],[591,521],[517,451],[596,786],[282,941],[855,337],[267,931],[741,595],[871,327],[370,107],[398,329],[885,113],[101,409],[886,695],[412,470],[124,976],[955,443],[459,6],[204,296],[54,695],[274,824],[343,204],[934,275],[471,435],[936,279],[159,884],[803,474],[591,417],[135,572],[663,406],[787,391],[623,127],[399,514],[944,769],[592,204],[479,409],[834,19],[238,359],[64,928],[364,890],[103,114],[435,947],[48,436],[513,540],[735,827],[632,845],[139,653],[648,814],[509,4],[199,95],[324,22],[8,4],[426,841],[48,490],[397,249],[465,469],[977,167],[651,805],[719,258],[757,531],[761,212],[49,727],[448,862],[402,740],[547,891],[500,653],[907,514],[582,900],[843,483],[170,529],[919,420],[304,643],[836,895],[374,914],[160,835],[360,684],[222,735],[458,923],[652,414],[735,698],[741,992],[670,747],[385,334],[553,679],[57,59],[10,833],[952,843],[184,830],[46,262],[166,982],[339,928],[850,469]]
@satyampatro
Copy link

satyampatro commented Dec 11, 2021

function findClosest(array) {
    const closest = array.slice(0, 100);

    // iteration from 100th index
    array.forEach(currentPoints => {
         const sum = currentPoints.reduce((a, b) => a + b);
         closest.forEach((closestPoints, closestIndex) => {
             const sum1 = closestPoints.reduce((a, b) => a + b);
             if(sum1 > sum) {
                closest.splice(closestIndex, 1);
                closest.push(currentPoints);
             }
         });
    })
    return closest.length > 100 ? closest.slice(0, 100) : closest;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment