A mathematical issue

  • Thread starter Thread starter Morten Snedker
  • Start date Start date
M

Morten Snedker

This hasn't to do with coding in particular, but since it is done in
vb.net this is where I'll try to find inspiration.

If I'm in the wrong group please re-direct me.


1,2,3,4,3,3,2,3,4,5,6,6,8,3,8,5,3 etc.

One number occuring more than once. Usually the amount of different
numbers are around 5, but it may vary.

Now for what makes my grey cells spin:

The numbers should be sorted by these prioritized rules:


1. A number in the sequence may not have same value as the previous.

1231 is good. (1 doesn't follow 1)
2113 is not good. (1 follows 1)


2. The spread between two numbers should as big as possible.

12341 is good (widest possible spread for 1)
12134 is okay according to rule 1, but the spread could be better.


Any thougts as how to handle the problem is greatly appreciated. If
any of you know of som .Net mathematical routines that might be of
help, naturally I'd love to hear of them.


Regards /Snedker
 
1. first, a question: for unsorted
112233333
which is the better sort
313231323 (maximize the minimum separation)
or
313232313 (maximize 1 separation at the expense of 2 separation)
?

2. the gist of my hack at this problem is as follows.
a. separate the input into pieces based on the symbol, eg 123123322 would
result in three pieces, 11, 2222, and 333.
b. combine the two smallest pieces into one larger piece by a shuffling
mechanism. a piece with one member should tend to the center (1/2 in the
interval 0..1), a piece with 2 members should tend to the 1/3 and 2/3
positions, and so on. The first such shuffle would combine 11 and 333 into
31313. The reason for this order is that 11's target positions are 1/3 and
2/3, and 333's target positions are 1/4, 1/2, and 3/4. when put in order,
you get 31313.
c. repeat step b until one piece remains.
 
On Tue, 28 Jun 2005 04:39:03 -0700, "AMercer"

Could I have it optional? ;-)

If not 1 is the better choice, maximizing the overall seperation.

Thanks for your response so far...I'd love to be better at logics but
have realized my shortcomings :-)

I'll try putting your ideas into shape...

Best regards /Morten
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top