Skip to main content
added 22 characters in body
Source Link
Ali Hashmi
  • 9.1k
  • 4
  • 22
  • 43
m = DeleteDuplicates[Map[Sort, Tuples[{a, b, c, d}, 3]]];

DeleteCases[m, {Alternatives@@Map[OrderlessPatternSequence[_Alternatives@@Function[x, #OrderlessPatternSequence[_, #]x, &x],
Listable], {b, c, d}]}]

(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d},{b, c, d}}*)

(* adopting Wizard's approach *)
DeleteCases[m, {OrderlessPatternSequence[x : b | c | d, x_, _] }] 
(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d}, {b, c, d}}*)
m = DeleteDuplicates[Map[Sort, Tuples[{a, b, c, d}, 3]]];

DeleteCases[m, {Alternatives@@Map[OrderlessPatternSequence[_, #, #] &, {b, c, d}]}]

(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d},{b, c, d}}*)

(* adopting Wizard's approach *)
DeleteCases[m, {OrderlessPatternSequence[x : b | c | d, x_, _] }] 
(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d}, {b, c, d}}*)
m = DeleteDuplicates[Map[Sort, Tuples[{a, b, c, d}, 3]]];

DeleteCases[m, {Alternatives@@Function[x, OrderlessPatternSequence[_, x, x],
Listable], {b, c, d}]}]

(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d},{b, c, d}}*)

(* adopting Wizard's approach *)
DeleteCases[m, {OrderlessPatternSequence[x : b | c | d, x_, _] }] 
(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d}, {b, c, d}}*)
deleted 46 characters in body
Source Link
Ali Hashmi
  • 9.1k
  • 4
  • 22
  • 43
m = DeleteDuplicates[Map[Sort, Tuples[{a, b, c, d}, 3]]];

DeleteCases[m, {OrderlessPatternSequence[_Alternatives@@Map[OrderlessPatternSequence[_, b#, b] |#] 
OrderlessPatternSequence[_&, c{b, c] | OrderlessPatternSequence[_c, d, d]}]}]

(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d},{b, c, d}}*)

(* adopting Wizard's approach *)
DeleteCases[m, {OrderlessPatternSequence[x : b | c | d, x_, _] }] 
(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d}, {b, c, d}}*)
m = DeleteDuplicates[Map[Sort, Tuples[{a, b, c, d}, 3]]];

DeleteCases[m, {OrderlessPatternSequence[_, b, b] | 
OrderlessPatternSequence[_, c, c] | OrderlessPatternSequence[_, d, d]}]

(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d},{b, c, d}}*)

(* adopting Wizard's approach *)
DeleteCases[m, {OrderlessPatternSequence[x : b | c | d, x_, _] }] 
(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d}, {b, c, d}}*)
m = DeleteDuplicates[Map[Sort, Tuples[{a, b, c, d}, 3]]];

DeleteCases[m, {Alternatives@@Map[OrderlessPatternSequence[_, #, #] &, {b, c, d}]}]

(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d},{b, c, d}}*)

(* adopting Wizard's approach *)
DeleteCases[m, {OrderlessPatternSequence[x : b | c | d, x_, _] }] 
(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d}, {b, c, d}}*)
added 65 characters in body
Source Link
Ali Hashmi
  • 9.1k
  • 4
  • 22
  • 43
m = DeleteDuplicates[Map[Sort, Tuples[{a, b, c, d}, 3]]];

DeleteCases[m, {OrderlessPatternSequence[_, b, b] | 
OrderlessPatternSequence[_, c, c] | OrderlessPatternSequence[_, d, d]}]

(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d},{b, c, d}}*)

(* adopting Wizard's approach *)
DeleteCases[m, {OrderlessPatternSequence[x : b | c | d, x_, _] }] 
(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d}, {b, c, d}}*)
DeleteCases[m, {OrderlessPatternSequence[_, b, b] | 
OrderlessPatternSequence[_, c, c] | OrderlessPatternSequence[_, d, d]}]

(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d},{b, c, d}}*)

(* adopting Wizard's approach *)
DeleteCases[m, {OrderlessPatternSequence[x : b | c | d, x_, _] }] 
(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d}, {b, c, d}}*)
m = DeleteDuplicates[Map[Sort, Tuples[{a, b, c, d}, 3]]];

DeleteCases[m, {OrderlessPatternSequence[_, b, b] | 
OrderlessPatternSequence[_, c, c] | OrderlessPatternSequence[_, d, d]}]

(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d},{b, c, d}}*)

(* adopting Wizard's approach *)
DeleteCases[m, {OrderlessPatternSequence[x : b | c | d, x_, _] }] 
(*{{a, a, a}, {a, a, b}, {a, a, c}, {a, a, d}, {a, b, c}, {a, b, d}, {a,c,d}, {b, c, d}}*)
Source Link
Ali Hashmi
  • 9.1k
  • 4
  • 22
  • 43
Loading