3 added 170 characters in body edited Jul 27 '17 at 19:02 kglr 218k1010 gold badges248248 silver badges499499 bronze badges  lists = {{1, 0, 1}, {2, 1, 2}, {1, 0, 3}, {2, 4, 2}, {2, 1, -1}, {1, 0, 0}}  Reap/Sow:Reap/Sow:  Reap[Sow[#[[3]], {#[[{1, 2}]]}] & /@ lists, _, Append[#1, Total@#2] &][[2]]  ReplaceRepeated:ReplaceRepeated:  lists //. {a___, {x_, y_, z_}, b___, {x_, y_, w_}, c___} :> {a, {x, y, z + w}, b, c}  Cases + DeleteDuplicates:Cases + DeleteDuplicates:  DeleteDuplicates@Cases[lists, {w : PatternSequence[_, _], _} :> {w, Total@(Last /@ Cases[lists, {w, _}])}]  all give {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} Update: In versions 10+, you can also use Merge:  (* {{1, 0,KeyValueMap[Append]@Merge[Tr][Most 4},@ {2,# 1,-> 1},Last {2,@ 4,#& 2}}/@ *)lists]  {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}}  lists = {{1, 0, 1}, {2, 1, 2}, {1, 0, 3}, {2, 4, 2}, {2, 1, -1}, {1, 0, 0}}  Reap/Sow:  Reap[Sow[#[[3]], {#[[{1, 2}]]}] & /@ lists, _, Append[#1, Total@#2] &][[2]]  ReplaceRepeated:  lists //. {a___, {x_, y_, z_}, b___, {x_, y_, w_}, c___} :> {a, {x, y, z + w}, b, c}  Cases + DeleteDuplicates:  DeleteDuplicates@Cases[lists, {w : PatternSequence[_, _], _} :> {w, Total@(Last /@ Cases[lists, {w, _}])}]  all give  (* {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} *)   lists = {{1, 0, 1}, {2, 1, 2}, {1, 0, 3}, {2, 4, 2}, {2, 1, -1}, {1, 0, 0}}  Reap/Sow:  Reap[Sow[#[[3]], {#[[{1, 2}]]}] & /@ lists, _, Append[#1, Total@#2] &][[2]]  ReplaceRepeated:  lists //. {a___, {x_, y_, z_}, b___, {x_, y_, w_}, c___} :> {a, {x, y, z + w}, b, c}  Cases + DeleteDuplicates:  DeleteDuplicates@Cases[lists, {w : PatternSequence[_, _], _} :> {w, Total@(Last /@ Cases[lists, {w, _}])}]  all give {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} Update: In versions 10+, you can also use Merge: KeyValueMap[Append]@Merge[Tr][Most @ # -> Last @ #& /@ lists]  {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} 2 added 128 characters in body edited Dec 18 '12 at 8:04 kglr 218k1010 gold badges248248 silver badges499499 bronze badges  lists = {{1, 0, 1}, {2, 1, 2}, {1, 0, 3}, {2, 4, 2}, {2, 1, -1}, {1, 0, 0}}  Reap/Sow:  Reap[Sow[#[[3]], {#[[{1, 2}]]}] & /@ lists, _, Append[#1, Total@#2] &][[2]] (* {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} *)  ReplaceRepeated:  lists //. {a___, {x_, y_, z_}, b___, {x_, y_, w_}, c___} :> {a, {x, y, z + w}, b, c}  Cases + DeleteDuplicates:  DeleteDuplicates@Cases[lists, {w : PatternSequence[_, _], _} :> {w, Total@(Last /@ Cases[lists, {w, _}])}]  all give  (* {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} *)   lists = {{1, 0, 1}, {2, 1, 2}, {1, 0, 3}, {2, 4, 2}, {2, 1, -1}, {1, 0, 0}}  Reap/Sow:  Reap[Sow[#[[3]], {#[[{1, 2}]]}] & /@ lists, _, Append[#1, Total@#2] &][[2]] (* {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} *)  ReplaceRepeated:  lists //. {a___, {x_, y_, z_}, b___, {x_, y_, w_}, c___} :> {a, {x, y, z + w}, b, c} (* {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} *)   lists = {{1, 0, 1}, {2, 1, 2}, {1, 0, 3}, {2, 4, 2}, {2, 1, -1}, {1, 0, 0}}  Reap/Sow:  Reap[Sow[#[[3]], {#[[{1, 2}]]}] & /@ lists, _, Append[#1, Total@#2] &][[2]]  ReplaceRepeated:  lists //. {a___, {x_, y_, z_}, b___, {x_, y_, w_}, c___} :> {a, {x, y, z + w}, b, c}  Cases + DeleteDuplicates:  DeleteDuplicates@Cases[lists, {w : PatternSequence[_, _], _} :> {w, Total@(Last /@ Cases[lists, {w, _}])}]  all give  (* {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} *)  1 answered Dec 18 '12 at 7:18 kglr 218k1010 gold badges248248 silver badges499499 bronze badges  lists = {{1, 0, 1}, {2, 1, 2}, {1, 0, 3}, {2, 4, 2}, {2, 1, -1}, {1, 0, 0}}  Reap/Sow:  Reap[Sow[#[[3]], {#[[{1, 2}]]}] & /@ lists, _, Append[#1, Total@#2] &][[2]] (* {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} *)  ReplaceRepeated:  lists //. {a___, {x_, y_, z_}, b___, {x_, y_, w_}, c___} :> {a, {x, y, z + w}, b, c} (* {{1, 0, 4}, {2, 1, 1}, {2, 4, 2}} *)