We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I have created what might be the worst possible functional solution:
intcompare(inta,intb){if(a>b){return1;}elseif(b>a){return-1;}else{return0;}}vector<int>solve(inta0,inta1,inta2,intb0,intb1,intb2){inta=0;// Difference of A and B's scoresintb=0;// Number of points awarded in totalintc=0;// Current return valueintd=0;// This is A's scoreinte=0;// This is B's scorec=compare(a0,b0);a+=c;b+=abs(c);c=compare(a1,b1);a+=c;b+=abs(c);c=compare(a2,b2);a+=c;b+=abs(c);d=a+(b-a)/2;e=b-d;vector<int>retvals={d,e};returnretvals;}
Good intentions lead me to bad code
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Compare the Triplets
You are viewing a single comment's thread. Return to all comments →
I have created what might be the worst possible functional solution:
Good intentions lead me to bad code