Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

code for a pattern

Posted on 2004-03-26
12
Medium Priority
?
359 Views
Last Modified: 2010-03-31
If I wanted to be able to recreate a pattern like   1,2,3,4,1,3,2,4,3,4,5,4,2,5,1,6,4,1,7,3,2,5,8  some thing like this is there a way to do this..This is way over my head....
0
Comment
Question by:Drop_of_Rain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10685992
This is a very mysterious question Drop_of_Rain, but i'll try to crack the riddle of the sphyinx:

are you saying you want to produce a random sequence of numbers within a particular range? If so, please name that range
0
 

Author Comment

by:Drop_of_Rain
ID: 10686071
I was looking for a pattren to use.  1,2,3,4    1,3,2,4  center numbered reversed 3,4,5,6,   3,6,4,5 end numbereds  reversed. Rotate from one group to the other 1,5,2,4, front to rear next set inside 4,6,1,3, then in for a new set of numbers like 4,6,1,3 through the numbers then go random.

I think this should be easier.
0
 

Author Comment

by:Drop_of_Rain
ID: 10686114
You can create whatever cycles you can recognize   It would be great to think of a way for it to be able to create its own patterns through a random choice that would create the new pattern. I hope you understand what I am trying to say.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:Mayank S
ID: 10686116
Is your set-size constant (equal to 4)?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10686156
>>I hope you understand what I am trying to say.

Not exactly ;-) If what you are saying is that you need to create a 'random' order, but one that recognizes and reproduces patterns, then you're looking at something pretty complex, maybe AI-based. If you want random sets in batches, then that's trivial
0
 

Author Comment

by:Drop_of_Rain
ID: 10686160
If that is good. Would it be able to have it change it itself like to 5 after one cycle. That would mix it up pretty good as well. Like as the total number like 1-8 has been reached the set-size could change. It would be great if I could change that set-size through checkboxs as well. or after a certain total number has been reached it is changed.

All of these would be great to have in the program and others that you think would be good. This in the the creative mode at this point.
0
 

Author Comment

by:Drop_of_Rain
ID: 10686308
NO we are in control of the pattern just using a system    abcd then d=b abcd then c=a then abcd then efgh then  something like I just did a is a variable. Would something like this work. You can create varibles through varibles right.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10686376
Maybe something like this?


      static void printRows() {
            final int INDEX_LIMIT = 8;
            final int BATCH_SIZE = 4;
            final int NUM_BATCH_GROUPS = 8;
            int batchLength = 4;
            Set numbers = new HashSet();
            // Add numbers
            for (int batchGroup = 0; batchGroup < NUM_BATCH_GROUPS; batchGroup++) {
                  while (numbers.size() < batchLength) {
                        numbers.add(new Integer((int)(Math.random()  * INDEX_LIMIT) + 1));
                  }
                  for (int batchSize = 0; batchSize < BATCH_SIZE; batchSize++) {
                        java.util.List list = new ArrayList(numbers);
                        Collections.shuffle(list);
                        System.out.println(list);
                  }
                  batchLength++;
                  System.out.println();
            }
      }
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10686458
Nasty little bug in that sorry. Replace while statement with

      while (numbers.size() < batchLength && numbers.size() < INDEX_LIMIT) {
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 10686767
This is a bit more organized:

  static void printRows() {
    final int INDEX_LIMIT = 8;
            final int BATCH_LENGTH_LIMIT = 8;
    final int BATCH_SIZE = 4;
    final int NUM_BATCH_GROUPS = 4;
    int batchLength = 4;
            // Disallow duplicates by using a Set
    Set numbers = new HashSet();
    for (int batchGroup = 0; batchGroup < NUM_BATCH_GROUPS; batchGroup++) {
                  // Add numbers if more needed
      while (numbers.size() < batchLength && batchLength < BATCH_LENGTH_LIMIT) {
        numbers.add(new Integer((int)(Math.random()  * INDEX_LIMIT) + 1));
      }
      for (int batchSize = 0; batchSize < BATCH_SIZE; batchSize++) {
        java.util.List list = new ArrayList(numbers);
                        // Shuffle and print
        Collections.shuffle(list);
        System.out.println(list);
      }
      batchLength++;
      System.out.println();
    }
  }
0
 

Author Comment

by:Drop_of_Rain
ID: 10689911
CEHJ  Thanks for the help.

rgds,
Christopher
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10689919
8-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question