Message Boards Message Boards

0
|
5598 Views
|
10 Replies
|
4 Total Likes
View groups...
Share
Share this post:

How to find list that contains different digits.

Posted 9 years ago
POSTED BY: Okkes Dulgerci
10 Replies
Posted 9 years ago

I figured it out in this way..

a = Permutations[Range@9, {9}];

b = Table[Partition[a[[i]], {3}], {i, Length@a}];

n = Table[FromDigits /@ b[[i]], {i, Length@b}]

Thanks for your helps..

POSTED BY: Okkes Dulgerci
Posted 9 years ago
n = Partition[ FromDigits /@ Partition[Flatten@Permutations@Range@9, 3], 3];

 DeleteDuplicates[Sort /@ n]
POSTED BY: Okkes Dulgerci
Posted 9 years ago

Maybe this is what you are looking for

Partition[FromDigits /@ Partition[Flatten[Permutations[Range[9]]], 3],
  3]
POSTED BY: Paul Cleary
Posted 9 years ago

Yes, I did that way. After I posted my solution I saw your solution, page was open :)

POSTED BY: Okkes Dulgerci
Posted 9 years ago

Still there are duplicated sets. Note that {123,456,789}={789,456,123}

POSTED BY: Okkes Dulgerci
Posted 9 years ago

Hi again, I guess there is a minor issue here. When I convert to digit, I cannot see, for example, this triple {132, 456, 879}

FromDigits/@Append[#,Complement[Range[9],Flatten[#]]]&/@all

First and Last set identically the same, there are more repetitions. Any suggestions. Thanks.

POSTED BY: Okkes Dulgerci
Posted 9 years ago
a = Subsets[Range[9], {3}];

b = Subsets[Complement[Range[9], #], {3}] & /@ a;

c = Flatten[MapThread[Tuples[{{#1}, #2}] &, {a, b}], 1];

n = DeleteDuplicates[
   Sort@Append[#, Complement[Range[9], Flatten[#]]] & /@ c];

d = Table[Permutations /@ n[[i]], {i, Length@n}];

m = Flatten[
   Table[Table[{d[[s, 1, i]], d[[s, 2, j]], d[[s, 3, k]]}, {i, 6}, {j,
       6}, {k, 6}], {s, Length@d}], 3];

Length@m

60480

p = Table[FromDigits /@ m[[i]], {i, Length@m}]

This is what I got after I modified your code but still I am not sure this cover all possibilities..

POSTED BY: Okkes Dulgerci
Posted 9 years ago

Thank you both for quick reply! This is awesome..

POSTED BY: Okkes Dulgerci
POSTED BY: Sander Huisman
FromDigits /@ Partition[RandomSample[Range[9]], 3]

yielding

{319, 584, 276}

The power here is doing your randomisation before you cut the data up into substructures.

POSTED BY: David Gathercole
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract