Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.5K Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

[?] Make the following conditions more compact?

Posted 6 years ago

What if I have the following conditions (when I use Solve-function)?

All characters are different numbers.

I always do this.

Solve[a != b && a != c && a != d && a != e && a != f && a != g &&   a !=
h && b != c && b != d && b != e && b != f && b != g && b != h &&   c
!= d &&.....

However, this method takes a lot of time. Is there a good way?

POSTED BY: Keito Tanemura
3 Replies
Posted 6 years ago

An alternative, a bit more compact:

Unequal[a, b, c, d, e, f, g, h]
POSTED BY: Hans Milton

The latter. Thank you very much.

POSTED BY: Keito Tanemura
Posted 6 years ago

Hi Keito,

By "takes a long time" do you mean it takes a long time for Solve to finish, or it takes a long time to manually construct the list of conditions? If the former, you will have to provide more details about the equation you are trying to solve, if the latter, then this is one way to programmatically construct the list of conditions.

ClearAll[a, b, c, d, e, f, g, h];
vars = {a, b, c, d, e, f, g, h};
And @@ (First@# != Last@# & /@ Subsets[vars, {2}])

(*
a != b && a != c && a != d && a != e && a != f && a != g && a != h && 
b != c && b != d && b != e && b != f && b != g && b != h && c != d &&
c != e && c != f && c != g && c != h && d != e && d != f && d != g &&
d != h && e != f && e != g && e != h && f != g && f != h && g != h
*)
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard