Skip to main content
deleted 28 characters in body
Source Link
khanhnguyendata
  • 5.2k
  • 1
  • 24
  • 33

A slightly different approach

Clear[dominateCount] dominateCount[points : {_, _} ..] := Module[{pairs, dominatePick, pickedPoints}, pairs = Subsets[{points}, {2}]; dominatePick[p1_List, p2_List] := Switch[p1 - p2, {_?NonNegative, _?NonPositive}, p1, {_?NonPositive, _?NonNegative}, p2, _, Null]; pickedPoints = dominatePick @@@ pairs; Print[pickedPoints]; DeleteCases[ Append[Tally@pickedPoints, Append[Complement[{points}, pickedPoints], 0]], {Null, _}] ] dominateCount[p1, p2, p3] (* {{{5, -2}, 2}, {{4, -1}, 1}, {{1, 5}, 0}} *) 

A slightly different approach

Clear[dominateCount] dominateCount[points : {_, _} ..] := Module[{pairs, dominatePick, pickedPoints}, pairs = Subsets[{points}, {2}]; dominatePick[p1_List, p2_List] := Switch[p1 - p2, {_?NonNegative, _?NonPositive}, p1, {_?NonPositive, _?NonNegative}, p2, _, Null]; pickedPoints = dominatePick @@@ pairs; Print[pickedPoints]; DeleteCases[ Append[Tally@pickedPoints, Append[Complement[{points}, pickedPoints], 0]], {Null, _}] ] dominateCount[p1, p2, p3] (* {{{5, -2}, 2}, {{4, -1}, 1}, {{1, 5}, 0}} *) 

A slightly different approach

Clear[dominateCount] dominateCount[points : {_, _} ..] := Module[{pairs, dominatePick, pickedPoints}, pairs = Subsets[{points}, {2}]; dominatePick[p1_List, p2_List] := Switch[p1 - p2, {_?NonNegative, _?NonPositive}, p1, {_?NonPositive, _?NonNegative}, p2, _, Null]; pickedPoints = dominatePick @@@ pairs; DeleteCases[ Append[Tally@pickedPoints, Append[Complement[{points}, pickedPoints], 0]], {Null, _}] ] dominateCount[p1, p2, p3] (* {{{5, -2}, 2}, {{4, -1}, 1}, {{1, 5}, 0}} *) 
added 106 characters in body
Source Link
khanhnguyendata
  • 5.2k
  • 1
  • 24
  • 33

A slightly different approach

Clear[dominateCount]   dominateCount[points : {_, _} ..] :=  Module[{pairs, dominatePick, pickedPoints}, pairs = Subsets[{points}, {2}]; dominatePick[p1_List, p2_List] := Switch[p1 - p2,  {_?NonNegative, _?NonPositive}, p1, {_?NonPositive, _?NonNegative}, p2,  _, Null]; pickedPoints = dominatePick @@@ pairs; Print[pickedPoints];  DeleteCases[   Append[Tally@pickedPoints,  Append[Complement[{points}, pickedPoints], 0]]]0]], {Null, _}]  ]  dominateCount[p1, p2, p3]  (* {{{5, -2}, 2}, {{4, -1}, 1}, {{1, 5}, 0}} *) 

{{{5, -2}, 2}, {{4, -1}, 1}, {{1, 5}, 0}}

A slightly different approach

Clear[dominateCount]   dominateCount[points : {_, _} ..] := Module[{pairs, dominatePick, pickedPoints}, pairs = Subsets[{points}, {2}]; dominatePick[p1_List, p2_List] := Switch[p1 - p2, {_?NonNegative, _?NonPositive}, p1, {_?NonPositive, _?NonNegative}, p2, _, Null]; pickedPoints = dominatePick @@@ pairs; Append[Tally@pickedPoints, Append[Complement[{points}, pickedPoints], 0]]] dominateCount[p1, p2, p3] 

{{{5, -2}, 2}, {{4, -1}, 1}, {{1, 5}, 0}}

A slightly different approach

Clear[dominateCount] dominateCount[points : {_, _} ..] :=  Module[{pairs, dominatePick, pickedPoints}, pairs = Subsets[{points}, {2}]; dominatePick[p1_List, p2_List] := Switch[p1 - p2,  {_?NonNegative, _?NonPositive}, p1, {_?NonPositive, _?NonNegative}, p2,  _, Null]; pickedPoints = dominatePick @@@ pairs; Print[pickedPoints];  DeleteCases[   Append[Tally@pickedPoints,  Append[Complement[{points}, pickedPoints], 0]], {Null, _}]  ]  dominateCount[p1, p2, p3]  (* {{{5, -2}, 2}, {{4, -1}, 1}, {{1, 5}, 0}} *) 
added 43 characters in body
Source Link
RunnyKine
  • 33.5k
  • 3
  • 111
  • 178

A slightly different approach

Clear[dominateCount]     dominateCount[points : {_, _} ..] :=Module[= Module[{pairs, dominatePick, pickedPoints},  pairs=Subsets[ pairs = Subsets[{points}, {2}];   dominatePick[p1_List, p2_List] :=Switch[p1= Switch[p1 - p2,   {_?NonNegative, _?NonPositive}, p1,   {_?NonPositive, _?NonNegative}, p2, _, Null]; pickedPoints = dominatePick @@@ pairs;  pickedPoints=dominatePick@@@pairs;  Append[Tally@pickedPoints, Append[Complement[{points}, pickedPoints],0]]  ] 0]]]  dominateCount[p1,p2,p3] (* {{{5,-2},2},{{4,-1},1},{{1,5}p2,0}} *)p3] 

{{{5, -2}, 2}, {{4, -1}, 1}, {{1, 5}, 0}}

A slightly different approach

Clear[dominateCount] dominateCount[points:{_,_}..]:=Module[{pairs,dominatePick,pickedPoints}, pairs=Subsets[{points},{2}]; dominatePick[p1_List,p2_List]:=Switch[p1-p2,   {_?NonNegative,_?NonPositive},p1,   {_?NonPositive,_?NonNegative},p2, _,Null]; pickedPoints=dominatePick@@@pairs; Append[Tally@pickedPoints,Append[Complement[{points},pickedPoints],0]]  ]  dominateCount[p1,p2,p3] (* {{{5,-2},2},{{4,-1},1},{{1,5},0}} *) 

A slightly different approach

Clear[dominateCount]     dominateCount[points : {_, _} ..] := Module[{pairs, dominatePick, pickedPoints},   pairs = Subsets[{points}, {2}];   dominatePick[p1_List, p2_List] := Switch[p1 - p2, {_?NonNegative, _?NonPositive}, p1, {_?NonPositive, _?NonNegative}, p2, _, Null]; pickedPoints = dominatePick @@@ pairs;    Append[Tally@pickedPoints, Append[Complement[{points}, pickedPoints], 0]]]  dominateCount[p1, p2, p3] 

{{{5, -2}, 2}, {{4, -1}, 1}, {{1, 5}, 0}}

Source Link
khanhnguyendata
  • 5.2k
  • 1
  • 24
  • 33
Loading